Personalization features for non-autosomal chromosomes - #4992
Conversation
|
A few comments:
In the long term, the |
|
Thanks for the close reading! I think I have a better understanding of some of the data structures now. My responses:
I'm now using the next/prev functions in the
I am doing it this way now.
Am I understanding correctly that the concern is that each fragment has a separate contig name, and could therefore be wrapped onto itself, despite actually being a mid-chromosome contig? If so, that does seem like a sticky issue. I guess we would need some strategy to associate a first and last contig for each sample on a given chain. Does machinery for that exist? I don't think I fully grok the suffix completion code in the
Good catch. The inserts now respect the bidirectionality of the GBWT.
No, it was not. I'm now tracking excluded contigs separately. Regarding a change in the .hapl format, I like the idea, but I think it's probably better for me to leave that as future work for someone who understands the implications of changing the format better. Anyway, this commit may or may not be mergeable depending on what we think the appropriate strategy is for your 3rd comment. |
The way you are now handling this in In the general case, there is a risk of wrapping a mid-chromosome contig onto itself. We had a proposal for haplotype-level metadata in GFA, which could be used for mapping assembly contigs to chromosomes and listing them in order. But the proposal has not been merged, because nobody has had the time to implement it. |
|
I wonder if the Do you have any leaning one way or the other? |
|
I don't have any preferences on that. The |
|
Makes sense. My read is that this is mergeable then. I'll do that in a day or two if nobody objects. |
Changelog Entry
To be copied to the draft changelog by merger:
vg haplotypesadds a--wrapoption for circular chromosomes, which doubles selected haplotypes after personalizationvg gbwtadds a--wrap-contigoption that performs the same operation on an existing GBWT/GBZvg haplotypesadds new scoring modes for non-diploid chromosomes:--high-cov-contig/--high-cov-num-haps,--half-cov-contig/--half-cov-num-haps, and--exclude-contigDescription
These options are intended to better support non-autosome chromosomes, which need somewhat different treatment. Previously, the best practices personalization pipeline applied a uniform, diploid scoring model to all chromosomes, which is normed to the expected coverage of a unique, diploid region of the genome. This led to a number of issues in a human pangenome:
There are also further complications for mapping to chrM due to the fact that it is a circular chromosome. GBZ does not natively support circular paths, in the sense of the libhandlegraph interface for them. The paths can be made "pseudo-circular" by wrapping the haplotypes around the path a second time. However, in that case,
vg haplotypesrefuses to operate on the graph because it contains a top-level chain that is a cycle. You might think that thevg giraffe --supplementaryoption might help obtain (at least some) alignments that wrap the 0-coordinate of chrM. Unfortunately, this doesn't help, because of the prevalence of NuMTs that include the 0-coordinate: there is always a contiguous alignment available for an entire short read, so the supplementary code path never has a reason to execute.This PR includes two main contributions to address these issues. The first is an addition of two new scoring models that can be selected on a per-contig basis:
The relevant contigs are specified by new command line options in
vg haplotypeslike this:In addition, there are accompanying parameters that indicate the number of haplotypes sampled under these models:
--high-cov-num-hapsand--half-cov-num-haps. Any contigs specified with these scoring models are automatically excluded from the second phase of diploid sampling, if diploid sampling is specified. Finally, there is also an option--exclude-contig, which can exempt a contig from personalization entirely.The next contribution is meant to address the issues with chrM being circular. Since having truly circular contigs is unsupported in GBZ, I went the less-principled-but-sufficient route of doubling the haplotype paths. This functionality can be accessed in
vg gbwtduring the modification step via the option--wrap-contig <CONTIG>. I also created a second access point as a mid-execution modification invg haplotypeswith the option--wrap <CONTIG>. The motivation for the second access point is that it allows you to apply the modification after haplotype sampling (which requires a linear top-level chain) but while still working with a mutable GBWTBuilder. In contrast, thevg gbwtentrypoint has to first convert back from the static GBWT to the GBWTBuilder to wrap a contig. The wrapping step is only applied to haplotype-sense paths out of fear of messing up coordinate systems by wrapping reference- or generic-sense paths.The PR's implementation does have some weaknesses that I'm aware of:
To be transparent, I've done more benchmarking on chrM than on chrX/chrY. I can pretty definitively say that you get better results with
--wrap chrM --high-cov-contig chrM. If you also use--supplementaryinvg giraffeorvg surject, you can get the 0-coordinate spanning reads nicely represented in the output BAM as well. For the allosomes, I think the logic is sound, but I need to do more benchmarking to be confident that it's a net positive in practice.