Public
Edited
Feb 6, 2022
1 fork
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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
metadata_table = {
var arr = []
for (const field of metadata_fields) {
arr.push({'Field': field, 'Value': metaraw_data['Assay'][field]})
}
return arr
}
Insert cell
metadata_fields = ['Cell name', 'Cell type', 'Organ', 'Organism']
Insert cell
Insert cell
metaraw_data = fetch(metadataset_url)
.then(response => {
if (!response.ok) throw new Error(response.status);
return response.json();})
Insert cell
Insert cell
// Copied from PCR analysis notebook

promises = {
var promises = [];
for (var compound of metaraw_data.Compound) {
const smiles = compound.SMILES;
const safeSmiles = encodeURIComponent(smiles);
const svg_url = "https://chemidconvert.cloud.douglasconnect.com/v1/asSvg?width=200&height=200&smiles=" + safeSmiles;
const svg = fetch(svg_url).then(response => response.text());
promises.push(svg);
}
return promises;
}
Insert cell
Insert cell
svgs = Promise.all(promises)
Insert cell
Insert cell
compounds_table = {
var tbl = [];
var i = 0;
for (var compound of metaraw_data.Compound) {
tbl.push({
//'Compound': compound['Compound name of actual form used'], // removed, as several entries seem faulty. Which column represents the compound name in the form it has in the real data, form which the triplets have been created??
'Chem name': compound['CHEM_NAME'],
'Compound code': compound['Compound code'],
'Mol': svgs[i],
})
i = i + 1
}
return tbl;
};
Insert cell
Insert cell
current_selected_compound_code=selected_triplet.split(', ')[1]
Insert cell
current_mol=compounds_table.filter(c => {
return c['Compound code'] == current_selected_compound_code
});
Insert cell
Insert cell
// Import libraries for data table rendering
import {render_data_table} from '@info474/utilities'
Insert cell
item_data_with_cell_info = item_data.map(item => {
item["Cell"] = item["Row"] + item["Column"];
return item
})
Insert cell
item_data_selected_timepoint_with_cell_info = item_data_selected_timepoint.map(item => {
item["Cell"] = item["Row"] + item["Column"];
return item
})
Insert cell
item_data = fetch_dataset_to_array(dataset_url, query_options_filter_item)
Insert cell
item_data_selected_timepoint = fetch_dataset_to_array(dataset_url, query_options_filter_item_and_timepoint)
Insert cell
selected_item = selected_triplet.split(",")[0]
Insert cell
query_options_filter_item = {
return {
method: 'POST',
body: JSON.stringify({
columns: ["Item number", "Concentration", "Endpoint 1 measure timepoint", "Endpoint 1 normalized data", "Endpoint 1 data", "Row", "Column"],
condition: {
and: [
{exactSearch: [{ column: ["Item number"] }, selected_item]},
]
}
})
}
}
Insert cell
query_options_filter_item_and_timepoint = {
return {
method: 'POST',
body: JSON.stringify({
columns: ["Item number", "Concentration", "Endpoint 1 measure timepoint", "Endpoint 1 normalized data", "Endpoint 1 data", "Row", "Column"],
condition: {
and: [
{exactSearch: [{ column: ["Item number"] }, selected_item]},
{containedIn: [{ column: ["Endpoint 1 measure timepoint"] }, selected_timepoints]}
]
}
})
}
}
Insert cell
unique_exposures = get_unique_elements(all_conditions, "Endpoint 1 measure timepoint")
Insert cell
unique_concentrations = get_unique_elements(all_conditions, "Concentration")
Insert cell
unique_triplets = Array.from(new Set(compound_triplets)).sort()
Insert cell
unique_timepoints = get_unique_elements(all_conditions, "Endpoint 1 measure timepoint")
Insert cell
unique_items = get_unique_elements(all_conditions, "Item number").sort()
Insert cell
compound_triplets = all_conditions.filter(function(el) {
return el["Compound"] != null;
}).map(item => item["Item number"] + ", " + item["Compound code"] + ", " + item["Compound"]).sort()
Insert cell
all_conditions = fetch_dataset_to_array(dataset_url, query_options)
Insert cell
get_unique_elements = function(array, parameter) {
return Array.from(new Set(all_conditions.map(item => item[parameter])))
}
Insert cell
query_options = {
return {
method: 'POST',
body: JSON.stringify({
columns: ["Item number", "Compound code", "Compound", "Concentration", "Endpoint 1 measure timepoint"]
})
}
}
Insert cell
// Create function to fetch data. Query options defined in cell above

// Pass in an optional variable 'meta' to the function to make it request the metadata!
function fetch_dataset_to_array(dataset_url, query_options, datatype) {
return fetch(dataset_url, query_options).then(response_dataset => {
if (!response_dataset.ok) throw new Error(response_dataset.status);
if (datatype == null)
return response_dataset.json().then(json => json.results.map(x => x.data));
else if (datatype == 'meta' )
return response_dataset.json().then(json => json.results);
})
}
Insert cell
// Based on selected experiment, create unique url for request from the database
dataset_url = base_url_edelweiss + dataset_id + "/versions/latest/data"
Insert cell
metadataset_url = base_url_edelweiss + dataset_id + "/versions/latest/metadata"
Insert cell
// Manually add the different unique identificators for
dataset_id = {
if (selected_experiment == 'Exp 3, GLO') {return "d2292a34-1605-4b60-9792-27244ddcb05a"}
if (selected_experiment == 'Exp 3, FLUO') {return "a428a89f-1c95-45c3-ba61-8da13933cf47"}
if (selected_experiment == 'Exp 2, GLO') {return "08142397-6e7f-408a-9b85-4e4419f0b9ed"}
if (selected_experiment == 'Exp 2, FLUO') {return "cb4ed15f-c6ef-4fc5-81d9-07bde53d3dfd"}
if (selected_experiment == 'Exp 1, GLO') {return "786a972b-a35b-440d-953b-1a90b1f94178"}
if (selected_experiment == 'Exp 1, FLUO') {return "f125c292-a42b-40ea-b56f-55b7bb41e0e0"}
}
Insert cell
summary_dataset_with_fitted_data = {
const arr = []
for (const obj of summary_dataset) {
const obj2 = Object.create(obj)
const obj3 = Object.create(obj)
obj2['type'] = 'Data'
arr.push(obj2)
obj3['IC50'] = obj2['K'] * Math.pow(obj2['Timepoint'], -obj2['n'])
obj3['type'] = 'Haber'
arr.push(obj3)
}
return arr
}
Insert cell
summary_dataset_formatted = {
var arr = []
for (let index = 0; index < summary_dataset.length; ++index) {
var obj = summary_dataset[index]
var formatted_obj = {}
for (const property in obj) {
var value = obj[property]
var new_value = value
if (typeof(value)==='number') {new_value = value.toFixed(2)}
formatted_obj[property] = new_value
}
arr.push(formatted_obj)
}
return arr
}
Insert cell
summary_dataset = fetch_dataset_to_array(summary_dataset_url, summary_query_options)
Insert cell
selected_compound_code = selected_triplet.split(", ")[1]
Insert cell
summary_query_options = {
return {
method: 'POST',
body: JSON.stringify({
condition: {exactSearch: [{ column: ["Compound code"] }, selected_compound_code]}
})
}
}
Insert cell
summary_dataset_url = base_url_edelweiss + summary_dataset_id + "/versions/latest/data"
Insert cell
// Manually add the different unique identificators for
summary_dataset_id = {
/*
if (selected_experiment == 'Exp 3, GLO') {return "27d3bb96-96f2-47ed-9127-69c1ff923e44"}
if (selected_experiment == 'Exp 3, FLUO') {return "e9d7040f-c497-41c2-9220-18178edb5eb6"}
if (selected_experiment == 'Exp 2, GLO') {return "f21c89f2-810c-410f-a9f7-f0c44e47b8c5"}
if (selected_experiment == 'Exp 2, FLUO') {return "0fe5c09e-591e-4964-bf6b-187107f3fef8"}
if (selected_experiment == 'Exp 1, GLO') {return "547169c5-d933-4c3a-819a-a007f2264696"}
if (selected_experiment == 'Exp 1, FLUO') {return "bb089d46-d2cf-428b-9c62-8b8325123c1c"}
*/
if (selected_experiment == 'Exp 3, GLO') {return "3babcd94-1252-4cfe-be9f-3c9ef55ea708"}
if (selected_experiment == 'Exp 3, FLUO') {return "d7800540-6484-4e47-9dfc-d3c679cab896"}
if (selected_experiment == 'Exp 2, GLO') {return "7796d14c-081e-4046-bc14-a96c18679b70"}
if (selected_experiment == 'Exp 2, FLUO') {return "8e817a36-49aa-4c80-8cde-0b6aaa383728"}
if (selected_experiment == 'Exp 1, GLO') {return "edbc750c-12a2-4203-af5c-541a25908e25"}
if (selected_experiment == 'Exp 1, FLUO') {return "7f8026d2-de41-4c62-aff4-2795caf10cb0"}

}

Insert cell
// Set url for data base
base_url_edelweiss = 'https://api.develop.edelweiss.douglasconnect.com/datasets/'
Insert cell
Insert cell
// Import selection, range and toggle tools from inputs notebook
import {Select, Range, Toggle} from "@observablehq/inputs"
Insert cell
// Import vega-lite visualization library
import {vl} from "@vega/vega-lite-api"
Insert cell
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