Published
Edited
Apr 20, 2020
1 fork
Importers
13 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//chart_treatment_by_severity_prevention = generate_research_evolution_treatment_type(
// "Research evolution for treatment types : prevention",
// d => d["Study aim"] === "Prevention"
//)
Insert cell
Insert cell
Insert cell
// No more relevant as
//chart_treatment_by_severity_post = generate_research_evolution_treatment_type(
// "Research evolution for treatment types : post treatment",
// d => d["Study aim"] === "Post treatment"
//)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data_agg_authors = d3.nest().key(function(d) { return d["First author"]; }).rollup(function(values) { return values.length }).entries(data_agg.map(d => d.value))
Insert cell
Insert cell
data_agg
Insert cell
data_agg_treatment1 = get_data_agg_field("Treatment type")
Insert cell
Insert cell
data_agg_treatment1
Insert cell
Insert cell
data_agg.map(d => d.value.values)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
data
Insert cell
data_agg
Insert cell
data_agg.map(function(d, i) { return d.value.values.map(e => e["Treatment type"]) })
Insert cell
html`<img src="https://covid-nma.com/wp-content/uploads/2020/04/network-mild-070420-800x450.jpg" width=500>
<br>
`
Insert cell
html`<img src="https://covid-nma.com/wp-content/uploads/2020/04/network-severe-070420-800x450.jpg" width=500>
<br>
`
Insert cell
html`<img src="https://covid-nma.com/wp-content/uploads/2020/04/network-heterogeneous-070420-800x450.jpg" width=600>
<br>
`
Insert cell
html`<img src="https://covid-nma.com/wp-content/uploads/2020/04/Network-europe-070420-800x450.jpg" width=600>
<br>`
Insert cell
html`<img src="https://covid-nma.com/wp-content/uploads/2020/04/Rplot-treatment-type-eu_page-0001-800x566.jpg" width=600>
<br>
`
Insert cell
d3 = require("d3@5")
Insert cell
vegalite = require("@observablehq/vega-lite@0.2")
Insert cell
data = d3.csvParse(await FileAttachment("Database 080420_140420.csv").text())
Insert cell
data_agg = d3.nest().key(function(d) { return d["Trial ID"]; }).rollup(function(values) {
return {values: values,
"Recruitment status": values[0]["Recruitment status"],
"Countries": values[0]["Countries"],
"Center": values[0]["Center"],
"First author": values[0]["First author"],
"Publication date online": values[0]["Publication date online"],
"Trial registration number": values[0]["Trial registration number"],
"Funding": values[0]["Funding"],
"Severity": values[0]["Severity scale"],
"Study design": values[0]["Study design"],
"registration_code": values[0]["Trial registration number"].slice(0, 3)
}
}).entries(data);
Insert cell
Treatment_type1 = new Set(data.map(d => d["Treatment type"]))
Insert cell
Treatment_type1_list = Array.from(Treatment_type1)
Insert cell
Array.from(Treatment_type1).map(d => 0)
Insert cell
Insert cell
md`Using [UpSets](https://observablehq.com/@sgratzl/upset-observable-example?collection=@sgratzl/upset-visualization-technique) to visualize co-occurences`
Insert cell
all_co_binary = data_agg.map(function(d, i) {
let a = Array.from(Treatment_type1).map(d => 0)
d.value.values.forEach(function(e) {
i = Treatment_type1_list.indexOf(e["Treatment type1"])
a[i] = 1
})
return a
})
Insert cell
// EXPERIMENTAL
// Only with a dataset otherwise too many intersections
// We need to reduce the number of categories
all_co_data = data_agg.filter((d, i) => i < 30).map(function(d, i) {
let sets = []
d.value.values.forEach(function(e) {
// if(e["Treatment type1"] != "*")
sets.push(e["Treatment type1"])
})
let a = {}
a["name"] = d.value["Trial registration number"]
a["Trial registration number"] = d.value["Trial registration number"]
a["First author"] = d.value["First author"]
a["Publication date online"] = d.value["Publication date online"]
a["sets"] = sets
return a
})
Insert cell
sets = extractSets(all_co_data)
Insert cell
intersections = generateIntersections(sets).sort(
(a, b) => b.cardinality - a.cardinality
)
Insert cell
intersections
Insert cell
viewof selection = UpSet(sets, intersections)
Insert cell
printTable(selection ? selection.elems.map(d => d): "")
Insert cell
selection
Insert cell
bycontinent = new Map(d3.nest().key(d => d).rollup(v => v.length).entries(Array.from(countriesIndex).map(d => Array.from(new Set(d[1].map(d => continents.get(d))))).flat()).map(d => [d.key, d.value]))
Insert cell
Insert cell
Insert cell
import {
checkbox,
slider,
button,
text,
select,
autoSelect,
radio
} from "@jashkenas/inputs"
Insert cell
import {printTable} from '@uwdata/data-utilities'
Insert cell
// https://observablehq.com/d/3c709ffbafcdb388
import {
map,
viewof textFilter,
viewof recruitmentFilter,
viewof zoomType,
countriesIndex,
continents
} from "3c709ffbafcdb388"
Insert cell
md`Other Viz

https://observablehq.com/d/8215857ffae42ded

`
Insert cell
stackedBar = vl.markBar()
.data(data_agg.map(d => d.value))
.encode(
vl.x().fieldO("Countries"),//.timeUnit("utcmonth"),
vl.y().count(), // .stack("normalize").axis({ format: "%" }),
vl.color().fieldN("continent") // .scale({ range: weatherColors })
)
.render()
Insert cell
// Without Date filter
chart_date_strip = embed({
data: {values: data},
mark: "tick",
width: width/2,
encoding: {
x: {field: "Registration date", type: "temporal"}
}
})
Insert cell
embed = require("vega-embed@6")
Insert cell
vegalite({
data: {values: data.filter(d => (new Date(d["Registration date"]) > new Date("2019")) )},
mark: "area",
width: width/2,
encoding: {
y: {aggregate: "count", field: "Treatment type1", type: "quantitative"},
x: {field: "Registration date", type: "temporal"},
color: {field: "Treatment type", "type":"nominal", "scale":{"scheme": "category20b"}}
},
})
Insert cell
md`OLD CHARTS`
Insert cell
html`<img src="https://covid-nma.com/wp-content/uploads/2020/04/Rplot-countries_page-0001-800x566.jpg" width=200>`
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more