Published
Edited
Apr 28, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
available_libs = [
'GO_Biological_Process_2018',
'GO_Cellular_Component_2018',
'GO_Molecular_Function_2018',
'GTEx_Tissue_Sample_Gene_Expression_Profiles_up',
'KEGG_2019_Human',
'ARCHS4_Tissues',
'ChEA_2016',
'MGI_Mammalian_Phenotype_Level_4_2019',
'Disease_Perturbations_from_GEO_up',
'Ligand_Perturbations_from_GEO_up',
'LINCS_L1000_Chem_Pert_down',
'Ligand_Perturbations_from_GEO_down',
]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
which_list = 'viz'
Insert cell
list_type = Generators.observe(notify => {

const mousemove = () => notify(cgm.params.tooltip.tooltip_type);
viewof cgm.addEventListener("click", mousemove);
notify(cgm.params.tooltip.tooltip_type);
return () => viewof cgm.removeEventListener("mousemove", mousemove);
})
Insert cell
dendro_gene_list = Generators.observe(notify => {

const mousemove = () => notify(cgm.params.dendro.selected_clust_names);
viewof cgm.addEventListener("click", mousemove);
notify(cgm.params.dendro.selected_clust_names);
return () => viewof cgm.removeEventListener("mousemove", mousemove);
})
Insert cell
viz_gene_list = Generators.observe(notify => {
const mouse_click = () => notify(cgm.params.labels.visible_labels.row);
viewof cgm.addEventListener("click", mouse_click);
notify(cgm.params.labels.visible_labels.row);
return () => viewof cgm.removeEventListener("mousemove", mouse_click);
})
Insert cell
gene_list = define_gene_list(dendro_gene_list, viz_gene_list)
Insert cell
function define_gene_list(dendro_gene_list, viz_gene_list){
let gene_list
console.log('list_type', list_type)
if (list_type === 'row-dendro'){
gene_list = dendro_gene_list
}
else if (list_type === 'matrix-cell'){
gene_list = viz_gene_list
} else {
// default to all visible genes
gene_list = viz_gene_list
}
return gene_list
}
Insert cell
Insert cell
// network = JSON.parse(viz_json_response.body)
network = FileAttachment("pbmc_2700.json").json()
Insert cell
// viz_json_response = {
// const response = await fetch(viz_json_url);
// return {
// ok: response.ok,
// body: await response.text()
// };
// }
Insert cell
// viz_json_url = 'https://raw.githubusercontent.com/ismms-himc/covid-19_tenoever/master/jsons/A549_diff_genes.json'
Insert cell
Insert cell
Insert cell
// list_id = JSON.parse(new_post_response.body).userListId.toString()
Insert cell
list_id = get_new_list_id(new_post_response)
Insert cell
function get_new_list_id(new_post_response){
console.log('get_new_list_id')
let new_list_id
try{
new_list_id = JSON.parse(new_post_response.body).userListId.toString()
} catch(err){
new_list_id = 'some-id'
}
return new_list_id
}
Insert cell
Insert cell
Insert cell
bar_data_ini = enr_arr//slice(0, num_enr_terms)
Insert cell
bar_data = bar_data_ini.slice(0, num_enr_terms)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// enr_arr_ini = JSON.parse(fetch_enrichment.body)[inst_lib]
enr_arr_ini = get_enr_arr_ini(fetch_enrichment, inst_lib)
Insert cell
function get_enr_arr_ini(fetch_enrichment, inst_lib){
let enr_arr_ini
try{
enr_arr_ini = JSON.parse(fetch_enrichment.body)[inst_lib]
} catch(err){
enr_arr_ini = []
}
return enr_arr_ini
}
Insert cell
Insert cell
Insert cell
// network = FileAttachment("pre-calc-viz.json").json()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
y_new = d3.scaleBand()
.domain(d3.range(bar_data_values.length))
.range([0, 22 * bar_data_values.length])
Insert cell
x_new = d3.scaleLinear()
.domain([0, d3.max(bar_data_values)])
.range([0, 950])
Insert cell
Insert cell
Insert cell
Insert cell
d3 = {
// const d3 = require('d3')
const d3 = await require("d3@5", "d3-array@2");
// d3.cloud = await require("d3-cloud@1");
return d3
}
Insert cell
Insert cell
Insert cell
// set table style to full width
html`
<style>
p {
min-width: 100%;
}
h1, h2, h3, h4 {
min-width: 100%;
}
`
Insert cell
Insert cell
Insert cell
d3format = require("d3-format@1")
Insert cell
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