-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Variants and Features GA4GH, with GA4GH example file #464
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Some data for the demo. | ||
|
||
// We are going to use the same data source for multiple tracks | ||
var bamSource = pileup.formats.bam({ | ||
url: '/test-data/synth3.normal.17.7500000-7515000.bam', | ||
indexUrl: '/test-data/synth3.normal.17.7500000-7515000.bam.bai' | ||
}); | ||
|
||
// This URL points to the GA4GH Reference Server, which | ||
// can be accessed for examples of standardized endpoints | ||
// for genomic data. All available GA4GH endpoints can | ||
// be found here: http://1kgenomes.ga4gh.org | ||
var ga4ghReferenceServer = 'http://1kgenomes.ga4gh.org'; | ||
|
||
var sources = [ | ||
{ | ||
viz: pileup.viz.genome(), | ||
isReference: true, | ||
data: pileup.formats.twoBit({ | ||
url: 'http://www.biodalliance.org/datasets/hg19.2bit' | ||
}), | ||
name: 'Reference' | ||
}, | ||
{ | ||
viz: pileup.viz.scale(), | ||
name: 'Scale' | ||
}, | ||
{ | ||
viz: pileup.viz.location(), | ||
name: 'Location' | ||
}, | ||
{ | ||
viz: pileup.viz.genes(), | ||
data: pileup.formats.bigBed({ | ||
url: 'http://www.biodalliance.org/datasets/ensGene.bb' | ||
}), | ||
name: 'Genes' | ||
}, | ||
{ | ||
viz: pileup.viz.variants(), | ||
data: pileup.formats.GAVariant({ | ||
endpoint: ga4ghReferenceServer, | ||
variantSetId: "WyIxa2dlbm9tZXMiLCJ2cyIsInBoYXNlMy1yZWxlYXNlIl0", | ||
callSetIds: ["WyIxa2dlbm9tZXMiLCJ2cyIsInBoYXNlMy1yZWxlYXNlIiwiSEcwMDA5NiJd"], | ||
killChr: true | ||
}), | ||
options: { | ||
onVariantClicked: function(data) { | ||
var content = "Variants:\n"; | ||
for (var i =0;i< data.length;i++) { | ||
content += `${data[i].id}: Ref: ${data[i].ref}, Alt: `; | ||
data[i].alt.forEach(alt => { | ||
content += `${alt} `; | ||
}) | ||
content += '\n'; | ||
} | ||
alert(content); | ||
}, | ||
}, | ||
name: 'Phase3 Release Variants' | ||
}, | ||
{ | ||
viz: pileup.viz.features(), | ||
data: pileup.formats.GAFeature({ | ||
endpoint: ga4ghReferenceServer, | ||
featureSetId: "WyIxa2dlbm9tZXMiLCJnZW5jb2RlX3YyNGxpZnQzNyJd", | ||
}), | ||
name: 'gencode_v24lift37' | ||
}, | ||
{ | ||
viz: pileup.viz.coverage(), | ||
data: pileup.formats.GAReadAlignment({ | ||
endpoint: ga4ghReferenceServer, | ||
readGroupId: "WyIxa2dlbm9tZXMiLCJyZ3MiLCJOQTEyODc4IiwiU1JSNjIyNDYxIl0", | ||
killChr: true, | ||
forcedReferenceId: "WyJOQ0JJMzciLCIxIl0" | ||
}), | ||
cssClass: 'normal', | ||
name: 'Coverage' | ||
}, | ||
{ | ||
viz: pileup.viz.pileup(), | ||
data: pileup.formats.GAReadAlignment({ | ||
endpoint: ga4ghReferenceServer, | ||
readGroupId: "WyIxa2dlbm9tZXMiLCJyZ3MiLCJOQTEyODc4IiwiU1JSNjIyNDYxIl0", | ||
killChr: true, | ||
forcedReferenceId: "WyJOQ0JJMzciLCIxIl0" | ||
}), | ||
cssClass: 'normal', | ||
name: 'NA12878' | ||
} | ||
]; | ||
|
||
var range = {contig: 'chr1', start: 120000, stop: 125000}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<link rel="stylesheet" href="../style/pileup.css" /> | ||
<link rel="stylesheet" href="demo.css" /> | ||
</head> | ||
|
||
<body> | ||
<button id="jiggle">FPS test</button> | ||
<div id="pileup"></div> | ||
</body> | ||
|
||
<script src="../node_modules/stats.js/build/stats.min.js"></script> | ||
<script src="../dist/pileup.js"></script> | ||
<!-- or: | ||
<script src="../dist/pileup.min.js"></script> | ||
--> | ||
|
||
<script src="data-ga4gh.js"></script> | ||
<script src="playground.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Class for parsing features. | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
import ContigInterval from '../ContigInterval'; | ||
|
||
class Feature { | ||
id: string; | ||
featureType: string; | ||
contig: string; | ||
start: number; | ||
stop: number; | ||
score: number; | ||
|
||
constructor(feature: Object) { | ||
this.id = feature.id; | ||
this.featureType = feature.featureType; | ||
this.contig = feature.contig; | ||
this.start = feature.start; | ||
this.stop = feature.stop; | ||
this.score = feature.score; | ||
} | ||
|
||
static fromGA4GH(ga4ghFeature: Object): Feature { | ||
return new Feature( | ||
{ | ||
id: ga4ghFeature.id, | ||
featureType: ga4ghFeature.featureType, | ||
contig: ga4ghFeature.referenceName, | ||
start: ga4ghFeature.start, | ||
stop: ga4ghFeature.end, | ||
score: 1000 | ||
}); | ||
} | ||
|
||
intersects(range: ContigInterval<string>): boolean { | ||
return range.intersects(new ContigInterval(this.contig, this.start, this.stop)); | ||
} | ||
} | ||
|
||
module.exports = Feature; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Class for parsing variants. | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
import ContigInterval from '../ContigInterval'; | ||
|
||
class Variant { | ||
contig: string; | ||
position: number; | ||
ref: string; | ||
alt: string; | ||
id: string; | ||
//this is the biggest allele frequency for single vcf entry | ||
//single vcf entry might contain more than one variant like the example below | ||
//20 1110696 rs6040355 A G,T 67 PASS NS=2;DP=10;AF=0.333,0.667;AA=T;DB | ||
majorFrequency: ?number; | ||
//this is the smallest allel frequency for single vcf entry | ||
minorFrequency: ?number; | ||
vcfLine: string; | ||
|
||
|
||
constructor(variant: Object) { | ||
this.contig = variant.contig; | ||
this.position = variant.position; | ||
this.ref = variant.ref; | ||
this.alt = variant.alt; | ||
this.id = variant.id; | ||
this.majorFrequency = variant.majorFrequency; | ||
this.minorFrequency = variant.minorFrequency; | ||
this.vcfLine = variant.vcfLine; | ||
} | ||
|
||
static fromGA4GH(ga4ghVariant: Object): Variant { | ||
return new Variant( | ||
{ | ||
contig: ga4ghVariant.referenceName, | ||
position: ga4ghVariant.start, | ||
id: ga4ghVariant.id, | ||
ref: ga4ghVariant.referenceBases, | ||
alt: ga4ghVariant.alternateBases, | ||
majorFrequency: 0, | ||
minorFrequency: 0, // TODO extract these | ||
vcfLine: "" // TODO | ||
}); | ||
} | ||
|
||
intersects(range: ContigInterval<string>): boolean { | ||
return intersects(this, range); | ||
} | ||
|
||
} | ||
|
||
function intersects(variant: Variant, range: ContigInterval<string>): boolean { | ||
return range.intersects(new ContigInterval(variant.contig, variant.position, variant.position + 1)); | ||
} | ||
|
||
module.exports = { | ||
Variant, | ||
intersects | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kudos for isolating all these GA4GH integration parts into a separate example 🙇