[Gmod-ajax] VCF Callbacks to load additional json data to a fieldname

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[Gmod-ajax] VCF Callbacks to load additional json data to a fieldname

Hans Vasquez-Gross
Hi All,

I have a new requirement for my project to display SeedAvailability for a given sample name displayed in a VCF track on JBrowse. The plan right now is to create a .json file with the Seed Availability information and create functions on the VCF tracks to pull in this information.  This way I can update the .json file with seed availability, without having to update the VCF file every time.

For now though, I'm having trouble just getting started using callbacks.  I am trying to configuration demo of changing alternative_alleles to be labled as "Alternative Alleles", but I'm not seeing the change.

[track configuration]
[ tracks.snpsgenomeHCsnpeff ]
storeClass     = JBrowse/Store/SeqFeature/VCFTabix
urlTemplate    = ../../vcf_files/genomeref/Kronos.ktc3.genomeref.HC.snpeff.withSeed.vcf.gz
tbiUrlTemplate = ../../vcf_files/genomeref/Kronos.ktc3.genomeref.HC.snpeff.withSeed.vcf.gz.tbi
category = Mutants
type = JBrowse/View/Track/CanvasVariants
fmtDetailField_alternative_alleles = function(fieldname) { return "Alternative alleles"; }
key  = Snpeff Mutants VCF

But I'm seeing no change in the track display.  Any suggestions would be greatly appreciated.

Inline image 1

Cheers,
-Hans

------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: VCF Callbacks to load additional json data to a fieldname

Colin
Do you have JBrowse 1.11.3? That is the first supported version of this feature. If so, can you try adding the same thing to volvox.vcf.conf and rerun setup.sh and check the volvox example to see if it worked?

Thanks
-Colin




On Fri, Apr 25, 2014 at 3:33 PM, Hans Vasquez-Gross <[hidden email]> wrote:
Hi All,

I have a new requirement for my project to display SeedAvailability for a given sample name displayed in a VCF track on JBrowse. The plan right now is to create a .json file with the Seed Availability information and create functions on the VCF tracks to pull in this information.  This way I can update the .json file with seed availability, without having to update the VCF file every time.

For now though, I'm having trouble just getting started using callbacks.  I am trying to configuration demo of changing alternative_alleles to be labled as "Alternative Alleles", but I'm not seeing the change.

[track configuration]
[ tracks.snpsgenomeHCsnpeff ]
storeClass     = JBrowse/Store/SeqFeature/VCFTabix
urlTemplate    = ../../vcf_files/genomeref/Kronos.ktc3.genomeref.HC.snpeff.withSeed.vcf.gz
tbiUrlTemplate = ../../vcf_files/genomeref/Kronos.ktc3.genomeref.HC.snpeff.withSeed.vcf.gz.tbi
category = Mutants
type = JBrowse/View/Track/CanvasVariants
fmtDetailField_alternative_alleles = function(fieldname) { return "Alternative alleles"; }
key  = Snpeff Mutants VCF

But I'm seeing no change in the track display.  Any suggestions would be greatly appreciated.

Inline image 1

Cheers,
-Hans

------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax



------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: VCF Callbacks to load additional json data to a fieldname

Hans Vasquez-Gross
Hi Colin,

I should have read the documentation more carefully.  After updating from 1.11.2 to 1.11.3, the simple example callback methods were working.  I successfully customized the 'View detail' popup by using the the fmtDetailValue_FOO operations to better display VCF files from the SnpEff program. 

Here is my code that I added:
fmtDetailValue_EFF = function(value) {
        newvalue = "";
        /* console.log(value); */
        if( value instanceof Array) {
            /* console.log(value[0]); */
            for(var i=0, len=value.length; i<len; i++) {
                counter = i+1;
                /* console.log(value[i]); */
                var firstSplit  = value[i].split("(");
                var dataSplit  = firstSplit[1].split("|");
                var eff_type = firstSplit[0];
                var eff_impact = dataSplit[0];
                var eff_class = dataSplit[1];
                var codondistance = dataSplit[2];
                var aa_change = dataSplit[3];
                var aa_length = dataSplit[4];
                var hit_name = dataSplit[5];
                var gene_name = dataSplit[8];
                var snp_warnings = dataSplit[11].replace(")", "");
                /* console.log("String array: " + dataSplit); */
                newvalue += "<b>SnpEffect_" + counter + ":</b><br>Transcript = " + gene_name + "<br>Mutation Effect = " + eff_type;
                if(codondistance != "") {
                    newvalue += "<br>Codon change/distance = " + codondistance;
                }
                if(aa_change != "") {
                    newvalue += "<br>Amino acid change = " + aa_change
                }
                if(eff_impact != "") {
                    newvalue += "<br>Effect impact = " + eff_impact
                }
                if(eff_class != "") {
                    newvalue += "<br>Functional class = " + eff_class;
                }
                if(snp_warnings != "") {
                    newvalue += "<br>SnpEff Warnings = " + snp_warnings + "<br>";
                }
            }
        }
        return newvalue;
    }

Original Screenshot:
Inline image 1

New Display ScreenShot:
Inline image 2



However, working through this example raised a question.  How do I get access to data outside the current FieldName?  IE. I was able to transform the SnpEff data with javascript functions because I had everything I needed in the original string.   However, now I want to also include the SampleID (third column in the VCF file header labeled as ID), I'm having trouble getting this data.  In this case, it would be Kronos166.   I tried adding 'feature' to the function 
 fmtDetailValue_EFF = function(value, feature) {
...
}

and getting the data using
 var sample_id = feature.get('ID');

but it didn't work.

Example VCF line with header information for the example above:
##CHROM POS     ID      REF     ALT     QUAL    FILTER  INFO
IWGSC_CSS_5BS_scaff_2265844     7444    Kronos166       C       T       40.0    Pass    Kronos166;EFF=NON_SYNONYMOUS_CODING(MODERATE|MISSENSE|gCc/gTc|A356V||Traes_5BS_8D39DFC55.E8|||transcript:Traes_5BS

Any advice would be greatly appreciated.

Cheers,
-Hans

  

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: VCF Callbacks to load additional json data to a fieldname

Colin
Hi Hans,
Great work with that customization.
As far as your question, I don't know if i have the exact thing you are looking for (accessing the outside information about the feature), but I might have a workaround to help display the name: add the following to your track configuration under the "style" subsection:

style {
"label": "name,id",
"description": "note, description",
}

This will pick up the name or and description of the feature and display it in the "View details" dialog. I actually made note about this on github because i felt this should be enabled by default https://github.com/GMOD/jbrowse/issues/463
 
Does that help?
-Colin


On Tue, Apr 29, 2014 at 7:09 PM, Hans Vasquez-Gross <[hidden email]> wrote:
Hi Colin,

I should have read the documentation more carefully.  After updating from 1.11.2 to 1.11.3, the simple example callback methods were working.  I successfully customized the 'View detail' popup by using the the fmtDetailValue_FOO operations to better display VCF files from the SnpEff program. 

Here is my code that I added:
fmtDetailValue_EFF = function(value) {
        newvalue = "";
        /* console.log(value); */
        if( value instanceof Array) {
            /* console.log(value[0]); */
            for(var i=0, len=value.length; i<len; i++) {
                counter = i+1;
                /* console.log(value[i]); */
                var firstSplit  = value[i].split("(");
                var dataSplit  = firstSplit[1].split("|");
                var eff_type = firstSplit[0];
                var eff_impact = dataSplit[0];
                var eff_class = dataSplit[1];
                var codondistance = dataSplit[2];
                var aa_change = dataSplit[3];
                var aa_length = dataSplit[4];
                var hit_name = dataSplit[5];
                var gene_name = dataSplit[8];
                var snp_warnings = dataSplit[11].replace(")", "");
                /* console.log("String array: " + dataSplit); */
                newvalue += "<b>SnpEffect_" + counter + ":</b><br>Transcript = " + gene_name + "<br>Mutation Effect = " + eff_type;
                if(codondistance != "") {
                    newvalue += "<br>Codon change/distance = " + codondistance;
                }
                if(aa_change != "") {
                    newvalue += "<br>Amino acid change = " + aa_change
                }
                if(eff_impact != "") {
                    newvalue += "<br>Effect impact = " + eff_impact
                }
                if(eff_class != "") {
                    newvalue += "<br>Functional class = " + eff_class;
                }
                if(snp_warnings != "") {
                    newvalue += "<br>SnpEff Warnings = " + snp_warnings + "<br>";
                }
            }
        }
        return newvalue;
    }

Original Screenshot:
Inline image 1

New Display ScreenShot:
Inline image 2



However, working through this example raised a question.  How do I get access to data outside the current FieldName?  IE. I was able to transform the SnpEff data with javascript functions because I had everything I needed in the original string.   However, now I want to also include the SampleID (third column in the VCF file header labeled as ID), I'm having trouble getting this data.  In this case, it would be Kronos166.   I tried adding 'feature' to the function 
 fmtDetailValue_EFF = function(value, feature) {
...
}

and getting the data using
 var sample_id = feature.get('ID');

but it didn't work.

Example VCF line with header information for the example above:
##CHROM POS     ID      REF     ALT     QUAL    FILTER  INFO
IWGSC_CSS_5BS_scaff_2265844     7444    Kronos166       C       T       40.0    Pass    Kronos166;EFF=NON_SYNONYMOUS_CODING(MODERATE|MISSENSE|gCc/gTc|A356V||Traes_5BS_8D39DFC55.E8|||transcript:Traes_5BS

Any advice would be greatly appreciated.

Cheers,
-Hans

  


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: VCF Callbacks to load additional json data to a fieldname

Hans Vasquez-Gross
Hi Colin,

I am using tracks.conf to configure most of the tracks, rather then trackList.json.  I tried adding the following to tracks.conf.  

style.label = "name,id"
style.description = "note, description"

Before the change:
Inline image 1


After the change:
Inline image 2

However, now don't get any text on the main jbrowse interface (and the detail popup is the same).  It would be best to get detailed information about the feature, within a given fmtDetailField operation (or fmtDetailValue in any case).  However, that does not seem possible yet.  For now, I possible workaround could be to make sure all the data I need is in a given fmtDetailField.  


Cheers,
-Hans

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: VCF Callbacks to load additional json data to a fieldname

Colin
For the tracks.conf format, you don't have to add quotes to the right-hand side (the conf file parameters are automatically quoted, so this causes "double quotes").

Also I can double check on getting the feature data, but if it isn't possible currently, then we can look into adding it!

Thanks again,
-Colin


On Tue, Apr 29, 2014 at 8:52 PM, Hans Vasquez-Gross <[hidden email]> wrote:
Hi Colin,

I am using tracks.conf to configure most of the tracks, rather then trackList.json.  I tried adding the following to tracks.conf.  

style.label = "name,id"
style.description = "note, description"

Before the change:
Inline image 1


After the change:
Inline image 2

However, now don't get any text on the main jbrowse interface (and the detail popup is the same).  It would be best to get detailed information about the feature, within a given fmtDetailField operation (or fmtDetailValue in any case).  However, that does not seem possible yet.  For now, I possible workaround could be to make sure all the data I need is in a given fmtDetailField.  


Cheers,
-Hans


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: VCF Callbacks to load additional json data to a fieldname

Hans Vasquez-Gross
Hi Colin,

   Thank you, that fixed the issue of naming the tracks in the main GenomeView.  I don't think it's necessary to add this feature request.  I've come up with a nice solution to include the sample_id where needed.  

   One more question for you, what's the preferred method to use ajax calls to get json data?  I want to include this in a different callback.  I'm familiar and used jQuery to do this quite a bit.  However, I know JBrowse is built upon Dojo, so would the .xhrGet method be preferred?  This is an example call I found for Dojo.

dojo.xhrGet({
    url:"data.json",
    handleAs:"json",
    load: function(data){
        for(var i in data){
           console.log("key", i, "value", data[i]);
        }
    }
});


Cheers,
-Hans

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: VCF Callbacks to load additional json data to a fieldname

Hans Vasquez-Gross
Hi all,

Just incase this helps others in the future, using the dojo.xhrGet function worked just great.   

Sorry to bother you again, Colin.  One more question that was raised when my boss asked for a feature request.  If you take a look at the original screenshot I sent in my previous email, you will notice the Detail Popup window includes information on standard VCF fields like 'Score' and 'filter'.   Is there a way to hide these two standard fields, as they aren't going to be useful for our users and just adds clutter to the interface?  I know you can change formatting with the fmtField or fmtValue, but can you remove it entirely?

I tried the following, but you can still see the empty box because of the empty strings.
fmtDetailField_filter = function(fieldname) { return ""; }
fmtDetailValue_filter = function(value) { return ""; }

Thank you,
-Hans

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: VCF Callbacks to load additional json data to a fieldname

Colin
Not sure if that's possible at the moment. Unless you want to really hack it and just use javascript to delete the row, I can't think of it.

I will definitely look into this though, I think the dialogs could be a really important way to make jbrowse a better browser...this first step at customization was quite basic !

Thanks,
-Colin


On Wed, Apr 30, 2014 at 2:29 PM, Hans Vasquez-Gross <[hidden email]> wrote:
Hi all,

Just incase this helps others in the future, using the dojo.xhrGet function worked just great.   

Sorry to bother you again, Colin.  One more question that was raised when my boss asked for a feature request.  If you take a look at the original screenshot I sent in my previous email, you will notice the Detail Popup window includes information on standard VCF fields like 'Score' and 'filter'.   Is there a way to hide these two standard fields, as they aren't going to be useful for our users and just adds clutter to the interface?  I know you can change formatting with the fmtField or fmtValue, but can you remove it entirely?

I tried the following, but you can still see the empty box because of the empty strings.
fmtDetailField_filter = function(fieldname) { return ""; }
fmtDetailValue_filter = function(value) { return ""; }

Thank you,
-Hans


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: VCF Callbacks to load additional json data to a fieldname

Hans Vasquez-Gross
Thank you Colin.  You  and Robert (and the team) have done a really good job making it customizable, recently!  It's amazing how extensible it is with just a bit of javascript.  

If it is annoying enough for my boss, maybe he'll be willing to let me spend some development time to either hack it, or create a plugin.  Lately, I've been spending some quality time with the JBrowse src just to get more familiar with all the moving parts.  I feel like I have just scratched the surface.

Cheers,
-Hans

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: VCF Callbacks to load additional json data to a fieldname

Jillian Rowe
In reply to this post by Colin
I'm a bit late to the party, but why not just write a plugin that inherits from the usual VCF writer and overrides whatever methods you want?

In my experience its a lot easier than using a callback, but maybe that is just because I am not terribly familiar with javascript. ;)

I've already written a VCF plugin to restrict some views for different levels of login (PIs can see the individual genotypes, public can only see summary data) let me know if you'd like to take a look.

On 05/03/2014 03:49 AM, Colin wrote:
Not sure if that's possible at the moment. Unless you want to really hack it and just use javascript to delete the row, I can't think of it.

I will definitely look into this though, I think the dialogs could be a really important way to make jbrowse a better browser...this first step at customization was quite basic !

Thanks,
-Colin


On Wed, Apr 30, 2014 at 2:29 PM, Hans Vasquez-Gross <[hidden email]> wrote:
Hi all,

Just incase this helps others in the future, using the dojo.xhrGet function worked just great.   

Sorry to bother you again, Colin.  One more question that was raised when my boss asked for a feature request.  If you take a look at the original screenshot I sent in my previous email, you will notice the Detail Popup window includes information on standard VCF fields like 'Score' and 'filter'.   Is there a way to hide these two standard fields, as they aren't going to be useful for our users and just adds clutter to the interface?  I know you can change formatting with the fmtField or fmtValue, but can you remove it entirely?

I tried the following, but you can still see the empty box because of the empty strings.
fmtDetailField_filter = function(fieldname) { return ""; }
fmtDetailValue_filter = function(value) { return ""; }

Thank you,
-Hans



------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs


_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: VCF Callbacks to load additional json data to a fieldname

Hans Vasquez-Gross
Jillian,

I like your suggestion!  If you wouldn't mind, I'd love to read through some example code of how you were able to inherit and extend the VCF writer.   Please contact me off the listserve with the details.

Cheers,
-Hans





------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax