Published
Edited
Oct 25, 2019
Insert cell
Insert cell
md`### Ki Oh
#### This Observable Notebook is a documentation of the progress in this project`
Insert cell
Insert cell
md `### Load other people's modules`


Insert cell
projectData_ugly=(await fetch('https://api.gdc.cancer.gov/projects?fields=disease_type,name,program.name,project_id,summary.case_count&from=0&size=1000&sort=disease_type:asc')).json()
Insert cell
betterFetch = async function(url,body) {
let fetchData = {
method: 'POST',
body: JSON.stringify(body),
headers:{'Content-Type':'application/json'}
}
let tmpData=(await fetch(url, fetchData)).json()
return(tmpData)
}
Insert cell
projectData = {
let url = 'https://api.gdc.cancer.gov/projects'
let body = ({
'fields': "disease_type,name,program.name,project_id,summary.case_count",
'from': 0,
'size': 1000
})
return(await betterFetch(url,body))
}
Insert cell
getCaseCounts = function(projectData) {
let caseCounts=[];
projectData.data.hits.forEach(function(prj,i){
// for each hit (project)
caseCounts = caseCounts.concat({
"label" : prj.id,
"y" : prj.summary.case_count,})
})
return caseCounts
};
Insert cell
getSortedHistData = function(hitdata) {
let histData={}
hitdata.map(x=>{
if(!histData[x]){
histData[x]=0
}
histData[x]+=1
})
let histSorted = Object.keys(histData)
.sort(function(a,b){return histData[b]-histData[a]})
.reduce(function (acc, key) {
acc[key] = histData[key];
return acc;
}, {})
return(histSorted)
}
Insert cell
PrintTCGA = function(projectData) {
let div = DOM.element('div') // set up the main object
div.innerHTML='<h3 style="color:green">TCGA Project types in GDC (<span id="caseCountSpan"></span>)</h3>'
let ol=DOM.element('ol') // set up the sub-object which will contain our data
div.appendChild(ol)
let caseCount=0
projectData.data.hits.forEach(function(prj,i){
// for each hit (project)
if ((/TCGA/.test(prj.id))) {
//if (true) {
let li = DOM.element('li') // build up the header "li"
li.innerHTML=`<b style="color:blue">${prj.id}</b>: ${prj.name}
(<span style="color:green">${prj.summary.case_count}</span>)`
caseCount=caseCount+prj.summary.case_count
ol.appendChild(li) // append the header "li" to the larger object "ol"
let ul = DOM.element('ul') // build up the bullets "ul"
prj.disease_type.forEach(function(dtp){
// for each disease_type
let li = DOM.element('li')
li.style.fontSize='small'
li.innerHTML=dtp
ul.appendChild(li) // append one bullet "li" to the list of bullets "ul"
})
li.appendChild(ul) // append the bullets "ul" to the header "li"
}
})
div.querySelector('#caseCountSpan').textContent=caseCount
return div
};
Insert cell
caseCounts = getCaseCounts(projectData)
Insert cell
{
let plotData = {
labels: caseCounts.map(x=>x["label"]),
values: caseCounts.map(x=>x["y"]),
type: 'pie',
}
let layout = {
autosize:true
}
const div = DOM.element('div')
Plotly.newPlot(div, [plotData],layout);
return div
}
Insert cell
Plotly = require("https://cdn.plot.ly/plotly-latest.min.js")
Insert cell
require('@oncojs/lolliplot')
Insert cell
hosturl = 'https://firebrowse.herokuapp.com'

Insert cell
endpointurl = "http://firebrowse.org/api/v1/Samples/mRNASeq"
Insert cell
queryJSON = {
let queryJSON = {
format: 'json',
gene: 'PSCA',
cohort: 'BLCA',
protocol: 'RSEM',
page: 1,
page_size: 250,
sort_by: 'cohort'
}
return queryJSON
}
Insert cell
queryurl = "format=json&gene=PSCA&cohort=BLCA&protocol=RSEM&page=1&page_size=250&sort_by=cohort"
Insert cell
queryurl =jq.param(queryJSON)
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