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.

Revisions

  1. flekschas revised this gist Mar 3, 2021. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # 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
  2. flekschas created this gist Mar 3, 2021.
    84 changes: 84 additions & 0 deletions gosling.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,84 @@
    {
    "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
    }
    ]
    }
    ]
    }