Public
Edited
Jan 24, 2023
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
figure1 = vegalite (plot_specs[plot_type])
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
fig1data = {
let in_set = new Set (_.map (table1, (d)=>d.Codon));
return _.filter (siteTableData[0], (x)=>in_set.has (x.Codon));
}
Insert cell
Insert cell
plot_options = [["Joy Plot", (d)=>1], ["Evidence ratio for ω>1 (constrained)", (d)=>1], ["Evidence ratio for ω>1 (optimized)", (d)=>1], ["Synonymous rates", (d)=>srv_rate_classes > 0], ["Support for positive selection", (d)=>1], ["Support for 2H", (d)=>mh_rates['DH']], ["Support for 3H", (d)=>mh_rates['TH']], ["Support for 2H+3H", (d)=>mh_rates['DH'] && mh_rates['TH']], ["LogL difference", (d)=>results_json && results_json_compare], ["LogL difference scatter", (d)=>results_json && results_json_compare], ["LR difference", (d)=>results_json && results_json_compare], ["LR difference scatter", (d)=>results_json && results_json_compare], ["Compare ER", (d)=>results_json && results_json_compare], ["Compare BS support", (d)=>results_json && results_json_compare], ["LR difference CDS", (d)=>results_json && results_json_compare]]
Insert cell
plot_specs = (
{
"Evidence ratio for ω>1 (constrained)" : {
"width": 800, "height": 150,
"vconcat" : _.map (_.range (1, fig1data.length + 1, 70), (d)=> {
return ERPlot (fig1data, d, 70, "ER (constrained)")
})},
"Evidence ratio for ω>1 (optimized)" : {
"width": 800, "height": 150,
"vconcat" : _.map (_.range (1, fig1data.length + 1, 70), (d)=> {
return ERPlot (fig1data, d, 70, "ER (optimized null)")
})},
"Synonymous rates" : {
"width": 800, "height": 150,
"vconcat" : _.map (_.range (1, fig1data.length + 1, 70), (d)=> {
return SRVPlot (fig1data, d, 70, "SRV posterior mean", srv_hmm ? "SRV viterbi" : null)
})},
"Support for positive selection" : {
"vconcat" : _.map (_.range (1, results_json.input["number of sites"], 1000), (d)=> {
return BSPosteriorPlot (bsPositiveSelection, d, 1000)
})},
"Joy Plot" : {
"vconcat" : _.map (_.range (1, results_json.input["number of sites"], 7000), (d)=> {
return BSPosteriorPlot_Joy (bsPositiveSelection, d, 7000)
})},
"Support for 2H" : {
"vconcat" : _.map (_.range (1, results_json.input["number of sites"], 70), (d)=> {
return BSPosteriorPlot (twoHBranchSite, d, 70)
})},
"Support for 3H" : {
"vconcat" : _.map (_.range (1, results_json.input["number of sites"], 70), (d)=> {
return BSPosteriorPlot (threeHBranchSite, d, 70)
})},
"Support for 2H+3H" : {
"vconcat" : _.map (_.range (1, results_json.input["number of sites"], 70), (d)=> {
return BSPosteriorPlot (multiHBranchSite, d, 70)
})},
"Compare ER" : ERPlotComp (fig1data, scatter_plot[0], scatter_plot[1], scatter_plot[2]),
"Compare BS support" : BSPlotComp (compBSModels, scatter_plot[2]),
"LR difference CDS" : cdsQuant (fig1data, "Diff LR"),
"LogL difference" : {
"width": 800, "height": 150,
"vconcat" : _.map (_.range (1, fig1data.length + 1, 70), (d)=> {
return ERPlot (fig1data, d, 70, "Diff logl")
})},
"LogL difference scatter" : ScatterPlotComp (fig1data, "LogL ref", "LogL comp", scatter_plot[2]),
"LR difference scatter" : ScatterPlotComp (fig1data, "LR ref", "LR comp", scatter_plot[2]),
"LR difference" : {
"width": 800, "height": 150,
"vconcat" : _.map (_.range (1, fig1data.length + 1, 70), (d)=> {
return ERPlot (fig1data, d, 70, "Diff LR")
})},
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mh_rates = ({
'DH' : _.get (results_json, ['fits', 'Unconstrained model','Rate Distributions', 'rate at which 2 nucleotides are changed instantly within a single codon']),
'TH' : _.get (results_json, ['fits', 'Unconstrained model','Rate Distributions', 'rate at which 3 nucleotides are changed instantly within a single codon'])
})
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
Insert cell
Insert cell
Insert cell
Insert cell
BSPosteriorPlot = (data, from, step)=> {
//console.log(data);
const branch_order = treeNodeOrdering (0);
let spec = {
"width": 2400,
"height" : 2400,
"data" : {"values" :
_.filter (data, (d,i)=> d.Codon >= from && d.Codon <= from + step),
},
"encoding": {
"x": {
"field": "Codon",
"type" : "nominal",
"axis": {"grid" : false,
"titleFontSize" : 14,
"title" : "Codon",
"labelFontSize" : 8}
},
"y": {
"field": "Branch",
"scale" : {"domain" : branch_order},
"type" : "nominal",
"axis": {"grid" : false,
"titleFontSize" : 14,
"title" : "Branch",
"labelFontSize" : 8}
}
},
"layer": [
{
"mark": {"type": "rect",
"size" : 2,
"color" : "black",
"opacity" : 1.0,
"tooltip" : true},
"encoding": {
"color": {
"field": "ER",
"type" : "quantitative",
"legend" : {"orient" : "top"},
"scale" : {"type" : "log",
"scheme": "redblue"}
}
}
}
]
};
return spec;
}
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

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