@sjcrh/proteinpaint-client 2.42.0 → 2.42.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{2dmaf-4c8115cb.js → 2dmaf-7f12f347.js} +1 -1
- package/dist/{DEanalysis-ae8b793e.js → DEanalysis-4e97eae7.js} +1 -1
- package/dist/{Disco-4ead6c6f.js → Disco-2910f321.js} +1 -1
- package/dist/{Disco.UI-a765390e.js → Disco.UI-266c3c98.js} +1 -1
- package/dist/{DragControls-03718ca8.js → DragControls-934cfddb.js} +1 -1
- package/dist/{OrbitControls-0a1bcd3b.js → OrbitControls-379215f5.js} +1 -1
- package/dist/{app-db79376c.js → app-53b444fe.js} +1 -1
- package/dist/{app-64537b0c.js → app-9ef9a482.js} +1 -1
- package/dist/{app-f70d9a0b.js → app-f73edb78.js} +1 -1
- package/dist/app.js +1 -1
- package/dist/{barchart-a4a6b4b4.js → barchart-5755e4b5.js} +1 -1
- package/dist/{barchart.events-3fd64094.js → barchart.events-cb8547bb.js} +1 -1
- package/dist/{bars.renderer-7c9358aa.js → bars.renderer-ffddf5f5.js} +1 -1
- package/dist/{block-ec15b4b6.js → block-06e306e9.js} +1 -1
- package/dist/{block.ds.gmcustomdata-4944ece7.js → block.ds.gmcustomdata-a0f1fd3e.js} +1 -1
- package/dist/block.lazyload-e9a6e4fc.js +1 -0
- package/dist/{block.legend-ebe13fbd.js → block.legend-ae9c9047.js} +1 -1
- package/dist/{block.mds-52af63e1.js → block.mds-125e263c.js} +1 -1
- package/dist/{block.mds.cnv-a40ea2e4.js → block.mds.cnv-80691b84.js} +1 -1
- package/dist/{block.mds.expressionrank-7357fa79.js → block.mds.expressionrank-8a4c69bb.js} +1 -1
- package/dist/{block.mds.expressionstat-4c3dcb37.js → block.mds.expressionstat-7ac00a72.js} +1 -1
- package/dist/{block.mds.geneboxplot-ba99239a.js → block.mds.geneboxplot-ec043226.js} +1 -1
- package/dist/{block.mds.junction-6b881504.js → block.mds.junction-5d744e19.js} +1 -1
- package/dist/{block.mds.svcnv-5bd2e65b.js → block.mds.svcnv-8aec47ec.js} +1 -1
- package/dist/{block.mds.svcnv.share-ebe307d2.js → block.mds.svcnv.share-eb86d7b0.js} +1 -1
- package/dist/{block.mds2-a039e999.js → block.mds2-08b79c5e.js} +1 -1
- package/dist/{block.svg-742bcd6f.js → block.svg-ca8e74f1.js} +1 -1
- package/dist/{block.tk.aicheck-c16f7c33.js → block.tk.aicheck-8c8c74ca.js} +1 -1
- package/dist/{block.tk.ase-5bd73577.js → block.tk.ase-27f2e649.js} +1 -1
- package/dist/{block.tk.bam-f39283bf.js → block.tk.bam-5d0cc18f.js} +1 -1
- package/dist/{block.tk.bam.gdc-66964f1c.js → block.tk.bam.gdc-318db418.js} +1 -1
- package/dist/{block.tk.bedgraphdot-d05f27a0.js → block.tk.bedgraphdot-1b5d99db.js} +1 -1
- package/dist/{block.tk.bigwig.ui-964986f8.js → block.tk.bigwig.ui-bc0afbf9.js} +1 -1
- package/dist/{block.tk.hicstraw-972dd3d4.js → block.tk.hicstraw-64610b08.js} +1 -1
- package/dist/{block.tk.junction-4e33561e.js → block.tk.junction-0febb7c5.js} +1 -1
- package/dist/{block.tk.junction.textmatrixui-e9fe9446.js → block.tk.junction.textmatrixui-11649433.js} +1 -1
- package/dist/{block.tk.ld-880fe55f.js → block.tk.ld-2449943d.js} +1 -1
- package/dist/{block.tk.menu-16e5a387.js → block.tk.menu-f4e2c9a6.js} +1 -1
- package/dist/{block.tk.pgv-daf6e812.js → block.tk.pgv-ac78e412.js} +1 -1
- package/dist/{boxplot-28751534.js → boxplot-cf99d543.js} +1 -1
- package/dist/{brush-bc06febc.js → brush-33697636.js} +1 -1
- package/dist/{categorical-c86731fd.js → categorical-024a02d0.js} +1 -1
- package/dist/{condition-59895ac1.js → condition-4c5195a9.js} +1 -1
- package/dist/{controls-cd2ff09c.js → controls-93c1b3a5.js} +1 -1
- package/dist/{controls.btns-86a413d5.js → controls.btns-af5280bd.js} +1 -1
- package/dist/{controls.config-ae99bcd1.js → controls.config-d936ea41.js} +1 -1
- package/dist/{controls.divide-8f26abff.js → controls.divide-e988fa36.js} +1 -1
- package/dist/{controls.overlay-a72d72e4.js → controls.overlay-9bfc642f.js} +1 -1
- package/dist/{controls.term1-3c9e55b8.js → controls.term1-62150931.js} +1 -1
- package/dist/{cuminc-e7326248.js → cuminc-9c7ff331.js} +1 -1
- package/dist/{dataDownload-f3cdbc7c.js → dataDownload-1f61a3fd.js} +1 -1
- package/dist/{databrowser.ui-52855244.js → databrowser.ui-0803623f.js} +1 -1
- package/dist/{density-33ec5f83.js → density-4ca7f14f.js} +1 -1
- package/dist/{dictionary-578c63d9.js → dictionary-943a4cd2.js} +1 -1
- package/dist/{drag-e2fbde14.js → drag-19604a2e.js} +1 -1
- package/dist/{e2pca-fa8ce887.js → e2pca-e18c801f.js} +1 -1
- package/dist/{ep-b51b82d5.js → ep-708f0514.js} +1 -1
- package/dist/{filter-5a5a1166.js → filter-6b0bd66e.js} +1 -1
- package/dist/{fusion.parse-d20a9d3d.js → fusion.parse-206fa8af.js} +1 -1
- package/dist/{gdc.maf-ced4bc13.js → gdc.maf-84509ef3.js} +1 -1
- package/dist/{gdc.singleCell-1fc3a5b9.js → gdc.singleCell-350d7e63.js} +1 -1
- package/dist/{geneExpression-0d0e9692.js → geneExpression-ef1eda3f.js} +1 -1
- package/dist/{geneSearch4GDCmds3-b3a65ff2.js → geneSearch4GDCmds3-e9196a30.js} +1 -1
- package/dist/{geneVariant-1100ab96.js → geneVariant-4b5d3728.js} +1 -1
- package/dist/genefusion.ui-31ff953e.js +1 -0
- package/dist/{geneset-b37a8d83.js → geneset-48feba0c.js} +1 -1
- package/dist/{genesetEdit-15cec871.js → genesetEdit-34f2ee5d.js} +1 -1
- package/dist/{genomeBrowser-10004899.js → genomeBrowser-f175f471.js} +1 -1
- package/dist/{genomeBrowser.controls-2d794ff1.js → genomeBrowser.controls-674775c6.js} +1 -1
- package/dist/{groupsetting-eaf40465.js → groupsetting-a58e1f5a.js} +1 -1
- package/dist/{hic.straw-1ca9ddd0.js → hic.straw-3143889c.js} +1 -1
- package/dist/{hierCluster-6e93c3b2.js → hierCluster-130e5722.js} +1 -1
- package/dist/{hierCluster.config-9b8fa78e.js → hierCluster.config-d4fdfeac.js} +1 -1
- package/dist/{hierCluster.interactivity-e379aa01.js → hierCluster.interactivity-4b1534bc.js} +1 -1
- package/dist/{hierCluster.renderers-7b35f0cc.js → hierCluster.renderers-cd618c97.js} +1 -1
- package/dist/{html.legend-48cf5c03.js → html.legend-f44f18ab.js} +1 -1
- package/dist/{lasso-afa6b87e.js → lasso-22efae36.js} +1 -1
- package/dist/launch.adhoc-7639eb4a.js +1 -0
- package/dist/{launchGdcHierCluster-ab790040.js → launchGdcHierCluster-001bc76e.js} +1 -1
- package/dist/{launchGdcMatrix-48c56699.js → launchGdcMatrix-6c906351.js} +1 -1
- package/dist/{legacyDataset-21fdc0fe.js → legacyDataset-661691af.js} +1 -1
- package/dist/{log-9e964794.js → log-848ca156.js} +1 -1
- package/dist/{maftimeline-fc71d7a0.js → maftimeline-8b2d8513.js} +1 -1
- package/dist/{matrix-d644b099.js → matrix-af727a11.js} +1 -1
- package/dist/{matrix.cells-5db8ba9e.js → matrix.cells-7ea665f3.js} +1 -1
- package/dist/{matrix.cluster-88a2266e.js → matrix.cluster-33321b79.js} +1 -1
- package/dist/{matrix.config-85132ec9.js → matrix.config-d8efc6dc.js} +1 -1
- package/dist/{matrix.controls-4933c41c.js → matrix.controls-b2dc0e5b.js} +1 -1
- package/dist/{matrix.data-b798eb7d.js → matrix.data-7feb7104.js} +1 -1
- package/dist/{matrix.dom-6971ecb1.js → matrix.dom-7394bd2c.js} +1 -1
- package/dist/{matrix.interactivity-380a57f9.js → matrix.interactivity-ff7ed88a.js} +1 -1
- package/dist/{matrix.layout-3165a88a.js → matrix.layout-168399d4.js} +1 -1
- package/dist/{matrix.legend-f0ab9a34.js → matrix.legend-10a21caa.js} +1 -1
- package/dist/{matrix.renderers-48826412.js → matrix.renderers-3a992e66.js} +1 -1
- package/dist/{matrix.serieses-610f9bc4.js → matrix.serieses-43f86542.js} +1 -1
- package/dist/{mavb-54aeff14.js → mavb-dc006bd3.js} +1 -1
- package/dist/{mds.fimo-fa2b1d1a.js → mds.fimo-fcc96802.js} +1 -1
- package/dist/{mds.samplescatterplot-669b4e1d.js → mds.samplescatterplot-c8732bae.js} +1 -1
- package/dist/{mds.survivalplot-055a1274.js → mds.survivalplot-4e72eb4b.js} +1 -1
- package/dist/{mdsjsonform-8d72a884.js → mdsjsonform-cd7cbed1.js} +1 -1
- package/dist/{nodrag-094c4b10.js → nodrag-39389c59.js} +1 -1
- package/dist/{numeric-939729b0.js → numeric-28b1370d.js} +1 -1
- package/dist/{numeric.binary-d1ada20b.js → numeric.binary-de25c5cb.js} +1 -1
- package/dist/{numeric.continuous-cf4fb4c0.js → numeric.continuous-78ae5f51.js} +1 -1
- package/dist/{numeric.discrete-ea17f823.js → numeric.discrete-7976336c.js} +1 -1
- package/dist/{numeric.spline-2d40b041.js → numeric.spline-1adcbe86.js} +1 -1
- package/dist/{numeric.toggle-7e1ae903.js → numeric.toggle-ba85b972.js} +1 -1
- package/dist/{plot.2dvaf-12d6ace7.js → plot.2dvaf-d8eda179.js} +1 -1
- package/dist/plot.app-cf29de59.js +1 -0
- package/dist/{plot.barplot-ab82cad5.js → plot.barplot-469de952.js} +1 -1
- package/dist/{plot.boxplot-d4984beb.js → plot.boxplot-29ed0bcd.js} +1 -1
- package/dist/{plot.disco-7efd2855.js → plot.disco-15695284.js} +1 -1
- package/dist/{plot.ssgq-e41ca8ac.js → plot.ssgq-ab818820.js} +1 -1
- package/dist/{plot.vaf2cov-0cf0bfb0.js → plot.vaf2cov-646c89ff.js} +1 -1
- package/dist/{polar-86a9ecb8.js → polar-57ab248e.js} +1 -1
- package/dist/{profileBarchart-a41a1fd8.js → profileBarchart-5eda57dd.js} +1 -1
- package/dist/{profileHome-1ada0bb1.js → profileHome-98d3bd09.js} +1 -1
- package/dist/{profilePlot-69af5e30.js → profilePlot-c1bc4e3f.js} +1 -1
- package/dist/{profilePolar-7446e230.js → profilePolar-d6a3ef51.js} +1 -1
- package/dist/{profileRadar-d23d8ebe.js → profileRadar-61cd7e72.js} +1 -1
- package/dist/{profileRadarFacility-9f9a324e.js → profileRadarFacility-fd292b0d.js} +1 -1
- package/dist/{recover-791d56f8.js → recover-97602f64.js} +1 -1
- package/dist/{regression.inputs-ba7b7342.js → regression.inputs-87698b93.js} +1 -1
- package/dist/{regression.inputs.values.table-3f6f7f0f.js → regression.inputs.values.table-be00c818.js} +1 -1
- package/dist/{regression.results-9bd02fe0.js → regression.results-d67d5723.js} +1 -1
- package/dist/{renderPvalueTable-f34371aa.js → renderPvalueTable-8ee523f4.js} +1 -1
- package/dist/{sampleScatter-ef4e3347.js → sampleScatter-dc8bd1d4.js} +1 -1
- package/dist/sampleScatter.interactivity-6b31c51d.js +1 -0
- package/dist/{sampleScatter.rendererThree-b0ddac07.js → sampleScatter.rendererThree-df642763.js} +2 -2
- package/dist/{sampleView-836462bb.js → sampleView-0d819313.js} +1 -1
- package/dist/{samplelst-6512a752.js → samplelst-e4224495.js} +1 -1
- package/dist/{samplematrix-8583e240.js → samplematrix-d77014f0.js} +1 -1
- package/dist/{scatter-a24646d2.js → scatter-df455b44.js} +1 -1
- package/dist/{selectGenomeWithTklst-c0822ac4.js → selectGenomeWithTklst-f927c08a.js} +1 -1
- package/dist/singleCellPlot-f4f9f8ce.js +1 -0
- package/dist/{singlecell-fc57d3bd.js → singlecell-d21858f6.js} +1 -1
- package/dist/{snplocus-502738fa.js → snplocus-cdb05467.js} +1 -1
- package/dist/{snplst-1b5cd5d8.js → snplst-8027603b.js} +1 -1
- package/dist/{spliceevent.a53ss.diagram-d6a9ec18.js → spliceevent.a53ss.diagram-305210e8.js} +1 -1
- package/dist/{spliceevent.exonskip.diagram-122b34c8.js → spliceevent.exonskip.diagram-b818e745.js} +1 -1
- package/dist/spliceevent.exonskip.getdefault-b539bbf8.js +1 -0
- package/dist/{spliceevent.noeventdiagram-24239df6.js → spliceevent.noeventdiagram-b8520d70.js} +1 -1
- package/dist/{spliceevent.phrase-3f069dbd.js → spliceevent.phrase-9e487144.js} +1 -1
- package/dist/{stattable-f81097a3.js → stattable-706eb093.js} +1 -1
- package/dist/{style.gdc-58cdad5e.js → style.gdc-0f9b5225.js} +1 -1
- package/dist/{summary-af438607.js → summary-e42dbeea.js} +1 -1
- package/dist/{sunburst-562d787b.js → sunburst-23a46601.js} +1 -1
- package/dist/survival-e1f95639.js +1 -0
- package/dist/{survival-d8c8c5b5.js → survival-fa638d4f.js} +1 -1
- package/dist/{svg.download-89c31ee5.js → svg.download-60935a3f.js} +1 -1
- package/dist/{svg.legend-5ce6961b.js → svg.legend-404a03f8.js} +1 -1
- package/dist/{svgraph-c326dadb.js → svgraph-22fb937c.js} +1 -1
- package/dist/{svmr-7de419fb.js → svmr-33a9543a.js} +1 -1
- package/dist/{table-141e31d7.js → table-6354b788.js} +1 -1
- package/dist/{table-2310e41b.js → table-dba817a9.js} +1 -1
- package/dist/{termInfo-3ae67507.js → termInfo-fdb502e7.js} +1 -1
- package/dist/{termsetting-8476b5ab.js → termsetting-720557a3.js} +1 -1
- package/dist/{tk-fc2e6168.js → tk-fcd7514e.js} +1 -1
- package/dist/{tp.ui-a59142ec.js → tp.ui-ece56c46.js} +1 -1
- package/dist/{tvs.density-a177d69f.js → tvs.density-411c1792.js} +1 -1
- package/dist/{tvs.geneVariant-68b9ca25.js → tvs.geneVariant-a6e91f37.js} +1 -1
- package/dist/{tvs.numeric-5c6f5524.js → tvs.numeric-358c99a0.js} +1 -1
- package/dist/{tvs.samplelst-3ddd4435.js → tvs.samplelst-946d4a6c.js} +1 -1
- package/dist/{uiUtils-60f490b2.js → uiUtils-be9b8f1b.js} +1 -1
- package/dist/{variantBrowser-882cd310.js → variantBrowser-91d4eb10.js} +1 -1
- package/dist/{vcf-ee473671.js → vcf-d8c0a17a.js} +1 -1
- package/dist/{violin-f96e92c7.js → violin-84138ebc.js} +1 -1
- package/dist/{violin.interactivity-5a9e20f2.js → violin.interactivity-31eff8d9.js} +1 -1
- package/dist/{violin.renderer-687d2341.js → violin.renderer-3d0d8f17.js} +1 -1
- package/dist/{violinRenderer-e37d4065.js → violinRenderer-ee11b031.js} +1 -1
- package/dist/{viridis-98237589.js → viridis-98f22f29.js} +1 -1
- package/dist/{y-8e1e7dad.js → y-836a433e.js} +1 -1
- package/dist/{zoom-eade983c.js → zoom-f044afad.js} +1 -1
- package/package.json +1 -1
- package/dist/block.lazyload-b81d268c.js +0 -1
- package/dist/genefusion.ui-b1264dc8.js +0 -1
- package/dist/launch.adhoc-50d81ba2.js +0 -1
- package/dist/plot.app-72083fe7.js +0 -1
- package/dist/sampleScatter.interactivity-22035655.js +0 -1
- package/dist/singleCellPlot-7caa7fdd.js +0 -1
- package/dist/spliceevent.exonskip.getdefault-f1bf3d40.js +0 -1
- package/dist/survival-e500bc6e.js +0 -1
package/dist/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{b_ as runproteinpaint}from"./app-
|
|
1
|
+
export{b_ as runproteinpaint}from"./app-f73edb78.js";import"path";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{az as t,aI as e,S as s,E as i,q as r,aR as a,aQ as o,aO as n}from"./app-f70d9a0b.js";import l from"./bars.settings-f7884503.js";import c from"./bars.renderer-7c9358aa.js";import{h as d}from"./html.legend-48cf5c03.js";import{s as h}from"./svg.legend-5ce6961b.js";import p from"./barchart.events-3fd64094.js";import{controlsInit as m}from"./controls-cd2ff09c.js";import{r as f}from"./table-2310e41b.js";import{f as g}from"./termsetting-8476b5ab.js";import"path";import"./axis-6cb4f314.js";import"./log-9e964794.js";import"./filter-5a5a1166.js";import"./controls.btns-86a413d5.js";import"./controls.config-ae99bcd1.js";import"./controls.overlay-a72d72e4.js";import"./controls.term1-3c9e55b8.js";import"./controls.divide-8f26abff.js";class u{constructor(t){this.type="barchart"}preApiFreeze(t){t.download=this.download}async init(t){const e=this.opts;const s=this.opts.controls?null:e.holder.append("div");const i=e.controls?e.holder:e.holder.append("div");this.dom={loadingDiv:i.append("div").style("position","absolute").style("display","none").style("padding","20px").html("Loading ..."),header:e.header,controls:s,holder:i,banner:i.append("div").style("display","none").style("text-align","center").style("padding","24px").style("font-size","16px").style("color","#aaa"),barDiv:i.append("div"),legendDiv:i.append("div").style("margin","5px 5px 15px 5px")};if(this.dom.header)this.dom.header.html("Barchart");this.settings=JSON.parse(l);v(this);x(this);this.renderers={};this.legendRenderer=d(this.dom.legendDiv,{settings:{legendOrientation:"vertical"},handlers:this.handlers},this.dom.barDiv);this.controls={};this.term2toColor={};await this.setControls(this.getState(t));if(this.opts.bar_click_override);else if(!this.opts.bar_click_opts){this.opts.bar_click_opts=["hide_bar"];if(this.app.getState().nav.header_mode==="with_tabs")this.opts.bar_click_opts.push("add_filter")}}async setControls(t){if(this.opts.controls){this.opts.controls.on("downloadClick.barchart",this.download)}else{this.dom.holder.attr("class","pp-termdb-plot-viz").style("display","inline-block").style("min-width","300px").style("margin-left","50px");const e=["term1",{type:"overlay",configKey:"term2",chartType:"barchart",usecase:{target:"barchart",detail:"term2",term1type:t.config.term.term.type},title:"Overlay data",label:"Overlay",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.opts.numericEditMenuVersion||["continuous","discrete"]},{type:"divideBy",configKey:"term0",chartType:"barchart",usecase:{target:"barchart",detail:"term0",term1type:t.config.term0?.term?.type},title:"Divide by data",label:"Divide by",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.opts.numericEditMenuVersion||["continuous","discrete"]},{label:"Orientation",type:"radio",chartType:"barchart",settingsKey:"orientation",options:[{label:"Vertical",value:"vertical"},{label:"Horizontal",value:"horizontal"}]},{label:"Scale",type:"radio",chartType:"barchart",settingsKey:"unit",options:[{label:"Linear",value:"abs"},{label:"Log",value:"log",getDisplayStyle:t=>t.term2?"none":"inline-block"},{label:"Proportion",value:"pct",getDisplayStyle:t=>t.term2?"inline-block":"none"}]},{label:"Multicolor bars",title:"Colors bars using the colors preassigned if available, otherwise generates a color",type:"checkbox",chartType:"barchart",settingsKey:"colorBars",boxLabel:"Yes",getDisplayStyle:t=>t.term2?"none":"table-row"},{label:"Deduplicate",title:"Use separate bars samples that has multiple values or belong to multiple groups",type:"checkbox",chartType:"barchart",settingsKey:"dedup",boxLabel:"Yes",getDisplayStyle:t=>this.chartsData.charts.find((t=>t.serieses.length!=t.dedupedSerieses.length))?"table-row":"none"},{label:"Default color",title:"Default color for bars when there is no overlay",type:"color",chartType:"barchart",settingsKey:"defaultColor"}];if(this.app.getState().termdbConfig.multipleTestingCorrection){e.push({label:"Asterisks",boxLabel:"Visible",type:"checkbox",chartType:"barchart",settingsKey:"asterisksVisible",title:"Display the asterisks"})}this.components={controls:await m({app:this.app,id:this.id,holder:this.dom.controls.attr("class","pp-termdb-plot-controls").style("display","inline-block"),inputs:e})};this.components.controls.on("downloadClick.barchart",this.download)}}reactsTo(t){if(t.type.startsWith("plot_")){return t.id===this.id&&(!t.config.childType||t.config.childType==this.type)}return true}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}return{nav:{header_mode:t.nav.header_mode},termfilter:t.termfilter,config:Object.assign({},e,{settings:{barchart:e.settings.barchart,common:e.settings.common},displaySampleIds:t.termdbConfig.displaySampleIds&&this.app.vocabApi.hasVerifiedToken()}),multipleTestingCorrection:t.termdbConfig.multipleTestingCorrection,bar_click_menu:t.bar_click_menu||{}}}async main(){const t=this.state.config;if(t.chartType!=this.type&&t.childType!=this.type)return;try{this.config=structuredClone(t);if(!this.currServerData)this.dom.barDiv.style("max-width",window.innerWidth+"px");this.prevConfig=this.config||{};if(this.dom.header)this.dom.header.html(this.config.term.term.name+` <span style="opacity:.6;font-size:.7em;margin-left:10px;">BARCHART</span>`);this.toggleLoadingDiv();const s=this.getDataRequestOpts();await this.getDescrStats();const i=await this.app.vocabApi.getNestedChartSeriesData(s);const r=i.data;this.bins=i.bins;this.toggleLoadingDiv("none");this.app.vocabApi.syncTermData(this.config,r,this.prevConfig);this.currServerData=r;if(this.currServerData.refs&&this.currServerData.refs.q){for(const t of this.currServerData.refs.q){if(t.error)throw t.error}}this.term1toColor={};this.term2toColor={};this.updateSettings(this.config);this.colorScale=e(this.config.term2?this.settings.cols.length:this.settings.rows.length);this.chartsData=this.processData(this.currServerData);this.render()}catch(t){throw t}}getDataRequestOpts(){const t=this.config;const e={term:t.term,filter:this.state.termfilter.filter};if(t.term2)e.term2=t.term2;if(t.term0)e.term0=t.term0;return e}async getDescrStats(){const t=[this.config.term];if(this.config.term2)t.push(this.config.term2);if(this.config.term0)t.push(this.config.term0);for(const e of t){if(e.term.type=="integer"||e.term.type=="float"){const t=await this.app.vocabApi.getDescrStats(e.id,this.state.termfilter.filter);if(t.error)throw t.error;e.q.descrStats=t.values}}}updateSettings(t){if(!t)return;this.state;const e={term0:t.term0?t.term0.term.id:"",term1:t.term.term.id,term2:t.term2?t.term2.term.id:"",unit:t.settings.barchart.unit,orientation:t.settings.barchart.orientation,asterisksVisible:t.settings.barchart.asterisksVisible,defaultColor:t.settings.barchart.defaultColor,colorBars:t.settings.barchart.colorBars,dedup:t.settings.barchart.dedup,colw:t.settings.common.barwidth,rowh:t.settings.common.barwidth,colspace:t.settings.common.barspace,rowspace:t.settings.common.barspace};this.setExclude(this.config.term,this.config.term2);Object.assign(this.settings,e,this.currServerData.refs||{},{exclude:this.settings.exclude});this.settings.cols=this.settings.dedup?this.currServerData.refs.dedupCols:this.currServerData.refs.cols;this.settings.numCharts=this.currServerData.charts?this.currServerData.charts.length:0;if(!t.term2&&this.settings.unit=="pct"){this.settings.unit="abs"}}mayResetHidden(t,e,s){const i=(t&&t.id)+";;"+(e&&e.id)+";;"+(s&&s.id);if(i===this.currCombinedTermIds)return;for(const s of this.currServerData.charts){if(t.q&&t.q.hiddenValues){this.mayEditHiddenValues(t,s.serieses.length,"term")}if(e&&e.q&&e.q.hiddenValues){for(const t of s.serieses){this.mayEditHiddenValues(e,t.data.length,"term2")}}}this.currCombinedTermIds=i}mayEditHiddenValues(t,e,s){const i=Object.keys(t.q.hiddenValues).filter((e=>t.q.hiddenValues[e])).length;if(i<e)return;for(const e in t.q.hiddenValues){if(!t.q.hiddenValues[e])return;delete t.q.hiddenValues[e]}this.app.save({type:"plot_edit",id:this.id,config:{[s]:t}})}setExclude(t,e){this.settings.exclude.cols=Object.keys(t.q?.hiddenValues||{}).filter((e=>t.q.hiddenValues[e])).map((e=>t.term.type=="categorical"?e:this.settings.cols?.includes(e)?e:t.term.values[e]?.label?t.term.values[e].label:e));this.settings.exclude.rows=!e?.q?.hiddenValues?[]:Object.keys(e.q.hiddenValues).filter((t=>e.q.hiddenValues[t])).map((t=>e.term.type=="categorical"?t:this.settings.rows?.includes(t)?t:e.term.values[t]?.label?e.term.values[t].label:t))}processData(t){this.seriesOrder=this.setMaxVisibleTotals(t);if(!t.charts.length){this.seriesOrder=[]}else if(t.refs.useColOrder){this.seriesOrder=this.settings.cols}const e=t.refs.rows;this.barSorter=(t,e)=>this.seriesOrder.indexOf(t)-this.seriesOrder.indexOf(e);this.overlaySorter=t.refs.useRowOrder?(t,s)=>e.indexOf(t.dataId)-e.indexOf(s.dataId):(t,e)=>this.totalsByDataId[e.dataId]>this.totalsByDataId[t.dataId]?1:this.totalsByDataId[e.dataId]<this.totalsByDataId[t.dataId]?-1:t.dataId<e.dataId?-1:1;this.visibleCharts=t.charts.filter((t=>t.visibleSerieses.length));const s=this.config.term;const i=this.config.term2;const r=t.tests;for(const t in r){const e=r[t];for(const t of e){const e=s.term.values&&t.term1comparison in s.term.values?s.term.values[t.term1comparison].label:t.term1comparison;t.term1Label=e;for(const e of t.term2tests){const t=i.term.values&&e.term2id in i.term.values?i.term.values[e.term2id].label:e.term2id;e.term2Label=t}}}return t}setMaxVisibleTotals(t){this.totalsByDataId={};const e=this.config.term;const s=this.config.term2;const i={};let r=0;for(const a of t.charts){if(!a.settings)a.settings=JSON.parse(l);Object.assign(a.settings,this.settings);a.visibleTotal=0;const t=this.settings.dedup?a.dedupedSerieses:a.serieses;a.visibleSerieses=t.filter((t=>{if(a.settings.exclude.cols.includes(t.seriesId))return false;t.visibleData=t.data.filter((t=>!a.settings.exclude.rows.includes(t.dataId)));t.visibleTotal=t.visibleData.reduce(((t,e)=>t+e.total),0);if(!t.visibleTotal)return false;a.visibleTotal+=t.visibleTotal;if(!(t.seriesId in i))i[t.seriesId]=t.visibleTotal;for(const i of t.data){i.seriesId=t.seriesId;if(e.term.type=="geneVariant"||s?.term.type=="geneVariant"){if(!(i.dataId in this.totalsByDataId)){this.totalsByDataId[i.dataId]={}}this.totalsByDataId[i.dataId][a.chartId]=this.totalsByDataId[i.dataId][a.chartId]?this.totalsByDataId[i.dataId][a.chartId]+i.total:0+i.total}else{if(!(i.dataId in this.totalsByDataId)){this.totalsByDataId[i.dataId]=0}this.totalsByDataId[i.dataId]+=i.total}}return true}));a.settings.colLabels=a.visibleSerieses.map((t=>{const i=t.seriesId;const r=e.term.values&&i in e.term.values?e.term.values[i].label:i;const a=t&&"AF"in t?", AF="+t.AF:"";const o=s&&s.term.type=="condition"&&s.q.value_by_computable_grade?"":`, n=${t.visibleTotal}`;return{id:i,label:r+a+o}}));a.maxVisibleSeriesTotal=a.visibleSerieses.reduce(((t,e)=>e.visibleTotal>t?e.visibleTotal:t),0);if(a.maxVisibleSeriesTotal>r){r=a.maxVisibleSeriesTotal}}for(const e of t.charts){e.maxVisibleAcrossCharts=r}return Object.keys(i).sort(((t,e)=>i[e]-i[t]))}sortStacking(t,e,s){this.term1toColor[t.seriesId]=this.settings.colorBars?this.getColor(this.config.term.term,t.seriesId,this.bins?.[1]):this.settings.defaultColor;t.visibleData.sort(this.overlaySorter);let i=0;for(const r of t.visibleData){r.colgrp="-";r.rowgrp="-";r.chartId=e.chartId;r.seriesId=t.seriesId;if(s.tests){r.groupPvalues=s.tests[e.chartId].find((e=>e.term1comparison===t.seriesId))}r.seriesTotal=t.total;r.chartTotal=e.visibleTotal;r.logTotal=Math.log10(r.total);i+=r.logTotal;this.setTerm2Color(r);r.color=this.term2toColor[r.dataId]||this.term1toColor[t.seriesId]}if(i>e.maxSeriesLogTotal){e.maxSeriesLogTotal=i}for(const e of t.data){if(e.color)continue;this.setTerm2Color(e);e.color=this.term2toColor[e.dataId]||this.term1toColor[t.seriesId]}}setTerm2Color(t){if(!this.config.term2)return;this.term2toColor[t.dataId]=this.getColor(this.config.term2.term,t.dataId,this.bins?.[2])}getColor(t,e,i){if(!t)return;if(t.values){for(const[s,i]of Object.entries(t.values)){if(!i.color)continue;if(s===e)return i.color;if(i.label===e)return i.color}}const r=i?.find((t=>t.label==e));if(r?.color)return r.color;if(t.type=="geneVariant")return this.getMutationColor(e);return s(this.colorScale(e)).toString()}getMutationColor(t){for(const e of Object.values(i))if(e.label===t&&e.color)return e.color;for(const e in i){if(i[e].label===t&&i[e].color)return i[e].color}}getLegendGrps(){const t=this.config.term;const e=this.config.term2;if(t.term.type=="geneVariant"||e?.term.type=="geneVariant"){const t=[];for(const e of this.chartsData.charts){t.push(this.getOneLegendGrps(e))}return t}return this.getOneLegendGrps()}getOneLegendGrps(t){const e=[];const s=this.settings;const i=this.config.term;const r=this.config.term2;const a="color: #aaa; font-weight: 400";if(i.q.descrStats){const t=i.q.descrStats.map((t=>({text:`${t.label}: ${t.value}`,noIcon:true})));const s=r?`Descriptive statistics: ${i.term.name}`:"Descriptive statistics";const o=`<span style="${a}">${s}</span>`;e.push({name:o,items:t})}if(r?.q.descrStats){const t=r.q.descrStats.map((t=>({text:`${t.label}: ${t.value}`,noIcon:true})));const s=`Descriptive statistics: ${r.term.name}`;const i=`<span style="${a}">${s}</span>`;e.push({name:i,items:t})}if(s.cols&&s.exclude.cols.length){const o=(t,e)=>t+e.total;const n=s.exclude.cols.filter((t=>s.cols.includes(t))).flatMap((e=>{const s=t=>t.seriesId==e;const a=r?.term?.type=="condition"?0:i.term.type=="geneVariant"||r?.term?.type=="geneVariant"?t.serieses.filter(s).reduce(o,0):this.currServerData.charts.reduce(((t,e)=>t+e.serieses.filter(s).reduce(o,0)),0);if(!a&&!r?.term?.type)return[];const n=i.term.values&&e in i.term.values?i.term.values[e].label:e;const l=a?", n="+a:"";return[{id:e,text:n+l,color:"#fff",textColor:"#000",border:"1px solid #333",noIcon:true,type:"col",isHidden:true,hiddenOpacity:1}]})).sort(this.barSorter);if(n.length){const t=r?i.term.name:"Other categories";e.push({name:`<span style="${a}">${t}</span>`,items:n})}}if(s.rows&&!s.hidelegend&&r&&this.term2toColor){const i=r.term.type!="condition"||!r.q?"":r.q.value_by_max_grade?"max. grade":r.q.value_by_most_recent?"most recent":"";e.push({name:`<span style="${a}">`+r.term.name+(i?", "+i:"")+"</span>",items:s.rows.flatMap((e=>{const i=t?this.totalsByDataId[e]?.[t.chartId]:this.totalsByDataId[e];if(!i)return[];const a=i?", n="+i:"";const o=r.term.values&&e in r.term.values?r.term.values[e].label:e;return[{dataId:e,text:o+a,color:this.term2toColor[e],type:"row",isHidden:s.exclude.rows.includes(e)}]})).sort(this.overlaySorter)})}if(r&&this.state.multipleTestingCorrection){let t=0;for(const e in this.chartsData.tests){t+=this.chartsData.tests[e].reduce(((t,e)=>t+e.term2tests.filter((t=>!t.skipped)).length),0)}e.push({name:`<span style="${a}">Statistical Significance</span>`,items:[{text:`* p-value < (0.05 / ${t} tests)`,noEditColor:true}]})}return e}toggleLoadingDiv(t=""){if(t!="none"){this.dom.loadingDiv.style("opacity",0).style("display",t).transition().duration("loadingWait"in this?this.loadingWait:0).style("opacity",1)}else{this.dom.loadingDiv.style("display",t)}this.loadingWait=1e3}}const b=t(u);const y=b;function v(t){t.render=function(){const e=t.dom.barDiv.selectAll(".pp-sbar-div").data(t.visibleCharts,(t=>t.chartId));e.exit().each(t.exitChart);e.each(t.updateChart);e.enter().append("div").each(t.addChart);t.dom.holder.selectAll(".pp-chart-title").style("display",t.visibleCharts.length<2?"none":"block");const s=t.getLegendGrps();t.legendRenderer(s);if(!t.visibleCharts.length){const e=t.settings.exclude.cols.length||t.settings.exclude.rows.length?`<br/><span>click on a legend label below to display the barchart</span>`:"";t.dom.banner.html(`<span>No visible barchart data to render</span>${e}`).style("display","block");t.dom.legendDiv.selectAll("*").remove()}else{t.dom.banner.text("").style("display","none")}};t.exitChart=function(e){delete t.renderers[e.chartId];r(this).remove()};t.updateChart=function(s){s.settings.cols.sort(t.barSorter);s.maxAcrossCharts=t.chartsData.maxAcrossCharts;s.handlers=t.handlers;s.maxSeriesLogTotal=0;s.visibleSerieses.forEach((e=>t.sortStacking(e,s,t.chartsData)));t.renderers[s.chartId](s);const i=r(this);i.select(".pp-sbar-div-chartLengends").selectAll("*").remove();if(t.chartsData.tests&&t.chartsData.tests[s.chartId]){e(s,i)}};t.addChart=function(s,i){const a=r(this).attr("class","pp-sbar-div").style("display","inline-block").style("padding","20px").style("vertical-align","top");t.renderers[s.chartId]=c(t,r(this));s.settings.cols.sort(t.barSorter);s.maxAcrossCharts=t.chartsData.maxAcrossCharts;s.handlers=t.handlers;s.maxSeriesLogTotal=0;s.visibleSerieses.forEach((e=>t.sortStacking(e,s,t.chartsData)));t.renderers[s.chartId](s);a.append("div").attr("class","pp-sbar-div-chartLengends").style("vertical-align","top").style("margin","10px 10px 10px 30px").style("display","none");if(t.chartsData.tests&&t.chartsData.tests[s.chartId]){e(s,a)}};function e(e,s){const i=s.select(".pp-sbar-div-chartLengends").style("display","inline-block").style("vertical-align","top").style("text-align","center").append("div");t.chartsData.tests[e.chartId].sort((function(e,s){return t.settings.cols.indexOf(e.term1comparison)-t.settings.cols.indexOf(s.term1comparison)}));for(const s of t.chartsData.tests[e.chartId]){s.term2tests.sort((function(e,s){return t.chartsData.refs.rows.indexOf(e.term2id)-t.chartsData.refs.rows.indexOf(s.term2id)}))}const r=[{label:"Row 1"},{label:"Row 2"},{label:"Column 1"},{label:"Column 2"},{label:"P-value"}];const a=t.chartsData.tests[e.chartId].every((t=>t.term2tests.every((t=>!t.skipped))));const o=[];const n=t.chartsData.tests[e.chartId].filter((t=>e.visibleSerieses.some((e=>e.seriesId===t.term1comparison))));for(const t of n){const s=e.visibleSerieses.find((e=>e.seriesId===t.term1comparison));const i=t.term2tests.filter((t=>s.visibleData.some((e=>e.dataId===t.term2id))));for(const e of i){o.push([{value:`${t.term1Label}`},{value:"not "+t.term1Label},{value:e.term2Label},{value:"not "+e.term2Label},{html:e.skipped?"N/A":e.pvalue>1e-4?Number(e.pvalue.toFixed(4)):Number(e.pvalue.toPrecision(4)).toExponential()}])}}i.append("div").style("font-weight","bold").style("padding-bottom","0.5em").html("2x2 Association test (Fisher's exact test)").style("font-size","0.9em");const l=i.append("div").style("font-size","0.9em");f({columns:r,rows:o,div:l,showLines:false,maxWidth:"70vw",maxHeight:`${e.svgh-100}px`,resize:true});l.append("div").style("margin-top","10px").style("text-align","left").style("font-size","10px").style("font-weight","normal").html(a?"":"N/A: association test skipped because of limited sample size <br>")}}function x(t){t.handlers=p(t);t.download=function(){if(!t.state)return;const e=[];const s={x:undefined,y:undefined};const i=[];let o=0,n=0,l=0;let c=0,d=0;t.dom.barDiv.selectAll(".sjpcb-bars-mainG").each((function(){e.push(this);const t=this.getBBox();if(t.width>o)o=t.width;if(t.height>n)n=t.height;const a=Math.round(this.parentNode.parentNode.getBoundingClientRect().y);if(!d){c=a;d++}else if(Math.abs(a-c)<5){d++}const h=r(this).attr("transform").split("translate(")[1].split(")")[0].split(",").map((t=>+t.trim()));if(s.x===undefined||h[0]>s.x)s.x=+h[0];if(s.y===undefined||h[1]>s.y)s.y=+h[1];const p=this.parentNode.parentNode.firstChild;const m=p.getBoundingClientRect();if(m.width>o)o=m.width;if(m.height>l)l=m.height;i.push({text:p.innerText,styles:window.getComputedStyle(p)})}));o+=30;n+=30;const p=document.createElementNS("http://www.w3.org/2000/svg","svg");const m=r(p).style("display","block").style("opacity",1).attr("width",d*o).attr("height",Math.floor(e.length/d)*n);const f=window.getComputedStyle(document.querySelector(".pp-bars-svg"));for(const t of f){if(t.startsWith("font"))m.style(t,f.getPropertyValue(t))}e.forEach(((t,e)=>{const a=t.cloneNode(true);const c=e%d;const h=Math.floor(e/d);const m={x:c*o+s.x,y:h*n+s.y};const f=r(p).append("text").attr("transform","translate("+m.x+","+m.y+")").text(i[e].text);for(const t of i[e].styles){if(t.startsWith("font"))f.style(t,i[e].styles.getPropertyValue(t))}r(a).attr("transform","translate("+m.x+","+(m.y+l)+")");p.appendChild(a)}));const g=r("body").append("div").style("opacity",0);g.node().appendChild(p);t.svgLegendRenderer=h({holder:m.append("g"),rectFillFxn:t=>t.color,iconStroke:"#aaa"});t.settings;const u=t.dom.barDiv.select("svg").node().getBoundingClientRect();let b=t.getLegendGrps();b.forEach((t=>{t.name=t.name.replace(/<[^>]*>?/gm,"");if(t.items)t.items=t.items.filter((t=>!t.isHidden))}));b=b.filter((t=>t.items.length&&!t.name.includes("tatistic")));const y=14;t.svgLegendRenderer(b,{settings:Object.assign({ontop:false,lineh:25,padx:5,padleft:0,padright:20,padbtm:30,fontsize:y,iconh:y-2,iconw:y-2,hangleft:1,linesep:false},{svgw:t.visibleCharts.length*u.width,svgh:u.height,dimensions:{xOffset:50},padleft:50})});const v=t.dom.legendDiv.node().getBoundingClientRect();r(p).attr("height",u.height+v.height+30);if(v.width>u.width)r(p).attr("width",v.width);g.remove();const x=t.config.term.term.name+" barchart";a(p,x,{apply_dom_styles:true})}}function D(t){return{orientation:"horizontal",unit:"abs",overlay:"none",divideBy:"none",rowlabelw:250,asterisksVisible:t?.getState()?.termdbConfig?.multipleTestingCorrection?true:false,defaultColor:o,colorBars:false,dedup:false}}async function w(t,e){if(!t.term)throw"barchart getPlotConfig: opts.term{} missing";try{await g(t.term,e.vocabApi);if(t.term2)await g(t.term2,e.vocabApi);if(t.term0)await g(t.term0,e.vocabApi)}catch(t){throw`${t} [barchart getPlotConfig()]`}const s={id:t.term.term.id,settings:{controls:{isOpen:false,term2:null,term0:null},common:{use_logscale:false,use_percentage:false,barheight:300,barwidth:20,barspace:2},barchart:D(e)}};return n(s,t)}export{b as barInit,y as componentInit,D as getDefaultBarSettings,w as getPlotConfig};
|
|
1
|
+
import{az as t,aI as e,S as s,E as i,q as r,aR as a,aQ as o,aO as n}from"./app-f73edb78.js";import l from"./bars.settings-f7884503.js";import c from"./bars.renderer-ffddf5f5.js";import{h as d}from"./html.legend-f44f18ab.js";import{s as h}from"./svg.legend-404a03f8.js";import p from"./barchart.events-cb8547bb.js";import{controlsInit as m}from"./controls-93c1b3a5.js";import{r as f}from"./table-dba817a9.js";import{f as g}from"./termsetting-720557a3.js";import"path";import"./axis-6cb4f314.js";import"./log-848ca156.js";import"./filter-6b0bd66e.js";import"./controls.btns-af5280bd.js";import"./controls.config-d936ea41.js";import"./controls.overlay-9bfc642f.js";import"./controls.term1-62150931.js";import"./controls.divide-e988fa36.js";class u{constructor(t){this.type="barchart"}preApiFreeze(t){t.download=this.download}async init(t){const e=this.opts;const s=this.opts.controls?null:e.holder.append("div");const i=e.controls?e.holder:e.holder.append("div");this.dom={loadingDiv:i.append("div").style("position","absolute").style("display","none").style("padding","20px").html("Loading ..."),header:e.header,controls:s,holder:i,banner:i.append("div").style("display","none").style("text-align","center").style("padding","24px").style("font-size","16px").style("color","#aaa"),barDiv:i.append("div"),legendDiv:i.append("div").style("margin","5px 5px 15px 5px")};if(this.dom.header)this.dom.header.html("Barchart");this.settings=JSON.parse(l);v(this);x(this);this.renderers={};this.legendRenderer=d(this.dom.legendDiv,{settings:{legendOrientation:"vertical"},handlers:this.handlers},this.dom.barDiv);this.controls={};this.term2toColor={};await this.setControls(this.getState(t));if(this.opts.bar_click_override);else if(!this.opts.bar_click_opts){this.opts.bar_click_opts=["hide_bar"];if(this.app.getState().nav.header_mode==="with_tabs")this.opts.bar_click_opts.push("add_filter")}}async setControls(t){if(this.opts.controls){this.opts.controls.on("downloadClick.barchart",this.download)}else{this.dom.holder.attr("class","pp-termdb-plot-viz").style("display","inline-block").style("min-width","300px").style("margin-left","50px");const e=["term1",{type:"overlay",configKey:"term2",chartType:"barchart",usecase:{target:"barchart",detail:"term2",term1type:t.config.term.term.type},title:"Overlay data",label:"Overlay",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.opts.numericEditMenuVersion||["continuous","discrete"]},{type:"divideBy",configKey:"term0",chartType:"barchart",usecase:{target:"barchart",detail:"term0",term1type:t.config.term0?.term?.type},title:"Divide by data",label:"Divide by",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.opts.numericEditMenuVersion||["continuous","discrete"]},{label:"Orientation",type:"radio",chartType:"barchart",settingsKey:"orientation",options:[{label:"Vertical",value:"vertical"},{label:"Horizontal",value:"horizontal"}]},{label:"Scale",type:"radio",chartType:"barchart",settingsKey:"unit",options:[{label:"Linear",value:"abs"},{label:"Log",value:"log",getDisplayStyle:t=>t.term2?"none":"inline-block"},{label:"Proportion",value:"pct",getDisplayStyle:t=>t.term2?"inline-block":"none"}]},{label:"Multicolor bars",title:"Colors bars using the colors preassigned if available, otherwise generates a color",type:"checkbox",chartType:"barchart",settingsKey:"colorBars",boxLabel:"Yes",getDisplayStyle:t=>t.term2?"none":"table-row"},{label:"Deduplicate",title:"Use separate bars samples that has multiple values or belong to multiple groups",type:"checkbox",chartType:"barchart",settingsKey:"dedup",boxLabel:"Yes",getDisplayStyle:t=>this.chartsData.charts.find((t=>t.serieses.length!=t.dedupedSerieses.length))?"table-row":"none"},{label:"Default color",title:"Default color for bars when there is no overlay",type:"color",chartType:"barchart",settingsKey:"defaultColor"}];if(this.app.getState().termdbConfig.multipleTestingCorrection){e.push({label:"Asterisks",boxLabel:"Visible",type:"checkbox",chartType:"barchart",settingsKey:"asterisksVisible",title:"Display the asterisks"})}this.components={controls:await m({app:this.app,id:this.id,holder:this.dom.controls.attr("class","pp-termdb-plot-controls").style("display","inline-block"),inputs:e})};this.components.controls.on("downloadClick.barchart",this.download)}}reactsTo(t){if(t.type.startsWith("plot_")){return t.id===this.id&&(!t.config.childType||t.config.childType==this.type)}return true}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}return{nav:{header_mode:t.nav.header_mode},termfilter:t.termfilter,config:Object.assign({},e,{settings:{barchart:e.settings.barchart,common:e.settings.common},displaySampleIds:t.termdbConfig.displaySampleIds&&this.app.vocabApi.hasVerifiedToken()}),multipleTestingCorrection:t.termdbConfig.multipleTestingCorrection,bar_click_menu:t.bar_click_menu||{}}}async main(){const t=this.state.config;if(t.chartType!=this.type&&t.childType!=this.type)return;try{this.config=structuredClone(t);if(!this.currServerData)this.dom.barDiv.style("max-width",window.innerWidth+"px");this.prevConfig=this.config||{};if(this.dom.header)this.dom.header.html(this.config.term.term.name+` <span style="opacity:.6;font-size:.7em;margin-left:10px;">BARCHART</span>`);this.toggleLoadingDiv();const s=this.getDataRequestOpts();await this.getDescrStats();const i=await this.app.vocabApi.getNestedChartSeriesData(s);const r=i.data;this.bins=i.bins;this.toggleLoadingDiv("none");this.app.vocabApi.syncTermData(this.config,r,this.prevConfig);this.currServerData=r;if(this.currServerData.refs&&this.currServerData.refs.q){for(const t of this.currServerData.refs.q){if(t.error)throw t.error}}this.term1toColor={};this.term2toColor={};this.updateSettings(this.config);this.colorScale=e(this.config.term2?this.settings.cols.length:this.settings.rows.length);this.chartsData=this.processData(this.currServerData);this.render()}catch(t){throw t}}getDataRequestOpts(){const t=this.config;const e={term:t.term,filter:this.state.termfilter.filter};if(t.term2)e.term2=t.term2;if(t.term0)e.term0=t.term0;return e}async getDescrStats(){const t=[this.config.term];if(this.config.term2)t.push(this.config.term2);if(this.config.term0)t.push(this.config.term0);for(const e of t){if(e.term.type=="integer"||e.term.type=="float"){const t=await this.app.vocabApi.getDescrStats(e.id,this.state.termfilter.filter);if(t.error)throw t.error;e.q.descrStats=t.values}}}updateSettings(t){if(!t)return;this.state;const e={term0:t.term0?t.term0.term.id:"",term1:t.term.term.id,term2:t.term2?t.term2.term.id:"",unit:t.settings.barchart.unit,orientation:t.settings.barchart.orientation,asterisksVisible:t.settings.barchart.asterisksVisible,defaultColor:t.settings.barchart.defaultColor,colorBars:t.settings.barchart.colorBars,dedup:t.settings.barchart.dedup,colw:t.settings.common.barwidth,rowh:t.settings.common.barwidth,colspace:t.settings.common.barspace,rowspace:t.settings.common.barspace};this.setExclude(this.config.term,this.config.term2);Object.assign(this.settings,e,this.currServerData.refs||{},{exclude:this.settings.exclude});this.settings.cols=this.settings.dedup?this.currServerData.refs.dedupCols:this.currServerData.refs.cols;this.settings.numCharts=this.currServerData.charts?this.currServerData.charts.length:0;if(!t.term2&&this.settings.unit=="pct"){this.settings.unit="abs"}}mayResetHidden(t,e,s){const i=(t&&t.id)+";;"+(e&&e.id)+";;"+(s&&s.id);if(i===this.currCombinedTermIds)return;for(const s of this.currServerData.charts){if(t.q&&t.q.hiddenValues){this.mayEditHiddenValues(t,s.serieses.length,"term")}if(e&&e.q&&e.q.hiddenValues){for(const t of s.serieses){this.mayEditHiddenValues(e,t.data.length,"term2")}}}this.currCombinedTermIds=i}mayEditHiddenValues(t,e,s){const i=Object.keys(t.q.hiddenValues).filter((e=>t.q.hiddenValues[e])).length;if(i<e)return;for(const e in t.q.hiddenValues){if(!t.q.hiddenValues[e])return;delete t.q.hiddenValues[e]}this.app.save({type:"plot_edit",id:this.id,config:{[s]:t}})}setExclude(t,e){this.settings.exclude.cols=Object.keys(t.q?.hiddenValues||{}).filter((e=>t.q.hiddenValues[e])).map((e=>t.term.type=="categorical"?e:this.settings.cols?.includes(e)?e:t.term.values[e]?.label?t.term.values[e].label:e));this.settings.exclude.rows=!e?.q?.hiddenValues?[]:Object.keys(e.q.hiddenValues).filter((t=>e.q.hiddenValues[t])).map((t=>e.term.type=="categorical"?t:this.settings.rows?.includes(t)?t:e.term.values[t]?.label?e.term.values[t].label:t))}processData(t){this.seriesOrder=this.setMaxVisibleTotals(t);if(!t.charts.length){this.seriesOrder=[]}else if(t.refs.useColOrder){this.seriesOrder=this.settings.cols}const e=t.refs.rows;this.barSorter=(t,e)=>this.seriesOrder.indexOf(t)-this.seriesOrder.indexOf(e);this.overlaySorter=t.refs.useRowOrder?(t,s)=>e.indexOf(t.dataId)-e.indexOf(s.dataId):(t,e)=>this.totalsByDataId[e.dataId]>this.totalsByDataId[t.dataId]?1:this.totalsByDataId[e.dataId]<this.totalsByDataId[t.dataId]?-1:t.dataId<e.dataId?-1:1;this.visibleCharts=t.charts.filter((t=>t.visibleSerieses.length));const s=this.config.term;const i=this.config.term2;const r=t.tests;for(const t in r){const e=r[t];for(const t of e){const e=s.term.values&&t.term1comparison in s.term.values?s.term.values[t.term1comparison].label:t.term1comparison;t.term1Label=e;for(const e of t.term2tests){const t=i.term.values&&e.term2id in i.term.values?i.term.values[e.term2id].label:e.term2id;e.term2Label=t}}}return t}setMaxVisibleTotals(t){this.totalsByDataId={};const e=this.config.term;const s=this.config.term2;const i={};let r=0;for(const a of t.charts){if(!a.settings)a.settings=JSON.parse(l);Object.assign(a.settings,this.settings);a.visibleTotal=0;const t=this.settings.dedup?a.dedupedSerieses:a.serieses;a.visibleSerieses=t.filter((t=>{if(a.settings.exclude.cols.includes(t.seriesId))return false;t.visibleData=t.data.filter((t=>!a.settings.exclude.rows.includes(t.dataId)));t.visibleTotal=t.visibleData.reduce(((t,e)=>t+e.total),0);if(!t.visibleTotal)return false;a.visibleTotal+=t.visibleTotal;if(!(t.seriesId in i))i[t.seriesId]=t.visibleTotal;for(const i of t.data){i.seriesId=t.seriesId;if(e.term.type=="geneVariant"||s?.term.type=="geneVariant"){if(!(i.dataId in this.totalsByDataId)){this.totalsByDataId[i.dataId]={}}this.totalsByDataId[i.dataId][a.chartId]=this.totalsByDataId[i.dataId][a.chartId]?this.totalsByDataId[i.dataId][a.chartId]+i.total:0+i.total}else{if(!(i.dataId in this.totalsByDataId)){this.totalsByDataId[i.dataId]=0}this.totalsByDataId[i.dataId]+=i.total}}return true}));a.settings.colLabels=a.visibleSerieses.map((t=>{const i=t.seriesId;const r=e.term.values&&i in e.term.values?e.term.values[i].label:i;const a=t&&"AF"in t?", AF="+t.AF:"";const o=s&&s.term.type=="condition"&&s.q.value_by_computable_grade?"":`, n=${t.visibleTotal}`;return{id:i,label:r+a+o}}));a.maxVisibleSeriesTotal=a.visibleSerieses.reduce(((t,e)=>e.visibleTotal>t?e.visibleTotal:t),0);if(a.maxVisibleSeriesTotal>r){r=a.maxVisibleSeriesTotal}}for(const e of t.charts){e.maxVisibleAcrossCharts=r}return Object.keys(i).sort(((t,e)=>i[e]-i[t]))}sortStacking(t,e,s){this.term1toColor[t.seriesId]=this.settings.colorBars?this.getColor(this.config.term.term,t.seriesId,this.bins?.[1]):this.settings.defaultColor;t.visibleData.sort(this.overlaySorter);let i=0;for(const r of t.visibleData){r.colgrp="-";r.rowgrp="-";r.chartId=e.chartId;r.seriesId=t.seriesId;if(s.tests){r.groupPvalues=s.tests[e.chartId].find((e=>e.term1comparison===t.seriesId))}r.seriesTotal=t.total;r.chartTotal=e.visibleTotal;r.logTotal=Math.log10(r.total);i+=r.logTotal;this.setTerm2Color(r);r.color=this.term2toColor[r.dataId]||this.term1toColor[t.seriesId]}if(i>e.maxSeriesLogTotal){e.maxSeriesLogTotal=i}for(const e of t.data){if(e.color)continue;this.setTerm2Color(e);e.color=this.term2toColor[e.dataId]||this.term1toColor[t.seriesId]}}setTerm2Color(t){if(!this.config.term2)return;this.term2toColor[t.dataId]=this.getColor(this.config.term2.term,t.dataId,this.bins?.[2])}getColor(t,e,i){if(!t)return;if(t.values){for(const[s,i]of Object.entries(t.values)){if(!i.color)continue;if(s===e)return i.color;if(i.label===e)return i.color}}const r=i?.find((t=>t.label==e));if(r?.color)return r.color;if(t.type=="geneVariant")return this.getMutationColor(e);return s(this.colorScale(e)).toString()}getMutationColor(t){for(const e of Object.values(i))if(e.label===t&&e.color)return e.color;for(const e in i){if(i[e].label===t&&i[e].color)return i[e].color}}getLegendGrps(){const t=this.config.term;const e=this.config.term2;if(t.term.type=="geneVariant"||e?.term.type=="geneVariant"){const t=[];for(const e of this.chartsData.charts){t.push(this.getOneLegendGrps(e))}return t}return this.getOneLegendGrps()}getOneLegendGrps(t){const e=[];const s=this.settings;const i=this.config.term;const r=this.config.term2;const a="color: #aaa; font-weight: 400";if(i.q.descrStats){const t=i.q.descrStats.map((t=>({text:`${t.label}: ${t.value}`,noIcon:true})));const s=r?`Descriptive statistics: ${i.term.name}`:"Descriptive statistics";const o=`<span style="${a}">${s}</span>`;e.push({name:o,items:t})}if(r?.q.descrStats){const t=r.q.descrStats.map((t=>({text:`${t.label}: ${t.value}`,noIcon:true})));const s=`Descriptive statistics: ${r.term.name}`;const i=`<span style="${a}">${s}</span>`;e.push({name:i,items:t})}if(s.cols&&s.exclude.cols.length){const o=(t,e)=>t+e.total;const n=s.exclude.cols.filter((t=>s.cols.includes(t))).flatMap((e=>{const s=t=>t.seriesId==e;const a=r?.term?.type=="condition"?0:i.term.type=="geneVariant"||r?.term?.type=="geneVariant"?t.serieses.filter(s).reduce(o,0):this.currServerData.charts.reduce(((t,e)=>t+e.serieses.filter(s).reduce(o,0)),0);if(!a&&!r?.term?.type)return[];const n=i.term.values&&e in i.term.values?i.term.values[e].label:e;const l=a?", n="+a:"";return[{id:e,text:n+l,color:"#fff",textColor:"#000",border:"1px solid #333",noIcon:true,type:"col",isHidden:true,hiddenOpacity:1}]})).sort(this.barSorter);if(n.length){const t=r?i.term.name:"Other categories";e.push({name:`<span style="${a}">${t}</span>`,items:n})}}if(s.rows&&!s.hidelegend&&r&&this.term2toColor){const i=r.term.type!="condition"||!r.q?"":r.q.value_by_max_grade?"max. grade":r.q.value_by_most_recent?"most recent":"";e.push({name:`<span style="${a}">`+r.term.name+(i?", "+i:"")+"</span>",items:s.rows.flatMap((e=>{const i=t?this.totalsByDataId[e]?.[t.chartId]:this.totalsByDataId[e];if(!i)return[];const a=i?", n="+i:"";const o=r.term.values&&e in r.term.values?r.term.values[e].label:e;return[{dataId:e,text:o+a,color:this.term2toColor[e],type:"row",isHidden:s.exclude.rows.includes(e)}]})).sort(this.overlaySorter)})}if(r&&this.state.multipleTestingCorrection){let t=0;for(const e in this.chartsData.tests){t+=this.chartsData.tests[e].reduce(((t,e)=>t+e.term2tests.filter((t=>!t.skipped)).length),0)}e.push({name:`<span style="${a}">Statistical Significance</span>`,items:[{text:`* p-value < (0.05 / ${t} tests)`,noEditColor:true}]})}return e}toggleLoadingDiv(t=""){if(t!="none"){this.dom.loadingDiv.style("opacity",0).style("display",t).transition().duration("loadingWait"in this?this.loadingWait:0).style("opacity",1)}else{this.dom.loadingDiv.style("display",t)}this.loadingWait=1e3}}const b=t(u);const y=b;function v(t){t.render=function(){const e=t.dom.barDiv.selectAll(".pp-sbar-div").data(t.visibleCharts,(t=>t.chartId));e.exit().each(t.exitChart);e.each(t.updateChart);e.enter().append("div").each(t.addChart);t.dom.holder.selectAll(".pp-chart-title").style("display",t.visibleCharts.length<2?"none":"block");const s=t.getLegendGrps();t.legendRenderer(s);if(!t.visibleCharts.length){const e=t.settings.exclude.cols.length||t.settings.exclude.rows.length?`<br/><span>click on a legend label below to display the barchart</span>`:"";t.dom.banner.html(`<span>No visible barchart data to render</span>${e}`).style("display","block");t.dom.legendDiv.selectAll("*").remove()}else{t.dom.banner.text("").style("display","none")}};t.exitChart=function(e){delete t.renderers[e.chartId];r(this).remove()};t.updateChart=function(s){s.settings.cols.sort(t.barSorter);s.maxAcrossCharts=t.chartsData.maxAcrossCharts;s.handlers=t.handlers;s.maxSeriesLogTotal=0;s.visibleSerieses.forEach((e=>t.sortStacking(e,s,t.chartsData)));t.renderers[s.chartId](s);const i=r(this);i.select(".pp-sbar-div-chartLengends").selectAll("*").remove();if(t.chartsData.tests&&t.chartsData.tests[s.chartId]){e(s,i)}};t.addChart=function(s,i){const a=r(this).attr("class","pp-sbar-div").style("display","inline-block").style("padding","20px").style("vertical-align","top");t.renderers[s.chartId]=c(t,r(this));s.settings.cols.sort(t.barSorter);s.maxAcrossCharts=t.chartsData.maxAcrossCharts;s.handlers=t.handlers;s.maxSeriesLogTotal=0;s.visibleSerieses.forEach((e=>t.sortStacking(e,s,t.chartsData)));t.renderers[s.chartId](s);a.append("div").attr("class","pp-sbar-div-chartLengends").style("vertical-align","top").style("margin","10px 10px 10px 30px").style("display","none");if(t.chartsData.tests&&t.chartsData.tests[s.chartId]){e(s,a)}};function e(e,s){const i=s.select(".pp-sbar-div-chartLengends").style("display","inline-block").style("vertical-align","top").style("text-align","center").append("div");t.chartsData.tests[e.chartId].sort((function(e,s){return t.settings.cols.indexOf(e.term1comparison)-t.settings.cols.indexOf(s.term1comparison)}));for(const s of t.chartsData.tests[e.chartId]){s.term2tests.sort((function(e,s){return t.chartsData.refs.rows.indexOf(e.term2id)-t.chartsData.refs.rows.indexOf(s.term2id)}))}const r=[{label:"Row 1"},{label:"Row 2"},{label:"Column 1"},{label:"Column 2"},{label:"P-value"}];const a=t.chartsData.tests[e.chartId].every((t=>t.term2tests.every((t=>!t.skipped))));const o=[];const n=t.chartsData.tests[e.chartId].filter((t=>e.visibleSerieses.some((e=>e.seriesId===t.term1comparison))));for(const t of n){const s=e.visibleSerieses.find((e=>e.seriesId===t.term1comparison));const i=t.term2tests.filter((t=>s.visibleData.some((e=>e.dataId===t.term2id))));for(const e of i){o.push([{value:`${t.term1Label}`},{value:"not "+t.term1Label},{value:e.term2Label},{value:"not "+e.term2Label},{html:e.skipped?"N/A":e.pvalue>1e-4?Number(e.pvalue.toFixed(4)):Number(e.pvalue.toPrecision(4)).toExponential()}])}}i.append("div").style("font-weight","bold").style("padding-bottom","0.5em").html("2x2 Association test (Fisher's exact test)").style("font-size","0.9em");const l=i.append("div").style("font-size","0.9em");f({columns:r,rows:o,div:l,showLines:false,maxWidth:"70vw",maxHeight:`${e.svgh-100}px`,resize:true});l.append("div").style("margin-top","10px").style("text-align","left").style("font-size","10px").style("font-weight","normal").html(a?"":"N/A: association test skipped because of limited sample size <br>")}}function x(t){t.handlers=p(t);t.download=function(){if(!t.state)return;const e=[];const s={x:undefined,y:undefined};const i=[];let o=0,n=0,l=0;let c=0,d=0;t.dom.barDiv.selectAll(".sjpcb-bars-mainG").each((function(){e.push(this);const t=this.getBBox();if(t.width>o)o=t.width;if(t.height>n)n=t.height;const a=Math.round(this.parentNode.parentNode.getBoundingClientRect().y);if(!d){c=a;d++}else if(Math.abs(a-c)<5){d++}const h=r(this).attr("transform").split("translate(")[1].split(")")[0].split(",").map((t=>+t.trim()));if(s.x===undefined||h[0]>s.x)s.x=+h[0];if(s.y===undefined||h[1]>s.y)s.y=+h[1];const p=this.parentNode.parentNode.firstChild;const m=p.getBoundingClientRect();if(m.width>o)o=m.width;if(m.height>l)l=m.height;i.push({text:p.innerText,styles:window.getComputedStyle(p)})}));o+=30;n+=30;const p=document.createElementNS("http://www.w3.org/2000/svg","svg");const m=r(p).style("display","block").style("opacity",1).attr("width",d*o).attr("height",Math.floor(e.length/d)*n);const f=window.getComputedStyle(document.querySelector(".pp-bars-svg"));for(const t of f){if(t.startsWith("font"))m.style(t,f.getPropertyValue(t))}e.forEach(((t,e)=>{const a=t.cloneNode(true);const c=e%d;const h=Math.floor(e/d);const m={x:c*o+s.x,y:h*n+s.y};const f=r(p).append("text").attr("transform","translate("+m.x+","+m.y+")").text(i[e].text);for(const t of i[e].styles){if(t.startsWith("font"))f.style(t,i[e].styles.getPropertyValue(t))}r(a).attr("transform","translate("+m.x+","+(m.y+l)+")");p.appendChild(a)}));const g=r("body").append("div").style("opacity",0);g.node().appendChild(p);t.svgLegendRenderer=h({holder:m.append("g"),rectFillFxn:t=>t.color,iconStroke:"#aaa"});t.settings;const u=t.dom.barDiv.select("svg").node().getBoundingClientRect();let b=t.getLegendGrps();b.forEach((t=>{t.name=t.name.replace(/<[^>]*>?/gm,"");if(t.items)t.items=t.items.filter((t=>!t.isHidden))}));b=b.filter((t=>t.items.length&&!t.name.includes("tatistic")));const y=14;t.svgLegendRenderer(b,{settings:Object.assign({ontop:false,lineh:25,padx:5,padleft:0,padright:20,padbtm:30,fontsize:y,iconh:y-2,iconw:y-2,hangleft:1,linesep:false},{svgw:t.visibleCharts.length*u.width,svgh:u.height,dimensions:{xOffset:50},padleft:50})});const v=t.dom.legendDiv.node().getBoundingClientRect();r(p).attr("height",u.height+v.height+30);if(v.width>u.width)r(p).attr("width",v.width);g.remove();const x=t.config.term.term.name+" barchart";a(p,x,{apply_dom_styles:true})}}function D(t){return{orientation:"horizontal",unit:"abs",overlay:"none",divideBy:"none",rowlabelw:250,asterisksVisible:t?.getState()?.termdbConfig?.multipleTestingCorrection?true:false,defaultColor:o,colorBars:false,dedup:false}}async function w(t,e){if(!t.term)throw"barchart getPlotConfig: opts.term{} missing";try{await g(t.term,e.vocabApi);if(t.term2)await g(t.term2,e.vocabApi);if(t.term0)await g(t.term0,e.vocabApi)}catch(t){throw`${t} [barchart getPlotConfig()]`}const s={id:t.term.term.id,settings:{controls:{isOpen:false,term2:null,term0:null},common:{use_logscale:false,use_percentage:false,barheight:300,barwidth:20,barspace:2},barchart:D(e)}};return n(s,t)}export{b as barInit,y as componentInit,D as getDefaultBarSettings,w as getPlotConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as t,S as e,w as a}from"./app-f70d9a0b.js";import{h as i,e as n,g as s,a as r}from"./filter-5a5a1166.js";import{r as o}from"./table-2310e41b.js";import"path";function l(a){const i=new t({padding:"5px"});a.dom.tip=i;const n=a.settings;function s(t){const e=t.target.__data__;if(e===undefined)return;e.type=="col"?"term":"term2";const i=a.config.term;a.app.dispatch({type:"plot_edit",id:a.id,config:{term:{isAtomic:true,id:i.id,term:i.term,q:u(e,i,true)}}})}return{chart:{title(t){if(!a.config.term0)return t.chartId;return a.config.term0.term.values&&t.chartId in a.config.term0.term.values?a.config.term0.term.values[t.chartId].label:t.chartId}},svg:{mouseout:()=>{i.hide()}},series:{mouseover(t,e){t.stopPropagation();const n=a.config.term.term;const s=a.config.term2&&a.config.term2.term;n.unit;const r=(n.values&&e.seriesId in n.values?n.values[e.seriesId].label:e.seriesId)+(n.unit?" "+n.unit:"");const o=(s&&s.values&&e.dataId in s.values?s.values[e.dataId].label:e.dataId)+(s&&s.unit?" "+s.unit:"");const l=!s?"":"<div style='display:inline-block; width:14px; height:14px; margin: 2px 3px; vertical-align:top; background:"+e.color+"'> </div>";const d=[`<tr><td colspan=2 style='padding:3px; text-align:center'>${r}</td></tr>`];if(s){d.push(`<tr><td colspan=2 style='padding:3px; text-align:center'>${l} <span>${o}</span></td></tr>`)}d.push(`<tr><td style='padding:3px; color:#aaa'>#Individuals</td><td style='padding:3px; text-align:center'>n=${e.total}</td></tr>`);if(s){const t=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).pvalue;const a=e.groupPvalues.term1Label;const i=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).term2Label;const n=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).tableValues;const s=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).skipped;d.push(`<tr>\n\t\t\t\t\t\t\t<td style='padding:3px; color:#aaa'>p-value</td>\n\t\t\t\t\t\t\t<td style='padding:3px; text-align:center'>${s?"N/A":t>1e-4?Number(t.toFixed(4)):Number(t.toPrecision(4)).toExponential()}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<table style="margin: 5px; text-align:left; font-size: 0.8em; border-spacing: 5px; border-collapse: separate;"\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'></td>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>${i}</td>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>not ${i}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>${a}</td>\n\t\t\t\t\t\t\t\t<td>${n.R1C1}</td>\n\t\t\t\t\t\t\t\t<td>${n.R1C2}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>not ${a}</td>\n\t\t\t\t\t\t\t\t<td>${n.R2C1}</td>\n\t\t\t\t\t\t\t\t<td>${n.R2C2}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>`)}if(!n.type=="condition"&&(!s||!s.type=="condition")){d.push(`<tr><td style='padding:3px; color:#aaa'>Percentage</td><td style='padding:3px; text-align:center'>${(100*e.total/(s?e.seriesTotal:e.chartTotal)).toFixed(1)}%</td></tr>`)}i.show(t.clientX,t.clientY).d.html(`<table class='sja_simpletable'>${d.join("\n")}</table>`)},mouseout:()=>{i.hide()},rectFill(t){return t.color},strokeFill(t){const a=e(t.color);const i=a.toString()==e("white").toString()?a.darker():a;return i},click:a.opts.bar_click_override?(t,e)=>a.opts.bar_click_override(v(e,a)):(t,e)=>m(t,a,e)},colLabel:{text:t=>"label"in t?t.label:a.config.term.values&&"id"in t&&t.id in a.config.term.values?a.config.term.values[t.id].label:t,click:s,mouseover:t=>{t.stopPropagation();i.show(t.clientX,t.clientY).d.html("Click to hide bar")},mouseout:()=>{i.hide()}},rowLabel:{text:t=>t.label?t.label:a.config.term.values&&"id"in t&&t.id in a.config.term.values?a.config.term.values[t.id].label:t,click:s,mouseover:t=>{t.stopPropagation();i.show(t.clientX,t.clientY).d.html("Click to hide bar")},mouseout:()=>{i.hide()}},legend:{onColorClick:t=>c(t.target,a),click:t=>c(t.target,a),mouseover:t=>{t.stopPropagation();const e=t.target.__data__;if(e===undefined)return;if(e.isHidden)i.show(t.clientX,t.clientY).d.html("Click to unhide bar")},mouseout:()=>{i.hide()}},yAxis:{text:t=>{const e=a.config.term;if(n.orientation=="vertical"){return n.unit=="pct"?"% of patients":"# of patients "+(e.q.bar_by_children||e.q.value_by_most_recent||e.q.value_by_computable_grade?"":`(n=${t})`)}else{return e.q.bar_by_children?"Sub-condition":e.q.value_by_max_grade?"Maximum grade":e.q.value_by_most_recent?"Most recent grade":e.q.value_by_computable_grade?"Any grade":e.type=="categorical"||!e.unit?"":e.unit}}},xAxis:{text:t=>{const e=a.config.term;if(n.orientation=="vertical"){return e.q.bar_by_children?"Sub-condition":e.q.value_by_max_grade?"Maximum grade":e.q.value_by_most_recent?"Most recent grade":e.q.value_by_computable_grade?"Any grade":e.type=="categorical"||!e.unit?"":e.unit}else{return n.unit=="pct"?"% of patients":"# of patients "+(e.q.bar_by_children||e.q.value_by_most_recent||e.q.value_by_computable_grade?"":`(n=${t})`)}}}}}function d(t,e,a){const i=t.type=="col"?"term":"term2";const n=e.config[i];let s=t.dataId;if(n.term.values&&!n.term.values?.[s])for(const[e,a]of Object.entries(n.term.values))if(a.label==t.dataId)s=e;if(n.term.values?.[s])n.term.values[s].color=a;if(n.term.type=="geneVariant"){if(!n.term.values)n.term.values={};n.term.values[t.dataId]={label:t.dataId,color:a}}let r=null;if(e.bins[2].length>0){r=e.bins[2].find((e=>e.label==t.dataId));r.color=a}e.app.dispatch({type:"plot_edit",id:e.id,config:{[i]:{isAtomic:true,id:n.id,term:n.term,q:u(t,n,t.isHidden,r)}}})}function c(t,a){const i=t.__data__;if(i===undefined)return;if(!("type"in i))return;const n=i.type=="col"?"term":"term2";const s=a.config[n];const r="isHidden"in i?!i.isHidden:!(s.q&&s.q.hiddenValues&&s.q.hiddenValues["dataId"in i?i.dataId:i.id]);const o=a.app.tip;const l=o.clear();l.showunder(t);const c=l.d.append("div");c.append("div").attr("class","sja_menuoption sja_sharp_border").text(!r?"Show":"Hide").on("click",(()=>{l.hide();p(i,a,r)}));if(s.q.hiddenValues&&Object.keys(s.q.hiddenValues).length>1)c.append("div").attr("class","sja_menuoption sja_sharp_border").text("Show all").on("click",(()=>{l.hide();const t=structuredClone(s);delete t.q.hiddenValues;a.app.dispatch({type:"plot_edit",id:a.id,config:{[n]:t}})}));const u=e(i.color).formatHex();if(u!="#ffffff"){const t=c.append("div").attr("class","sja_sharp_border").style("padding","0px 10px").text("Color:").append("input").attr("type","color").attr("value",u).on("change",(()=>{d(i,a,t.node().value);l.hide()}))}}function p(t,e,a){const i=t.type=="col"?"term":"term2";const n=e.config[i];e.app.dispatch({type:"plot_edit",id:e.id,config:{[i]:{isAtomic:true,id:n.id,term:n.term,q:u(t,n,a)}}})}function u(t,e,a=false,i=null){const n="id"in t?t.id:t.type=="col"?t.seriesId:t.dataId;const s=e.term.values&&Object.keys(e.term.values).find((t=>e.term.values[t].label===n));const r=!s?n:s;const o=JSON.parse(JSON.stringify(e.q));if(!o.hiddenValues)o.hiddenValues={};if(a)o.hiddenValues[r]=1;else delete o.hiddenValues[r];if(i)o.binColored=i;return o}function m(t,e,a){const n=t.target.__data__||t.target.parentNode.__data__;const s=e.config.term.term;const r=e.config.term2?e.config.term2.term:null;const o=s.values?Object.values(s.values).map((t=>t.label)):[];const l=r&&r.values?Object.values(r.values).map((t=>t.label)):[];const d=s.unit&&!o.includes(n.seriesId||n.id)?" "+s.unit:"";const c=r&&r.unit&&!l.includes(n.dataId||n.id)?" "+r.unit:"";const p=(s.values&&n.seriesId in s.values?s.values[n.seriesId].label:n.seriesId?n.seriesId:n.id)+d;const m=(r&&r.values&&n.dataId in r.values?r.values[n.dataId].label:n.dataId?n.dataId:n.id)+c;const b=!r?"":"<div style='display:inline-block; width:14px; height:14px; margin: 2px 3px; vertical-align:top; background:"+n.color+"'> </div>";const h=`<div style='padding:2px'><b>${s.name}</b>: ${p}</div>`+(n.seriesId&&r?`<div style='padding:2px'><b>${r.name}</b>: ${m} ${b}</div>`:"");const y=n.seriesId||n.seriesId===0?n:{seriesId:n.id,dataId:n.dataId};const I=[];if(e.opts.bar_click_opts.includes("hide_bar")){I.push({label:n.seriesId?'Hide "'+p+'"':"Hide",callback:()=>{const t=e.config.term;e.app.dispatch({type:"plot_edit",id:e.id,config:{term:{isAtomic:true,id:t.id,term:t.term,q:u({id:n.seriesId,type:"col"},t,true)}}})}});if(n.dataId||n.dataId===0){I.push({label:'Hide "'+m+'" '+b,callback:()=>{const t=e.config.term2;e.app.dispatch({isAtomic:true,type:"plot_edit",id:e.id,config:{term2:{isAtomic:true,id:t.id,term:t.term,q:u({id:n.dataId,type:"row"},t,true)}}})}})}}if(e.opts.bar_click_opts.includes("add_filter")&&(!r||!r.isgenotype)){const t=i(e.state.termfilter.filter,e.config.term.term.id);if(!t){I.push({label:"Add as filter",callback:g})}}if(e.config.displaySampleIds){I.push({label:"List samples",callback:async()=>await f(t,e,n.seriesId,n.dataId,a.chartId)})}if(e.opts.bar_click_opts.includes("select_to_gp")){I.push({label:"Select to GenomePaint",callback:_})}if(!I.length)return;e.app.tip.clear();if(h){e.app.tip.d.append("div").html(h)}const x=v(y,e);e.app.tip.d.append("div").selectAll("div").data(I).enter().append("div").attr("class","sja_menuoption").html((t=>t.label)).on("click",(async(t,a)=>{e.app.tip.hide();await a.callback(e,x)}));e.app.tip.show(t.clientX,t.clientY)}async function f(e,a,i,s,r){const l={type:"tvslst",in:true,join:"and",lst:[b(1,i)]};const d=[a.config.term];if(a.config.term2){d.push(a.config.term2);l.lst.push(b(2,s))}if(a.config.term0){d.push(a.config.term0);l.lst.push(b(0,r))}const c={terms:d,filter:n([a.state.termfilter.filter,l])};const p=await a.app.vocabApi.getAnnotatedSampleData(c);const u=[];for(const t of p.lst)u.push([{value:t.sampleName}]);const m=[{label:"Sample"}];const f=new t({padding:"5px"});const g=f.d.append("div");o({rows:u,columns:m,div:g,showLines:true,maxWidth:"27vw",maxHeight:"40vh",resize:true});f.show(e.clientX,e.clientY,false);function b(t,e){const i=t==0?a.config.term0:t==1?a.config.term:a.config.term2;const n={type:"tvs",tvs:{term:i.term,values:[{key:e}]}};if(i.term.type=="integer"||i.term.type=="float"){const i=a.bins[t];n.tvs.ranges=[i.find((t=>t.label==e))]}return n}}function g(t,e){if(!e)return;if(!t.state.termfilter||t.state.nav?.header_mode!=="with_tabs"){return}const a=s(t.state.termfilter.filter,"filterUiRoot");const i=n([a,{type:"tvslst",in:true,join:e.length>1?"and":"",lst:[...e.map(b)]}]);i.tag="filterUiRoot";t.app.dispatch({type:"filter_replace",filter:i})}function b(t){return t.type==="tvs"?t:{type:"tvs",tvs:t}}function _(t,e){const n=[];for(const a of e){b(a);const e=i(t.state.termfilter.filter,a.tvs.term.id);if(!e)n.push(b(a))}import("./block-ec15b4b6.js").then((function(t){return t.c})).then((async e=>{const i={genome:t.app.opts.genome,dslabel:t.state.dslabel};const o=a({x:100,y:100});const l=r(t.state.termfilter.filter);const d=s(l,d);if(d&&d!=l)delete d.tag;l.tag="filterUiRoot";if(n.length){l.join="and";l.lst.push(...n)}const c=s(l,"cohortFilter");if(c){c.renderAs="htmlSelect";c.selectOptionsFrom="selectCohort"}new e.Block({hostURL:sessionStorage.getItem("hostURL"),holder:o.body,genome:i.genome,nobox:true,chr:i.genome.defaultcoord.chr,start:i.genome.defaultcoord.start,stop:i.genome.defaultcoord.stop,nativetracks:[i.genome.tracks.find((t=>t.__isgene)).name.toLowerCase()],tklst:[{type:"mds2",dslabel:i.dslabel,vcf:{numerical_axis:{AFtest:{groups:[{is_termdb:true,filter:l},{is_population:true,key:"gnomAD",allowto_adjust_race:true,adjust_race:true}]}}}}]})}))}function v(t,e){const a=[];if(e.state.nav?.header_mode=="with_cohortHtmlSelect"){const t=s(e.state.termfilter.filter,"cohortFilter");if(t)a.push(JSON.parse(JSON.stringify(t)))}const i=e.config.term;const n=i.term.values&&Object.keys(i.term.values).filter((e=>i.term.values[e].label===t.seriesId))[0];const r=i.term.values&&n in i.term.values?n:t.seriesId;const o=e.config.term2;const l=o&&o.term.values&&Object.keys(o.term.values).filter((e=>o.term.values[e].label===t.dataId))[0];const d=o&&o.term.values&&l in o.term.values?l:t.dataId;for(const n of[i,o]){if(!n)continue;const s=n==i?1:2;const l=n==i?r:d;const c=n.q;const p=!n||!n.term.values?l:l in n.term.values?n.term.values[l].label:l;if(c.groupsetting&&c.groupsetting.inuse){const t="predefined_groupset_idx"in c.groupsetting?n.term.groupsetting.lst[c.groupsetting.predefined_groupset_idx]:c.groupsetting.customset;const e=t.groups.find((t=>t.name===l));const i={term:n.term,values:e.values,groupset_label:e.name};if(n.term.type=="condition"){i.bar_by_children=n.q.bar_by_children;i.bar_by_grade=n.q.bar_by_grade;i.value_by_most_recent=n.q.value_by_most_recent;i.value_by_max_grade=n.q.value_by_max_grade}a.push(i)}else if(n.term.type=="condition"){if(!o||i.id!=o.id){a.push(Object.assign({term:n.term,values:[{key:l,label:p}]},c))}if(n==i&&o&&n.term.id==o.id){const i=o.q;const s=o.term.values&&t.dataId in o.term.values?e.config.term2.values[t.dataId].label:t.dataId;a.push(Object.assign({term:n.term,grade_and_child:[{grade:i.bar_by_grade?t.dataId:l,grade_label:i.bar_by_grade?s:p,child_id:i.bar_by_children?t.dataId:l,child_label:i.bar_by_children?s:p}]},i))}}else{const t=e.currServerData.refs.bins[s];if(!t||!t.length){a.push({term:n.term,values:[{key:l,label:p}]})}else{const e=t.find((t=>t.label==p||t.name==p));if(e)a.push({term:n.term,ranges:[e]});else if(n==i){a.push({term:n.term,ranges:[{value:l}]})}else if(n==o){a.push({term:n.term,ranges:[{value:l}]})}else{throw"should not happen"}}}}return a.map((t=>b(t)))}export{l as default,p as hideCategory};
|
|
1
|
+
import{M as t,S as e,w as a}from"./app-f73edb78.js";import{h as i,e as n,g as s,a as r}from"./filter-6b0bd66e.js";import{r as o}from"./table-dba817a9.js";import"path";function l(a){const i=new t({padding:"5px"});a.dom.tip=i;const n=a.settings;function s(t){const e=t.target.__data__;if(e===undefined)return;e.type=="col"?"term":"term2";const i=a.config.term;a.app.dispatch({type:"plot_edit",id:a.id,config:{term:{isAtomic:true,id:i.id,term:i.term,q:u(e,i,true)}}})}return{chart:{title(t){if(!a.config.term0)return t.chartId;return a.config.term0.term.values&&t.chartId in a.config.term0.term.values?a.config.term0.term.values[t.chartId].label:t.chartId}},svg:{mouseout:()=>{i.hide()}},series:{mouseover(t,e){t.stopPropagation();const n=a.config.term.term;const s=a.config.term2&&a.config.term2.term;n.unit;const r=(n.values&&e.seriesId in n.values?n.values[e.seriesId].label:e.seriesId)+(n.unit?" "+n.unit:"");const o=(s&&s.values&&e.dataId in s.values?s.values[e.dataId].label:e.dataId)+(s&&s.unit?" "+s.unit:"");const l=!s?"":"<div style='display:inline-block; width:14px; height:14px; margin: 2px 3px; vertical-align:top; background:"+e.color+"'> </div>";const d=[`<tr><td colspan=2 style='padding:3px; text-align:center'>${r}</td></tr>`];if(s){d.push(`<tr><td colspan=2 style='padding:3px; text-align:center'>${l} <span>${o}</span></td></tr>`)}d.push(`<tr><td style='padding:3px; color:#aaa'>#Individuals</td><td style='padding:3px; text-align:center'>n=${e.total}</td></tr>`);if(s){const t=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).pvalue;const a=e.groupPvalues.term1Label;const i=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).term2Label;const n=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).tableValues;const s=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).skipped;d.push(`<tr>\n\t\t\t\t\t\t\t<td style='padding:3px; color:#aaa'>p-value</td>\n\t\t\t\t\t\t\t<td style='padding:3px; text-align:center'>${s?"N/A":t>1e-4?Number(t.toFixed(4)):Number(t.toPrecision(4)).toExponential()}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<table style="margin: 5px; text-align:left; font-size: 0.8em; border-spacing: 5px; border-collapse: separate;"\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'></td>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>${i}</td>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>not ${i}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>${a}</td>\n\t\t\t\t\t\t\t\t<td>${n.R1C1}</td>\n\t\t\t\t\t\t\t\t<td>${n.R1C2}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>not ${a}</td>\n\t\t\t\t\t\t\t\t<td>${n.R2C1}</td>\n\t\t\t\t\t\t\t\t<td>${n.R2C2}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>`)}if(!n.type=="condition"&&(!s||!s.type=="condition")){d.push(`<tr><td style='padding:3px; color:#aaa'>Percentage</td><td style='padding:3px; text-align:center'>${(100*e.total/(s?e.seriesTotal:e.chartTotal)).toFixed(1)}%</td></tr>`)}i.show(t.clientX,t.clientY).d.html(`<table class='sja_simpletable'>${d.join("\n")}</table>`)},mouseout:()=>{i.hide()},rectFill(t){return t.color},strokeFill(t){const a=e(t.color);const i=a.toString()==e("white").toString()?a.darker():a;return i},click:a.opts.bar_click_override?(t,e)=>a.opts.bar_click_override(v(e,a)):(t,e)=>m(t,a,e)},colLabel:{text:t=>"label"in t?t.label:a.config.term.values&&"id"in t&&t.id in a.config.term.values?a.config.term.values[t.id].label:t,click:s,mouseover:t=>{t.stopPropagation();i.show(t.clientX,t.clientY).d.html("Click to hide bar")},mouseout:()=>{i.hide()}},rowLabel:{text:t=>t.label?t.label:a.config.term.values&&"id"in t&&t.id in a.config.term.values?a.config.term.values[t.id].label:t,click:s,mouseover:t=>{t.stopPropagation();i.show(t.clientX,t.clientY).d.html("Click to hide bar")},mouseout:()=>{i.hide()}},legend:{onColorClick:t=>c(t.target,a),click:t=>c(t.target,a),mouseover:t=>{t.stopPropagation();const e=t.target.__data__;if(e===undefined)return;if(e.isHidden)i.show(t.clientX,t.clientY).d.html("Click to unhide bar")},mouseout:()=>{i.hide()}},yAxis:{text:t=>{const e=a.config.term;if(n.orientation=="vertical"){return n.unit=="pct"?"% of patients":"# of patients "+(e.q.bar_by_children||e.q.value_by_most_recent||e.q.value_by_computable_grade?"":`(n=${t})`)}else{return e.q.bar_by_children?"Sub-condition":e.q.value_by_max_grade?"Maximum grade":e.q.value_by_most_recent?"Most recent grade":e.q.value_by_computable_grade?"Any grade":e.type=="categorical"||!e.unit?"":e.unit}}},xAxis:{text:t=>{const e=a.config.term;if(n.orientation=="vertical"){return e.q.bar_by_children?"Sub-condition":e.q.value_by_max_grade?"Maximum grade":e.q.value_by_most_recent?"Most recent grade":e.q.value_by_computable_grade?"Any grade":e.type=="categorical"||!e.unit?"":e.unit}else{return n.unit=="pct"?"% of patients":"# of patients "+(e.q.bar_by_children||e.q.value_by_most_recent||e.q.value_by_computable_grade?"":`(n=${t})`)}}}}}function d(t,e,a){const i=t.type=="col"?"term":"term2";const n=e.config[i];let s=t.dataId;if(n.term.values&&!n.term.values?.[s])for(const[e,a]of Object.entries(n.term.values))if(a.label==t.dataId)s=e;if(n.term.values?.[s])n.term.values[s].color=a;if(n.term.type=="geneVariant"){if(!n.term.values)n.term.values={};n.term.values[t.dataId]={label:t.dataId,color:a}}let r=null;if(e.bins[2].length>0){r=e.bins[2].find((e=>e.label==t.dataId));r.color=a}e.app.dispatch({type:"plot_edit",id:e.id,config:{[i]:{isAtomic:true,id:n.id,term:n.term,q:u(t,n,t.isHidden,r)}}})}function c(t,a){const i=t.__data__;if(i===undefined)return;if(!("type"in i))return;const n=i.type=="col"?"term":"term2";const s=a.config[n];const r="isHidden"in i?!i.isHidden:!(s.q&&s.q.hiddenValues&&s.q.hiddenValues["dataId"in i?i.dataId:i.id]);const o=a.app.tip;const l=o.clear();l.showunder(t);const c=l.d.append("div");c.append("div").attr("class","sja_menuoption sja_sharp_border").text(!r?"Show":"Hide").on("click",(()=>{l.hide();p(i,a,r)}));if(s.q.hiddenValues&&Object.keys(s.q.hiddenValues).length>1)c.append("div").attr("class","sja_menuoption sja_sharp_border").text("Show all").on("click",(()=>{l.hide();const t=structuredClone(s);delete t.q.hiddenValues;a.app.dispatch({type:"plot_edit",id:a.id,config:{[n]:t}})}));const u=e(i.color).formatHex();if(u!="#ffffff"){const t=c.append("div").attr("class","sja_sharp_border").style("padding","0px 10px").text("Color:").append("input").attr("type","color").attr("value",u).on("change",(()=>{d(i,a,t.node().value);l.hide()}))}}function p(t,e,a){const i=t.type=="col"?"term":"term2";const n=e.config[i];e.app.dispatch({type:"plot_edit",id:e.id,config:{[i]:{isAtomic:true,id:n.id,term:n.term,q:u(t,n,a)}}})}function u(t,e,a=false,i=null){const n="id"in t?t.id:t.type=="col"?t.seriesId:t.dataId;const s=e.term.values&&Object.keys(e.term.values).find((t=>e.term.values[t].label===n));const r=!s?n:s;const o=JSON.parse(JSON.stringify(e.q));if(!o.hiddenValues)o.hiddenValues={};if(a)o.hiddenValues[r]=1;else delete o.hiddenValues[r];if(i)o.binColored=i;return o}function m(t,e,a){const n=t.target.__data__||t.target.parentNode.__data__;const s=e.config.term.term;const r=e.config.term2?e.config.term2.term:null;const o=s.values?Object.values(s.values).map((t=>t.label)):[];const l=r&&r.values?Object.values(r.values).map((t=>t.label)):[];const d=s.unit&&!o.includes(n.seriesId||n.id)?" "+s.unit:"";const c=r&&r.unit&&!l.includes(n.dataId||n.id)?" "+r.unit:"";const p=(s.values&&n.seriesId in s.values?s.values[n.seriesId].label:n.seriesId?n.seriesId:n.id)+d;const m=(r&&r.values&&n.dataId in r.values?r.values[n.dataId].label:n.dataId?n.dataId:n.id)+c;const b=!r?"":"<div style='display:inline-block; width:14px; height:14px; margin: 2px 3px; vertical-align:top; background:"+n.color+"'> </div>";const h=`<div style='padding:2px'><b>${s.name}</b>: ${p}</div>`+(n.seriesId&&r?`<div style='padding:2px'><b>${r.name}</b>: ${m} ${b}</div>`:"");const y=n.seriesId||n.seriesId===0?n:{seriesId:n.id,dataId:n.dataId};const I=[];if(e.opts.bar_click_opts.includes("hide_bar")){I.push({label:n.seriesId?'Hide "'+p+'"':"Hide",callback:()=>{const t=e.config.term;e.app.dispatch({type:"plot_edit",id:e.id,config:{term:{isAtomic:true,id:t.id,term:t.term,q:u({id:n.seriesId,type:"col"},t,true)}}})}});if(n.dataId||n.dataId===0){I.push({label:'Hide "'+m+'" '+b,callback:()=>{const t=e.config.term2;e.app.dispatch({isAtomic:true,type:"plot_edit",id:e.id,config:{term2:{isAtomic:true,id:t.id,term:t.term,q:u({id:n.dataId,type:"row"},t,true)}}})}})}}if(e.opts.bar_click_opts.includes("add_filter")&&(!r||!r.isgenotype)){const t=i(e.state.termfilter.filter,e.config.term.term.id);if(!t){I.push({label:"Add as filter",callback:g})}}if(e.config.displaySampleIds){I.push({label:"List samples",callback:async()=>await f(t,e,n.seriesId,n.dataId,a.chartId)})}if(e.opts.bar_click_opts.includes("select_to_gp")){I.push({label:"Select to GenomePaint",callback:_})}if(!I.length)return;e.app.tip.clear();if(h){e.app.tip.d.append("div").html(h)}const x=v(y,e);e.app.tip.d.append("div").selectAll("div").data(I).enter().append("div").attr("class","sja_menuoption").html((t=>t.label)).on("click",(async(t,a)=>{e.app.tip.hide();await a.callback(e,x)}));e.app.tip.show(t.clientX,t.clientY)}async function f(e,a,i,s,r){const l={type:"tvslst",in:true,join:"and",lst:[b(1,i)]};const d=[a.config.term];if(a.config.term2){d.push(a.config.term2);l.lst.push(b(2,s))}if(a.config.term0){d.push(a.config.term0);l.lst.push(b(0,r))}const c={terms:d,filter:n([a.state.termfilter.filter,l])};const p=await a.app.vocabApi.getAnnotatedSampleData(c);const u=[];for(const t of p.lst)u.push([{value:t.sampleName}]);const m=[{label:"Sample"}];const f=new t({padding:"5px"});const g=f.d.append("div");o({rows:u,columns:m,div:g,showLines:true,maxWidth:"27vw",maxHeight:"40vh",resize:true});f.show(e.clientX,e.clientY,false);function b(t,e){const i=t==0?a.config.term0:t==1?a.config.term:a.config.term2;const n={type:"tvs",tvs:{term:i.term,values:[{key:e}]}};if(i.term.type=="integer"||i.term.type=="float"){const i=a.bins[t];n.tvs.ranges=[i.find((t=>t.label==e))]}return n}}function g(t,e){if(!e)return;if(!t.state.termfilter||t.state.nav?.header_mode!=="with_tabs"){return}const a=s(t.state.termfilter.filter,"filterUiRoot");const i=n([a,{type:"tvslst",in:true,join:e.length>1?"and":"",lst:[...e.map(b)]}]);i.tag="filterUiRoot";t.app.dispatch({type:"filter_replace",filter:i})}function b(t){return t.type==="tvs"?t:{type:"tvs",tvs:t}}function _(t,e){const n=[];for(const a of e){b(a);const e=i(t.state.termfilter.filter,a.tvs.term.id);if(!e)n.push(b(a))}import("./block-06e306e9.js").then((function(t){return t.c})).then((async e=>{const i={genome:t.app.opts.genome,dslabel:t.state.dslabel};const o=a({x:100,y:100});const l=r(t.state.termfilter.filter);const d=s(l,d);if(d&&d!=l)delete d.tag;l.tag="filterUiRoot";if(n.length){l.join="and";l.lst.push(...n)}const c=s(l,"cohortFilter");if(c){c.renderAs="htmlSelect";c.selectOptionsFrom="selectCohort"}new e.Block({hostURL:sessionStorage.getItem("hostURL"),holder:o.body,genome:i.genome,nobox:true,chr:i.genome.defaultcoord.chr,start:i.genome.defaultcoord.start,stop:i.genome.defaultcoord.stop,nativetracks:[i.genome.tracks.find((t=>t.__isgene)).name.toLowerCase()],tklst:[{type:"mds2",dslabel:i.dslabel,vcf:{numerical_axis:{AFtest:{groups:[{is_termdb:true,filter:l},{is_population:true,key:"gnomAD",allowto_adjust_race:true,adjust_race:true}]}}}}]})}))}function v(t,e){const a=[];if(e.state.nav?.header_mode=="with_cohortHtmlSelect"){const t=s(e.state.termfilter.filter,"cohortFilter");if(t)a.push(JSON.parse(JSON.stringify(t)))}const i=e.config.term;const n=i.term.values&&Object.keys(i.term.values).filter((e=>i.term.values[e].label===t.seriesId))[0];const r=i.term.values&&n in i.term.values?n:t.seriesId;const o=e.config.term2;const l=o&&o.term.values&&Object.keys(o.term.values).filter((e=>o.term.values[e].label===t.dataId))[0];const d=o&&o.term.values&&l in o.term.values?l:t.dataId;for(const n of[i,o]){if(!n)continue;const s=n==i?1:2;const l=n==i?r:d;const c=n.q;const p=!n||!n.term.values?l:l in n.term.values?n.term.values[l].label:l;if(c.groupsetting&&c.groupsetting.inuse){const t="predefined_groupset_idx"in c.groupsetting?n.term.groupsetting.lst[c.groupsetting.predefined_groupset_idx]:c.groupsetting.customset;const e=t.groups.find((t=>t.name===l));const i={term:n.term,values:e.values,groupset_label:e.name};if(n.term.type=="condition"){i.bar_by_children=n.q.bar_by_children;i.bar_by_grade=n.q.bar_by_grade;i.value_by_most_recent=n.q.value_by_most_recent;i.value_by_max_grade=n.q.value_by_max_grade}a.push(i)}else if(n.term.type=="condition"){if(!o||i.id!=o.id){a.push(Object.assign({term:n.term,values:[{key:l,label:p}]},c))}if(n==i&&o&&n.term.id==o.id){const i=o.q;const s=o.term.values&&t.dataId in o.term.values?e.config.term2.values[t.dataId].label:t.dataId;a.push(Object.assign({term:n.term,grade_and_child:[{grade:i.bar_by_grade?t.dataId:l,grade_label:i.bar_by_grade?s:p,child_id:i.bar_by_children?t.dataId:l,child_label:i.bar_by_children?s:p}]},i))}}else{const t=e.currServerData.refs.bins[s];if(!t||!t.length){a.push({term:n.term,values:[{key:l,label:p}]})}else{const e=t.find((t=>t.label==p||t.name==p));if(e)a.push({term:n.term,ranges:[e]});else if(n==i){a.push({term:n.term,ranges:[{value:l}]})}else if(n==o){a.push({term:n.term,ranges:[{value:l}]})}else{throw"should not happen"}}}}return a.map((t=>b(t)))}export{l as default,p as hideCategory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as t,q as e,f as o}from"./app-f70d9a0b.js";import{b as a,d as s}from"./axis-6cb4f314.js";import{l}from"./log-9e964794.js";import"path";function n(n,r){const i={},c={};const d={};let h;let p;let g,f,u,m,w;let y,x,b,v,k,z,I;let S,B,M;let A;let T=[];let L;function P(t,e){let o=i.orientation;h=t;Object.assign(i,h.settings);i.handlers=h.handlers;i.cols=i.cols.filter((t=>i.colLabels.find((e=>e.id==t))));i.rows=i.rows?.filter((t=>!i.exclude.rows.includes(t)))||[];const a=!g;if(a)_();const s=i.colw;T=h.visibleSerieses;T.map(C);h.serieses.map(C);j();p.style("width",i.svgw+100+"px").style("font-weight",600).style("font-size","20px").style("margin-bottom","24px").html(i.handlers.chart.title(h));if(a){g.attr("height",0).attr("width",0).style("opacity",0);f.attr("transform","translate("+i.rowlabelw+",0)")}const l=u.attr("transform",G).selectAll(".bars-cell-grp").data(T,F);l.exit().each(O);l.each(N);l.enter().append("g").each(H);const n=m.attr("transform",Q).style("opacity",o!=i.orientation?1e-4:1).style("display",i.orientation!="vertical"?"none":"").selectAll("g").data(i.colLabels,(t=>t.id));n.exit().remove();n.each(Y);n.enter().append("g").each(X);const r=w.attr("transform",Z).style("opacity",o!=i.orientation?1e-4:1).style("display",i.orientation!="horizontal"?"none":"").selectAll("g").data(i.colLabels,(t=>t.id));r.exit().remove();r.each(et);r.enter().append("g").each(tt);u.selectAll("rect");M=m.selectAll("text");i.delay=.35*i.duration;it(i,o,h.visibleTotal);i.colw=s;if(o!=i.orientation){const t=i.orientation=="vertical"?m:w;t.transition().duration(1500).style("opacity",1)}if(a){g.transition().duration(100).attr("height",1).attr("width",1).style("opacity",1)}setTimeout((()=>{const t=20;const e=f.node().getBBox();const o=!L||e.width?e:L;L=o;g.transition().duration(e.width?100:0).attr("width",o.width+t).attr("height",o.height+t);if(i.orientation=="vertical"){const a=m.node().getBBox();const s=b.node().getBBox();const l=Math.max(-a.x,-s.x,-o.x);f.transition().duration(e.width?100:0).attr("transform","translate("+l+","+-t+")")}else{const t=w.node().getBBox();const o=b.node().getBBox();const a=z.node().getBBox();f.transition().duration(e.width?100:0).attr("transform","translate("+Math.max(-t.x,-o.x)+","+-a.y+")")}}),a?110:510)}function _(){A={geneonrow:i.geneonrow,nicenames:{},colw:i.geneonrow?Math.min(15,Math.max(1,Math.floor(document.body.clientWidth*.7/i.cols.length))):20,rowh:i.geneonrow?20:Math.min(18,Math.max(10,Math.floor(document.body.clientHeight*.7/i.rows.length))),rowspace:i.geneonrow?2:i.rows.length>100?0:1,colspace:!i.geneonrow?2:i.cols.length>100?0:1,rowtick:8,coltick:5,rowlabtickspace:4,collabtickspace:4,collabelh:150,rowlabelw:250,rowheadleft:true,colheadtop:false,samplecount4gene:true,samplecount4legend:false,showgrid:true,gridstroke:"#fff",showEmptyCells:false,cellbg:"#eeeeee",fontsizeratio:.9,rowlabelfontsizemax:16,collabelfontsizemax:12,crudefill:i.colw<=2,duration:1e3,delay:0};for(let t in A){if(!(t in i)||t=="cols"||t=="rows")i[t]=A[t]}if(!g){p=r.append("div").attr("class","pp-chart-title").style("text-align","center");g=r.append("svg").attr("class","pp-bars-svg").style("overflow","visible").on("mouseover.tphm2",i.handlers.svg.mouseover).on("mouseout.tphm2",i.handlers.svg.mouseout).on("click.tphm2",i.handlers.svg.click)}f=g.append("g").attr("class","sjpcb-bars-mainG");i.h.svg=g;i.h.mainG=f;m=f.append("g").attr("class","bars-collabels").style("cursor",i.handlers.colLabel.click?"pointer":"").on("mouseover.tphm2",gt).on("mouseout.tphm2",ft).on("click.tphm2",i.handlers.colLabel.click);w=f.append("g").attr("class","bars-rowlabels").style("cursor",i.handlers.rowLabel.click?"pointer":"").on("mouseover.tphm2",gt).on("mouseout.tphm2",ft).on("click.tphm2",i.handlers.rowLabel.click);u=f.append("g").attr("class","bars-series").on("mouseover.tphm2",ht).on("mouseout.tphm2",pt).on("click",ut).style("cursor","pointer");y=f.append("g").attr("class","sjpcb-bar-chart-axis-g");x=y.append("g").attr("class","sjpcb-bar-chart-y-axis");v=y.append("line").attr("class","sjpcb-bar-chart-y-line").style("stroke","#000");b=y.append("g").attr("class","sjpcb-bar-chart-y-title").style("cursor","default");k=y.append("g").attr("class","sjpcb-bar-chart-x-axis");I=y.append("line").attr("class","sjpcb-bar-chart-x-line").style("stroke","#000");z=y.append("g").attr("class","sjpcb-bar-chart-x-title").style("cursor","default")}function j(){const e=i.numCharts<4?i.numCharts:i.numCharts%3==0?3:2;const o=i.cols.length*i.colspace+(i.colgrps.length-1)*i.colgspace+i.rowlabelw+i.rowgrplabelw;if(i.orientation=="horizontal"){i.svgw=Math.min(400,.92*window.innerWidth/e);i.rowh=Math.max(14,Math.min(22,.7*window.innerHeight/i.cols.length));i.svgh=i.cols.length*(i.rowh+i.colspace)-i.colspace+(i.colgrps.length-1)*i.colgspace+i.rowlabelw+i.rowgrplabelw}else{const t=window.innerWidth*.92/e;i.colw=Math.min(Math.max(16,Math.round((t-o)/i.cols.length)),30);i.svgw=i.cols.length*(i.colw+i.colspace)-i.colspace+(i.colgrps.length-1)*i.colgspace+i.rowlabelw+i.rowgrplabelw;const a=Math.ceil(i.numCharts/e);i.svgh=Math.max(350,Math.min(400,window.innerHeight*.5))/(a>3?2:1)}h.svgh=i.svgh;i.h.yScale={};i.h.xScale={};i.h.yPrevBySeries={};i.h.xPrevBySeries={};const a=i.scale=="byChart"?1:h.maxVisibleSeriesTotal/h.maxVisibleAcrossCharts;for(const e of T){if(e.visibleData[0]){const o=i.unit=="log"?1:0;const s=i.unit=="pct"?e.visibleTotal:i.unit=="log"?h.maxSeriesLogTotal:h.maxVisibleSeriesTotal;i.h.yScale[e.seriesId]=t().domain([o,s/a]).range([0,i.svgh-i.collabelh]);i.h.xScale[e.seriesId]=t().domain([o,s/a]).range([0,i.svgw-i.rowlabelw]);i.h.yPrevBySeries[e.seriesId]=0;i.h.xPrevBySeries[e.seriesId]=0;for(const t of e.visibleData){t.height=R(t);t.y=q(t);t.x=K(t);t.width=J(t)}}}c.colfontsize=Math.min(i.colw*i.fontsizeratio,i.collabelfontsizemax);c.rowfontsize=Math.min(i.rowh*i.fontsizeratio,i.rowlabelfontsizemax);c.rowtextyalign=Math.min(i.rowh,(i.rowh+c.rowfontsize)/2)+i.rowspace}function C(t){if(!("seriesId"in t)){t.data.map((e=>{if(e)t.seriesId=e[i.serieskey]}))}t.data.map((t=>{t.rowId=t[i.rowkey];t.colId=t[i.colkey]}))}function F(t){return t.seriesId}function V(t){return t.rowId+" "+t.colId}function O(){e(this).remove()}function N(t){const o=e(this).selectAll(".bars-cell").data(t.data.filter(W),V);o.exit().each((function(){e(this).remove()}));o.style("display",(t=>i.cols.includes(t.colId)?"block":"none"));o.select("rect").datum((t=>t)).transition().duration(i.duration).attr("x",(t=>t.x)).attr("y",(t=>t.y)).attr("width",(t=>t.width)).attr("height",(t=>t.height)).attr("fill",i.handlers.series.rectFill).attr("stroke",i.handlers.series.strokeFill);o.enter().append("g").each(D);o.selectAll("text").remove();E(o)}function H(t){if(!t||!t.data.length)return;e(this).attr("class","bars-cell-grp").selectAll("g").data(t.data.filter(W),V).enter().append("g").each(D)}function W(t){return i.rows.includes(t.dataId)}function D(t){const o=e(this).attr("class","bars-cell").datum(t);o.style("display",(t=>i.cols.includes(t.colId)?"block":"none"));o.append("rect").attr("x",(t=>t.x)).attr("y",(t=>t.y)).attr("width",(t=>t.width)).attr("height",(t=>t.height)).attr("fill",i.handlers.series.rectFill).attr("stroke",i.handlers.series.strokeFill).attr("shape-rendering","crispEdges").style("opacity",0).transition().delay(i.delay).duration(i.duration).style("opacity",1);E(o)}function E(t){if(!n.config.settings.barchart.asterisksVisible){return}t.append("text").text((t=>{const e=t.groupPvalues&&t.groupPvalues.term2tests.find((e=>e.term2id==t.dataId));if(!e||e.skipped||!e.adjusted_p_value)return"";return e.adjusted_p_value<.05?"*":""})).attr("x",(t=>t.x+t.width/2)).attr("y",(t=>t.y+t.height/2)).attr("dy","0.6em").style("text-anchor","middle").style("opacity",0).transition().delay(i.delay).duration(i.duration).style("opacity",1)}function G(){const t=i.colspace;let e=i.colheadtop?i.collabelh:i.colgrplabelh;if(i.legendontop)e+=i.legendh;return"translate("+t+","+e+")"}function R(t){const e=i.unit=="log"?t.logTotal:t.total;const o=i.orientation=="vertical"?i.h.yScale[t.seriesId](e):i.rowh;const a=0;i.h.yPrevBySeries[t.seriesId]+=o+a;return Math.max(1,o-a)}function q(t){const e=i.colgrps.indexOf(t[i.colgrpkey])*i.colgspace;const o=i.unit=="log"?Math.max(0,i.h.yPrevBySeries[t.seriesId]):i.h.yPrevBySeries[t.seriesId];return i.orientation=="vertical"?i.svgh-i.collabelh-o:i.cols.indexOf(t.colId)*(i.rowh+i.rowspace)+e}function J(t){const e=i.unit=="log"?t.logTotal:t.total;const o=i.orientation=="vertical"?i.colw:i.h.xScale[t.seriesId](e);const a=0;i.h.xPrevBySeries[t.seriesId];i.h.xPrevBySeries[t.seriesId]+=Math.max(1,o+a);return Math.max(1,o-a)}function K(t){const e=i.colgrps.indexOf(t[i.colgrpkey])*i.colgspace;return i.orientation=="vertical"?i.cols.indexOf(t.colId)*(i.colw+i.colspace)+e:i.h.xPrevBySeries[t.seriesId]}function Q(){let t=5+i.colspace;let e=i.colheadtop?i.borderwidth+1:i.svgh-i.collabelh+25;if(i.legendontop)e+=i.legendh;return"translate("+t+","+e+")"}function U(t){const e=i.col2name[t]?i.col2name[t].grp:"";const o=i.colgrps.indexOf(e)*i.colgspace+i.cols.indexOf("id"in t?t.id:t)*(i.colw+i.colspace)+i.colw/2;const a=i.colheadtop?-1*(i.coltick+i.collabtickspace):i.coltick+i.collabtickspace;return"translate("+o+","+a+")"}function X(t){if(!this||t===undefined)return;const o=e(this).attr("transform",U).style("opacity",0);o.append("text").attr("transform","rotate(-40)").attr("y",2).attr("text-anchor","end").attr("font-size",c.colfontsize+"px").html(i.handlers.colLabel.text);o.transition().delay(i.delay).duration(i.duration).style("opacity",1)}function Y(t){const o=e(this).datum(t);o.attr("transform",U);o.selectAll("text").datum(t).attr("y",2).attr("text-anchor","end").attr("font-size",c.colfontsize+"px").html(i.handlers.colLabel.text)}function Z(){const t=i.colheadtop?i.collabelh:i.colgrplabelh;const e=i.rowheadleft?i.borderwidth+1:i.svgw-i.rowlabelw+20;return"translate("+e+","+t+")"}function $(t){const e=i.row2name[t]?i.row2name[t].grp:"";const o=i.colgrps.indexOf(e)*i.rowgspace+i.cols.indexOf("id"in t?t.id:t)*(i.rowh+i.rowspace)+c.rowtextyalign;const a=i.rowheadleft?-1*(i.rowtick+i.rowlabtickspace):i.rowtick+i.rowlabtickspace;return"translate("+a+","+o+")"}function tt(t){if(!this||t===undefined)return;const o=e(this).attr("transform",$).style("opacity",0);o.append("text").attr("x",2).attr("text-anchor","end").attr("font-size",c.rowfontsize+"px").html(i.handlers.rowLabel.text);o.transition().delay(i.delay).duration(i.duration).style("opacity",1)}function et(t){const o=e(this).datum(t);o.attr("transform",$);o.selectAll("text").datum(t).attr("x",2).attr("text-anchor","end").attr("font-size",c.rowfontsize+"px").html(i.handlers.rowLabel.text)}function ot(t){return t==S.rowId?700:""}function at(t){return t==S.rowId?Math.max(12,c.rowfontsize):c.rowfontsize}function st(t){return t==S.rowId?"#00f":""}function lt(t){return t==S.colId?700:""}function nt(t){return t==S.colId?12:c.colfontsize}function rt(t){return t==S.colId?"#00f":""}function it(t,e,o){y.style("opacity",e!=t.orientation?0:1).transition().duration(1500).style("opacity",1);if(t.orientation=="vertical"){ct(t,o)}else{dt(t,o)}}function ct(e,s){k.style("display","none");v.style("display","none");const n=m.node().getBBox();e.svgh-e.collabelh+24;z.selectAll("*").remove();const r=i.handlers.xAxis.text(s);z.append("text").style("text-anchor","middle").style("font-size",e.axisTitleFontSize+"px").style("font-weight",600).text(r);setTimeout((()=>{z.attr("transform","translate("+(e.svgw-e.svgPadding.left-e.svgPadding.right-e.rowlabelw)/2+","+(n.height+i.svgh-i.collabelh+20+e.axisTitleFontSize)+")")}),0);const c=i.scale=="byChart"||i.clickedAge?1:h.maxVisibleSeriesTotal/h.maxVisibleAcrossCharts;const d=i.unit=="log"?1:0;const p=i.unit=="pct"?100:h.maxVisibleSeriesTotal;x.style("display","block").call(a((i.unit=="log"?l():t()).domain([p/c,d]).range([e.colgrplabelh,e.svgh-e.collabelh+e.colgrplabelh-e.borderwidth+1])).ticks(4,o("d")));b.selectAll("*").remove();const g=e.svgh-e.collabelh;b.style("font-weight",600).attr("transform","translate("+(-e.svgPadding.left-e.axisTitleFontSize)+","+g/2+")rotate(-90)").append("text").style("text-anchor","middle").style("font-size",e.axisTitleFontSize+"px").text(i.handlers.yAxis.text(s))}function dt(e,a){x.style("display","none");I.style("display","none");b.selectAll("*").remove();const n=i.handlers.yAxis.text(a);b.append("text").style("text-anchor","end").style("font-size",e.axisTitleFontSize+"px").style("font-weight",600).text(n);w.node().getBBox();setTimeout((()=>{b.style("text-anchor","end").attr("transform","translate("+0+",0)")}),0);const r=i.scale=="byChart"||i.clickedAge?1:h.maxVisibleSeriesTotal/h.maxVisibleAcrossCharts;const c=i.unit=="log"?1:0;const d=i.unit=="pct"?100:h.maxVisibleSeriesTotal;let p=e.colheadtop?e.collabelh-2:e.colgrplabelh-2;if(e.legendontop)p+=e.legendh;k.style("display","block").attr("transform","translate(2.5,"+p+")").call(s((i.unit=="log"?l():t()).domain([c,d/r]).range([0,e.svgw-e.rowlabelw])).ticks(4,o("d")));z.selectAll("*").remove();const g=e.svgw-e.rowlabelw;z.attr("transform","translate("+g/2+",0)").append("text").style("text-anchor","middle").style("font-size",e.axisTitleFontSize+"px").style("font-weight",600).text(i.handlers.xAxis.text(a))}function ht(t){const e=t.target.tagName=="tspan"?t.target.parentNode:t.target;const o=e.__data__;if(o&&(e.tagName=="rect"||e.nodeName=="text")){S=o;o.x;q(o.cellmates?o.cellmates[0]:o);M.attr("font-weight",lt).attr("font-size",nt).style("fill",rt)}else{S=d;B.attr("font-weight",ot).attr("font-size",at).style("fill",st);M.attr("font-weight",lt).attr("font-size",nt).style("fill",rt)}i.handlers.series.mouseover(t,o)}function pt(t){t.stopPropagation();M.attr("font-weight","").attr("font-size",c.colfontsize).style("fill","");S=d;if(i.handlers.series.mouseout)i.handlers.series.mouseout(t)}function gt(t){const e=t.target.__data__;if(!e)return;const o=i.col2name["id"in e?e.id:e];const a={colId:o.name};a[i.colkey]=o.name;a[i.colgrpkey]=o.grp;if(i.handlers.colLabel.mouseover)i.handlers.colLabel.mouseover(t)}function ft(t){S=d;if(i.handlers.colLabel.mouseout)i.handlers.colLabel.mouseout(t)}function ut(t){const e=t.target.__data__;n.handlers.series.click(t,e)}P.hm=i;P.styles=()=>{const t={};for(const e in A){t[e]=i[e]}if(legendRenderer){for(const e in legendRenderer.defaults)t[e]=i[e]}return t};return P}export{n as default};
|
|
1
|
+
import{l as t,q as e,f as o}from"./app-f73edb78.js";import{b as a,d as s}from"./axis-6cb4f314.js";import{l}from"./log-848ca156.js";import"path";function n(n,r){const i={},c={};const d={};let h;let p;let g,f,u,m,w;let y,x,b,v,k,z,I;let S,B,M;let A;let T=[];let L;function P(t,e){let o=i.orientation;h=t;Object.assign(i,h.settings);i.handlers=h.handlers;i.cols=i.cols.filter((t=>i.colLabels.find((e=>e.id==t))));i.rows=i.rows?.filter((t=>!i.exclude.rows.includes(t)))||[];const a=!g;if(a)_();const s=i.colw;T=h.visibleSerieses;T.map(C);h.serieses.map(C);j();p.style("width",i.svgw+100+"px").style("font-weight",600).style("font-size","20px").style("margin-bottom","24px").html(i.handlers.chart.title(h));if(a){g.attr("height",0).attr("width",0).style("opacity",0);f.attr("transform","translate("+i.rowlabelw+",0)")}const l=u.attr("transform",G).selectAll(".bars-cell-grp").data(T,F);l.exit().each(O);l.each(N);l.enter().append("g").each(H);const n=m.attr("transform",Q).style("opacity",o!=i.orientation?1e-4:1).style("display",i.orientation!="vertical"?"none":"").selectAll("g").data(i.colLabels,(t=>t.id));n.exit().remove();n.each(Y);n.enter().append("g").each(X);const r=w.attr("transform",Z).style("opacity",o!=i.orientation?1e-4:1).style("display",i.orientation!="horizontal"?"none":"").selectAll("g").data(i.colLabels,(t=>t.id));r.exit().remove();r.each(et);r.enter().append("g").each(tt);u.selectAll("rect");M=m.selectAll("text");i.delay=.35*i.duration;it(i,o,h.visibleTotal);i.colw=s;if(o!=i.orientation){const t=i.orientation=="vertical"?m:w;t.transition().duration(1500).style("opacity",1)}if(a){g.transition().duration(100).attr("height",1).attr("width",1).style("opacity",1)}setTimeout((()=>{const t=20;const e=f.node().getBBox();const o=!L||e.width?e:L;L=o;g.transition().duration(e.width?100:0).attr("width",o.width+t).attr("height",o.height+t);if(i.orientation=="vertical"){const a=m.node().getBBox();const s=b.node().getBBox();const l=Math.max(-a.x,-s.x,-o.x);f.transition().duration(e.width?100:0).attr("transform","translate("+l+","+-t+")")}else{const t=w.node().getBBox();const o=b.node().getBBox();const a=z.node().getBBox();f.transition().duration(e.width?100:0).attr("transform","translate("+Math.max(-t.x,-o.x)+","+-a.y+")")}}),a?110:510)}function _(){A={geneonrow:i.geneonrow,nicenames:{},colw:i.geneonrow?Math.min(15,Math.max(1,Math.floor(document.body.clientWidth*.7/i.cols.length))):20,rowh:i.geneonrow?20:Math.min(18,Math.max(10,Math.floor(document.body.clientHeight*.7/i.rows.length))),rowspace:i.geneonrow?2:i.rows.length>100?0:1,colspace:!i.geneonrow?2:i.cols.length>100?0:1,rowtick:8,coltick:5,rowlabtickspace:4,collabtickspace:4,collabelh:150,rowlabelw:250,rowheadleft:true,colheadtop:false,samplecount4gene:true,samplecount4legend:false,showgrid:true,gridstroke:"#fff",showEmptyCells:false,cellbg:"#eeeeee",fontsizeratio:.9,rowlabelfontsizemax:16,collabelfontsizemax:12,crudefill:i.colw<=2,duration:1e3,delay:0};for(let t in A){if(!(t in i)||t=="cols"||t=="rows")i[t]=A[t]}if(!g){p=r.append("div").attr("class","pp-chart-title").style("text-align","center");g=r.append("svg").attr("class","pp-bars-svg").style("overflow","visible").on("mouseover.tphm2",i.handlers.svg.mouseover).on("mouseout.tphm2",i.handlers.svg.mouseout).on("click.tphm2",i.handlers.svg.click)}f=g.append("g").attr("class","sjpcb-bars-mainG");i.h.svg=g;i.h.mainG=f;m=f.append("g").attr("class","bars-collabels").style("cursor",i.handlers.colLabel.click?"pointer":"").on("mouseover.tphm2",gt).on("mouseout.tphm2",ft).on("click.tphm2",i.handlers.colLabel.click);w=f.append("g").attr("class","bars-rowlabels").style("cursor",i.handlers.rowLabel.click?"pointer":"").on("mouseover.tphm2",gt).on("mouseout.tphm2",ft).on("click.tphm2",i.handlers.rowLabel.click);u=f.append("g").attr("class","bars-series").on("mouseover.tphm2",ht).on("mouseout.tphm2",pt).on("click",ut).style("cursor","pointer");y=f.append("g").attr("class","sjpcb-bar-chart-axis-g");x=y.append("g").attr("class","sjpcb-bar-chart-y-axis");v=y.append("line").attr("class","sjpcb-bar-chart-y-line").style("stroke","#000");b=y.append("g").attr("class","sjpcb-bar-chart-y-title").style("cursor","default");k=y.append("g").attr("class","sjpcb-bar-chart-x-axis");I=y.append("line").attr("class","sjpcb-bar-chart-x-line").style("stroke","#000");z=y.append("g").attr("class","sjpcb-bar-chart-x-title").style("cursor","default")}function j(){const e=i.numCharts<4?i.numCharts:i.numCharts%3==0?3:2;const o=i.cols.length*i.colspace+(i.colgrps.length-1)*i.colgspace+i.rowlabelw+i.rowgrplabelw;if(i.orientation=="horizontal"){i.svgw=Math.min(400,.92*window.innerWidth/e);i.rowh=Math.max(14,Math.min(22,.7*window.innerHeight/i.cols.length));i.svgh=i.cols.length*(i.rowh+i.colspace)-i.colspace+(i.colgrps.length-1)*i.colgspace+i.rowlabelw+i.rowgrplabelw}else{const t=window.innerWidth*.92/e;i.colw=Math.min(Math.max(16,Math.round((t-o)/i.cols.length)),30);i.svgw=i.cols.length*(i.colw+i.colspace)-i.colspace+(i.colgrps.length-1)*i.colgspace+i.rowlabelw+i.rowgrplabelw;const a=Math.ceil(i.numCharts/e);i.svgh=Math.max(350,Math.min(400,window.innerHeight*.5))/(a>3?2:1)}h.svgh=i.svgh;i.h.yScale={};i.h.xScale={};i.h.yPrevBySeries={};i.h.xPrevBySeries={};const a=i.scale=="byChart"?1:h.maxVisibleSeriesTotal/h.maxVisibleAcrossCharts;for(const e of T){if(e.visibleData[0]){const o=i.unit=="log"?1:0;const s=i.unit=="pct"?e.visibleTotal:i.unit=="log"?h.maxSeriesLogTotal:h.maxVisibleSeriesTotal;i.h.yScale[e.seriesId]=t().domain([o,s/a]).range([0,i.svgh-i.collabelh]);i.h.xScale[e.seriesId]=t().domain([o,s/a]).range([0,i.svgw-i.rowlabelw]);i.h.yPrevBySeries[e.seriesId]=0;i.h.xPrevBySeries[e.seriesId]=0;for(const t of e.visibleData){t.height=R(t);t.y=q(t);t.x=K(t);t.width=J(t)}}}c.colfontsize=Math.min(i.colw*i.fontsizeratio,i.collabelfontsizemax);c.rowfontsize=Math.min(i.rowh*i.fontsizeratio,i.rowlabelfontsizemax);c.rowtextyalign=Math.min(i.rowh,(i.rowh+c.rowfontsize)/2)+i.rowspace}function C(t){if(!("seriesId"in t)){t.data.map((e=>{if(e)t.seriesId=e[i.serieskey]}))}t.data.map((t=>{t.rowId=t[i.rowkey];t.colId=t[i.colkey]}))}function F(t){return t.seriesId}function V(t){return t.rowId+" "+t.colId}function O(){e(this).remove()}function N(t){const o=e(this).selectAll(".bars-cell").data(t.data.filter(W),V);o.exit().each((function(){e(this).remove()}));o.style("display",(t=>i.cols.includes(t.colId)?"block":"none"));o.select("rect").datum((t=>t)).transition().duration(i.duration).attr("x",(t=>t.x)).attr("y",(t=>t.y)).attr("width",(t=>t.width)).attr("height",(t=>t.height)).attr("fill",i.handlers.series.rectFill).attr("stroke",i.handlers.series.strokeFill);o.enter().append("g").each(D);o.selectAll("text").remove();E(o)}function H(t){if(!t||!t.data.length)return;e(this).attr("class","bars-cell-grp").selectAll("g").data(t.data.filter(W),V).enter().append("g").each(D)}function W(t){return i.rows.includes(t.dataId)}function D(t){const o=e(this).attr("class","bars-cell").datum(t);o.style("display",(t=>i.cols.includes(t.colId)?"block":"none"));o.append("rect").attr("x",(t=>t.x)).attr("y",(t=>t.y)).attr("width",(t=>t.width)).attr("height",(t=>t.height)).attr("fill",i.handlers.series.rectFill).attr("stroke",i.handlers.series.strokeFill).attr("shape-rendering","crispEdges").style("opacity",0).transition().delay(i.delay).duration(i.duration).style("opacity",1);E(o)}function E(t){if(!n.config.settings.barchart.asterisksVisible){return}t.append("text").text((t=>{const e=t.groupPvalues&&t.groupPvalues.term2tests.find((e=>e.term2id==t.dataId));if(!e||e.skipped||!e.adjusted_p_value)return"";return e.adjusted_p_value<.05?"*":""})).attr("x",(t=>t.x+t.width/2)).attr("y",(t=>t.y+t.height/2)).attr("dy","0.6em").style("text-anchor","middle").style("opacity",0).transition().delay(i.delay).duration(i.duration).style("opacity",1)}function G(){const t=i.colspace;let e=i.colheadtop?i.collabelh:i.colgrplabelh;if(i.legendontop)e+=i.legendh;return"translate("+t+","+e+")"}function R(t){const e=i.unit=="log"?t.logTotal:t.total;const o=i.orientation=="vertical"?i.h.yScale[t.seriesId](e):i.rowh;const a=0;i.h.yPrevBySeries[t.seriesId]+=o+a;return Math.max(1,o-a)}function q(t){const e=i.colgrps.indexOf(t[i.colgrpkey])*i.colgspace;const o=i.unit=="log"?Math.max(0,i.h.yPrevBySeries[t.seriesId]):i.h.yPrevBySeries[t.seriesId];return i.orientation=="vertical"?i.svgh-i.collabelh-o:i.cols.indexOf(t.colId)*(i.rowh+i.rowspace)+e}function J(t){const e=i.unit=="log"?t.logTotal:t.total;const o=i.orientation=="vertical"?i.colw:i.h.xScale[t.seriesId](e);const a=0;i.h.xPrevBySeries[t.seriesId];i.h.xPrevBySeries[t.seriesId]+=Math.max(1,o+a);return Math.max(1,o-a)}function K(t){const e=i.colgrps.indexOf(t[i.colgrpkey])*i.colgspace;return i.orientation=="vertical"?i.cols.indexOf(t.colId)*(i.colw+i.colspace)+e:i.h.xPrevBySeries[t.seriesId]}function Q(){let t=5+i.colspace;let e=i.colheadtop?i.borderwidth+1:i.svgh-i.collabelh+25;if(i.legendontop)e+=i.legendh;return"translate("+t+","+e+")"}function U(t){const e=i.col2name[t]?i.col2name[t].grp:"";const o=i.colgrps.indexOf(e)*i.colgspace+i.cols.indexOf("id"in t?t.id:t)*(i.colw+i.colspace)+i.colw/2;const a=i.colheadtop?-1*(i.coltick+i.collabtickspace):i.coltick+i.collabtickspace;return"translate("+o+","+a+")"}function X(t){if(!this||t===undefined)return;const o=e(this).attr("transform",U).style("opacity",0);o.append("text").attr("transform","rotate(-40)").attr("y",2).attr("text-anchor","end").attr("font-size",c.colfontsize+"px").html(i.handlers.colLabel.text);o.transition().delay(i.delay).duration(i.duration).style("opacity",1)}function Y(t){const o=e(this).datum(t);o.attr("transform",U);o.selectAll("text").datum(t).attr("y",2).attr("text-anchor","end").attr("font-size",c.colfontsize+"px").html(i.handlers.colLabel.text)}function Z(){const t=i.colheadtop?i.collabelh:i.colgrplabelh;const e=i.rowheadleft?i.borderwidth+1:i.svgw-i.rowlabelw+20;return"translate("+e+","+t+")"}function $(t){const e=i.row2name[t]?i.row2name[t].grp:"";const o=i.colgrps.indexOf(e)*i.rowgspace+i.cols.indexOf("id"in t?t.id:t)*(i.rowh+i.rowspace)+c.rowtextyalign;const a=i.rowheadleft?-1*(i.rowtick+i.rowlabtickspace):i.rowtick+i.rowlabtickspace;return"translate("+a+","+o+")"}function tt(t){if(!this||t===undefined)return;const o=e(this).attr("transform",$).style("opacity",0);o.append("text").attr("x",2).attr("text-anchor","end").attr("font-size",c.rowfontsize+"px").html(i.handlers.rowLabel.text);o.transition().delay(i.delay).duration(i.duration).style("opacity",1)}function et(t){const o=e(this).datum(t);o.attr("transform",$);o.selectAll("text").datum(t).attr("x",2).attr("text-anchor","end").attr("font-size",c.rowfontsize+"px").html(i.handlers.rowLabel.text)}function ot(t){return t==S.rowId?700:""}function at(t){return t==S.rowId?Math.max(12,c.rowfontsize):c.rowfontsize}function st(t){return t==S.rowId?"#00f":""}function lt(t){return t==S.colId?700:""}function nt(t){return t==S.colId?12:c.colfontsize}function rt(t){return t==S.colId?"#00f":""}function it(t,e,o){y.style("opacity",e!=t.orientation?0:1).transition().duration(1500).style("opacity",1);if(t.orientation=="vertical"){ct(t,o)}else{dt(t,o)}}function ct(e,s){k.style("display","none");v.style("display","none");const n=m.node().getBBox();e.svgh-e.collabelh+24;z.selectAll("*").remove();const r=i.handlers.xAxis.text(s);z.append("text").style("text-anchor","middle").style("font-size",e.axisTitleFontSize+"px").style("font-weight",600).text(r);setTimeout((()=>{z.attr("transform","translate("+(e.svgw-e.svgPadding.left-e.svgPadding.right-e.rowlabelw)/2+","+(n.height+i.svgh-i.collabelh+20+e.axisTitleFontSize)+")")}),0);const c=i.scale=="byChart"||i.clickedAge?1:h.maxVisibleSeriesTotal/h.maxVisibleAcrossCharts;const d=i.unit=="log"?1:0;const p=i.unit=="pct"?100:h.maxVisibleSeriesTotal;x.style("display","block").call(a((i.unit=="log"?l():t()).domain([p/c,d]).range([e.colgrplabelh,e.svgh-e.collabelh+e.colgrplabelh-e.borderwidth+1])).ticks(4,o("d")));b.selectAll("*").remove();const g=e.svgh-e.collabelh;b.style("font-weight",600).attr("transform","translate("+(-e.svgPadding.left-e.axisTitleFontSize)+","+g/2+")rotate(-90)").append("text").style("text-anchor","middle").style("font-size",e.axisTitleFontSize+"px").text(i.handlers.yAxis.text(s))}function dt(e,a){x.style("display","none");I.style("display","none");b.selectAll("*").remove();const n=i.handlers.yAxis.text(a);b.append("text").style("text-anchor","end").style("font-size",e.axisTitleFontSize+"px").style("font-weight",600).text(n);w.node().getBBox();setTimeout((()=>{b.style("text-anchor","end").attr("transform","translate("+0+",0)")}),0);const r=i.scale=="byChart"||i.clickedAge?1:h.maxVisibleSeriesTotal/h.maxVisibleAcrossCharts;const c=i.unit=="log"?1:0;const d=i.unit=="pct"?100:h.maxVisibleSeriesTotal;let p=e.colheadtop?e.collabelh-2:e.colgrplabelh-2;if(e.legendontop)p+=e.legendh;k.style("display","block").attr("transform","translate(2.5,"+p+")").call(s((i.unit=="log"?l():t()).domain([c,d/r]).range([0,e.svgw-e.rowlabelw])).ticks(4,o("d")));z.selectAll("*").remove();const g=e.svgw-e.rowlabelw;z.attr("transform","translate("+g/2+",0)").append("text").style("text-anchor","middle").style("font-size",e.axisTitleFontSize+"px").style("font-weight",600).text(i.handlers.xAxis.text(a))}function ht(t){const e=t.target.tagName=="tspan"?t.target.parentNode:t.target;const o=e.__data__;if(o&&(e.tagName=="rect"||e.nodeName=="text")){S=o;o.x;q(o.cellmates?o.cellmates[0]:o);M.attr("font-weight",lt).attr("font-size",nt).style("fill",rt)}else{S=d;B.attr("font-weight",ot).attr("font-size",at).style("fill",st);M.attr("font-weight",lt).attr("font-size",nt).style("fill",rt)}i.handlers.series.mouseover(t,o)}function pt(t){t.stopPropagation();M.attr("font-weight","").attr("font-size",c.colfontsize).style("fill","");S=d;if(i.handlers.series.mouseout)i.handlers.series.mouseout(t)}function gt(t){const e=t.target.__data__;if(!e)return;const o=i.col2name["id"in e?e.id:e];const a={colId:o.name};a[i.colkey]=o.name;a[i.colgrpkey]=o.grp;if(i.handlers.colLabel.mouseover)i.handlers.colLabel.mouseover(t)}function ft(t){S=d;if(i.handlers.colLabel.mouseout)i.handlers.colLabel.mouseout(t)}function ut(t){const e=t.target.__data__;n.handlers.series.click(t,e)}P.hm=i;P.styles=()=>{const t={};for(const e in A){t[e]=i[e]}if(legendRenderer){for(const e in legendRenderer.defaults)t[e]=i[e]}return t};return P}export{n as default};
|