Skip to content

Instantly share code, notes, and snippets.

@bherr2
Last active May 1, 2019 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bherr2/542482aea690cea2a299f5153aa212eb to your computer and use it in GitHub Desktop.
Save bherr2/542482aea690cea2a299f5153aa212eb to your computer and use it in GitHub Desktop.
HuBMAP Partonomy Tree Visualization
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 1200,
"height": 2400,
"padding": 5,
"signals": [
{
"name": "labels",
"value": true,
"bind": {
"input": "checkbox"
}
},
{
"name": "layout",
"value": "tidy",
"bind": {
"input": "radio",
"options": [
"tidy",
"cluster"
]
}
},
{
"name": "links",
"value": "diagonal",
"bind": {
"input": "select",
"options": [
"line",
"curve",
"diagonal",
"orthogonal"
]
}
}
],
"data": [
{
"name": "tree",
"url": "https://cdn.jsdelivr.net/gh/hubmapconsortium/hubmap-ontology/ontologies/partonomy/reifications/partonomy.jsonld",
"transform": [
{
"type": "project",
"fields": [
"@id",
{
"expr": "if(isArray(datum.parent), datum.parent[0]['@id'], null)"
},
{
"expr": "datum['http://www.w3.org/2000/01/rdf-schema#label'][0]['@value']"
},
{
"expr": "if(isArray(datum['http://www.geneontology.org/formats/oboInOwl#id']), datum['http://www.geneontology.org/formats/oboInOwl#id'][0]['@value'], datum['@id'])"
},
{
"expr": "datum['http://www.geneontology.org/formats/oboInOwl#hasExactSynonym']"
}
],
"as": [
"iri",
"parent",
"name",
"id",
"altLabels"
]
},
{
"type": "stratify",
"key": "iri",
"parentKey": "parent"
},
{
"type": "tree",
"method": {
"signal": "layout"
},
"size": [
{
"signal": "height"
},
{
"signal": "width - 100"
}
],
"as": [
"y",
"x",
"depth",
"children"
]
}
]
},
{
"name": "links",
"source": "tree",
"transform": [
{
"type": "treelinks"
},
{
"type": "linkpath",
"orient": "horizontal",
"shape": {
"signal": "links"
}
}
]
}
],
"scales": [
{
"name": "color",
"type": "linear",
"range": {
"scheme": "magma"
},
"domain": {
"data": "tree",
"field": "depth"
},
"zero": true
}
],
"marks": [
{
"type": "path",
"from": {
"data": "links"
},
"encode": {
"update": {
"path": {
"field": "path"
},
"stroke": {
"value": "#ccc"
}
}
}
},
{
"type": "symbol",
"from": {
"data": "tree"
},
"encode": {
"enter": {
"size": {
"value": 100
},
"stroke": {
"value": "#fff"
}
},
"update": {
"x": {
"field": "x"
},
"y": {
"field": "y"
},
"fill": {
"scale": "color",
"field": "depth"
}
}
}
},
{
"type": "text",
"from": {
"data": "tree"
},
"encode": {
"enter": {
"text": {
"field": "name"
},
"fontSize": {
"value": 9
},
"baseline": {
"value": "middle"
}
},
"update": {
"x": {
"field": "x"
},
"y": {
"field": "y"
},
"dx": {
"signal": "datum.children ? -7 : 7"
},
"align": {
"signal": "datum.children ? 'right' : 'left'"
},
"opacity": {
"signal": "labels ? 1 : 0"
}
}
}
}
]
}
@bherr2
Copy link
Author

bherr2 commented Apr 24, 2019

You can see the visualization live here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment