Published
Edited
Dec 8, 2020
Insert cell
md`# WEBgen doc`
Insert cell
md`## Query a firebrowse JSON`
Insert cell
hosturl = 'https://firebrowse.herokuapp.com' // overall data location
Insert cell
endpointurl = "http://firebrowse.org/api/v1/Samples/mRNASeq" // seq data specifically
Insert cell
jq = require("https://code.jquery.com/jquery-3.4.1.js") // import the json query package
Insert cell
queryJSON = {
let queryJSON = {
format: 'json',
gene: 'SRY',
cohort: 'PAAD',
protocol: 'RSEM',
page: 1,
page_size: 2000,
sort_by: 'cohort'
}
return queryJSON
}
Insert cell
queryurl =jq.param(queryJSON) // formats query into full URL
Insert cell
PAAD_data=(await fetch(hosturl +'?'+endpointurl +'?' + queryurl)).json() // run query
Insert cell
hosturl +'?'+endpointurl +'?' + queryurl
Insert cell
md`## Plot some data with Plotly`
Insert cell
Plotly = require("https://cdn.plot.ly/plotly-latest.min.js")
Insert cell
md`### Sample Plot with fake data`
Insert cell
{
var trace1 = {
x: [1, 2, 3, 4],
y: [10, 15, 13, 17],
mode: 'markers',
type: 'scatter'
};
var trace2 = {
x: [2, 3, 4, 5],
y: [16, 5, 11, 9],
mode: 'lines',
type: 'scatter'
};
var trace3 = {
x: [1, 2, 3, 4],
y: [12, 9, 15, 12],
mode: 'lines+markers',
type: 'scatter'
};
var data = [trace1, trace2, trace3];
const div = DOM.element('div');
Plotly.newPlot(div, data, {width: width});
return div;
}
Insert cell
md`### Plot with TCGA data`
Insert cell
plot_data=PAAD_data.mRNASeq
Insert cell
md`## Clinical Query`
Insert cell
Clinendpointurl = "http://firebrowse.org/api/v1/Samples/Clinical_FH" // clin data specifically
Insert cell
clinQueryJSON = {
let queryJSON = {
format: 'json',
fh_cde_name: "psa_value",
tcga_participant_barcode: "TCGA-2A-A8VL, TCGA-CH-5738", // look into replacing this with barcode so we can take specific patients.
page: '1',
page_size: 2001,
sort_by: 'tcga_participant_barcode'
}
debugger
return queryJSON
}
Insert cell
Clinqueryurl = "http://firebrowse.org/api/v1/Samples/Clinical_FH?format=json&cohort=PRAD&fh_cde_name=psa_value&page=1&page_size=250&sort_by=cohort" // formats query into full URL
Insert cell
temp = jq.param(clinQueryJSON)
Insert cell
PRAD_data=(await fetch(hosturl + '?' + Clinendpointurl +'?'+temp)).json() // run query
Insert cell
// http://firebrowse.org/api/v1/Samples/Clinical_FH?format=json&cohort=PRAD&fh_cde_name=psa_value&page=1&page_size=250&sort_by=cohort
PRAD_data.Clinical_FH
Insert cell
md`#### Comparing the API generated URL with my manual URL, all checks out`
Insert cell
hosturl +'?' + Clinqueryurl
Insert cell
hosturl + '?' + Clinendpointurl + '?' + temp
Insert cell
md`### Extract barcodes from a gene query to query clinical data`
Insert cell
PAAD_data
Insert cell
PAAD_data_trim = PAAD_data.mRNASeq
Insert cell
PAAD_data_trim.length
Insert cell
barcodes = {
var barcodes =[];
for (var i = 0;i < 10; i++){
barcodes.push(PAAD_data_trim[i].tcga_participant_barcode)
}
return barcodes
}

Insert cell
barcodes.join()
Insert cell
newPAADquery = {
let queryJSON = {
format: 'json',
fh_cde_name: "gender",
tcga_participant_barcode: barcodes.join(), // obj is an array of barcodes
page: '1',
page_size: 2001,
sort_by: 'tcga_participant_barcode'
}
return queryJSON
}
Insert cell
tempPAAD = jq.param(newPAADquery)
Insert cell
newPAADclin=(await fetch(hosturl + '?' + Clinendpointurl +'?'+tempPAAD)).json()

Insert cell
hosturl + '?' + Clinendpointurl +'?'+tempPAAD
Insert cell
md `## Integrate clinical with expression`
Insert cell
trimmedClin = newPAADclin.Clinical_FH
Insert cell
PAAD_data_trim
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