Last active
July 22, 2021 00:42
-
-
Save sacundim/19953a4dc104e0434612ed176cc763b6 to your computer and use it in GitHub Desktop.
Visualización Vega-Lite de CoVariants.org para Puerto Rico
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
{ | |
"config": { | |
"axis": {"labelFontSize": 14, "titleFontSize": 14}, | |
"header": {"labelFontSize": 14, "titleFontSize": 14}, | |
"legend": {"labelFontSize": 14, "titleFontSize": 14}, | |
"title": {"align": "center", "fontSize": 20, "offset": 15} | |
}, | |
"data": { | |
"url": "https://raw.githubusercontent.com/hodcroftlab/covariants/master/cluster_tables/USAClusters_data.json", | |
"format": { | |
"type": "json", | |
"property": "countries['Puerto Rico']" | |
} | |
}, | |
"title": { | |
"text": "Porcientos de secuencias de variantes en Puerto Rico", | |
"subtitle": [ | |
"Datos y análisis: CoVariants.org. Fechas recientes o con pocos datos son menos fiables." | |
] | |
}, | |
"vconcat": [ | |
{ | |
"mark": {"type": "bar", "opacity": 0.9, "tooltip": true}, | |
"encoding": { | |
"x": { | |
"type": "temporal", | |
"timeUnit": "yearmonthdate", | |
"field": "since", | |
"title": null, | |
"axis": { | |
"labels": false | |
} | |
}, | |
"x2": { | |
"field": "until" | |
}, | |
"y": { | |
"type": "quantitative", | |
"field": "percent", | |
"title": "% variantes", | |
"axis": { | |
"format": "%" | |
} | |
}, | |
"color": { | |
"type": "nominal", | |
"field": "key", | |
"title": "Variante", | |
"legend": { | |
"orient": "top", | |
"columns": 5, | |
"direction": "vertical" | |
} | |
}, | |
"order": { | |
"type":"quantitative", | |
"field": "percent", | |
"sort": "descending" | |
} | |
}, | |
"width": 575, | |
"height": 300 | |
}, | |
{ | |
"mark": { | |
"type": "bar", | |
"opacity": 0.85, | |
"color": "grey", | |
"tooltip": true | |
}, | |
"encoding": { | |
"x": { | |
"type": "temporal", | |
"field": "since", | |
"title": "Fecha muestra" | |
}, | |
"x2": { | |
"field": "until" | |
}, | |
"y": { | |
"type": "quantitative", | |
"field": "total_sequences", | |
"aggregate": "max", | |
"title": "Secuencias", | |
"axis": { | |
"format": ",d" | |
} | |
} | |
}, | |
"width": 575, | |
"height": 75 | |
} | |
], | |
"transform": [ | |
{ | |
"flatten": [ | |
"week", | |
"total_sequences", | |
"20I (Alpha, V1)", | |
"20H (Beta, V2)", | |
"20J (Gamma, V3)", | |
"21A (Delta)", | |
"21B (Kappa)", | |
"21C (Epsilon)", | |
"21D (Eta)", | |
"21F (Iota)", | |
"21G (Lambda)", | |
"21H" | |
] | |
}, | |
{"calculate": "toDate(datum.week)", "as": "since"}, | |
{ | |
"window": [{ | |
"op": "lead", | |
"param": 1, | |
"field": "since", | |
"as": "until" | |
}] | |
}, | |
{ | |
"fold": [ | |
"20I (Alpha, V1)", | |
"20H (Beta, V2)", | |
"20J (Gamma, V3)", | |
"21A (Delta)", | |
"21B (Kappa)", | |
"21C (Epsilon)", | |
"21D (Eta)", | |
"21F (Iota)", | |
"21G (Lambda)", | |
"21H" | |
] | |
}, | |
{"joinaggregate": [ | |
{ | |
"as": "variant", | |
"op": "sum", | |
"field": "value" | |
} | |
], | |
"groupby": ["week"] | |
}, | |
{"calculate": "datum.variant - datum.value", "as": "Other"}, | |
{"calculate": "datum.value / datum.total_sequences", "as": "percent"} | |
], | |
"$schema": "https://vega.github.io/schema/vega-lite/v4.8.1.json", | |
"datasets": { | |
"covariants": { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment