elsiklab / multivariantviewer

A JBrowse plugin with a custom variant track for multi-VCF files and optionally plotting LD scores
9 stars 0 forks source link

Use on haploid data #8

Closed sravel closed 7 years ago

sravel commented 7 years ago

Hello, I would like to use your plugin on my jBrowse but my organisme is haploid and therefore the VCF is not formatting in the same way. Will it be possible to modify your code so that the haploid data is processed? For recall in the VCF the data are in the form 0 or n without separator Thanks

cmdcolin commented 7 years ago

Good question. I added a patch to make jbrowse itself support haploid VCFs awhile back actually

I'll see if it can be added here too

cmdcolin commented 7 years ago

Should be a bit more consistent now. Feel free to try it out and let me know

sravel commented 7 years ago

Sorry but all SNPs are displayed as reference (blue). I do not know enough javascript but in another version or I test I modify in Variant.js

"Keys.forEach (function (key, ret) { Var col; If (genotypes [key] .GT) { Var valueParse = genotypes [key] .GT.values ​​[0]; // var splitter = (valueParse.match (/ [\ | \ /] / g) || []) [0]; // var split = valueParse.split; If ((valueParse! = 0)) { Col = color (fRect.f, 'alt', valueParse); } Else { Col = color (fRect.f, 'ref', valueParse); } } Else { Col = color (fRect.f, 'ref'); } "

And in Grid.js

" _defaultConfig: function () { Return Util.deepUpdate (lang.clone (this.inherited (arguments)), { Glyph: 'MultiVariantHaploidViewer / View / FeatureGlyph / Variant', Style: { Height: 5, MatrixColor: function (feat, gt, gtString) { // if (console.log) {console.log (feat, gt, gtString)}; If (gt === 'ref') { Return 'blue'; } Else { Return 'red'; } Return 'cyan'; } } }); "

And I have my SNP

But I also have a bug when I class my populations: When I use "sortByPopulation": true, Only labels change positions and SNPs no longer correspond to the correct strains capture du 2016-12-01 09-03-09 capture du 2016-12-01 09-04-06

cmdcolin commented 7 years ago

In the ideal case, you could actually just change colors using the config file instead of modifying the code

If the code is modified though, it helps if it is properly formatted, and even more ideally, posted as the output of git diff so that I can see the differences

Sorry to be picky, hope to help though

cmdcolin commented 7 years ago

I added a fix for the sort by population thing. I think it should help

Also I added an example to the test/data/ folder for custom coloring -- here's a simple example that works on haploid vcf (and shouldn't require modifying the plugin source code)

    {
         "label": "haploid (altcolor)",
         "urlTemplate": "out.vcf.gz",
         "storeClass": "JBrowse/Store/SeqFeature/VCFTabix",
         "type": "MultiVariantViewer/View/Track/Grid",
         "style": {
             "matrixColor": "function(feat, ref, gt) { return ref=='ref' ? 'blue' : 'red'; }"
         }
sravel commented 7 years ago

Thanks for quick fixes I updated the code then I try your example but I think there is still a problem.

If I look at the log I have: Object {data: Object, _id: "Chromosome_8.1 / 2774991 // A / G / 1492.0 / ..."} alt 1 Object {data: Object, _id: "Chromosome_8.1 / 2774991 // A / G / 1492.0 / ..."} alt 0

So it takes alt in any case ... I think the problem come from Variant.js Line 37: if (split == '') Split in my case returns undefined in not an empty string

cmdcolin commented 7 years ago

Thanks for the testing @sravel. I went back and made this part of the code for determining how to handle haploid vcf more intuitive and robust. Specifically it handles the "alt allele is 0 means reference base" case that I think you have. Hopefully that fixes it!

sravel commented 7 years ago

Thanks you for the quick fix, everything works correctly on my haploid data

cmdcolin commented 7 years ago

Awesome :)