Skip to content

Instantly share code, notes, and snippets.

@flekschas
Last active March 3, 2021 19:06
Show Gist options
  • Save flekschas/a43a1c9924b36d9f0c66862c3314689c to your computer and use it in GitHub Desktop.
Save flekschas/a43a1c9924b36d9f0c66862c3314689c to your computer and use it in GitHub Desktop.
Sample-based encoding of multivecs

Sample-based encoding of multivecs

Using overlay in combination with dataTransform and filter we can customize the color encoding of each row in the multivec dataset.

This is more of a proof of concept rather than a recommendation. Normally you would just want to just one colormap instead of different once!

Live demo: https://gosling.js.org?gist=flekschas/a43a1c9924b36d9f0c66862c3314689c

{
"title": "Sample-based encoding of multivecs",
"subtitle": "Use different colormap per sample",
"layout": "circular",
// "arrangement": "vertical",
"centerRadius": 0.7,
"views": [
{
"tracks": [
{
"data": {
"url": "https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec",
"type": "multivec",
"row": "sample",
"column": "position",
"value": "peak",
"categories": ["sample 1", "sample 2", "sample 3", "sample 4"],
"binSize": 4
},
"overlay": [
{
"mark": "rect",
"dataTransform": {
"filter": [
{ "field": "sample", "oneOf": ["sample 1"] }
]
},
"color": {
"field": "peak",
"type": "quantitative",
"range": "viridis"
}
},
{
"mark": "rect",
"dataTransform": {
"filter": [
{ "field": "sample", "oneOf": ["sample 2"] }
]
},
"color": {
"field": "peak",
"type": "quantitative",
"range": "bupu"
}
},
{
"mark": "rect",
"dataTransform": {
"filter": [
{ "field": "sample", "oneOf": ["sample 3"] }
]
},
"color": {
"field": "peak",
"type": "quantitative",
"range": "spectral"
}
},
{
"mark": "rect",
"dataTransform": {
"filter": [
{ "field": "sample", "oneOf": ["sample 4"] }
]
},
"color": {
"field": "peak",
"type": "quantitative",
"range": "warm"
}
}
],
"x": {"field": "start", "type": "genomic", "axis": "top"},
"xe": {"field": "end", "type": "genomic"},
"row": {"field": "sample", "type": "nominal" , "domain": ["sample 1", "sample 2", "sample 3", "sample 4"]},
"color": {"field": "peak", "type": "quantitative"},
"width": 600,
"height": 46
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment