Skip to content

Instantly share code, notes, and snippets.

@ngehlenborg
Created May 10, 2022 21:34
Show Gist options
  • Save ngehlenborg/afcce2bf8f31f0203f83f89d5cd51235 to your computer and use it in GitHub Desktop.
Save ngehlenborg/afcce2bf8f31f0203f83f89d5cd51235 to your computer and use it in GitHub Desktop.
Gosling Data Transformation Example: Filtering reads from an indexed BAM file based on MAPQ score

Gosling Data Transformation Example

Filter reads from an indexed BAM file based on MAPQ score

Created with help by @sehilyi

{
"title": "Filtering Reads Based on MAPQ Scores",
"subtitle": "",
"static": false,
"layout": "linear",
"centerRadius": 0.05,
"xDomain": {"chromosome": "1", "interval": [136750, 139450]},
"spacing": 0.01,
"tracks": [
{
"alignment": "overlay",
"title": "Original Coverage",
"data": {
"type": "bam",
"url": "https://s3.amazonaws.com/gosling-lang.org/data/example_higlass.bam",
"indexUrl": "https://s3.amazonaws.com/gosling-lang.org/data/example_higlass.bam.bai",
"loadMates": true
},
"mark": "bar",
"tracks": [
{
"dataTransform": [
{"type": "coverage", "startField": "start", "endField": "end"}
],
"x": {"field": "start", "type": "genomic"},
"xe": {"field": "end", "type": "genomic"},
"y": {"field": "coverage", "type": "quantitative", "axis": "right"},
"color": {"value": "#C6C6C6"}
}
],
"width": 1250,
"height": 80
},
{
"alignment": "overlay",
"title": "Original Reads",
"data": {
"type": "bam",
"url": "https://s3.amazonaws.com/gosling-lang.org/data/example_higlass.bam",
"indexUrl": "https://s3.amazonaws.com/gosling-lang.org/data/example_higlass.bam.bai",
"loadMates": true,
"maxInsertSize": 300
},
"mark": "rect",
"tracks": [
{
"dataTransform": [
{
"type": "displace",
"method": "pile",
"boundingBox": {
"startField": "start",
"endField": "end",
"padding": 5,
"isPaddingBP": true
},
"newField": "pileup-row"
}
],
"x": {"field": "start", "type": "genomic"},
"xe": {"field": "end", "type": "genomic"},
"color": {
"field": "mapq",
"type": "quantitative",
"legend": true
}
}
],
"tooltip": [
{"field": "start", "type": "genomic"},
{"field": "end", "type": "genomic"},
{"field": "insertSize", "type": "quantitative"},
{"field": "mapq", "type": "quantitative"},
{"field": "svType", "type": "nominal"},
{"field": "strand", "type": "nominal"},
{"field": "numMates", "type": "quantitative"},
{"field": "mateIds", "type": "nominal"}
],
"row": {"field": "pileup-row", "type": "nominal", "padding": 0.2},
"width": 1250,
"height": 400
},
{
"alignment": "overlay",
"title": "Filtered Coverage (mapq = 0)",
"data": {
"type": "bam",
"url": "https://s3.amazonaws.com/gosling-lang.org/data/example_higlass.bam",
"indexUrl": "https://s3.amazonaws.com/gosling-lang.org/data/example_higlass.bam.bai",
"loadMates": true
},
"mark": "bar",
"tracks": [
{
"dataTransform": [
{ "type": "filter", "field": "mapq", "oneOf": [0] },
{"type": "coverage", "startField": "start", "endField": "end"}
],
"x": {"field": "start", "type": "genomic"},
"xe": {"field": "end", "type": "genomic"},
"y": {"field": "coverage", "type": "quantitative", "axis": "right"},
"color": {"value": "#C6C6C6"}
}
],
"width": 1250,
"height": 80
},
{
"alignment": "overlay",
"title": "Filtered Reads (mapq = 0)",
"data": {
"type": "bam",
"url": "https://s3.amazonaws.com/gosling-lang.org/data/example_higlass.bam",
"indexUrl": "https://s3.amazonaws.com/gosling-lang.org/data/example_higlass.bam.bai",
"loadMates": true,
"maxInsertSize": 300
},
"mark": "rect",
"tracks": [
{
"dataTransform": [
{
"type": "filter",
"field": "mapq",
"oneOf": [0]
},
{
"type": "displace",
"method": "pile",
"boundingBox": {
"startField": "start",
"endField": "end",
"padding": 5,
"isPaddingBP": true
},
"newField": "pileup-row"
}
],
"x": {"field": "start", "type": "genomic"},
"xe": {"field": "end", "type": "genomic"},
"color": { "value": "#440154" }
}
],
"tooltip": [
{"field": "start", "type": "genomic"},
{"field": "end", "type": "genomic"},
{"field": "insertSize", "type": "quantitative"},
{"field": "mapq", "type": "quantitative"},
{"field": "svType", "type": "nominal"},
{"field": "strand", "type": "nominal"},
{"field": "numMates", "type": "quantitative"},
{"field": "mateIds", "type": "nominal"}
],
"row": {"field": "pileup-row", "type": "nominal", "padding": 0.2},
"width": 1250,
"height": 400
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment