[Gmod-ajax] Data Access within VCF tracks and callbacks

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

[Gmod-ajax] Data Access within VCF tracks and callbacks

Paul Hale
Hi all,

I've been playing around with VCF files and I was curious if it's possible to set up SNP tracks with the ability to color code by differences in between two strains (of mice in this case)?  So idea being user selects strain A and B (from a drop-down menu or similar) and the track colors the features based on if there is a difference in strain.  I can see two hurdles with this... first, is there an easy way to assign track specific variables from drop down menus that can be accessible via style callbacks? Secondly, can you access elements of VCF files like you can with other feature tracks with feature.get() and then color with style.color= function(something)?  It's possible to recode these files into GFF3 then load via flatfile to json but I like certain elements of how the VCF details are displayed.

Thanks,
Paul Hale
Bioinformatics Analyst I
The Jackson Laboratory



The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: Data Access within VCF tracks and callbacks

Colin
There's actually a good example of customized coloring of a VCF track that you might have seen already that does something similar to what you were interested in: http://gmod.org/wiki/JBrowse_Configuration_Guide#Customizing_CanvasFeatures_tracks_with_callbacks
In this example, it actually calls feature.get('genotypes') and then it uses that to change the style.color=function(){} just as you suspected. Of course, this example has a crazy regex to parse the genotype, but you might be able to build on it to get the information about the different mouse strains.

-Colin


On Wed, Mar 19, 2014 at 10:52 AM, Paul Hale <[hidden email]> wrote:
Hi all,

I've been playing around with VCF files and I was curious if it's possible to set up SNP tracks with the ability to color code by differences in between two strains (of mice in this case)?  So idea being user selects strain A and B (from a drop-down menu or similar) and the track colors the features based on if there is a difference in strain.  I can see two hurdles with this... first, is there an easy way to assign track specific variables from drop down menus that can be accessible via style callbacks? Secondly, can you access elements of VCF files like you can with other feature tracks with feature.get() and then color with style.color= function(something)?  It's possible to recode these files into GFF3 then load via flatfile to json but I like certain elements of how the VCF details are displayed.

Thanks,
Paul Hale
Bioinformatics Analyst I
The Jackson Laboratory



The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: Data Access within VCF tracks and callbacks

Paul Hale

Duh… how’d I miss this?  At first I had thought this wasn’t working but I had these as HTML tracks instead.  Had to make a few changes as the example wasn’t working the way it was written for me.  So I currently have…

(line breaks added for clarity)

 

variantIsDistinct = function( feature )

{

var strainA = 'PWK/PhJ';

var strainB = 'DBA/2J';

var genotypes = feature.get('genotypes');

var gtStringA = genotypes[strainA].GT.values[0];

var gtStringB = genotypes[strainB].GT.values[0];

if (gtStringA===gtStringB){return 'blue';}else {return 'green';}

}

style.color =function(feature) {return this.track.config.variantIsDistinct(feature);}

 

Okay so right now I have the strains hard coded in… is there a good way to go about letting users change these strains to whatever they might want?  So say I have a right click context menu built up and I’d like to have clicking on a specific strain execute a function to update the strainA or strainB variables on a track wide scale so that this info is accessible to my style callback. 

 

Paul

 

From: Colin [[hidden email]]
Sent: Wednesday, March 19, 2014 12:50 PM
To: Paul Hale
Cc: [hidden email]
Subject: Re: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

There's actually a good example of customized coloring of a VCF track that you might have seen already that does something similar to what you were interested in: http://gmod.org/wiki/JBrowse_Configuration_Guide#Customizing_CanvasFeatures_tracks_with_callbacks

In this example, it actually calls feature.get('genotypes') and then it uses that to change the style.color=function(){} just as you suspected. Of course, this example has a crazy regex to parse the genotype, but you might be able to build on it to get the information about the different mouse strains.

 

-Colin

 

On Wed, Mar 19, 2014 at 10:52 AM, Paul Hale <[hidden email]> wrote:

Hi all,

I've been playing around with VCF files and I was curious if it's possible to set up SNP tracks with the ability to color code by differences in between two strains (of mice in this case)?  So idea being user selects strain A and B (from a drop-down menu or similar) and the track colors the features based on if there is a difference in strain.  I can see two hurdles with this... first, is there an easy way to assign track specific variables from drop down menus that can be accessible via style callbacks? Secondly, can you access elements of VCF files like you can with other feature tracks with feature.get() and then color with style.color= function(something)?  It's possible to recode these files into GFF3 then load via flatfile to json but I like certain elements of how the VCF details are displayed.

Thanks,
Paul Hale
Bioinformatics Analyst I
The Jackson Laboratory



The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax

 

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: Data Access within VCF tracks and callbacks

Paul Hale
In reply to this post by Colin

Colin,

 

So I’ve sort of answered my own question on this one… but now I have another issue.  So right now I have a small right click context menu that can update the strain.  A user clicks say DBA/2J and it runs a callback that sets this.track.strainA to DBA/2J or whatever.  That variable is then accessible via the style callback if I move all of the code into the style.color line itself rather than having a separate function like in the example (don’t know why). So everything works peachy other than the fact that this does not update the coloring until you move the browser a bit or mouse over each feature… which is annoying.  Is there something that I can set that will re-render the track when a user clicks on a new strain?  Trial and error has yet to produce results.

 

Thanks,

Paul

 

From: Paul Hale
Sent: Wednesday, March 19, 2014 3:57 PM
To: 'Colin'
Cc: [hidden email]
Subject: RE: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

Duh… how’d I miss this?  At first I had thought this wasn’t working but I had these as HTML tracks instead.  Had to make a few changes as the example wasn’t working the way it was written for me.  So I currently have…

(line breaks added for clarity)

 

variantIsDistinct = function( feature )

{

var strainA = 'PWK/PhJ';

var strainB = 'DBA/2J';

var genotypes = feature.get('genotypes');

var gtStringA = genotypes[strainA].GT.values[0];

var gtStringB = genotypes[strainB].GT.values[0];

if (gtStringA===gtStringB){return 'blue';}else {return 'green';}

}

style.color =function(feature) {return this.track.config.variantIsDistinct(feature);}

 

Okay so right now I have the strains hard coded in… is there a good way to go about letting users change these strains to whatever they might want?  So say I have a right click context menu built up and I’d like to have clicking on a specific strain execute a function to update the strainA or strainB variables on a track wide scale so that this info is accessible to my style callback. 

 

Paul

 

From: Colin [[hidden email]]
Sent: Wednesday, March 19, 2014 12:50 PM
To: Paul Hale
Cc:
[hidden email]
Subject: Re: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

There's actually a good example of customized coloring of a VCF track that you might have seen already that does something similar to what you were interested in: http://gmod.org/wiki/JBrowse_Configuration_Guide#Customizing_CanvasFeatures_tracks_with_callbacks

In this example, it actually calls feature.get('genotypes') and then it uses that to change the style.color=function(){} just as you suspected. Of course, this example has a crazy regex to parse the genotype, but you might be able to build on it to get the information about the different mouse strains.

 

-Colin

 

On Wed, Mar 19, 2014 at 10:52 AM, Paul Hale <[hidden email]> wrote:

Hi all,

I've been playing around with VCF files and I was curious if it's possible to set up SNP tracks with the ability to color code by differences in between two strains (of mice in this case)?  So idea being user selects strain A and B (from a drop-down menu or similar) and the track colors the features based on if there is a difference in strain.  I can see two hurdles with this... first, is there an easy way to assign track specific variables from drop down menus that can be accessible via style callbacks? Secondly, can you access elements of VCF files like you can with other feature tracks with feature.get() and then color with style.color= function(something)?  It's possible to recode these files into GFF3 then load via flatfile to json but I like certain elements of how the VCF details are displayed.

Thanks,
Paul Hale
Bioinformatics Analyst I
The Jackson Laboratory



The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax

 

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.


------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees_APR
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: Data Access within VCF tracks and callbacks

Colin
You could maybe try using "this.track.redraw()" at the end of the function to force a redraw. I'm glad you got this far though, this seems like a very good feature.

Also, as far as the function problem you had, you may need to pass the 'this' parameter manually to that function (not too sure about scoping but it sounds like that could be the issue).

Thanks,
-Colin




On Mon, Apr 7, 2014 at 10:50 AM, Paul Hale <[hidden email]> wrote:

Colin,

 

So I’ve sort of answered my own question on this one… but now I have another issue.  So right now I have a small right click context menu that can update the strain.  A user clicks say DBA/2J and it runs a callback that sets this.track.strainA to DBA/2J or whatever.  That variable is then accessible via the style callback if I move all of the code into the style.color line itself rather than having a separate function like in the example (don’t know why). So everything works peachy other than the fact that this does not update the coloring until you move the browser a bit or mouse over each feature… which is annoying.  Is there something that I can set that will re-render the track when a user clicks on a new strain?  Trial and error has yet to produce results.

 

Thanks,

Paul

 

From: Paul Hale
Sent: Wednesday, March 19, 2014 3:57 PM
To: 'Colin'
Cc: [hidden email]
Subject: RE: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

Duh… how’d I miss this?  At first I had thought this wasn’t working but I had these as HTML tracks instead.  Had to make a few changes as the example wasn’t working the way it was written for me.  So I currently have…

(line breaks added for clarity)

 

variantIsDistinct = function( feature )

{

var strainA = 'PWK/PhJ';

var strainB = 'DBA/2J';

var genotypes = feature.get('genotypes');

var gtStringA = genotypes[strainA].GT.values[0];

var gtStringB = genotypes[strainB].GT.values[0];

if (gtStringA===gtStringB){return 'blue';}else {return 'green';}

}

style.color =function(feature) {return this.track.config.variantIsDistinct(feature);}

 

Okay so right now I have the strains hard coded in… is there a good way to go about letting users change these strains to whatever they might want?  So say I have a right click context menu built up and I’d like to have clicking on a specific strain execute a function to update the strainA or strainB variables on a track wide scale so that this info is accessible to my style callback. 

 

Paul

 

From: Colin [[hidden email]]
Sent: Wednesday, March 19, 2014 12:50 PM
To: Paul Hale
Cc:
[hidden email]
Subject: Re: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

There's actually a good example of customized coloring of a VCF track that you might have seen already that does something similar to what you were interested in: http://gmod.org/wiki/JBrowse_Configuration_Guide#Customizing_CanvasFeatures_tracks_with_callbacks

In this example, it actually calls feature.get('genotypes') and then it uses that to change the style.color=function(){} just as you suspected. Of course, this example has a crazy regex to parse the genotype, but you might be able to build on it to get the information about the different mouse strains.

 

-Colin

 

On Wed, Mar 19, 2014 at 10:52 AM, Paul Hale <[hidden email]> wrote:

Hi all,

I've been playing around with VCF files and I was curious if it's possible to set up SNP tracks with the ability to color code by differences in between two strains (of mice in this case)?  So idea being user selects strain A and B (from a drop-down menu or similar) and the track colors the features based on if there is a difference in strain.  I can see two hurdles with this... first, is there an easy way to assign track specific variables from drop down menus that can be accessible via style callbacks? Secondly, can you access elements of VCF files like you can with other feature tracks with feature.get() and then color with style.color= function(something)?  It's possible to recode these files into GFF3 then load via flatfile to json but I like certain elements of how the VCF details are displayed.

Thanks,
Paul Hale
Bioinformatics Analyst I
The Jackson Laboratory



The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax

 

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.



------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: Data Access within VCF tracks and callbacks

Paul Hale

Colin,

 

Eureka!  I think that finishes it up.  Should be a very useful feature indeed.  Makes sense now with the function scoping but since its working I’m not going to mess with it.

 

Thanks again,

Paul

 

From: Colin [mailto:[hidden email]]
Sent: Monday, April 07, 2014 1:47 PM
To: Paul Hale
Cc: [hidden email]
Subject: Re: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

You could maybe try using "this.track.redraw()" at the end of the function to force a redraw. I'm glad you got this far though, this seems like a very good feature.

Also, as far as the function problem you had, you may need to pass the 'this' parameter manually to that function (not too sure about scoping but it sounds like that could be the issue).

Thanks,

-Colin

 

 

 

On Mon, Apr 7, 2014 at 10:50 AM, Paul Hale <[hidden email]> wrote:

Colin,

 

So I’ve sort of answered my own question on this one… but now I have another issue.  So right now I have a small right click context menu that can update the strain.  A user clicks say DBA/2J and it runs a callback that sets this.track.strainA to DBA/2J or whatever.  That variable is then accessible via the style callback if I move all of the code into the style.color line itself rather than having a separate function like in the example (don’t know why). So everything works peachy other than the fact that this does not update the coloring until you move the browser a bit or mouse over each feature… which is annoying.  Is there something that I can set that will re-render the track when a user clicks on a new strain?  Trial and error has yet to produce results.

 

Thanks,

Paul

 

From: Paul Hale
Sent: Wednesday, March 19, 2014 3:57 PM
To: 'Colin'
Cc: [hidden email]
Subject: RE: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

Duh… how’d I miss this?  At first I had thought this wasn’t working but I had these as HTML tracks instead.  Had to make a few changes as the example wasn’t working the way it was written for me.  So I currently have…

(line breaks added for clarity)

 

variantIsDistinct = function( feature )

{

var strainA = 'PWK/PhJ';

var strainB = 'DBA/2J';

var genotypes = feature.get('genotypes');

var gtStringA = genotypes[strainA].GT.values[0];

var gtStringB = genotypes[strainB].GT.values[0];

if (gtStringA===gtStringB){return 'blue';}else {return 'green';}

}

style.color =function(feature) {return this.track.config.variantIsDistinct(feature);}

 

Okay so right now I have the strains hard coded in… is there a good way to go about letting users change these strains to whatever they might want?  So say I have a right click context menu built up and I’d like to have clicking on a specific strain execute a function to update the strainA or strainB variables on a track wide scale so that this info is accessible to my style callback. 

 

Paul

 

From: Colin [[hidden email]]
Sent: Wednesday, March 19, 2014 12:50 PM
To: Paul Hale
Cc:
[hidden email]
Subject: Re: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

There's actually a good example of customized coloring of a VCF track that you might have seen already that does something similar to what you were interested in: http://gmod.org/wiki/JBrowse_Configuration_Guide#Customizing_CanvasFeatures_tracks_with_callbacks

In this example, it actually calls feature.get('genotypes') and then it uses that to change the style.color=function(){} just as you suspected. Of course, this example has a crazy regex to parse the genotype, but you might be able to build on it to get the information about the different mouse strains.

 

-Colin

 

On Wed, Mar 19, 2014 at 10:52 AM, Paul Hale <[hidden email]> wrote:

Hi all,

I've been playing around with VCF files and I was curious if it's possible to set up SNP tracks with the ability to color code by differences in between two strains (of mice in this case)?  So idea being user selects strain A and B (from a drop-down menu or similar) and the track colors the features based on if there is a difference in strain.  I can see two hurdles with this... first, is there an easy way to assign track specific variables from drop down menus that can be accessible via style callbacks? Secondly, can you access elements of VCF files like you can with other feature tracks with feature.get() and then color with style.color= function(something)?  It's possible to recode these files into GFF3 then load via flatfile to json but I like certain elements of how the VCF details are displayed.

Thanks,
Paul Hale
Bioinformatics Analyst I
The Jackson Laboratory



The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax

 

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

 

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.


------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: Data Access within VCF tracks and callbacks

Paul Hale
In reply to this post by Colin

Colin,

 

So I’ve been messing around with this some more and I have found a new issue… and I’m not sure where its coming from.  I have two tracks configured like this and both have the same issue… the last strain in each file is unable to be accessed.  Every other strain is accessible but even trying to access it causes an error.  Out of curiosity I set up a callback to extract all strains and this returned…

 

129P2,129S1,129S5,AJ,AKRJ,BALBcJ,C3HHeJ,C57BL6NJ,CASTEiJ,CBAJ,DBA2J,FVBNJ,LPJ,NODShiLtJ,NZOHlLtJ,PWKPhJ,SPRETEiJ,WSBEiJ ,toString,

 

So it shows a space after the strain… then it returns toString.  Tried to add the space after the strain name but that didn’t help either.  Both VCF’s appear to be correctly formed so I don’t know if the issue could be from the VCF store. 

 

Thanks,

Paul 

 

From: Colin [mailto:[hidden email]]
Sent: Monday, April 07, 2014 1:47 PM
To: Paul Hale
Cc: [hidden email]
Subject: Re: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

You could maybe try using "this.track.redraw()" at the end of the function to force a redraw. I'm glad you got this far though, this seems like a very good feature.

Also, as far as the function problem you had, you may need to pass the 'this' parameter manually to that function (not too sure about scoping but it sounds like that could be the issue).

Thanks,

-Colin

 

 

 

On Mon, Apr 7, 2014 at 10:50 AM, Paul Hale <[hidden email]> wrote:

Colin,

 

So I’ve sort of answered my own question on this one… but now I have another issue.  So right now I have a small right click context menu that can update the strain.  A user clicks say DBA/2J and it runs a callback that sets this.track.strainA to DBA/2J or whatever.  That variable is then accessible via the style callback if I move all of the code into the style.color line itself rather than having a separate function like in the example (don’t know why). So everything works peachy other than the fact that this does not update the coloring until you move the browser a bit or mouse over each feature… which is annoying.  Is there something that I can set that will re-render the track when a user clicks on a new strain?  Trial and error has yet to produce results.

 

Thanks,

Paul

 

From: Paul Hale
Sent: Wednesday, March 19, 2014 3:57 PM
To: 'Colin'
Cc: [hidden email]
Subject: RE: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

Duh… how’d I miss this?  At first I had thought this wasn’t working but I had these as HTML tracks instead.  Had to make a few changes as the example wasn’t working the way it was written for me.  So I currently have…

(line breaks added for clarity)

 

variantIsDistinct = function( feature )

{

var strainA = 'PWK/PhJ';

var strainB = 'DBA/2J';

var genotypes = feature.get('genotypes');

var gtStringA = genotypes[strainA].GT.values[0];

var gtStringB = genotypes[strainB].GT.values[0];

if (gtStringA===gtStringB){return 'blue';}else {return 'green';}

}

style.color =function(feature) {return this.track.config.variantIsDistinct(feature);}

 

Okay so right now I have the strains hard coded in… is there a good way to go about letting users change these strains to whatever they might want?  So say I have a right click context menu built up and I’d like to have clicking on a specific strain execute a function to update the strainA or strainB variables on a track wide scale so that this info is accessible to my style callback. 

 

Paul

 

From: Colin [[hidden email]]
Sent: Wednesday, March 19, 2014 12:50 PM
To: Paul Hale
Cc:
[hidden email]
Subject: Re: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

There's actually a good example of customized coloring of a VCF track that you might have seen already that does something similar to what you were interested in: http://gmod.org/wiki/JBrowse_Configuration_Guide#Customizing_CanvasFeatures_tracks_with_callbacks

In this example, it actually calls feature.get('genotypes') and then it uses that to change the style.color=function(){} just as you suspected. Of course, this example has a crazy regex to parse the genotype, but you might be able to build on it to get the information about the different mouse strains.

 

-Colin

 

On Wed, Mar 19, 2014 at 10:52 AM, Paul Hale <[hidden email]> wrote:

Hi all,

I've been playing around with VCF files and I was curious if it's possible to set up SNP tracks with the ability to color code by differences in between two strains (of mice in this case)?  So idea being user selects strain A and B (from a drop-down menu or similar) and the track colors the features based on if there is a difference in strain.  I can see two hurdles with this... first, is there an easy way to assign track specific variables from drop down menus that can be accessible via style callbacks? Secondly, can you access elements of VCF files like you can with other feature tracks with feature.get() and then color with style.color= function(something)?  It's possible to recode these files into GFF3 then load via flatfile to json but I like certain elements of how the VCF details are displayed.

Thanks,
Paul Hale
Bioinformatics Analyst I
The Jackson Laboratory



The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax

 

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

 

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: Data Access within VCF tracks and callbacks

Colin
When I tried just printing out the contents of feature.get('genotypes') as a raw string from a VCF with many samples it looked sort of how you described it


{"c181.variant":{"GT":["1/1"],"GQ":["99"],"PL":["255","75","0"]},"c182.variant2":{"GT":["1/1"],"GQ":["99"],"PL":["255","75","0"]},"c195.variant3":{"GT":["1/1"],"GQ":["99"],"PL":["255","60","0"]},"c196.variant4":{"GT":["./."],"GQ":[""],"PL":[""]},...more here....,"s302_d05_hybrid.variant39\n":{"GT":["./."],"GQ":[""],"PL":[""]},"toString":{}}

We might be able to open an issue to remove that "toString" property since it seems odd, but i would just filter it manually for now. For the whitespace problem, i'm not too sure what the cause is, but some of my examples contained newlines as well, so the names might need to be trimmed manually too.

-Colin



On Tue, Apr 15, 2014 at 1:07 PM, Paul Hale <[hidden email]> wrote:

Colin,

 

So I’ve been messing around with this some more and I have found a new issue… and I’m not sure where its coming from.  I have two tracks configured like this and both have the same issue… the last strain in each file is unable to be accessed.  Every other strain is accessible but even trying to access it causes an error.  Out of curiosity I set up a callback to extract all strains and this returned…

 

129P2,129S1,129S5,AJ,AKRJ,BALBcJ,C3HHeJ,C57BL6NJ,CASTEiJ,CBAJ,DBA2J,FVBNJ,LPJ,NODShiLtJ,NZOHlLtJ,PWKPhJ,SPRETEiJ,WSBEiJ ,toString,

 

So it shows a space after the strain… then it returns toString.  Tried to add the space after the strain name but that didn’t help either.  Both VCF’s appear to be correctly formed so I don’t know if the issue could be from the VCF store. 

 

Thanks,

Paul 

 

From: Colin [mailto:[hidden email]]
Sent: Monday, April 07, 2014 1:47 PM


To: Paul Hale
Cc: [hidden email]
Subject: Re: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

You could maybe try using "this.track.redraw()" at the end of the function to force a redraw. I'm glad you got this far though, this seems like a very good feature.

Also, as far as the function problem you had, you may need to pass the 'this' parameter manually to that function (not too sure about scoping but it sounds like that could be the issue).

Thanks,

-Colin

 

 

 

On Mon, Apr 7, 2014 at 10:50 AM, Paul Hale <[hidden email]> wrote:

Colin,

 

So I’ve sort of answered my own question on this one… but now I have another issue.  So right now I have a small right click context menu that can update the strain.  A user clicks say DBA/2J and it runs a callback that sets this.track.strainA to DBA/2J or whatever.  That variable is then accessible via the style callback if I move all of the code into the style.color line itself rather than having a separate function like in the example (don’t know why). So everything works peachy other than the fact that this does not update the coloring until you move the browser a bit or mouse over each feature… which is annoying.  Is there something that I can set that will re-render the track when a user clicks on a new strain?  Trial and error has yet to produce results.

 

Thanks,

Paul

 

From: Paul Hale
Sent: Wednesday, March 19, 2014 3:57 PM
To: 'Colin'
Cc: [hidden email]
Subject: RE: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

Duh… how’d I miss this?  At first I had thought this wasn’t working but I had these as HTML tracks instead.  Had to make a few changes as the example wasn’t working the way it was written for me.  So I currently have…

(line breaks added for clarity)

 

variantIsDistinct = function( feature )

{

var strainA = 'PWK/PhJ';

var strainB = 'DBA/2J';

var genotypes = feature.get('genotypes');

var gtStringA = genotypes[strainA].GT.values[0];

var gtStringB = genotypes[strainB].GT.values[0];

if (gtStringA===gtStringB){return 'blue';}else {return 'green';}

}

style.color =function(feature) {return this.track.config.variantIsDistinct(feature);}

 

Okay so right now I have the strains hard coded in… is there a good way to go about letting users change these strains to whatever they might want?  So say I have a right click context menu built up and I’d like to have clicking on a specific strain execute a function to update the strainA or strainB variables on a track wide scale so that this info is accessible to my style callback. 

 

Paul

 

From: Colin [[hidden email]]
Sent: Wednesday, March 19, 2014 12:50 PM
To: Paul Hale
Cc:
[hidden email]
Subject: Re: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

There's actually a good example of customized coloring of a VCF track that you might have seen already that does something similar to what you were interested in: http://gmod.org/wiki/JBrowse_Configuration_Guide#Customizing_CanvasFeatures_tracks_with_callbacks

In this example, it actually calls feature.get('genotypes') and then it uses that to change the style.color=function(){} just as you suspected. Of course, this example has a crazy regex to parse the genotype, but you might be able to build on it to get the information about the different mouse strains.

 

-Colin

 

On Wed, Mar 19, 2014 at 10:52 AM, Paul Hale <[hidden email]> wrote:

Hi all,

I've been playing around with VCF files and I was curious if it's possible to set up SNP tracks with the ability to color code by differences in between two strains (of mice in this case)?  So idea being user selects strain A and B (from a drop-down menu or similar) and the track colors the features based on if there is a difference in strain.  I can see two hurdles with this... first, is there an easy way to assign track specific variables from drop down menus that can be accessible via style callbacks? Secondly, can you access elements of VCF files like you can with other feature tracks with feature.get() and then color with style.color= function(something)?  It's possible to recode these files into GFF3 then load via flatfile to json but I like certain elements of how the VCF details are displayed.

Thanks,
Paul Hale
Bioinformatics Analyst I
The Jackson Laboratory



The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax

 

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

 

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.



------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: Data Access within VCF tracks and callbacks

Paul Hale

Colin,

 

I’ve tried looking at the VCF store but it’s a bit beyond me.  Short term solution for anyone else that might have this issue is manually adding another genotype at the end of the geno line in the VCF.  So in my case I’ve added a reference genotype and just coded it 0/0 down the board.  Since I can get the reference allele other ways this doesn’t trip me up and the last real genotype is again accessible to my callback. 

 

Paul

 

From: Colin [mailto:[hidden email]]
Sent: Thursday, April 17, 2014 4:31 PM
To: Paul Hale
Cc: [hidden email]
Subject: Re: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

When I tried just printing out the contents of feature.get('genotypes') as a raw string from a VCF with many samples it looked sort of how you described it


{"c181.variant":{"GT":["1/1"],"GQ":["99"],"PL":["255","75","0"]},"c182.variant2":{"GT":["1/1"],"GQ":["99"],"PL":["255","75","0"]},"c195.variant3":{"GT":["1/1"],"GQ":["99"],"PL":["255","60","0"]},"c196.variant4":{"GT":["./."],"GQ":[""],"PL":[""]},...more here....,"s302_d05_hybrid.variant39\n":{"GT":["./."],"GQ":[""],"PL":[""]},"toString":{}}

We might be able to open an issue to remove that "toString" property since it seems odd, but i would just filter it manually for now. For the whitespace problem, i'm not too sure what the cause is, but some of my examples contained newlines as well, so the names might need to be trimmed manually too.

-Colin

 

On Tue, Apr 15, 2014 at 1:07 PM, Paul Hale <[hidden email]> wrote:

Colin,

 

So I’ve been messing around with this some more and I have found a new issue… and I’m not sure where its coming from.  I have two tracks configured like this and both have the same issue… the last strain in each file is unable to be accessed.  Every other strain is accessible but even trying to access it causes an error.  Out of curiosity I set up a callback to extract all strains and this returned…

 

129P2,129S1,129S5,AJ,AKRJ,BALBcJ,C3HHeJ,C57BL6NJ,CASTEiJ,CBAJ,DBA2J,FVBNJ,LPJ,NODShiLtJ,NZOHlLtJ,PWKPhJ,SPRETEiJ,WSBEiJ ,toString,

 

So it shows a space after the strain… then it returns toString.  Tried to add the space after the strain name but that didn’t help either.  Both VCF’s appear to be correctly formed so I don’t know if the issue could be from the VCF store. 

 

Thanks,

Paul 

 

From: Colin [mailto:[hidden email]]
Sent: Monday, April 07, 2014 1:47 PM


To: Paul Hale
Cc: [hidden email]
Subject: Re: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

You could maybe try using "this.track.redraw()" at the end of the function to force a redraw. I'm glad you got this far though, this seems like a very good feature.

Also, as far as the function problem you had, you may need to pass the 'this' parameter manually to that function (not too sure about scoping but it sounds like that could be the issue).

Thanks,

-Colin

 

 

 

On Mon, Apr 7, 2014 at 10:50 AM, Paul Hale <[hidden email]> wrote:

Colin,

 

So I’ve sort of answered my own question on this one… but now I have another issue.  So right now I have a small right click context menu that can update the strain.  A user clicks say DBA/2J and it runs a callback that sets this.track.strainA to DBA/2J or whatever.  That variable is then accessible via the style callback if I move all of the code into the style.color line itself rather than having a separate function like in the example (don’t know why). So everything works peachy other than the fact that this does not update the coloring until you move the browser a bit or mouse over each feature… which is annoying.  Is there something that I can set that will re-render the track when a user clicks on a new strain?  Trial and error has yet to produce results.

 

Thanks,

Paul

 

From: Paul Hale
Sent: Wednesday, March 19, 2014 3:57 PM
To: 'Colin'
Cc: [hidden email]
Subject: RE: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

Duh… how’d I miss this?  At first I had thought this wasn’t working but I had these as HTML tracks instead.  Had to make a few changes as the example wasn’t working the way it was written for me.  So I currently have…

(line breaks added for clarity)

 

variantIsDistinct = function( feature )

{

var strainA = 'PWK/PhJ';

var strainB = 'DBA/2J';

var genotypes = feature.get('genotypes');

var gtStringA = genotypes[strainA].GT.values[0];

var gtStringB = genotypes[strainB].GT.values[0];

if (gtStringA===gtStringB){return 'blue';}else {return 'green';}

}

style.color =function(feature) {return this.track.config.variantIsDistinct(feature);}

 

Okay so right now I have the strains hard coded in… is there a good way to go about letting users change these strains to whatever they might want?  So say I have a right click context menu built up and I’d like to have clicking on a specific strain execute a function to update the strainA or strainB variables on a track wide scale so that this info is accessible to my style callback. 

 

Paul

 

From: Colin [[hidden email]]
Sent: Wednesday, March 19, 2014 12:50 PM
To: Paul Hale
Cc:
[hidden email]
Subject: Re: [Gmod-ajax] Data Access within VCF tracks and callbacks

 

There's actually a good example of customized coloring of a VCF track that you might have seen already that does something similar to what you were interested in: http://gmod.org/wiki/JBrowse_Configuration_Guide#Customizing_CanvasFeatures_tracks_with_callbacks

In this example, it actually calls feature.get('genotypes') and then it uses that to change the style.color=function(){} just as you suspected. Of course, this example has a crazy regex to parse the genotype, but you might be able to build on it to get the information about the different mouse strains.

 

-Colin

 

On Wed, Mar 19, 2014 at 10:52 AM, Paul Hale <[hidden email]> wrote:

Hi all,

I've been playing around with VCF files and I was curious if it's possible to set up SNP tracks with the ability to color code by differences in between two strains (of mice in this case)?  So idea being user selects strain A and B (from a drop-down menu or similar) and the track colors the features based on if there is a difference in strain.  I can see two hurdles with this... first, is there an easy way to assign track specific variables from drop down menus that can be accessible via style callbacks? Secondly, can you access elements of VCF files like you can with other feature tracks with feature.get() and then color with style.color= function(something)?  It's possible to recode these files into GFF3 then load via flatfile to json but I like certain elements of how the VCF details are displayed.

Thanks,
Paul Hale
Bioinformatics Analyst I
The Jackson Laboratory



The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax

 

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

 

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

 

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax