Published
Edited
May 7, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
pathways = enrichr_output['KEGG_2015'].map(item => {return {
Pathway: item[1],
'Gene symbol': item[5].join(', '),
Rank: item[0],
'p-value': item[2],
'Adj. p-value': item[6],
'Z-score': item[3],
'Combined score': item[4]
}})
Insert cell
enrichr_output = fetch_enrichr(enrich_get_url, {method: 'GET'})
Insert cell
enrich_get_url = fetch_enrichr("https://amp.pharm.mssm.edu/Enrichr/addList", enrichr_post_query_options)
.then(content => content.userListId)
.then(userid => "https://amp.pharm.mssm.edu/Enrichr/enrich?userListId=" + userid + "&backgroundType=KEGG_2015")
Insert cell
formData = {
var f = new FormData()
f.append('list', genes_for_lineplot.join('\n'))
return f}
Insert cell
enrichr_post_query_options = {
return {
method: "POST",
body: formData}
}
Insert cell
function fetch_enrichr(url, query_options) {
return fetch(url, query_options).then(response_dataset => {
if (!response_dataset.ok) throw new Error(response_dataset.status);
return response_dataset.json();})
}
Insert cell
unique_deregulated_genes = Array.from(new Set(deregulated_genes))
Insert cell
deregulated_genes = [].concat(...reshaped_drugmatrix_fold_changes).map(item => item.SYMBOL)
Insert cell
reshaped_drugmatrix_fold_changes = [].concat(...drugmatrix_significant_fold_changes)
Insert cell
drugmatrix_significant_fold_changes.forEach((dataset, index_dataset) => get_fold_changes_with_samplenames(dataset, index_dataset, drugmatrix_samples_array))
Insert cell
get_fold_changes_with_samplenames = function(dataset, index_dataset, array_of_samplenames) {
dataset.forEach((row, index_row) => {
row["Sample"] = array_of_samplenames[index_dataset]
return row
})
return dataset
}
Insert cell
drugmatrix_significant_fold_changes = get_datasets_from_promises(drugmatrix_promised_fold_changes)
Insert cell
get_datasets_from_promises = function(array_of_promises) {
return Promise.all(array_of_promises).then(item => item.map(dataset => dataset.results.map(row => row.data)))
}
Insert cell
get_unique_sample_names = function(array_of_datasets, selected_datasets) {
var samplenames = [];
selected_datasets.forEach(dataset_id =>
{var samplename = array_of_datasets.filter(object => object["Dataset ID"] == dataset_id)[0]["Sample"]
samplenames.push(samplename)}
)
return samplenames;
}
Insert cell
drugmatrix_samples_array = get_unique_sample_names(drugmatrix_datasets_of_selected_compound, unique_drugmatrix_fold_changes_datasets)
Insert cell
drugmatrix_promised_fold_changes = get_promised_fold_changes_datasets(unique_drugmatrix_fold_changes_datasets)
Insert cell
get_promised_fold_changes_datasets = function(array_of_datasets) {
return array_of_datasets.map(dataset => {
return fetch(base_url_edelweiss + dataset + "/versions/latest/data", query_options_for_fold_changes).then(response_dataset => {
if (!response_dataset.ok) throw new Error(response_dataset.status);
return response_dataset.json();
})
})
}
Insert cell
query_options_for_fold_changes = {
return {
method: 'POST',
body: JSON.stringify({
condition: {
and: [
{lt: [{column: ["adj.P.Val"]}, padj_threshold]},
{or: [
{lt: [{column: ["logFC"]}, -logfc_threshold]},
{gt: [{column: ["logFC"]}, logfc_threshold]},
]},
]
},
columns: ["logFC", "SYMBOL", "ENSEMBL", "ENTREZID", "adj.P.Val"]
})
}
}
Insert cell
unique_drugmatrix_fold_changes_datasets = get_unique_fold_changes_datasets(drugmatrix_datasets_of_selected_compound)
Insert cell
function get_unique_fold_changes_datasets(array_of_datasets) {
var set_of_datasets = new Set(array_of_datasets.map(x =>x["Dataset ID"]));
return Array.from(set_of_datasets).filter(function(item) {return item != null;})
}
Insert cell
Insert cell
drugmatrix_datasets_of_selected_compound = fetch_dataset_to_array(drugmatrix_summary_url, query_options_filter_compound)
Insert cell
query_options_filter_inchikey_lowercase = {
return {
method: 'POST',
body: JSON.stringify({
condition: {
exactSearch: [{ column: ["InChI key"] }, selected_compound_inchikey.replace('InChIKey=','')],
}
})
}
}
Insert cell
query_options_filter_inchikey = {
return {
method: 'POST',
body: JSON.stringify({
condition: {exactSearch: [{ column: ["InChI Key"] }, selected_compound_inchikey]}
})
}
}
Insert cell
query_options_filter_compound = {
return {
method: 'POST',
body: JSON.stringify({
condition: {
exactSearch: [{ column: ["Compound"] }, selected_compound]
}
})
}
}
Insert cell
selected_compound_smiles = selected_compound_object["SMILES"]["canonical"]
Insert cell
function get_svg_from_smiles(smiles) {
const safeSmiles = encodeURIComponent(smiles);
const svg_url = "https://chemidconvert.cloud.douglasconnect.com/v1/asSvg?width=200&height=200&smiles=" + safeSmiles;
return fetch(svg_url).then(response => response.text());
}
Insert cell
Insert cell
compound_svg = get_svg_from_smiles(selected_compound_smiles)
Insert cell
selected_compound_inchikey = selected_compound_object["InChI Key"]
Insert cell
selected_compound_object = drugmatrix_summary_dataset.find(obj => {return obj.Compound === selected_compound})
Insert cell
compound_options = Array.from(new Set(drugmatrix_summary_dataset.map(obj => obj.Compound))).sort()
Insert cell
drugmatrix_summary_dataset = fetch_dataset_to_array(drugmatrix_summary_url, query_options_for_summary_compounds)
Insert cell
query_options_for_summary_compounds = {
return {
method: 'POST',
body: JSON.stringify({
columns: ["Compound", "SMILES", "InChI Key", "InChI", "CAS", "IUPAC name"]
})
}
}
Insert cell
function fetch_dataset_to_array(dataset_url, query_options) {
return fetch(dataset_url, query_options).then(response_dataset => {
if (!response_dataset.ok) throw new Error(response_dataset.status);
return response_dataset.json();}).then(json => json.results.map(x => x.data));
}
Insert cell
drugmatrix_summary_url = base_url_edelweiss + drugmatrix_summary_id + "/versions/latest/data"
Insert cell
drugmatrix_summary_id = '9c1c25e0-2943-4c36-9123-ccbb1f4ef2ae'
Insert cell
base_url_edelweiss = 'https://api.kit.edelweissconnect.com/datasets/'
Insert cell
import {Select, Range, Toggle, Table} from "@observablehq/inputs"
Insert cell
import {select, slider} from "@jashkenas/inputs"
Insert cell
import {vl} from "@vega/vega-lite-api"
Insert cell
import {render_data_table, table_styles, displayImage, displayCaution} from '@info474/utilities'
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more