You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some applications it would be useful to know the reference sequence that a tree sequence coordinate space refers to. For example, with real data, we should (at a minimum) record the reference build (e.g., GRCh38) and the contig ID (e.g., chr22) associated with a tree sequence. Ideally, we would also like to be able to do things like:
As well as situations in which a well-known canonical reference is available, we may also have a one-off reference sequence that we wish to record, e.g., in simulations.
To support this, I suggest adding a reference section to the file store, with some fields. Roughly, these might looks like:
reference/build -- e.g. GRCh38
reference/contig -- e.g. chr22
reference/id -- md5 hash of the sequence, c.f. refget
reference/sequence -- Actual sequence information
The references section would be itself optional (keeping backward compatability), and some fields would probably be optional within this section (for example, reference/sequence would definitely be optional --- no point in storing GRCh38 chr1 over and over again). We can imagine having some mechanisms for automatically retrieving sequences using refget, but this isn't at all necessary for a basic implementation.
At a high-level, we should try to follow any upstream standards as closely as possible, e.g. GA4GH refget and any others that are relevant.
This seems very sensible, but I wonder if the word "reference" is a bit too context-dependent. Perhaps "genome_reference" or something similar would be clearer?
In SLiM I'm calling it the "ancestral sequence". I'm fine with "reference" or "genome_reference" or any such variant. The rest of the proposal seems good to me. It should be clarified, when this is documented, exactly what format reference/sequence is expected to be in – FASTA? Is a FASTA header allowed? Are newline characters allowed (\r, \n)? Nucleotides only, presumably, not FASTA amino acid sequences? But FASTA codes for ambiguous nucleotides of various sorts? But I think SLiM will just dump an unbroken stream of ACGT into it, so that is all that I need to be supported.
I think this is a great idea, and lean towards calling it just reference (although reference_sequence would also be fine). I don't think it should be called ancestral_sequence, because I'd argue these shouldn't be the same thing, necessarily. Here's some reasons:
If we say they're supposed to be the same, then the ancestral_state column of the Site table is supposed to match the positions in the reference sequence, which is annoying and redundant.
The reference sequence is usually not the ancestral sequence, in practice. (eg GRCh38), but is still useful.
The reference sequence could still be used by e.g. SLiM to store, essentially, the ancestral sequence.
Reacted by Kevin R. Thornton, Ben Haller, Ariella Gladstein and Jerome Kelleher
FWIW I would (marginally) vote for reference_sequence. reference sounds like it might contain metadata about bibliographic references relevant to the provenance of the data. But maybe I'm being too naive.
@bhaller is going to actually start storing a reference sequence on output from SLiM nucleotide models, so we should at least get it nailed down what we will call it. The proposal is, I think,
reference_sequence/build -- e.g. GRCh38
reference_sequence/contig -- e.g. chr22
reference_sequence/id -- md5 hash of the sequence, c.f. refget
reference_sequence/sequence -- Actual sequence information
OK, sounds good. I haven't researched what the right names for build, contig etc should be, so perhaps we could just keep it to reference_sequence/sequence if we're going to ship files that include it?
Also reference_sequence/sequence seems repetitive and unintuitive. Maybe reference_sequence/data would be better?
Besides deciding what to name these entries in the kastore, we should record this somehow, possibly by providing API functions that will write and read it. We think the main question is: is the reference sequence part of a table collection object? It would seem natural to make it a part of the table collection, because then you would get it when you read the .trees file. But, in the SLiM application, the reference sequence is expected to be large, and making it part of the table collection object means that there will be more than one copy of it sitting around, because:
we have to copy the table collection when we write it out; and also
SLiM has an internal version of the reference sequence, so when reading in the .trees file with table_collection_load( ), if reference_sequence was part of the resulting object, it would need to be copied over to where SLiM wants it
Since a table_collection_thas a kastore_t, we could define a function tsk_table_collection_read_reference_sequence( ) that would go into the store and pull out the reference sequence (if indeed such a store is associated). I'm not sure how to deal with writing out, though?
I don't know how we're going to manage it from the C perspective @petrelharp, and I'm afraid I just don't have time to work on it right now. I don't want to rush in changes to the C API without thinking through the consequences very carefully (particularly not with something this fundamental).
I think the best thing to do from a SLiM perspective is to reopen the kastore in append mode after tskit has written it out, and write the reference sequence/data key in. Should be ~10 lines of code.
Does it make sense to add just the reference state at each variable site vs
the entire reference?
__
Kevin Thornton
Associate Professor
Ecology and Evolutionary Biology
UC Irvine
www.molpopgen.org
github.com/molpopgen
github.com/ThorntonLab
OK, so if I understand correctly, @petrelharp, I will back out the changes I made to move the reference sequence into metadata and go back to doing it exactly as it was before; as I understand it, that is the right move to be compatible with the tskit changes proposed here. I guess I'll wait to do that until the dust has settled here, to be sure that nothing changes.
Don't make any changes yet @bhaller! We haven't decided we're definitely going to do it yet, it's a question now of whether we want to get Python 0.4.0 out sooner without reference sequences or a bit later with them. Any opinions @bhaller@petrelharp ?
Well, it'd be nice to not change where reference sequences go and then change back; if this doesn't go into tskit now we'll need to put them in metadata for the time being. But, @bhaller has done the hard work already...
My gut says to get it in, but undocumented for 0.4.0. I will have a quick recce to guage required effort. As it's just extra fields should be straight forward.
I'd very much like to see it happen now, so that SLiM 3.7 can have this stuff in place. Ties up a loose end for us, and as @petrelharp says, avoid having to move the reference sequence into metadata and then back out again, which is rather confusing for those users who use it. Undocumented for 0.4.0 seems fine from our end; let's just get it to its final resting place.
Sorry forgot you don't subscribe to the firehose! #1911
OK, great! So the decision has been made, the reference sequence will go in reference_sequence/data in kastore for sure? I should set the wheels in motion on my end?
[EDIT: Well, it sure looks that way from the diffs at #1911, so I'm going to go ahead and do it. :-> Thanks all – good to have this settled!]
Sorry forgot you don't subscribe to the firehose! #1911
OK, great! So the decision has been made, the reference sequence will go in reference_sequence/data in kastore for sure? I should set the wheels in motion on my end?
[EDIT: Well, it sure looks that way from the diffs at #1911, so I'm going to go ahead and do it. :-> Thanks all – good to have this settled!]
Yes, but you should use the APIs, not accessing the kastore directly.
Activity
hyanwong commentedon Mar 13, 2019
This seems very sensible, but I wonder if the word "reference" is a bit too context-dependent. Perhaps "genome_reference" or something similar would be clearer?
bhaller commentedon Mar 13, 2019
In SLiM I'm calling it the "ancestral sequence". I'm fine with "reference" or "genome_reference" or any such variant. The rest of the proposal seems good to me. It should be clarified, when this is documented, exactly what format reference/sequence is expected to be in – FASTA? Is a FASTA header allowed? Are newline characters allowed (\r, \n)? Nucleotides only, presumably, not FASTA amino acid sequences? But FASTA codes for ambiguous nucleotides of various sorts? But I think SLiM will just dump an unbroken stream of ACGT into it, so that is all that I need to be supported.
jeromekelleher commentedon Mar 13, 2019
Thanks @bhaller. To clarify, it'll be a flat array of chars, such that
reference[pos]is the reference allele at positionpos.[-]Support for references[/-][+]Support for reference sequences[/+]petrelharp commentedon Mar 15, 2019
I think this is a great idea, and lean towards calling it just
reference(althoughreference_sequencewould also be fine). I don't think it should be calledancestral_sequence, because I'd argue these shouldn't be the same thing, necessarily. Here's some reasons:ancestral_statecolumn of the Site table is supposed to match the positions in the reference sequence, which is annoying and redundant.hyanwong commentedon Mar 15, 2019
FWIW I would (marginally) vote for
reference_sequence.referencesounds like it might contain metadata about bibliographic references relevant to the provenance of the data. But maybe I'm being too naive.molpopgen commentedon Mar 15, 2019
@petrelharp is right here. I actually get papers across my desk where someone has calculated Fay and Wu's H w.r.to the reference allelic state :(.
I do like @hyanwong's idea to call it
reference_sequence. At first, I thought this thread was about adding bibtex support to the docs.petrelharp commentedon Mar 19, 2019
@bhaller is going to actually start storing a reference sequence on output from SLiM nucleotide models, so we should at least get it nailed down what we will call it. The proposal is, I think,
reference_sequence/build-- e.g. GRCh38reference_sequence/contig-- e.g. chr22reference_sequence/id-- md5 hash of the sequence, c.f. refgetreference_sequence/sequence-- Actual sequence informationAll of these would be optional. How about it?
jeromekelleher commentedon Mar 19, 2019
OK, sounds good. I haven't researched what the right names for
build,contigetc should be, so perhaps we could just keep it toreference_sequence/sequenceif we're going to ship files that include it?Also
reference_sequence/sequenceseems repetitive and unintuitive. Maybereference_sequence/datawould be better?petrelharp commentedon Mar 19, 2019
Besides deciding what to name these entries in the kastore, we should record this somehow, possibly by providing API functions that will write and read it. We think the main question is: is the reference sequence part of a table collection object? It would seem natural to make it a part of the table collection, because then you would get it when you read the
.treesfile. But, in the SLiM application, the reference sequence is expected to be large, and making it part of the table collection object means that there will be more than one copy of it sitting around, because:.treesfile withtable_collection_load( ), ifreference_sequencewas part of the resulting object, it would need to be copied over to where SLiM wants itSince a
table_collection_thas akastore_t, we could define a functiontsk_table_collection_read_reference_sequence( )that would go into the store and pull out the reference sequence (if indeed such a store is associated). I'm not sure how to deal with writing out, though?petrelharp commentedon Mar 19, 2019
We could at least write a function that would re-open a
.treesfile and add a reference sequence to it.jeromekelleher commentedon Mar 19, 2019
I don't know how we're going to manage it from the C perspective @petrelharp, and I'm afraid I just don't have time to work on it right now. I don't want to rush in changes to the C API without thinking through the consequences very carefully (particularly not with something this fundamental).
I think the best thing to do from a SLiM perspective is to reopen the kastore in append mode after tskit has written it out, and write the
reference sequence/datakey in. Should be ~10 lines of code.molpopgen commentedon Mar 19, 2019
jeromekelleher commentedon Mar 19, 2019
That was my original proposal, but Ben has reasons for wanting the full reference/ancestral sequence.
24 remaining items
jeromekelleher commentedon Nov 11, 2021
Don't make any changes yet @bhaller! We haven't decided we're definitely going to do it yet, it's a question now of whether we want to get Python 0.4.0 out sooner without reference sequences or a bit later with them. Any opinions @bhaller @petrelharp ?
petrelharp commentedon Nov 11, 2021
Well, it'd be nice to not change where reference sequences go and then change back; if this doesn't go into tskit now we'll need to put them in metadata for the time being. But, @bhaller has done the hard work already...
benjeffery commentedon Nov 11, 2021
My gut says to get it in, but undocumented for 0.4.0. I will have a quick recce to guage required effort. As it's just extra fields should be straight forward.
bhaller commentedon Nov 11, 2021
I'd very much like to see it happen now, so that SLiM 3.7 can have this stuff in place. Ties up a loose end for us, and as @petrelharp says, avoid having to move the reference sequence into metadata and then back out again, which is rather confusing for those users who use it. Undocumented for 0.4.0 seems fine from our end; let's just get it to its final resting place.
jeromekelleher commentedon Nov 12, 2021
We'll have a look at the details @bhaller and report back with a proposal by Monday.
bhaller commentedon Nov 16, 2021
Hi campers. Just a ping, since Monday is now history. :->
benjeffery commentedon Nov 17, 2021
Sorry forgot you don't subscribe to the firehose! #1911
bhaller commentedon Nov 17, 2021
OK, great! So the decision has been made, the reference sequence will go in
reference_sequence/datainkastorefor sure? I should set the wheels in motion on my end?[EDIT: Well, it sure looks that way from the diffs at #1911, so I'm going to go ahead and do it. :-> Thanks all – good to have this settled!]
benjeffery commentedon Nov 18, 2021
Yes, but you should use the APIs, not accessing the kastore directly.
bhaller commentedon Nov 18, 2021
Ah, yes, indeed. Thanks for reminding me.
Closes tskit-dev#146
Basic undocumented support for reference sequences.
Basic undocumented support for reference sequences.
Basic undocumented support for reference sequences.