@sjcrh/proteinpaint-client 2.76.1 → 2.76.2
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-593951c7.js → 2dmaf-f240211f.js} +1 -1
- package/dist/{AppHeader-29b88e14.js → AppHeader-c9432a24.js} +1 -1
- package/dist/{ColorScale-3d3c42dc.js → ColorScale-b991fc9e.js} +1 -1
- package/dist/{DEanalysis-f81e0f19.js → DEanalysis-bbfad00d.js} +1 -1
- package/dist/{Disco-db386f7a.js → Disco-b7c9bf72.js} +1 -1
- package/dist/{Disco.UI-8ed9cb39.js → Disco.UI-a5296c36.js} +1 -1
- package/dist/{DragControls-d6250d18.js → DragControls-ca3fa0cf.js} +1 -1
- package/dist/{DziViewer-9352e224.js → DziViewer-28915c11.js} +1 -1
- package/dist/{FilterRxComp-0f35b322.js → FilterRxComp-02e68f1b.js} +1 -1
- package/dist/{FilterStateless-b1c6ee04.js → FilterStateless-16a33070.js} +1 -1
- package/dist/{HicApp-14b94b20.js → HicApp-e713aa40.js} +1 -1
- package/dist/{OrbitControls-45f56ed4.js → OrbitControls-2466d420.js} +1 -1
- package/dist/{WSIViewer-80f60272.js → WSIViewer-957695a8.js} +1 -1
- package/dist/{adSandbox-94424b88.js → adSandbox-27d93bc0.js} +1 -1
- package/dist/app-42f69951.js +1 -0
- package/dist/{app-2cd97738.js → app-6fb77603.js} +1 -1
- package/dist/{app-686b9547.js → app-d215327f.js} +1 -1
- package/dist/app.js +1 -1
- package/dist/{bam-6631640f.js → bam-d67e5315.js} +1 -1
- package/dist/{barchart-3c5d734c.js → barchart-2898d229.js} +1 -1
- package/dist/{barchart.events-df44e666.js → barchart.events-426d737a.js} +1 -1
- package/dist/{bars.renderer-b232d882.js → bars.renderer-71935d34.js} +1 -1
- package/dist/{block-4134e823.js → block-75d4ff92.js} +1 -1
- package/dist/block.lazyload-d2951c91.js +1 -0
- package/dist/{block.legend-d2b7f1cb.js → block.legend-93d85a6e.js} +1 -1
- package/dist/{block.mds-ebe7b58d.js → block.mds-84b9d1c1.js} +1 -1
- package/dist/{block.mds.cnv-99f0a414.js → block.mds.cnv-a991ed79.js} +1 -1
- package/dist/{block.mds.expressionrank-96bf864b.js → block.mds.expressionrank-33b858de.js} +1 -1
- package/dist/{block.mds.expressionstat-dcab3fd1.js → block.mds.expressionstat-3093599f.js} +1 -1
- package/dist/{block.mds.geneboxplot-e5b2a4ce.js → block.mds.geneboxplot-b8391d18.js} +1 -1
- package/dist/{block.mds.junction-534eef9b.js → block.mds.junction-69708c7f.js} +1 -1
- package/dist/{block.mds.svcnv-de6a3c7d.js → block.mds.svcnv-322baea6.js} +1 -1
- package/dist/{block.mds.svcnv.share-2c2c16db.js → block.mds.svcnv.share-c5c38237.js} +1 -1
- package/dist/{block.mds2-373fcb4d.js → block.mds2-de4811dd.js} +1 -1
- package/dist/{block.svg-be5d741d.js → block.svg-ac9fec2d.js} +1 -1
- package/dist/{block.tk.aicheck-f2da5e81.js → block.tk.aicheck-ac4b8d4d.js} +1 -1
- package/dist/{block.tk.ase-ef848944.js → block.tk.ase-6dc0f9f1.js} +1 -1
- package/dist/{block.tk.bam-11fcba17.js → block.tk.bam-8f68b41d.js} +1 -1
- package/dist/{block.tk.bedgraphdot-a81b0709.js → block.tk.bedgraphdot-d8878860.js} +1 -1
- package/dist/{block.tk.bigwig.ui-f8e5ba71.js → block.tk.bigwig.ui-f6ed051c.js} +1 -1
- package/dist/{block.tk.hicstraw-e7072b25.js → block.tk.hicstraw-725bdc8a.js} +1 -1
- package/dist/{block.tk.junction-1c9a7854.js → block.tk.junction-f8b0b51d.js} +1 -1
- package/dist/{block.tk.junction.textmatrixui-ffecbb16.js → block.tk.junction.textmatrixui-252e7d7e.js} +1 -1
- package/dist/{block.tk.ld-274c3a82.js → block.tk.ld-11acf730.js} +1 -1
- package/dist/{block.tk.menu-e970cd4a.js → block.tk.menu-5e04436d.js} +1 -1
- package/dist/{block.tk.pgv-f4d4dbf7.js → block.tk.pgv-fef17dc4.js} +1 -1
- package/dist/{boxplot-44d3b48f.js → boxplot-4c9a5479.js} +1 -1
- package/dist/{brainImaging-2eaa419d.js → brainImaging-7716bc66.js} +1 -1
- package/dist/{brush-bb4ae2fb.js → brush-9faa7ae7.js} +1 -1
- package/dist/{categorical-db9b0175.js → categorical-1dea48ba.js} +1 -1
- package/dist/{condition-4e788f7d.js → condition-ebac4f75.js} +1 -1
- package/dist/{controls-3c1691d7.js → controls-268e40e6.js} +1 -1
- package/dist/{controls.btns-5b1240c8.js → controls.btns-5bf9e7d7.js} +1 -1
- package/dist/controls.config-2f0fa061.js +1 -0
- package/dist/{cuminc-c4db28f0.js → cuminc-8dffb765.js} +1 -1
- package/dist/{customdata.inputui-f9234d1f.js → customdata.inputui-b229d3a0.js} +1 -1
- package/dist/{dataDownload-a4dfa2d0.js → dataDownload-452ae3cd.js} +1 -1
- package/dist/{databrowser.ui-a64bab0c.js → databrowser.ui-2197fc73.js} +1 -1
- package/dist/{density-69a732f6.js → density-09feb0c9.js} +1 -1
- package/dist/{dictionary-e2232e84.js → dictionary-a132a3cc.js} +1 -1
- package/dist/{drag-d8daa62f.js → drag-2e9c80bb.js} +1 -1
- package/dist/{e2pca-f9324654.js → e2pca-4f1648e3.js} +1 -1
- package/dist/{ep-a5c1ee3a.js → ep-1d4c58b4.js} +1 -1
- package/dist/{facet-98971c68.js → facet-fa4fe49c.js} +1 -1
- package/dist/{fusion.parse-466ded6d.js → fusion.parse-7dfd6988.js} +1 -1
- package/dist/{geneExpClustering-66c05fb1.js → geneExpClustering-ed9121b8.js} +1 -1
- package/dist/{geneExpression-ff46a389.js → geneExpression-394672ff.js} +1 -1
- package/dist/{geneExpression-b5d0261f.js → geneExpression-66208299.js} +1 -1
- package/dist/geneExpression-c61e8f1c.js +1 -0
- package/dist/{geneORA-f1a90d02.js → geneORA-9456872c.js} +1 -1
- package/dist/{geneVariant-1cf17b3b.js → geneVariant-beaf9adb.js} +1 -1
- package/dist/{geneVariant-d0b9e1cb.js → geneVariant-f17cda85.js} +1 -1
- package/dist/{genefusion.ui-89a727ea.js → genefusion.ui-9238ec7f.js} +1 -1
- package/dist/{genesearch-41cb55ce.js → genesearch-ffd88bf2.js} +1 -1
- package/dist/{geneset-b63496eb.js → geneset-0315daf8.js} +1 -1
- package/dist/{genomeBrowser-ec8fbddc.js → genomeBrowser-608b924e.js} +1 -1
- package/dist/{genomeBrowser.controls-2dcaf4f5.js → genomeBrowser.controls-2601cab5.js} +1 -1
- package/dist/{groupsetting-3fef59f9.js → groupsetting-e3a4ecd5.js} +1 -1
- package/dist/{gsea-3075c82c.js → gsea-0c0cf8de.js} +1 -1
- package/dist/{hierCluster-33a828a1.js → hierCluster-7ab62ca5.js} +1 -1
- package/dist/hierCluster.config-f4daaf92.js +1 -0
- package/dist/{hierCluster.interactivity-6d453881.js → hierCluster.interactivity-7f475259.js} +1 -1
- package/dist/{hierCluster.renderers-6279d7fb.js → hierCluster.renderers-19b79639.js} +1 -1
- package/dist/{html.legend-fac5cb07.js → html.legend-80b2b3ec.js} +1 -1
- package/dist/{imagePlot-38254245.js → imagePlot-1ef24562.js} +1 -1
- package/dist/{lasso-e8b9500e.js → lasso-1a02a545.js} +1 -1
- package/dist/launch.adhoc-e124c993.js +1 -0
- package/dist/{leftlabel.sample-afcdcefd.js → leftlabel.sample-59f99ef5.js} +1 -1
- package/dist/{legacyDataset-3b08c91a.js → legacyDataset-fbaa5ebb.js} +1 -1
- package/dist/{log-4d84c357.js → log-c26b6cfd.js} +1 -1
- package/dist/{lollipop-64c5cdfc.js → lollipop-3aebe5d3.js} +1 -1
- package/dist/{maf-fd4ffbd0.js → maf-c439c851.js} +1 -1
- package/dist/{maftimeline-3e892da7.js → maftimeline-0da64e54.js} +1 -1
- package/dist/{matrix-e371888a.js → matrix-38cd47c3.js} +1 -1
- package/dist/{matrix.cells-eb4110a7.js → matrix.cells-a018d731.js} +1 -1
- package/dist/{matrix.cluster-0df274ed.js → matrix.cluster-a6e713e8.js} +1 -1
- package/dist/{matrix.config-3ef822b9.js → matrix.config-2c550b5d.js} +1 -1
- package/dist/matrix.controls-42ad4912.js +1 -0
- package/dist/{matrix.data-27b8e3a9.js → matrix.data-2b814c9f.js} +1 -1
- package/dist/{matrix.dom-1bbe1f39.js → matrix.dom-1e0da5b3.js} +1 -1
- package/dist/{matrix.groups-67606700.js → matrix.groups-824a7244.js} +1 -1
- package/dist/{matrix.interactivity-cdcc56c9.js → matrix.interactivity-1cb56534.js} +1 -1
- package/dist/{matrix.layout-857cd336.js → matrix.layout-47e44357.js} +1 -1
- package/dist/{matrix.legend-09f6dc57.js → matrix.legend-9af0c757.js} +1 -1
- package/dist/{matrix.renderers-d392fb69.js → matrix.renderers-337ce240.js} +1 -1
- package/dist/{matrix.serieses-b03b62aa.js → matrix.serieses-7b7184c9.js} +1 -1
- package/dist/{matrix.sort-9440c86a.js → matrix.sort-1ac05842.js} +1 -1
- package/dist/{matrix.sorterUi-2c5eb35f.js → matrix.sorterUi-1c60c145.js} +1 -1
- package/dist/{mavb-9d86df89.js → mavb-da8d1a0a.js} +1 -1
- package/dist/{mds.fimo-bffccb9f.js → mds.fimo-8604c3f8.js} +1 -1
- package/dist/{mds.samplescatterplot-b3908cc7.js → mds.samplescatterplot-3f09ae0e.js} +1 -1
- package/dist/{mds.survivalplot-9ad7dabc.js → mds.survivalplot-1d8f2b7e.js} +1 -1
- package/dist/{metaboliteIntensity-ec3176f4.js → metaboliteIntensity-bbb23c76.js} +1 -1
- package/dist/niceNumLabels-29a7c6ca.js +1 -0
- package/dist/{nodrag-ab7d5a9f.js → nodrag-b2737073.js} +1 -1
- package/dist/{notify-59f61230.js → notify-0cb8904f.js} +1 -1
- package/dist/{numeric-4853b665.js → numeric-24dacbee.js} +1 -1
- package/dist/{numeric.binary-1dd9a2b4.js → numeric.binary-f382cc98.js} +1 -1
- package/dist/{numeric.continuous-ed132eea.js → numeric.continuous-6feb34a7.js} +1 -1
- package/dist/{numeric.discrete-d780d076.js → numeric.discrete-ed10bbc1.js} +1 -1
- package/dist/{numeric.spline-abe07708.js → numeric.spline-a35cfbf0.js} +1 -1
- package/dist/{numeric.toggle-647423dd.js → numeric.toggle-2f98d6e5.js} +1 -1
- package/dist/oncomatrix-c0b2d635.js +1 -0
- package/dist/{parseData-567f3d70.js → parseData-292648dd.js} +1 -1
- package/dist/{plot.2dvaf-4016e75e.js → plot.2dvaf-6ae22dc1.js} +1 -1
- package/dist/plot.app-2a805759.js +1 -0
- package/dist/plot.barplot-34841e70.js +1 -0
- package/dist/{plot.boxplot-76229491.js → plot.boxplot-87ac2ce9.js} +1 -1
- package/dist/{plot.brainImaging-39b80a1c.js → plot.brainImaging-32a484b6.js} +1 -1
- package/dist/{plot.disco-9a544f9a.js → plot.disco-1fdfee3c.js} +1 -1
- package/dist/{plot.dzi-f1658ebf.js → plot.dzi-e3d0f610.js} +1 -1
- package/dist/{plot.ssgq-aeb2dabc.js → plot.ssgq-d33113d5.js} +1 -1
- package/dist/{plot.vaf2cov-ba8332ed.js → plot.vaf2cov-9f4f1776.js} +1 -1
- package/dist/{plot.wsi-2d802557.js → plot.wsi-dea124a7.js} +1 -1
- package/dist/{profileBarchart-72adc533.js → profileBarchart-58f0a8c0.js} +1 -1
- package/dist/{profileHome-37fd52e5.js → profileHome-7f404152.js} +1 -1
- package/dist/{profilePlot-0b897a05.js → profilePlot-4db8ca78.js} +1 -1
- package/dist/{profilePolar-a7248d48.js → profilePolar-50b8e40e.js} +1 -1
- package/dist/{profileRadar-1ba5d8fd.js → profileRadar-fff0b004.js} +1 -1
- package/dist/{profileRadarFacility-452e76ef.js → profileRadarFacility-d6d34c15.js} +1 -1
- package/dist/{profileSummary-7f0eacf0.js → profileSummary-04b8b15b.js} +1 -1
- package/dist/{recover-74f2e965.js → recover-299ffdb3.js} +1 -1
- package/dist/{regression.inputs-ff00f74e.js → regression.inputs-14df7c31.js} +1 -1
- package/dist/{regression.inputs.values.table-1753d56b.js → regression.inputs.values.table-d79efa9e.js} +1 -1
- package/dist/{regression.results-6f85a5dc.js → regression.results-4767144e.js} +1 -1
- package/dist/{renderPvalueTable-17558d6a.js → renderPvalueTable-002cc8ff.js} +1 -1
- package/dist/{sampleScatter-97917406.js → sampleScatter-55d9eb74.js} +1 -1
- package/dist/{sampleScatter.rendererThree-4649d1ec.js → sampleScatter.rendererThree-ef289434.js} +2 -2
- package/dist/{sampleView-f86dc5ea.js → sampleView-1dff3fca.js} +1 -1
- package/dist/{samplelst-4a5512df.js → samplelst-d2db0f24.js} +1 -1
- package/dist/{samplematrix-1192e5e2.js → samplematrix-0841387f.js} +1 -1
- package/dist/{scatter-cc1b0d07.js → scatter-f8285107.js} +1 -1
- package/dist/{select2Terms-d4f6ed9e.js → select2Terms-d48d037e.js} +1 -1
- package/dist/{selectGenomeWithTklst-b5cfd153.js → selectGenomeWithTklst-9af86d31.js} +1 -1
- package/dist/{singleCellCellType-d8c58253.js → singleCellCellType-fd1606b8.js} +1 -1
- package/dist/{singleCellGeneExpression-b7209531.js → singleCellGeneExpression-537f1157.js} +1 -1
- package/dist/{singleCellPlot-e6f83b2a.js → singleCellPlot-eff5760b.js} +1 -1
- package/dist/{singlecell-321dd973.js → singlecell-38336cbc.js} +1 -1
- package/dist/{singlecell-879235b3.js → singlecell-87b4b9a9.js} +1 -1
- package/dist/{snp-b046b7e6.js → snp-b81ef740.js} +1 -1
- package/dist/snp-f6123244.js +1 -0
- package/dist/{snplocus-61ff1c10.js → snplocus-acafb1ba.js} +1 -1
- package/dist/{spliceevent.a53ss.diagram-1a84db58.js → spliceevent.a53ss.diagram-5f8352eb.js} +1 -1
- package/dist/{spliceevent.exonskip.diagram-da10648b.js → spliceevent.exonskip.diagram-0d30a735.js} +1 -1
- package/dist/spliceevent.exonskip.getdefault-237c481c.js +1 -0
- package/dist/{spliceevent.noeventdiagram-1d6d790d.js → spliceevent.noeventdiagram-df9ce4bc.js} +1 -1
- package/dist/{spliceevent.phrase-2ca0ce59.js → spliceevent.phrase-a8401d53.js} +1 -1
- package/dist/{stattable-c5f12d9c.js → stattable-46cde32c.js} +1 -1
- package/dist/{style.gdc-5b7d90c6.js → style.gdc-72d730f2.js} +1 -1
- package/dist/{summary-0624f5e6.js → summary-a6c15c9e.js} +1 -1
- package/dist/{sunburst-30295714.js → sunburst-fe95832e.js} +1 -1
- package/dist/{survival-fcc7719f.js → survival-52714cd3.js} +1 -1
- package/dist/survival-57ff3c03.js +1 -0
- package/dist/{svg.download-e89a7369.js → svg.download-f4aa48e4.js} +1 -1
- package/dist/{svg.legend-c93f2980.js → svg.legend-749348e0.js} +1 -1
- package/dist/{svgraph-6ab3011b.js → svgraph-b46f1f92.js} +1 -1
- package/dist/{svmr-3ad3d600.js → svmr-9a76c6d4.js} +1 -1
- package/dist/{table-f50a9344.js → table-0daf2b89.js} +1 -1
- package/dist/{table-4d3a771e.js → table-bf40249b.js} +1 -1
- package/dist/{termInfo-d0a9e65f.js → termInfo-491b10af.js} +1 -1
- package/dist/{termdb.bins-01e8cce6.js → termdb.bins-39d11f24.js} +1 -1
- package/dist/termsetting-492eefa7.js +1 -0
- package/dist/{tk-e74c9beb.js → tk-ac524564.js} +1 -1
- package/dist/{toggleButtons-04c5ad7c.js → toggleButtons-c4d6f260.js} +1 -1
- package/dist/{tp.ui-7b24f0ef.js → tp.ui-0a476325.js} +1 -1
- package/dist/tvs.density-034b506d.js +1 -0
- package/dist/{tvs.geneVariant-418ed4ff.js → tvs.geneVariant-c59c8b54.js} +1 -1
- package/dist/{tvs.numeric-de14101f.js → tvs.numeric-aa1f892f.js} +1 -1
- package/dist/{tvs.samplelst-15bb62f1.js → tvs.samplelst-515f27b9.js} +1 -1
- package/dist/{uiUtils-ff2d4a6a.js → uiUtils-ea7dfea2.js} +1 -1
- package/dist/{variantBrowser-261373bf.js → variantBrowser-14d5c3f6.js} +1 -1
- package/dist/{vcf-145bf5dd.js → vcf-d357ce08.js} +1 -1
- package/dist/{violin-e647aac9.js → violin-74d26b75.js} +1 -1
- package/dist/{violin.interactivity-30a239fe.js → violin.interactivity-bf40ddde.js} +1 -1
- package/dist/{violin.renderer-e29d2700.js → violin.renderer-469fa0ff.js} +1 -1
- package/dist/{violinRenderer-08b3b58c.js → violinRenderer-14fa200d.js} +1 -1
- package/dist/{viridis-d86ad99b.js → viridis-cc59f478.js} +1 -1
- package/dist/{y-06b0d47c.js → y-59cbff5e.js} +1 -1
- package/dist/{zoom-d6ef6f3f.js → zoom-f445cfef.js} +1 -1
- package/package.json +1 -1
- package/dist/app-f031940d.js +0 -1
- package/dist/block.lazyload-eda77d9b.js +0 -1
- package/dist/controls.config-81cd5749.js +0 -1
- package/dist/geneExpression-5685eae2.js +0 -1
- package/dist/hierCluster.config-fa799d06.js +0 -1
- package/dist/launch.adhoc-2799109b.js +0 -1
- package/dist/matrix.controls-42bb2063.js +0 -1
- package/dist/niceNumLabels-5f45218a.js +0 -1
- package/dist/oncomatrix-7ac995a2.js +0 -1
- package/dist/plot.app-d6fe76e2.js +0 -1
- package/dist/plot.barplot-d2fc5020.js +0 -1
- package/dist/snp-541ec14d.js +0 -1
- package/dist/spliceevent.exonskip.getdefault-8028e522.js +0 -1
- package/dist/survival-816e055a.js +0 -1
- package/dist/termsetting-ad8c4f3a.js +0 -1
- package/dist/tvs.density-b2790080.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as t,d as e,M as s,a as r,z as i,A as o,B as a,h as n,C as l,D as p,r as c,m as d,E as m,F as u}from"./app-2cd97738.js";import{T as h,N as f,g}from"./termsetting-ad8c4f3a.js";import{F as b,g as j,a as y,f as v}from"./FilterRxComp-0f35b322.js";import{f as x}from"./FilterStateless-b1c6ee04.js";import{appInit as w}from"./app-686b9547.js";import{r as C}from"./table-f50a9344.js";import{_ as T}from"./tslib.es6-c3c2d88f.js";import{a as k}from"./genesearch-41cb55ce.js";import{m as S}from"./checkbox-96437f4d.js";import{r as _}from"./rehydrateFilter-12d118cb.js";class I extends b{constructor(t){super(t);this.api={main:this.main.bind(this),getNormalRoot:()=>j(this.rawFilter),getPromise:t=>this.promises[t]};if(t.debug)this.api.Inner=this}async main(t,e={}){this.dom.controlsTip.hide();this.dom.treeTip.hide();const s="activeCohort"in e?e.activeCohort:this.activeCohort;const r=y(t,"filterUiRoot");if(r)delete r.tag;t.lst.push({tag:"filterUiRoot",type:"tvslst",join:"",lst:[]});t.join=t.lst.length>1?"and":"";const i=JSON.stringify(t);if(this.rawCopy==i&&JSON.stringify(this.activeCohort)==JSON.stringify(s))return;await super.main(i,e)}refresh(t){this.dom.controlsTip.hide();this.dom.treeTip.hide();const e=JSON.parse(JSON.stringify(this.rawFilter));const s=v(e,this.filter.$id);if(!s||this.rawFilter.$id===this.filter.$id){this.opts.callback(e)}else{const r=s.lst.findIndex((t=>t.$id==this.filter.$id));s.lst[r]=t;this.opts.callback(e)}const r=e.lst.findIndex((e=>e.$id===t.$id));e.lst.splice(r,1);this.main(e)}}const A=t(I);function P(t){if(!t.div||!t.text||!t.callback)throw new Error("Missing required parameters");return t.div.append("button").property("disabled",t.disabled||false).style("border","none").style("border-radius","20px").style("padding","10px 15px").text(t.text).on("click",(()=>{t.callback()}))}function D(t,s){const r=s.selectAll().data(t,(t=>t.value)).enter().append("div").style("margin","5px");const i=r.append("label").on("mousedown",(t=>{t.stopPropagation()}));const o=i.append("input").attr("type","radio").attr("name",(t=>t.label)).attr("value",(t=>t.value)).property("checked",(t=>t.checked)).on("input",(function(t,r){return T(this,void 0,void 0,(function*(){t.stopPropagation();o.property("disabled",true);o.property("checked",false);s.selectAll(".contentDiv").style("display","none");const i=e(this.parentNode).append("div").classed("contentDiv",true).style("padding-left","25px").style("display","block");yield r.callback(i);e(this).property("checked",true);o.property("disabled",false)}))}));o.filter((t=>t.checked)).property("checked",true);i.append("span").html((t=>" "+t.label));i.append("span").style("display","block").style("padding-left","25px").style("font-size","0.75em").html((t=>t.sublabel||""))}class B{constructor(t){this.params2Add=[];this.tip=t.tip;this.params=t.params;this.callback=t.callback;this.addOptionalParams=t.addOptionalParams;this.tip.d.style("padding","15px");this.render();for(const t of this.params2Add)this.addOptionalParams(t)}render(){for(const t of this.params){const e=this.addParameter(t.param,this.tip.d.append("div"));t.input=e}const t=P({div:this.tip.d.append("div").style("padding","20px").style("display","inline-block"),text:"Calculate genes",callback:()=>T(this,void 0,void 0,(function*(){t.property("disabled",true).text("Loading...");yield this.callback();this.tip.hide()}))})}addParameter(t,e){var s;let r;if(t.type=="boolean"){if((s=t===null||t===void 0?void 0:t.options)===null||s===void 0?void 0:s.length){const s=e.append("div").style("margin","10px 0px").on("mousedown",(t=>{t.stopPropagation()}));r=s.append("input").attr("type","checkbox").attr("id",t.id);this.addLabels(s,"label",t);const i=e.append("div").style("padding-left","20px");for(const e of t.options){const t=this.addParameter(e,i.append("div"));this.params2Add.push({param:e,input:t})}if(t.value){r.property("checked",t.value);i.style("display","block")}else i.style("display","none");r.on("change",(()=>{i.style("display",r.property("checked")?"block":"none")}))}else{r=e.append("input").style("padding","2px").attr("type","checkbox").attr("id",t.id);if(t.value)r.property("checked",t.value);this.addLabels(e,"label",t)}}else if(t.type=="string"&&t.value){r=S({holder:e,id:t.id,checked:true,labeltext:t.label,callback:()=>{}})}else if(t.type=="number"){r=e.append("input").attr("type","number").style("width","50px").style("padding","5px").attr("id",t.id);if(t.value)r.attr("value",t.value);this.addLabels(e,"span",t)}else if(t.type=="radio"){const s=t.options.find((t=>t.checked));if(!s)t.options[0].checked=true;r=e.append("div").attr("id",t.id);r.append("p").style("font-size","0.8em").style("opacity",.75).text(t.label);D(t.options,r)}return r}addLabels(t,e,s){if(!s.sublabel)t.append(e).html(s.label).attr("for",s.id);else{const r=t.append("div").style("display","inline-block").style("vertical-align","middle");r.append(e).style("display","block").style("padding-top","3px").html(s.label).attr("for",s.id);r.append("span").style("display","block").style("font-size","0.75em").html(s.sublabel)}}}class G{constructor(t){var e,r,i;this.holder=t.holder;this.genome=t.genome;this.callback=t.callback;this.vocabApi=t.vocabApi;this.customInputs=t.customInputs;this.geneList=structuredClone(t.geneList||[]);this.tip2=new s({padding:"0px",parent_menu:t.holder.node(),test:"test"});this.minNumGenes=t.minNumGenes||0;if("mode"in t)this.mode=t.mode;if("titleText"in t)this.titleText=t.titleText;this.origLst=structuredClone(this.geneList);this.origNames=JSON.stringify(this.geneList.map((t=>t.gene)).sort());this.holder.selectAll("*").remove();const o=this.holder.append("div").style("padding","5px");if(this.titleText){o.append("div").style("margin-bottom","10px").html(this.titleText)}const a=o.append("div");const n=a.append("label");n.append("span").html("Search");const l=n.append("div").style("display","inline-flex").style("align-items","center").style("margin","8px 0px -5px 0px");const p=a.append("div").style("display","inline-flex").style("align-items","center").style("float","right").style("gap","5px");const c=this.addGene.bind(this);this.geneSearch=k({tip:this.tip2,genome:this.genome,row:l,searchOnly:"gene",callback:c,hideHelp:true,focusOff:true});this.menuList=[];this.api={dom:{holder:o,textControlDiv:p.append("div"),clearBtn:P({div:p,text:"Clear",disabled:!((e=this.geneList)===null||e===void 0?void 0:e.length),callback:()=>{this.geneList=[];this.renderGenes()}}),restoreBtn:((r=this.geneList)===null||r===void 0?void 0:r.length)?P({div:p,disabled:true,text:"Restore",callback:()=>{this.geneList=this.origLst;this.renderGenes()}}):null,geneHoldingDiv:this.renderGeneHoldingDiv(o),statLegendDiv:o.append("div"),submitBtn:P({div:o.append("div").style("margin-top","10px"),text:"Submit",disabled:!((i=this.geneList)===null||i===void 0?void 0:i.length),callback:()=>{this.callback({geneList:this.geneList})}})},topMutatedGenesParams:[],topVariablyExpressedGenesParams:[],statColor2label:new Map,destroy(){t.holder.remove()}};this.getParams();this.createMenuList();this.renderTextControls(this.api.dom.textControlDiv);this.renderGenes()}getParams(){var t,e,s,i;if(this.mode==h.GENE_VARIANT&&((e=(t=this.vocabApi.termdbConfig)===null||t===void 0?void 0:t.queries)===null||e===void 0?void 0:e.topMutatedGenes)){if(this.vocabApi.termdbConfig.queries.topMutatedGenes.arguments){for(const t of this.vocabApi.termdbConfig.queries.topMutatedGenes.arguments)this.api.topMutatedGenesParams.push({param:t})}}if(this.mode==h.GENE_EXPRESSION&&((i=(s=this.vocabApi.termdbConfig)===null||s===void 0?void 0:s.queries)===null||i===void 0?void 0:i.topVariablyExpressedGenes)){if(this.vocabApi.termdbConfig.queries.topVariablyExpressedGenes.arguments){for(const t of this.vocabApi.termdbConfig.queries.topVariablyExpressedGenes.arguments){if(t.type=="radio"){if(!t.options||t.options.length==0)throw"Radio button must have options";for(const e of t.options){if(e.type=="tree"){e.callback=s=>T(this,void 0,void 0,(function*(){const r=yield import("./app-686b9547.js");const i=s.append("div");yield r.appInit({holder:i,state:{dslabel:e.value,genome:this.genome.name,nav:{header_mode:"search_only"}},tree:{click_term:r=>{s.append("div").classed("ts_pill sja_filter_tag_btn sja_tree_click_term termlabel",true).style("margin","5px").text(`${r.id}`);t.value={type:e.value,geneList:r._geneset.map((t=>t.symbol))};i.selectAll("*").remove()}}})}))}if(e.type=="text"){e.callback=s=>T(this,void 0,void 0,(function*(){s.append("span").style("display","block").style("font-size","0.8em").style("opacity",.75).text("Enter genes separated by spaces or commas");s.append("textarea").style("display","block").on("keyup",r.debounce((function(){const s=this.value.split(/[\s,]+/).map((t=>t.trim())).filter((t=>t!==""));t.value={type:e.value,geneList:s}})),500)}))}if(e.type=="boolean"){e.callback=()=>{t.value={type:e.value,geneList:null}}}}}this.api.topVariablyExpressedGenesParams.push({param:t})}}}}baseGeneMenuArgs(t){t=this.removeDuplicates(t);return{tip:this.tip2,params:t,addOptionalParams:({param:e,input:s})=>{t.push({param:e,input:s})}}}removeDuplicates(t){var e;for(const s of t){if((e=s.param)===null||e===void 0?void 0:e.options){s.param.options.forEach((e=>{if(!e.id)return;const s=t.findIndex((t=>t.param.id==e.id));if(s!=-1)t.splice(s,1)}))}}return t}createMenuList(){var t,e,s,r;if(((t=this.api)===null||t===void 0?void 0:t.topMutatedGenesParams.length)>0){this.menuList.push({label:"Top mutated genes",callback:t=>T(this,void 0,void 0,(function*(){this.tip2.clear().showunder(t.target);const e=()=>T(this,void 0,void 0,(function*(){const t={filter0:this.vocabApi.state.termfilter.filter0};for(const{param:e,input:s}of this.api.topMutatedGenesParams){const r=s.attr("id");t[r]=this.getInputValue({param:e,input:s})}const e=yield this.vocabApi.getTopMutatedGenes(t);this.geneList=[];this.geneList.push(...e.genes);this.renderGenes()}));const s=Object.assign(this.baseGeneMenuArgs(this.api.topMutatedGenesParams),{callback:e});new B(s)}))})}if(((e=this.api)===null||e===void 0?void 0:e.topVariablyExpressedGenesParams.length)>0){this.menuList.push({label:"Top variably expressed genes",callback:t=>{this.api.topVariablyExpressedGenesParams.filter((t=>{var e;return t.param.type=="radio"&&((e=t.param)===null||e===void 0?void 0:e.options)})).forEach((t=>{if(typeof t.param.options[0].value==="string"){t.param.value={type:t.param.options[0].value,value:null}}else{console.error(`Unexpected radio button value type: ${typeof t.param.options[0].value}`)}}));this.tip2.clear().showunder(t.target);const e=()=>T(this,void 0,void 0,(function*(){const t={genome:this.vocabApi.state.vocab.genome,dslabel:this.vocabApi.state.vocab.dslabel};if(this.vocabApi.state.termfilter){if(this.vocabApi.state.termfilter.filter)t.filter=this.vocabApi.state.termfilter.filter;if(this.vocabApi.state.termfilter.filter0)t.filter0=this.vocabApi.state.termfilter.filter0}for(const{param:e,input:s}of this.api.topVariablyExpressedGenesParams){const r=s.attr("id");t[r]=this.getInputValue({param:e,input:s})}const e=yield this.vocabApi.getTopVariablyExpressedGenes(t);this.geneList=[];if(e.genes){for(const t of e.genes)this.geneList.push({gene:t})}this.renderGenes()}));const s=Object.assign(this.baseGeneMenuArgs(this.api.topVariablyExpressedGenesParams),{callback:e});new B(s)}})}if((r=(s=this.genome)===null||s===void 0?void 0:s.termdbs)===null||r===void 0?void 0:r.msigdb){for(const t in this.genome.termdbs){const e=this.genome.termdbs[t];this.menuList.push({label:`${e.label} gene set`,callback:()=>T(this,void 0,void 0,(function*(){this.tip2.clear().showunder(this.api.dom.textControlDiv.node());const e=yield import("./app-686b9547.js");e.appInit({holder:this.tip2.d,state:{dslabel:t,genome:this.genome.name,nav:{header_mode:"search_only"}},tree:{click_term:t=>{this.geneList=[];const e=t._geneset;if(e){for(const t of e)this.geneList.push({gene:t.symbol});this.renderGenes()}this.tip2.hide();this.api.dom.submitBtn.node().focus()}}})}))})}}if(this.customInputs){for(const t of this.customInputs){this.menuList.push({label:t.label,callback:()=>{t.showInput({callback:({geneList:t})=>{this.geneList=t;this.renderGenes()}})},tagName:"button"})}}}renderTextControls(t){for(const e of this.menuList){if(e.tagName=="button")P({div:t,text:e.label,callback:e.callback});else t.append("a").style("text-decoration","underline").style("padding","0px 10px").style("color","black").html(`${e.label} ▼`).on("click",(t=>T(this,void 0,void 0,(function*(){yield e.callback(t)}))))}}getInputValue({param:t,input:e}){if(t.type=="radio")return t.value;const s=e.node().value;if(e.attr("type")=="number")return Number(s);if(e.attr("type")=="checkbox"){if(t.type=="string")return e.node().checked?t.value:"";if(t.type=="boolean")return e.node().checked?1:0}}renderGeneHoldingDiv(t){return t.append("div").append("div").style("display","flex").style("flex-wrap","wrap").style("gap","5px").style("min-height","20px").style("border","solid 1px #aaa").style("margin","15px 0px").style("padding","6px 2px").style("min-height","30px")}renderStatLegend(){if(!this.api.statColor2label||this.api.statColor2label.size==0){this.api.dom.statLegendDiv.style("display","none");return}this.api.dom.statLegendDiv.style("display","block").selectAll("*").remove();for(const[t,e]of this.api.statColor2label){this.api.dom.statLegendDiv.append("div").style("display","inline-block").style("width","12px").style("height","12px").style("background-color",t);this.api.dom.statLegendDiv.append("span").html(` ${e} `)}return this.api.dom.statLegendDiv}addGene(){const t=this.geneSearch.geneSymbol;for(const e of this.geneList){if(e.gene==t){window.alert(`The gene ${t} has already been added`);return}}if(t)this.geneList.push({gene:t});this.renderGenes()}renderGenes(){var t,s,r,i;const o=this.geneList.some((t=>t.mutationStat));if(!o)this.geneList.sort(((t,e)=>{if(t.gene<e.gene)return-1;if(t.gene>e.gene)return 1;return 0}));this.api.dom.geneHoldingDiv.selectAll("*").remove();const a=this.renderGene.bind(this);const n=this.deleteGene.bind(this);this.api.dom.geneHoldingDiv.selectAll("div").data(this.geneList||[]).enter().append("div").attr("aria-label","Click to delete").attr("class","sja_menuoption").attr("tabindex",0).style("position","relative").style("display","inline-block").style("padding","5px 16px 5px 9px").style("margin-left","5px").each((function(t){const s=e(this).style("border-radius","5px");a(s,t);s.on("click",(()=>n(t)))})).on("mouseover",(function(t){const s=e(t.target);s.append("div").style("margin-left","4px").classed("sjpp_deletebt",true).style("display","inline-block").style("position","absolute").style("right","0px").style("top","0px").style("transform","scale(0.6)").style("pointer-events","none").html(`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-x-lg" viewBox="0 0 16 16">\n <path stroke='#f00' d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>\n </svg>`)})).on("mouseout",(function(t){e(t.target).select(".sjpp_deletebt").remove()})).on("focus",(t=>{t.target.dispatchEvent(new PointerEvent("mouseover"))})).on("blur",(t=>{t.target.dispatchEvent(new PointerEvent("mouseout"))})).on("keyup",(t=>{if(t.key=="Enter")t.target.click()}));this.renderStatLegend();this.api.dom.clearBtn.property("disabled",!((t=this.geneList)===null||t===void 0?void 0:t.length));const l=this.origNames!==JSON.stringify(this.geneList.map((t=>t.gene)).sort());(s=this.api.dom.restoreBtn)===null||s===void 0?void 0:s.property("disabled",!l);this.api.dom.submitBtn.property("disabled",!l||((r=this.geneList)===null||r===void 0?void 0:r.length)<this.minNumGenes||!((i=this.geneList)===null||i===void 0?void 0:i.length));if(l)this.api.dom.submitBtn.node().focus()}renderGene(t,e){if(e.mutationStat){t.html(`${e.gene} `);for(const s of e.mutationStat){let e;let r="black";if("class"in s){if(!i[s.class])throw"invalid stat class";e=i[s.class].color;this.api.statColor2label.set(e,i[s.class].label)}else if("dt"in s){if(!o[s["dt"]])throw"invalid stat dt";e=o[s["dt"]];r="white";this.api.statColor2label.set(e,a[s["dt"]])}else{throw"stat missing dt/class"}t.insert("span").style("font-size",".7em").style("background-color",e).style("padding","1px 2px").style("color",r).text(s.count)}}else{t.insert("div").style("display","inline-block").html(e.gene)}}deleteGene(t){const e=this.geneList.findIndex((e=>e.gene===t.gene));if(e!=-1){this.geneList.splice(e,1);this.renderGenes()}}}function L(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-f81e0f19.js");case"../plots/Disco.js":return import("./Disco-db386f7a.js");case"../plots/DziViewer.js":return import("./DziViewer-9352e224.js");case"../plots/WSIViewer.js":return import("./WSIViewer-80f60272.js");case"../plots/barchart.data.js":return import("./FilterRxComp-0f35b322.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-df44e666.js");case"../plots/barchart.js":return import("./barchart-3c5d734c.js");case"../plots/bars.renderer.js":return import("./bars.renderer-b232d882.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-44d3b48f.js");case"../plots/brainImaging.js":return import("./brainImaging-2eaa419d.js");case"../plots/controls.btns.js":return import("./controls.btns-5b1240c8.js");case"../plots/controls.config.js":return import("./controls.config-81cd5749.js");case"../plots/controls.js":return import("./controls-3c1691d7.js");case"../plots/cuminc.js":return import("./cuminc-c4db28f0.js");case"../plots/dataDownload.js":return import("./dataDownload-a4dfa2d0.js");case"../plots/dictionary.js":return import("./dictionary-e2232e84.js");case"../plots/facet.js":return import("./facet-98971c68.js");case"../plots/geneExpression.js":return import("./geneExpression-b5d0261f.js");case"../plots/geneORA.js":return import("./geneORA-f1a90d02.js");case"../plots/geneset.js":return import("./geneset-b63496eb.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-2dcaf4f5.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-ec8fbddc.js");case"../plots/gsea.js":return import("./gsea-3075c82c.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-fa799d06.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-6d453881.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-33a828a1.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-6279d7fb.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-38254245.js");case"../plots/matrix.cells.js":return import("./matrix.cells-eb4110a7.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-0df274ed.js");case"../plots/matrix.config.js":return import("./matrix.config-3ef822b9.js");case"../plots/matrix.controls.js":return import("./matrix.controls-42bb2063.js");case"../plots/matrix.data.js":return import("./matrix.data-27b8e3a9.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-1bbe1f39.js");case"../plots/matrix.groups.js":return import("./matrix.groups-67606700.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-cdcc56c9.js");case"../plots/matrix.js":return import("./matrix-e371888a.js");case"../plots/matrix.layout.js":return import("./matrix.layout-857cd336.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-09f6dc57.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-d392fb69.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-b03b62aa.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-9440c86a.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-2c5eb35f.js");case"../plots/plot.app.js":return import("./plot.app-d6fe76e2.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-39b80a1c.js");case"../plots/plot.disco.js":return import("./plot.disco-9a544f9a.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-aeb2dabc.js");case"../plots/profileBarchart.js":return import("./profileBarchart-72adc533.js");case"../plots/profilePlot.js":return import("./profilePlot-0b897a05.js");case"../plots/profilePolar.js":return import("./profilePolar-a7248d48.js");case"../plots/profileRadar.js":return import("./profileRadar-1ba5d8fd.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-452e76ef.js");case"../plots/profileSummary.js":return import("./profileSummary-7f0eacf0.js");case"../plots/regression.inputs.js":return import("./regression.inputs-ff00f74e.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-ff00f74e.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-1753d56b.js");case"../plots/regression.js":return import("./regression.inputs-ff00f74e.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-6f85a5dc.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-97917406.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-97917406.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-97917406.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-4649d1ec.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-f86dc5ea.js");case"../plots/scatter.js":return import("./scatter-cc1b0d07.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-e6f83b2a.js");case"../plots/stattable.js":return import("./stattable-c5f12d9c.js");case"../plots/summary.js":return import("./summary-0624f5e6.js");case"../plots/survival.js":return import("./survival-fcc7719f.js");case"../plots/table.js":return import("./table-4d3a771e.js");case"../plots/variantBrowser.js":return import("./variantBrowser-261373bf.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-30a239fe.js");case"../plots/violin.js":return import("./violin-e647aac9.js");case"../plots/violin.renderer.js":return import("./violin.renderer-e29d2700.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}class E{constructor(t={}){this.type="charts";q(this)}async init(t){this.dom={holder:this.opts.holder,tip:new s({padding:"0px"})};this.makeButtons(t)}getState(t){const e=N(t);const s=JSON.parse(JSON.stringify(t.termdbConfig?.supportedChartTypes||{}));const r={vocab:t.vocab,activeCohort:t.activeCohort,termfilter:t.termfilter,supportedChartTypes:s[e]||["summary"],termdbConfig:t.termdbConfig};if(t?.termfilter?.filter){r.filter=j(t.termfilter.filter)}if(!r.supportedChartTypes.includes("dictionary")&&!r.termdbConfig.hiddenChartTypes?.includes("dictionary")){if(r.vocab.dslabel=="ProfileFull"||r.vocab.dslabel=="ProfileAbbrev")r.supportedChartTypes.push(...t.termdbConfig.allowedChartTypes);r.supportedChartTypes.push("dictionary");r.supportedChartTypes.push("facet")}return r}main(){this.dom.btns.style("display",(t=>this.state.supportedChartTypes.includes(t.chartType)?"":"none"))}}const R=n(E);function N(t){if(t?.termdbConfig?.selectCohort?.values){if(!Number.isInteger(t.activeCohort))throw"appState.activeCohort is not integer array index";const e=t.termdbConfig.selectCohort.values[t.activeCohort];if(!e)throw"appState.activeCohort array index out of bound";return[...e.keys].sort().join(",")}return""}function M(t,e){const s=[{label:"Data Dictionary",clickTo:t.prepPlot,chartType:"dictionary",config:{chartType:"dictionary"}},{label:"Sample View",clickTo:t.prepPlot,chartType:"sampleView",config:{chartType:"sampleView"}},{label:"Summary Plots",chartType:"summary",clickTo:t.showTree_select1term,usecase:{target:"summary",detail:"term"}},{label:"Scatter Plot",chartType:"sampleScatter",clickTo:t.loadChartSpecificMenu},{label:"Cumulative Incidence",chartType:"cuminc",clickTo:t.showTree_select1term,usecase:{target:"cuminc",detail:"term"}},{label:"Survival",chartType:"survival",clickTo:t.showTree_select1term,usecase:{target:"survival",detail:"term"}},{label:"Regression Analysis",chartType:"regression",clickTo:t.loadChartSpecificMenu},{label:"Sample Matrix",chartType:"matrix",clickTo:t.loadChartSpecificMenu},{label:"Genome Browser",chartType:"genomeBrowser",clickTo:t.loadChartSpecificMenu},{label:"Differential Expression",chartType:"DEanalysis",clickTo:t.loadChartSpecificMenu},{label:"Data Download",clickTo:t.prepPlot,chartType:"dataDownload",config:{chartType:"dataDownload",terms:[]}},{label:"Facet Table",clickTo:t.loadChartSpecificMenu,chartType:"facet",config:{chartType:"facet"}},{label:"Brain Imaging",clickTo:t.loadChartSpecificMenu,chartType:"brainImaging",config:{chartType:"brainImaging"}},{label:"Single Cell Plot",clickTo:t.loadChartSpecificMenu,chartType:"singleCellPlot",config:{chartType:"singleCellPlot"}},{label:"Gene Expression",chartType:"geneExpression",clickTo:t.showGenesetEditUI,usecase:{target:"geneExpression"}},{label:"Metabolite Intensity",chartType:"metaboliteIntensity",clickTo:t.showTree_selectlst,usecase:{target:"metaboliteIntensity",detail:"term"},updateActionBySelectedTerms:(t,e)=>{const s=e.map((t=>({term:structuredClone(t),q:{mode:f.continuous}})));if(s.length==1){t.config.chartType="summary";t.config.term=s[0];return}if(s.length==2){t.config.chartType="summary";t.config.term=s[0];t.config.term2=s[1];return}t.config.chartType="hierCluster";t.config.dataType=h.METABOLITE_INTENSITY;t.config.termgroups=[{name:"Metabolite Intensity Cluster",lst:s,type:"hierCluster"}]}}];if(e.vocab.dslabel=="ProfileFull"||e.vocab.dslabel=="ProfileAbbrev"){const r=O(t,e);s.unshift(...r)}for(const t in e?.termdbConfig.renamedChartTypes||[]){const r=s.find((e=>e.chartType===t));if(r){r.label=e.termdbConfig.renamedChartTypes[t]}}return s}function O(t,e){const s=[{label:"Profile Polar",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profilePolar",header:"Polar Graph",logged:true}}),chartType:"profilePolar"},{label:"Profile Barchart",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profileBarchart",header:"Barchart Graph",logged:true}}),chartType:"profileBarchart"},{label:"Radar 1-Score-based(Site)",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profileRadarFacility",plot:"plot1",header:"Radar 1-Score-based(Site)",logged:true}}),chartType:"profileRadarFacility"},{label:"Radar 2-Impressions",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profileRadar",plot:"plot1",header:"Radar 2-Impressions",logged:true}}),chartType:"profileRadar"}];if(e.vocab.dslabel=="ProfileFull"){s.push({label:"Radar 3-Score-based(SC & POC)s",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profileRadar",plot:"plot2",header:"Radar 3-Score-based(SC & POC)",logged:true}}),chartType:"profileRadar"})}return s}function q(t){t.makeButtons=function(e){const s=M(t,e);t.dom.btns=t.dom.holder.selectAll("button").data(s).enter().append("button").style("margin","10px").style("padding","10px 15px").style("border-radius","20px").style("border-color","#ededed").html((t=>t.label)).on("click",(function(e,s){t.dom.tip.clear().showunder(this);s.clickTo(s)}))};t.showTree_select1term=async e=>{if(e.usecase.label){t.dom.tip.d.append("div").style("margin","3px 5px").style("padding","3px 5px").style("font-weight",600).html(e.usecase.label)}const s={type:"plot_create",id:F(),config:{chartType:e.chartType}};if(e.parentId)s.parentId=e.parentId;const r=await import("./app-686b9547.js");r.appInit({vocabApi:t.app.vocabApi,holder:t.dom.tip.d.append("div"),state:{activeCohort:t.state.activeCohort,nav:{header_mode:"search_only"},tree:{usecase:e.usecase}},tree:{click_term:r=>{const i=r.term?r:{term:r};s.config[e.usecase.detail]=i;t.dom.tip.hide();t.app.dispatch(s)}}})};t.showGenesetEditUI=async e=>{const s=[];const r=t.app;const i=t.dom.tip;const o=t.dom.tip.d;o.selectAll("*").remove();const a=o.append("div").style("padding","5px");const n=a.append("label");n.append("span").text("Create ");let l;const p=n.append("input").style("margin","2px 5px").style("width","210px").attr("placeholder","Group Name").on("input",(()=>{l=p.property("value")}));const c={index:0,name:l,label:l,lst:[],status:"new"};new G({holder:o.append("div"),genome:r.opts.genome,geneList:s,mode:"geneExpression",vocabApi:r.vocabApi,callback:async({geneList:t,groupName:e})=>{if(!c)throw`missing selectedGroup`;i.hide();const s={name:e||l,lst:[],type:"hierCluster"};const a=s.lst.filter((t=>t.term.type!="geneVariant"));const n=await Promise.all(t.map((async t=>{const e={gene:t.symbol||t.gene,name:t.symbol||t.gene,type:"geneExpression"};let r=s.lst.find((e=>e.term.name==t.symbol||e.term.name==t.gene));if(!r){r={term:e,q:{}}}return r})));if(n.length==1){const t=n[0];r.dispatch({type:"plot_create",config:{chartType:"summary",term:t}});return}if(n.length==2){const t=n[0];const e=n[1];r.dispatch({type:"plot_create",config:{chartType:"summary",term:t,term2:e}});return}s.lst=[...a,...n];if(!s.lst.length)tg.splice(c.index,1);o.selectAll("*").remove();r.dispatch({type:"plot_create",config:{chartType:"hierCluster",termgroups:[s],dataType:h.GENE_EXPRESSION}})}})};t.showTree_selectlst=async e=>{t.dom.tip.clear();if(e.usecase?.label){t.dom.tip.d.append("div").style("margin","3px 5px").style("padding","3px 5px").style("font-weight",600).html(e.usecase.label)}const s={type:"plot_create",id:F(),config:{chartType:e.chartType}};const r=await import("./app-686b9547.js");t.dom.submenu=t.dom.tip.d.append("div");r.appInit({holder:t.dom.submenu,vocabApi:t.app.vocabApi,state:{activeCohort:t.state.activeCohort,nav:{header_mode:"search_only"},tree:{usecase:e.usecase}},tree:{submit_lst:r=>{const i=e.processSelection?e.processSelection(r):r;s.config[e.usecase.detail]=i;if(e.updateActionBySelectedTerms)e.updateActionBySelectedTerms(s,r);t.dom.tip.hide();t.app.dispatch(s)}}})};t.loadChartSpecificMenu=async e=>{t.dom.tip.clear();const s=await L(`../plots/${e.chartType}.js`);s.makeChartBtnMenu(t.dom.tip.d,t)};t.prepPlot=function(e){const s={type:"plot_prep",config:e.config,id:F()};t.app.dispatch(s)}}const V="_CHART_AUTOID_";let $=Date.now();function F(){return V+$++}const H=l(5);class U{constructor(t={}){this.type="groups";this.selectedGroupsIdx=new Set}async init(){this.dom={holder:this.opts.holder.append("div").style("margin","10px")};W(this);this.tip=new s({padding:"0px"})}getState(t){const e=N(t);const s={termfilter:t.termfilter,groups:Y(t),termdbConfig:t.termdbConfig,customTerms:t.customTerms,supportedChartTypes:t.termdbConfig.supportedChartTypes[e],matrixplots:t.termdbConfig.matrixplots};return s}async main(){await X(this)}getMassFilter(){if(!this.state.termfilter.filter||this.state.termfilter.filter.lst.length==0){return{type:"tvslst",in:true,join:"",lst:[]}}const t=j(structuredClone(this.state.termfilter.filter));return t}async groups2samplelst(t){const e=[];const s=new Set,r=[];for(const i of t){const t=await this.app.vocabApi.getFilteredSampleList(i.filter);const o=[];for(const i of t){const t={sampleId:i.id};if("name"in i){t.sample=i.name}if(!s.has(i.id))o.push(t);else{for(const t of e){const e=t.items.findIndex((t=>t.sampleId===i.id));if(e!==-1)r.push(...t.items.splice(e,1))}}s.add(t.sampleId)}if(o.length)e.push({name:i.name,items:o,color:i.color})}if(r.length){const t=confirm('Overlap detected: 1 or more samples belong to >1 groups. A new group will be created for these "overlap" samples.');if(!t)return;e.push({name:"Group overlap",items:r})}const i=e.length==1?e[0].name:"Sample groups";const o=lt(e,i,this.app.vocabApi);if(t.length==1){const t=await this.app.vocabApi.getCohortSampleCount(this.activeCohortName);const e=parseInt(t,10);const s=Object.values(o.term.values).find((t=>t.key.startsWith("Not in")));s.othersGroupSampleNum=e-s.list.length}for(const t of o.q.groups){o.term.values[t.name].list=t.values;o.term.values[t.name].inuse=t.inuse}return o}updateLaunchButton(){this.dom.newTermSpan.style("display","none");this.dom.noGroupSelected.style("display","none");if(this.state.groups.length==0)return;if(this.state.groups.length==1){this.dom.newTermSpan.style("display","");this.dom.launchButton.text(`Create variable using "${this.state.groups[0].name}"`);this.dom.newTermNameInput.property("value",this.state.groups[0].name+" vs others");return}const t=[...this.selectedGroupsIdx];if(t.length==0){this.dom.noGroupSelected.style("display","");return}this.dom.newTermSpan.style("display","");if(t.length==1){this.dom.launchButton.text(`Create variable using "${this.state.groups[t[0]]?.name}"`);this.dom.newTermNameInput.property("value",this.state.groups[t[0]].name+" vs others");return}this.dom.launchButton.text(`Create variable using ${t.length} groups`);this.dom.newTermNameInput.property("value",t.map((t=>this.state.groups[t].name)).join(" vs "))}displayCustomTerms(){this.dom.customTermDiv.selectAll("*").remove();if(this.state.customTerms.length==0){this.dom.customTermDiv.append("div").text("No custom variables. Use above controls to create new ones. Custom variables are added to dictionary.").style("font-size",".8em");return}this.dom.customTermDiv.append("div").style("margin-bottom","10px").style("font-size",".8em").text("Following custom variables are available in all charts where variables are used. Click one to delete.");for(const{name:t,tw:e}of this.state.customTerms){const s=this.dom.customTermDiv.append("div");s.text(t).attr("class","sja_filter_tag_btn").style("padding","3px 6px").style("border-radius","6px").style("margin-right","5px").on("click",(s=>{const r=()=>this.app.vocabApi.deleteCustomTerm(t);this.showGroupsMenu(s,e,r)}))}}newId(){this.lastId=g();return this.lastId}showGroupsMenu(t,e,s){const r=structuredClone(e);this.tip.clear();const i=this.tip.d.append("div");const o=this?.lastId;const a=i.append("div");const n=p({holder:a});for(const[t,s]of Object.entries(e.term.values)){const t=s.color?`<span style="display:inline-block; width:12px; height:12px; background-color:${s.color}" ></span>`:`<span style="display:inline-block; width:11px; height:11px; background-color:${"#fff"}; border: 0.1px solid black" ></span>`;const[e,r]=n.addRow();e.html(`${t} ${s.label}:`);r.html(`${s.othersGroupSampleNum||s.list.length} samples`)}i.append("div");it(this.tip,i,r,this.app,o,this.state,(()=>this.newId));if(this.state.supportedChartTypes.includes("DEanalysis")&&r.q.groups.length==2)J(i,this,this.state,r);if(this.state.supportedChartTypes.includes("survival"))st("survival",i,"Compare survival",this.tip,r,o,this,true);if(this.state.supportedChartTypes.includes("geneExpression"))rt("geneExpression",i,"Gene expression",this.tip,r,o,this,true);if(this.state.supportedChartTypes.includes("cuminc"))st("cuminc",i,"Compare cumulative incidence",this.tip,r,o,this,true);const l=i.append("div").attr("class","sja_menuoption sja_sharp_border").html("Summarize");l.insert("div").html("›").style("float","right");l.on("click",(async t=>{et(l,(t=>{Z(t,r,this.app,o,(()=>this.newId))}),this.app,this.tip)}));i.append("div").attr("class","sja_menuoption sja_sharp_border").text("Delete variable").on("click",(t=>{s();this.tip.hide()}));if(this.state.termdbConfig.scatterplots)for(const t of this.state.termdbConfig.scatterplots){if(t.colorTW)i.append("div").attr("class","sja_menuoption sja_sharp_border").text(`Open ${t.name}`).on("click",(()=>{let e={chartType:"sampleScatter",name:t.name};if(t.sampleCategory)e.sampleCategory={tw:structuredClone(t.sampleCategory.tw),order:t.sampleCategory.order,defaultValue:t.sampleCategory.defaultValue};if(t.sampleType)e.sampleType=t.sampleType;e.colorTW=structuredClone(r);if(t.settings)e.settings=structuredClone(t.settings);this.app.dispatch({type:"plot_create",config:e});this.tip.hide()}))}this.tip.showunder(t.target)}}const z=n(U);function J(t,e,s,r,i){t.append("div").attr("class","sja_menuoption sja_sharp_border").text("Differential expression").on("click",(t=>{const i=[];for(const t of r.q.groups){if(t.values&&t.values.length>0){i.push(t)}else{throw"group does not contain samples for DE analysis"}}const o={chartType:"DEanalysis",state:s,samplelst:{groups:i}};e.tip.hide();e.app.dispatch({type:"plot_create",config:o})}))}function W(t){t.dom.filterTableDiv=t.dom.holder.append("div").style("margin-bottom","10px");const e=t.dom.holder.append("div");t.dom.addNewGroupBtnHolder=e.append("span").style("margin-right","20px");t.dom.newTermSpan=e.append("span");t.dom.newTermSpan.append("span").style("padding-left","15px").text("Add variable:");t.dom.newTermNameInput=t.dom.newTermSpan.append("input").attr("type","text");t.dom.launchButton=t.dom.newTermSpan.append("span").attr("class","sja_menuoption").on("click",(()=>Q(t)));t.dom.noGroupSelected=e.append("span").text("No groups selected").style("opacity",.5);t.dom.customTermDiv=t.dom.holder.append("div").style("margin","20px").style("border-left","solid 1px black").style("padding","10px");t.dom.holder.on("click",(t=>{if(tt)tt.hide()}))}async function X(t){if(!t.filterPrompt)t.filterPrompt=await A({holder:t.dom.addNewGroupBtnHolder,vocabApi:t.app.vocabApi,emptyLabel:"Add group",termdbConfig:t.state.termdbConfig,callback:e=>{ot(t.app,e,t.state.groups)},debug:t.opts.debug});t.filterPrompt.main(t.getMassFilter());const e=structuredClone(t.state.groups);if(!e.length){t.updateLaunchButton();t.dom.filterTableDiv.style("display","none");t.displayCustomTerms();return}t.dom.filterTableDiv.style("display","").selectAll("*").remove();const s={div:t.dom.filterTableDiv,columns:[{label:"NAME",editCallback:async(e,s)=>{const r=s.value;const i=t.state.groups.findIndex((t=>t.name==r));if(i!=-1){alert(`Group named ${r} already exists`);X(t)}else await t.app.dispatch({type:"rename_group",index:e,newName:s.value})}},{label:"COLOR",editCallback:async(e,s)=>{await t.app.dispatch({type:"change_color_group",index:e,newColor:s.color})}},{label:"#SAMPLE"},{label:"FILTER"}],columnButtons:[{text:"Delete",callback:(s,r)=>{const i=e[r];t.app.vocabApi.deleteGroup(i.name)}}],rows:[]};for(const r of e){s.rows.push([{value:r.name},{color:r.color},{value:"n="+await t.app.vocabApi.getFilteredSampleCount(r.filter)},{}])}t.selectedGroupsIdx.clear();if(e.length==1){t.selectedGroupsIdx.add(0)}else{s.noButtonCallback=(e,s)=>{if(s.checked)t.selectedGroupsIdx.add(e);else t.selectedGroupsIdx.delete(e);t.updateLaunchButton()};s.selectedRows=[];for(let r=0;r<e.length;r++){s.selectedRows.push(r);t.selectedGroupsIdx.add(r)}}C(s);for(const[r,i]of s.rows.entries()){const s=e[r];x({holder:i[3].__td,vocabApi:t.app.vocabApi,termdbConfig:t.state.termdbConfig,callback:r=>{if(!r||r.lst.length==0){const t=e.findIndex((t=>t.name==s.name));e.splice(t,1)}else{s.filter=r}t.app.dispatch({type:"app_refresh",state:{groups:e}})}}).main(s.filter)}t.updateLaunchButton();t.displayCustomTerms()}async function Q(t){const e=[];for(const s of t.selectedGroupsIdx){const r=t.state.groups[s];if(r)e.push(r)}if(e.length==0)throw"No groups, should not happen";const s=t.dom.newTermNameInput.property("value");const r=await t.groups2samplelst(e);if(!r)return;r.term.name=s;t.app.vocabApi.addCustomTerm({name:s,tw:r});t.dom.newTermSpan.style("display","none")}function Y(t){if(!t.termfilter?.filter||t.termfilter.filter.lst.length==0){return t.groups}const e=[];for(const s of t.groups){const r=j(structuredClone(t.termfilter.filter));const i=y(s.filter,"filterUiRoot");if(!i){e.push(s);continue}r.lst.push(i);r.join=r.lst.length>1?"and":"";const o={name:s.name,filter:r,color:s.color};e.push(o)}return e}async function K(t,e,s,r,i,o){let a={chartType:t,term:e,term2:s};if(i)a.insertBefore=i;if(o)a.id=o();await r.dispatch({type:"plot_create",config:a})}async function Z(t,e,s,r,i){const o=t.term?t:{term:t};let a={chartType:"summary",childType:"barchart",term:o,term2:e};if(r)a.insertBefore=r;if(i)a.id=i();await s.dispatch({type:"plot_create",config:a})}let tt;async function et(t,e,r,i,o={tree:{usecase:{target:"default",detail:"term"}}},a=true,n=true,l=[]){if(!tt)tt=new s({padding:0,offsetX:162,offsetY:-34,parent_menu:i.d.node()});tt.clear();if(n)tt.showunderoffset(t.node());else tt.showunder(t.node());w({holder:tt.d,vocabApi:r.vocabApi,state:o,tree:{disable_terms:l,click_term:t=>{e(t);tt.hide();if(a)i.hide()}}})}function st(t,e,s,r,i,o,a,n=false){const l=e.append("div").attr("class","sja_menuoption sja_sharp_border").html(`${s} ›`).on("click",(e=>{const s={tree:{usecase:{target:t,detail:"term"}}};if(t=="survival")s.nav={header_mode:"hide_search"};et(l,(e=>{K(t,e,i,a.app,o,n?()=>a.newId:null)}),a.app,r,s)}))}function rt(t,e,r,i,o,a,n,l=false){const p=e.append("div").attr("class","sja_menuoption sja_sharp_border").html(`${r} ›`).on("click",(()=>{if(!tt)tt=new s({padding:0,offsetX:162,offsetY:-34,parent_menu:i.d.node()});tt.clear();tt.showunderoffset(p.node());new G({holder:tt.d,genome:n.app.opts.genome,geneList:[],vocabApi:n.app.vocabApi,callback:async({geneList:t,groupName:e})=>{i.hide();const s={name:e,lst:[],type:"hierCluster"};const r=s.lst.filter((t=>t.term.type!="geneExpression"));const a=await Promise.all(t.map((async t=>{const e={gene:t.symbol||t.gene,name:t.symbol||t.gene,type:"geneExpression"};let r=s.lst.find((e=>e.term.name==t.symbol||e.term.name==t.gene));if(!r){r={term:e,q:{}}}return r})));tt.d.selectAll("*").remove();if(a.length==1){const t=a[0];n.app.dispatch({type:"plot_create",config:{chartType:"summary",term:t,term2:o}});return}if(a.length==2){const t=a[0];const e=a[1];n.app.dispatch({type:"plot_create",config:{chartType:"summary",term:t,term2:e,colorTW:o}});return}s.lst=[...r,...a];n.app.dispatch({type:"plot_create",config:{chartType:"hierCluster",termgroups:[s],dataType:h.GENE_EXPRESSION,divideBy:o,settings:{hierCluster:{yDendrogramHeight:0,clusterSamples:false}}}})}})}))}function it(t,e,s,r,i,o,a){if(o.matrixplots){for(const n of o.matrixplots){e.append("div").attr("class","sja_menuoption sja_sharp_border").text(n.name).on("click",(async()=>{const e=await r.vocabApi.getMatrixByName(n.name);e.divideBy=s;e.insertBefore=i;e.settings.matrix.colw=0;if(a)e.id=a();r.dispatch({type:"plot_create",config:e});t.hide()}))}}}function ot(t,e,s){s=JSON.parse(JSON.stringify(s));let r="New group";let i=0;while(1){const t=r+(i==0?"":" "+i);if(!s.find((e=>e.name==t)))break;i++}r=r+(i==0?"":" "+i);const o={name:r,filter:e,color:c(H(s.length)).formatHex()};s.push(o);t.dispatch({type:"app_refresh",state:{groups:s}})}function at(t){let e=0;let s=true;for(const r in t.term.values){const i=t.q.groups[e].values;t.term.values[r].list=i;if(i[0]&&"sample"in i[0])s=false;e++}const r={type:"tvslst",in:true,join:"",lst:[{type:"tvs",tvs:{term:t.term},noEdit:s}]};return r}function nt(t){const e={name:"",index:0,items:[{sampleId:t}]};const s=lt([e],"",false);const r=at(s);return r}function lt(t,e="groups",s=true){const r={};const i=[];let o;for(const e of t){o=n(e);const t={name:e.name,in:true,values:o};i.push(t);r[e.name]={key:e.name,label:e.name,color:e.color,list:o}}if(t.length==1&&s){const e="Not in "+t[0].name;r[e]={key:e,label:e,color:"#aaa",list:o};i.push({name:e,in:false,values:o})}const a={isAtomic:true,term:{name:e,type:"samplelst",values:r},q:{groups:i}};return a;function n(t){const e=[];for(const s of t.items){const t={sampleId:s.sampleId};if("sample"in s){t.sample=s.sample}e.push(t)}return e}}function pt(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-f81e0f19.js");case"../plots/Disco.js":return import("./Disco-db386f7a.js");case"../plots/DziViewer.js":return import("./DziViewer-9352e224.js");case"../plots/WSIViewer.js":return import("./WSIViewer-80f60272.js");case"../plots/barchart.data.js":return import("./FilterRxComp-0f35b322.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-df44e666.js");case"../plots/barchart.js":return import("./barchart-3c5d734c.js");case"../plots/bars.renderer.js":return import("./bars.renderer-b232d882.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-44d3b48f.js");case"../plots/brainImaging.js":return import("./brainImaging-2eaa419d.js");case"../plots/controls.btns.js":return import("./controls.btns-5b1240c8.js");case"../plots/controls.config.js":return import("./controls.config-81cd5749.js");case"../plots/controls.js":return import("./controls-3c1691d7.js");case"../plots/cuminc.js":return import("./cuminc-c4db28f0.js");case"../plots/dataDownload.js":return import("./dataDownload-a4dfa2d0.js");case"../plots/dictionary.js":return import("./dictionary-e2232e84.js");case"../plots/facet.js":return import("./facet-98971c68.js");case"../plots/geneExpression.js":return import("./geneExpression-b5d0261f.js");case"../plots/geneORA.js":return import("./geneORA-f1a90d02.js");case"../plots/geneset.js":return import("./geneset-b63496eb.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-2dcaf4f5.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-ec8fbddc.js");case"../plots/gsea.js":return import("./gsea-3075c82c.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-fa799d06.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-6d453881.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-33a828a1.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-6279d7fb.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-38254245.js");case"../plots/matrix.cells.js":return import("./matrix.cells-eb4110a7.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-0df274ed.js");case"../plots/matrix.config.js":return import("./matrix.config-3ef822b9.js");case"../plots/matrix.controls.js":return import("./matrix.controls-42bb2063.js");case"../plots/matrix.data.js":return import("./matrix.data-27b8e3a9.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-1bbe1f39.js");case"../plots/matrix.groups.js":return import("./matrix.groups-67606700.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-cdcc56c9.js");case"../plots/matrix.js":return import("./matrix-e371888a.js");case"../plots/matrix.layout.js":return import("./matrix.layout-857cd336.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-09f6dc57.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-d392fb69.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-b03b62aa.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-9440c86a.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-2c5eb35f.js");case"../plots/plot.app.js":return import("./plot.app-d6fe76e2.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-39b80a1c.js");case"../plots/plot.disco.js":return import("./plot.disco-9a544f9a.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-aeb2dabc.js");case"../plots/profileBarchart.js":return import("./profileBarchart-72adc533.js");case"../plots/profilePlot.js":return import("./profilePlot-0b897a05.js");case"../plots/profilePolar.js":return import("./profilePolar-a7248d48.js");case"../plots/profileRadar.js":return import("./profileRadar-1ba5d8fd.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-452e76ef.js");case"../plots/profileSummary.js":return import("./profileSummary-7f0eacf0.js");case"../plots/regression.inputs.js":return import("./regression.inputs-ff00f74e.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-ff00f74e.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-1753d56b.js");case"../plots/regression.js":return import("./regression.inputs-ff00f74e.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-6f85a5dc.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-97917406.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-97917406.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-97917406.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-4649d1ec.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-f86dc5ea.js");case"../plots/scatter.js":return import("./scatter-cc1b0d07.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-e6f83b2a.js");case"../plots/stattable.js":return import("./stattable-c5f12d9c.js");case"../plots/summary.js":return import("./summary-0624f5e6.js");case"../plots/survival.js":return import("./survival-fcc7719f.js");case"../plots/table.js":return import("./table-4d3a771e.js");case"../plots/variantBrowser.js":return import("./variantBrowser-261373bf.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-30a239fe.js");case"../plots/violin.js":return import("./violin-e647aac9.js");case"../plots/violin.renderer.js":return import("./violin.renderer-e29d2700.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}function ct(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-f81e0f19.js");case"../plots/Disco.js":return import("./Disco-db386f7a.js");case"../plots/DziViewer.js":return import("./DziViewer-9352e224.js");case"../plots/WSIViewer.js":return import("./WSIViewer-80f60272.js");case"../plots/barchart.data.js":return import("./FilterRxComp-0f35b322.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-df44e666.js");case"../plots/barchart.js":return import("./barchart-3c5d734c.js");case"../plots/bars.renderer.js":return import("./bars.renderer-b232d882.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-44d3b48f.js");case"../plots/brainImaging.js":return import("./brainImaging-2eaa419d.js");case"../plots/controls.btns.js":return import("./controls.btns-5b1240c8.js");case"../plots/controls.config.js":return import("./controls.config-81cd5749.js");case"../plots/controls.js":return import("./controls-3c1691d7.js");case"../plots/cuminc.js":return import("./cuminc-c4db28f0.js");case"../plots/dataDownload.js":return import("./dataDownload-a4dfa2d0.js");case"../plots/dictionary.js":return import("./dictionary-e2232e84.js");case"../plots/facet.js":return import("./facet-98971c68.js");case"../plots/geneExpression.js":return import("./geneExpression-b5d0261f.js");case"../plots/geneORA.js":return import("./geneORA-f1a90d02.js");case"../plots/geneset.js":return import("./geneset-b63496eb.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-2dcaf4f5.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-ec8fbddc.js");case"../plots/gsea.js":return import("./gsea-3075c82c.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-fa799d06.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-6d453881.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-33a828a1.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-6279d7fb.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-38254245.js");case"../plots/matrix.cells.js":return import("./matrix.cells-eb4110a7.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-0df274ed.js");case"../plots/matrix.config.js":return import("./matrix.config-3ef822b9.js");case"../plots/matrix.controls.js":return import("./matrix.controls-42bb2063.js");case"../plots/matrix.data.js":return import("./matrix.data-27b8e3a9.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-1bbe1f39.js");case"../plots/matrix.groups.js":return import("./matrix.groups-67606700.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-cdcc56c9.js");case"../plots/matrix.js":return import("./matrix-e371888a.js");case"../plots/matrix.layout.js":return import("./matrix.layout-857cd336.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-09f6dc57.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-d392fb69.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-b03b62aa.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-9440c86a.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-2c5eb35f.js");case"../plots/plot.app.js":return import("./plot.app-d6fe76e2.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-39b80a1c.js");case"../plots/plot.disco.js":return import("./plot.disco-9a544f9a.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-aeb2dabc.js");case"../plots/profileBarchart.js":return import("./profileBarchart-72adc533.js");case"../plots/profilePlot.js":return import("./profilePlot-0b897a05.js");case"../plots/profilePolar.js":return import("./profilePolar-a7248d48.js");case"../plots/profileRadar.js":return import("./profileRadar-1ba5d8fd.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-452e76ef.js");case"../plots/profileSummary.js":return import("./profileSummary-7f0eacf0.js");case"../plots/regression.inputs.js":return import("./regression.inputs-ff00f74e.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-ff00f74e.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-1753d56b.js");case"../plots/regression.js":return import("./regression.inputs-ff00f74e.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-6f85a5dc.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-97917406.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-97917406.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-97917406.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-4649d1ec.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-f86dc5ea.js");case"../plots/scatter.js":return import("./scatter-cc1b0d07.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-e6f83b2a.js");case"../plots/stattable.js":return import("./stattable-c5f12d9c.js");case"../plots/summary.js":return import("./summary-0624f5e6.js");case"../plots/survival.js":return import("./survival-fcc7719f.js");case"../plots/table.js":return import("./table-4d3a771e.js");case"../plots/variantBrowser.js":return import("./variantBrowser-261373bf.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-30a239fe.js");case"../plots/violin.js":return import("./violin-e647aac9.js");case"../plots/violin.renderer.js":return import("./violin.renderer-e29d2700.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}function dt(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-f81e0f19.js");case"../plots/Disco.js":return import("./Disco-db386f7a.js");case"../plots/DziViewer.js":return import("./DziViewer-9352e224.js");case"../plots/WSIViewer.js":return import("./WSIViewer-80f60272.js");case"../plots/barchart.data.js":return import("./FilterRxComp-0f35b322.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-df44e666.js");case"../plots/barchart.js":return import("./barchart-3c5d734c.js");case"../plots/bars.renderer.js":return import("./bars.renderer-b232d882.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-44d3b48f.js");case"../plots/brainImaging.js":return import("./brainImaging-2eaa419d.js");case"../plots/controls.btns.js":return import("./controls.btns-5b1240c8.js");case"../plots/controls.config.js":return import("./controls.config-81cd5749.js");case"../plots/controls.js":return import("./controls-3c1691d7.js");case"../plots/cuminc.js":return import("./cuminc-c4db28f0.js");case"../plots/dataDownload.js":return import("./dataDownload-a4dfa2d0.js");case"../plots/dictionary.js":return import("./dictionary-e2232e84.js");case"../plots/facet.js":return import("./facet-98971c68.js");case"../plots/geneExpression.js":return import("./geneExpression-b5d0261f.js");case"../plots/geneORA.js":return import("./geneORA-f1a90d02.js");case"../plots/geneset.js":return import("./geneset-b63496eb.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-2dcaf4f5.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-ec8fbddc.js");case"../plots/gsea.js":return import("./gsea-3075c82c.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-fa799d06.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-6d453881.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-33a828a1.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-6279d7fb.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-38254245.js");case"../plots/matrix.cells.js":return import("./matrix.cells-eb4110a7.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-0df274ed.js");case"../plots/matrix.config.js":return import("./matrix.config-3ef822b9.js");case"../plots/matrix.controls.js":return import("./matrix.controls-42bb2063.js");case"../plots/matrix.data.js":return import("./matrix.data-27b8e3a9.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-1bbe1f39.js");case"../plots/matrix.groups.js":return import("./matrix.groups-67606700.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-cdcc56c9.js");case"../plots/matrix.js":return import("./matrix-e371888a.js");case"../plots/matrix.layout.js":return import("./matrix.layout-857cd336.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-09f6dc57.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-d392fb69.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-b03b62aa.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-9440c86a.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-2c5eb35f.js");case"../plots/plot.app.js":return import("./plot.app-d6fe76e2.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-39b80a1c.js");case"../plots/plot.disco.js":return import("./plot.disco-9a544f9a.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-aeb2dabc.js");case"../plots/profileBarchart.js":return import("./profileBarchart-72adc533.js");case"../plots/profilePlot.js":return import("./profilePlot-0b897a05.js");case"../plots/profilePolar.js":return import("./profilePolar-a7248d48.js");case"../plots/profileRadar.js":return import("./profileRadar-1ba5d8fd.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-452e76ef.js");case"../plots/profileSummary.js":return import("./profileSummary-7f0eacf0.js");case"../plots/regression.inputs.js":return import("./regression.inputs-ff00f74e.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-ff00f74e.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-1753d56b.js");case"../plots/regression.js":return import("./regression.inputs-ff00f74e.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-6f85a5dc.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-97917406.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-97917406.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-97917406.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-4649d1ec.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-f86dc5ea.js");case"../plots/scatter.js":return import("./scatter-cc1b0d07.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-e6f83b2a.js");case"../plots/stattable.js":return import("./stattable-c5f12d9c.js");case"../plots/summary.js":return import("./summary-0624f5e6.js");case"../plots/survival.js":return import("./survival-fcc7719f.js");case"../plots/table.js":return import("./table-4d3a771e.js");case"../plots/variantBrowser.js":return import("./variantBrowser-261373bf.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-30a239fe.js");case"../plots/violin.js":return import("./violin-e647aac9.js");case"../plots/violin.renderer.js":return import("./violin.renderer-e29d2700.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}const mt="_MASS_AUTOID_"+Math.random().toString().slice(-6);let ut=(+new Date).toString().slice(-8);function ht(){return mt+"_"+ut++}const ft=new Set(["with_tabs","hidden","search_only","hide_search","only_buttons","with_cohortHtmlSelect"]);const gt={nav:{header_mode:"with_tabs",activeTab:0},activeCohort:0,search:{isVisible:true},plots:[],termfilter:{filter:{type:"tvslst",in:true,join:"",lst:[]}},reuse:{customTermQ:{byId:{},byName:{}}},groups:[],customTerms:[],autoSave:true};class bt{constructor(t){this.type="store";this.defaultState=gt;this.prevGeneratedId=0}validateOpts(t){const e=t.state;if(e.vocab.dslabel){if(!e.vocab.genome)throw".state[.vocab].genome missing"}else{if(!Array.isArray(e.vocab.terms))throw"vocab.terms must be an array of objects"}}validateState(){if(!ft.has(this.state.nav.header_mode))throw"invalid state.nav.header_mode"}async init(){try{this.state.termdbConfig=await this.app.vocabApi.getTermdbConfig();await this.setTermfilter();await this.rehydrateGroups();await this.app.vocabApi.main({termfilter:JSON.parse(JSON.stringify(this.state.termfilter)),termdbConfig:this.state.termdbConfig});const t=[];for(const[e,s]of this.state.plots.entries()){let r;try{const t=await dt(`../plots/${s.chartType}.js`);r=await t.getPlotConfig(s,this.app)}catch(t){this.app.printError(t);console.error(`getPlotConfig() failed: ${t}`)}if(!r){t.push(e);continue}this.state.plots[e]=r;if(!("id"in r))r.id=`_AUTOID_${ut++}_${e}`;if(r.mayAdjustConfig)r.mayAdjustConfig(r)}if(t.length){for(const e of t){this.state.plots.splice(e,1)}}}catch(t){throw t}}setId(t){t.$id=this.prevGeneratedId++;if(t.$lst){for(const e of t.$lst){this.setId(e)}}}async setTermfilter(){let t=y(this.state.termfilter.filter,"filterUiRoot");if(!t){this.state.termfilter.filter.tag="filterUiRoot";t=this.state.termfilter.filter}await Promise.all(_(this.state.termfilter.filter,this.app.vocabApi));if(!this.state.termdbConfig.selectCohort){this.state.activeCohort=-1;if(this.state.activeTab===0)this.state.activeTab=1;if(this.state.nav.header_mode==="with_cohortHtmlSelect"){console.warn(`no termdbConfig.selectCohort to use for nav.header_mode = 'with_cohortHtmlSelect'`);this.state.nav.header_mode="search_only"}}else{let e=y(this.state.termfilter.filter,"cohortFilter");if(!e){e={tag:"cohortFilter",type:"tvs",tvs:{term:JSON.parse(JSON.stringify(this.state.termdbConfig.selectCohort.term)),values:this.state.activeCohort==-1?[]:this.state.termdbConfig.selectCohort.values[this.state.activeCohort].keys.map((t=>({key:t,label:t})))}};this.state.termfilter.filter={type:"tvslst",in:true,join:"and",lst:[e,t]}}else{const t=(t,e)=>t<e?-1:1;e.tvs.values.sort(((t,e)=>t.key<e.key?-1:1));const s=JSON.stringify(e.tvs.values.map((t=>t.key)).sort(t));const r=this.state.termdbConfig.selectCohort.values.findIndex((e=>s==JSON.stringify(e.keys.sort(t))));if(this.state.activeCohort!==-1&&this.state.activeCohort!==0&&r!==this.state.activeCohort){console.log("Warning: cohortFilter will override the state.activeCohort due to mismatch")}this.state.activeCohort=r}}}async rehydrateGroups(){const t=[];for(const e of this.state.groups){t.push(..._(e.filter,this.app.vocabApi))}await Promise.all(t)}}bt.prototype.actions={app_refresh(t={}){this.state=this.copyMerge(this.toJson(this.state),t.state||{});const e=new Set;if(t.subactions){for(const s of t.subactions){this.actions[s.type].call(this,s);if(s.type.startsWith("plot_"))e.add(s.id)}}for(const s in this.state.plots){if(s.mayAdjustConfig&&!e.has(s.id)){s.mayAdjustConfig(s,t.config)}}},tab_set(t){this.state.nav.activeTab=t.activeTab},cohort_set(t){this.state.activeCohort=t.activeCohort;const e=this.state.termdbConfig.selectCohort.values[t.activeCohort];const s=y(this.state.termfilter.filter,"cohortFilter");if(!s)throw`No item tagged with 'cohortFilter'`;s.tvs.values=e.keys.map((t=>({key:t,label:t})))},async plot_prep(t){const e={id:"id"in t?t.id:ht()};if(!t.config)throw".config{} missing for plot_prep";if(t.config.chartType&&Object.keys(t.config).length==1){const e=await ct(`../plots/${t.config.chartType}.js`);const s=await e.getPlotConfig(t.config,this.app);t.config=Object.assign(s,t.config)}Object.assign(e,t.config);this.state.plots.push(e)},async plot_create(t){const e=await pt(`../plots/${t.config.chartType}.js`);const s=await e.getPlotConfig(t.config,this.app);if(!("id"in t))t.id=ht();s.id=t.id;if(s.mayAdjustConfig){s.mayAdjustConfig(s,t.config)}this.state.plots.push(s)},plot_edit(t){const e=this.state.plots.find((e=>e.id===t.id));if(!e)throw`missing plot id='${t.id}' in store.plot_edit()`;this.copyMerge(e,t.config,t.opts?t.opts:{});if(e.mayAdjustConfig){e.mayAdjustConfig(e,t.config)}if(t.config&&"cutoff"in t.config){e.cutoff=t.config.cutoff}else{delete e.cutoff}},plot_delete(t){const e=this.state.plots.findIndex((e=>e.id===t.id));if(e!==-1)this.state.plots.splice(e,1)},plot_nestedEdits(t){const e=this.state.plots.find((e=>e.id===t.id));if(!e)throw`missing plot id='${t.id}' in store.plot_edit_nested`;for(const s of t.edits){const t=s.nestedKeys.pop();const r=s.nestedKeys.reduce(((t,e)=>t[e]),e);r[t]=s.value}},async plot_splice(t){for(const e of t.subactions){await this.actions[e.type].call(this,e)}},filter_replace(t){if("filter0"in t){this.state.termfilter.filter0=t.filter0;return}const e=t.filter?t.filter:{type:"tvslst",join:"",in:1,lst:[]};if(!t.filter.tag){this.state.termfilter.filter=e}else{const s=y(this.state.termfilter.filter,t.filter.tag);if(!s)throw`cannot replace missing filter with tag '${t.filter.tag}'`;const r=v(this.state.termfilter.filter,s.$id);if(r==s){this.state.termfilter.filter=e}else{const t=r.lst.indexOf(s);r.lst[t]=e}}},cache_termq({termId:t,q:e}){if(!t)throw`missing termId for caching custom term.q`;if(!e?.reuseId)throw`missing or empty tw.q.reuseId as cache identifier for term='${t}'`;const s=this.state.reuse.customTermQ.byId;if(!s[t])s[t]={};s[t][e.reuseId]=e;for(const t of this.state.plots){if(!(t.chartType in yt))continue;const s=yt[t.chartType](t);for(const t of s){if(t?.q?.reuseId===e.reuseId)t.q=e}}},uncache_termq({term:t,q:e}){if(!t.id)throw`missing term.id for uncaching custom term.q`;if(!e.reuseId)throw`missing qname as uncache identifier for term.id='${t.id}'`;const s=this.state.reuse.customTermQ.byId[t.id];if(!s)throw`missing term.q cache for term.id='${t.id}`;if(!(e.reuseId in s))console.warn(`q.reuseId='${e.cacheid}' not cached for term.id='${t.id}'`);else{delete s[e.reuseId];for(const t of this.state.plots){if(!(t.chartType in yt))continue;const s=yt[t.chartType](t);for(const t of s){if(t.q.reuseId===e.reuseId){delete t.q.reuseId;delete t.q.name}}}}},add_customTerm(t){this.state.customTerms.push(t.obj)},delete_customTerm({name:t}){const e=this.state.customTerms.findIndex((e=>e.name==t));if(e!=-1)this.state.customTerms.splice(e,1)},add_group(t){if(this.state.nav.header_mode!="hidden"){const e=t.obj;const s=`Group ${this.state.groups.length+1}`;const r=lt([e]);const i={name:s,filter:at(r),plotId:e.plotId};this.state.groups.push(i);this.state.nav.activeTab=1}else if("plotId"in t.obj){const e=this.state.plots.find((e=>e.id==t.obj.plotId));if(e.groups){t.obj.index=e.groups.length;t.obj.name=`Group ${e.groups.length+1}`;e.groups.push(t.obj)}}},rename_group(t){const e=t.index;const s=t.newName;if(this.state.nav.header_mode!="hidden"){this.state.groups[e].name=s}else{for(const t of this.state.plots){if(t?.groups){t.groups[e].name=s}}}},change_color_group(t){const e=t.index;const s=t.newColor;if(this.state.nav.header_mode!="hidden"){this.state.groups[e].color=s}else{for(const t of this.state.plots){if(t?.groups){t.groups[e].color=s}}}},delete_group({name:t}){if(this.state.nav.header_mode!="hidden"){const e=this.state.groups.findIndex((e=>e.name==t));if(e!=-1)this.state.groups.splice(e,1)}else{for(const e of this.state.plots){if(e?.groups){const s=e.groups.findIndex((e=>e.name==t));if(s!=-1)e.groups.splice(s,1)}}}}};const jt=t=>[t.term0,t.term,t.term2].filter((t=>!!t));const yt={summary:jt,survival:jt,cuminc:jt,regression:t=>[t.outcome,...t.independent].filter((t=>!!t)),matrix:t=>t.termgroups.reduce(((t,e)=>{t.push(...e.lst);return t}),[])};const vt=d(bt);class xt{constructor(t={}){this.type="recover";this.initialHolderDisplay=t.holder.style("display");this.dom={holder:t.holder,btnDiv:t.holder.append("div").style("position","sticky").style("top","12px").style("right","20px").style("margin",t.margin?t.margin:"10px").style("text-align","right")};this.hasStatePreMain=true;this.reactsTo=t.reactsTo||(()=>true);this.getState=t.getState||(t=>t);this.debouncedTrack=()=>{this.trackPending=true;this.trackState();this.render()};this.wait="wait"in t?t.wait:800;this.maxHistoryLen=t.maxHistoryLen||10}preApiFreeze(t){t.replaceLastState=t=>{if(this.isRecovering)return;this.state=this.getState(t);if(!this.trackPending)this.history[this.currIndex]=this.state}}init(){this.app.register(this.api);this.currIndex=-1;this.history=[];this.isActive=!isNaN(this.maxHistoryLen)&&+this.maxHistoryLen>0;if(this.isActive){Ct(this);this.initUi()}this.eventTypes=["postInit","postRender"]}async main(){if(!this.isActive)return;if(this.opts.hide?.(this.state)){this.dom.holder.style("display","none");return}this.dom.holder.style("display",this.initialHolderDisplay||"");if(!this.timedTrack){this.trackState();this.trackPending=true;this.timedTrack=setTimeout((()=>{}),this.wait);return}clearTimeout(this.timedTrack);this.trackPending=true;this.timedTrack=setTimeout(this.debouncedTrack,this.wait)}trackState(){if(this.isRecovering){this.isRecovering=false;return}if(this.state._scope_=="none")return;this.isRecovering=false;const t=this.opts.adjustTrackedState?this.opts.adjustTrackedState(this.state):this.state;if(!t){console.error("no state to track");return}if(!Object.isFrozen(t))m(t);if(this.currIndex==-1)this.origState=t;if(this.currIndex<this.history.length-1){this.history.splice(this.currIndex,this.history.length-(this.currIndex+1))}if(u(t,this.history[this.history.length-1]))return;this.history.push(t);this.currIndex+=1;if(this.history.length>this.maxHistoryLen){this.history.splice(1,1);this.currIndex+=-1}this.trackPending=false}goto(t){if(t<0&&this.currIndex+t>-1)this.currIndex+=t;else if(t>0&&this.currIndex+t<this.history.length)this.currIndex+=t;else return;this.isRecovering=true;const e=this.history[this.currIndex];this.render();if(this.opts.plot_id){const t=structuredClone(e);this.app.dispatch({type:"plot_edit",id:this.opts.plot_id,config:t.config,_scope_:t._scope_})}else{this.app.dispatch({type:"app_refresh",state:e})}}reset(){this.currIndex=0;this.isRecovering=true;const t=this.origState;if(this.opts.plot_id){const e=t.plots.find((t=>t.id===this.opts.plot_id));this.app.dispatch({type:"plot_edit",id:this.opts.plot_id,config:structuredClone(e)})}else this.app.dispatch({type:"app_refresh",state:t})}}const wt=n(xt);function Ct(t){t.initUi=function(){t.dom.undoBtn=t.dom.btnDiv.append("button").attr("aria-label","undo the previous action").property("disabled",true).style("margin","0 0 0 4px").style("border","1px solid #ccc").style("vertical-align","middle").html(t.opts.undoHtml||`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-arrow-counterclockwise" viewBox="0 0 16 16" style='vertical-align: middle'>\n\t\t\t <path stroke='#000' stroke-width='0.25' fill-rule="evenodd" d="M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2v1z"/>\n\t\t\t <path d="M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466z"/>\n\t\t\t</svg>`).on("click",(()=>t.goto(-1)));t.dom.redoBtn=t.dom.btnDiv.append("button").attr("aria-label","redo a subsequent action").property("disabled",true).style("margin",t.opts.resetHtml?"0":"0 4px 0 0").style("border","1px solid #ccc").style("vertical-align","middle").html(t.opts.redoHtml||`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-arrow-clockwise" viewBox="0 0 16 16" style='vertical-align: middle'>\n\t\t\t <path stroke='#000' stroke-width='0.25' fill-rule="evenodd" d="M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2v1z"/>\n\t\t\t <path d="M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 4.658A.25.25 0 0 1 8 4.466z"/>\n\t\t\t</svg>`).on("click",(()=>t.goto(1)));if(t.opts.resetHtml)t.dom.resetBtn=t.dom.btnDiv.append("button").attr("aria-label","Restore the initial rendered state").property("disabled",true).style("margin","0 4px 0 0").style("border","1px solid #ccc").style("vertical-align","middle").html(t.opts.resetHtml).on("click",(()=>t.reset()))};t.render=function(){if(t.dom.undoBtn)t.dom.undoBtn.property("disabled",t.currIndex<1||t.history.length===1);if(t.dom.redoBtn)t.dom.redoBtn.property("disabled",t.history.length<2||t.currIndex>=t.history.length-1);if(t.dom.resetBtn)t.dom.resetBtn.property("disabled",t.currIndex===0)}}export{G,lt as a,at as b,R as c,ot as d,it as e,st as f,z as g,et as h,N as i,Y as j,nt as k,Z as o,wt as r,vt as s};
|
|
1
|
+
import{i as t,d as e,M as s,a as r,z as i,A as o,B as a,h as n,C as l,D as p,r as c,m as d,E as m,F as u}from"./app-6fb77603.js";import{T as h,N as f,g}from"./termsetting-492eefa7.js";import{F as b,g as j,a as y,f as v}from"./FilterRxComp-02e68f1b.js";import{f as x}from"./FilterStateless-16a33070.js";import{appInit as w}from"./app-d215327f.js";import{r as C}from"./table-0daf2b89.js";import{_ as T}from"./tslib.es6-c3c2d88f.js";import{a as k}from"./genesearch-ffd88bf2.js";import{m as S}from"./checkbox-96437f4d.js";import{r as _}from"./rehydrateFilter-12d118cb.js";class I extends b{constructor(t){super(t);this.api={main:this.main.bind(this),getNormalRoot:()=>j(this.rawFilter),getPromise:t=>this.promises[t]};if(t.debug)this.api.Inner=this}async main(t,e={}){this.dom.controlsTip.hide();this.dom.treeTip.hide();const s="activeCohort"in e?e.activeCohort:this.activeCohort;const r=y(t,"filterUiRoot");if(r)delete r.tag;t.lst.push({tag:"filterUiRoot",type:"tvslst",join:"",lst:[]});t.join=t.lst.length>1?"and":"";const i=JSON.stringify(t);if(this.rawCopy==i&&JSON.stringify(this.activeCohort)==JSON.stringify(s))return;await super.main(i,e)}refresh(t){this.dom.controlsTip.hide();this.dom.treeTip.hide();const e=JSON.parse(JSON.stringify(this.rawFilter));const s=v(e,this.filter.$id);if(!s||this.rawFilter.$id===this.filter.$id){this.opts.callback(e)}else{const r=s.lst.findIndex((t=>t.$id==this.filter.$id));s.lst[r]=t;this.opts.callback(e)}const r=e.lst.findIndex((e=>e.$id===t.$id));e.lst.splice(r,1);this.main(e)}}const A=t(I);function P(t){if(!t.div||!t.text||!t.callback)throw new Error("Missing required parameters");return t.div.append("button").property("disabled",t.disabled||false).style("border","none").style("border-radius","20px").style("padding","10px 15px").text(t.text).on("click",(()=>{t.callback()}))}function D(t,s){const r=s.selectAll().data(t,(t=>t.value)).enter().append("div").style("margin","5px");const i=r.append("label").on("mousedown",(t=>{t.stopPropagation()}));const o=i.append("input").attr("type","radio").attr("name",(t=>t.label)).attr("value",(t=>t.value)).property("checked",(t=>t.checked)).on("input",(function(t,r){return T(this,void 0,void 0,(function*(){t.stopPropagation();o.property("disabled",true);o.property("checked",false);s.selectAll(".contentDiv").style("display","none");const i=e(this.parentNode).append("div").classed("contentDiv",true).style("padding-left","25px").style("display","block");yield r.callback(i);e(this).property("checked",true);o.property("disabled",false)}))}));o.filter((t=>t.checked)).property("checked",true);i.append("span").html((t=>" "+t.label));i.append("span").style("display","block").style("padding-left","25px").style("font-size","0.75em").html((t=>t.sublabel||""))}class B{constructor(t){this.params2Add=[];this.tip=t.tip;this.params=t.params;this.callback=t.callback;this.addOptionalParams=t.addOptionalParams;this.tip.d.style("padding","15px");this.render();for(const t of this.params2Add)this.addOptionalParams(t)}render(){for(const t of this.params){const e=this.addParameter(t.param,this.tip.d.append("div"));t.input=e}const t=P({div:this.tip.d.append("div").style("padding","20px").style("display","inline-block"),text:"Calculate genes",callback:()=>T(this,void 0,void 0,(function*(){t.property("disabled",true).text("Loading...");yield this.callback();this.tip.hide()}))})}addParameter(t,e){var s;let r;if(t.type=="boolean"){if((s=t===null||t===void 0?void 0:t.options)===null||s===void 0?void 0:s.length){const s=e.append("div").style("margin","10px 0px").on("mousedown",(t=>{t.stopPropagation()}));r=s.append("input").attr("type","checkbox").attr("id",t.id);this.addLabels(s,"label",t);const i=e.append("div").style("padding-left","20px");for(const e of t.options){const t=this.addParameter(e,i.append("div"));this.params2Add.push({param:e,input:t})}if(t.value){r.property("checked",t.value);i.style("display","block")}else i.style("display","none");r.on("change",(()=>{i.style("display",r.property("checked")?"block":"none")}))}else{r=e.append("input").style("padding","2px").attr("type","checkbox").attr("id",t.id);if(t.value)r.property("checked",t.value);this.addLabels(e,"label",t)}}else if(t.type=="string"&&t.value){r=S({holder:e,id:t.id,checked:true,labeltext:t.label,callback:()=>{}})}else if(t.type=="number"){r=e.append("input").attr("type","number").style("width","50px").style("padding","5px").attr("id",t.id);if(t.value)r.attr("value",t.value);this.addLabels(e,"span",t)}else if(t.type=="radio"){const s=t.options.find((t=>t.checked));if(!s)t.options[0].checked=true;r=e.append("div").attr("id",t.id);r.append("p").style("font-size","0.8em").style("opacity",.75).text(t.label);D(t.options,r)}return r}addLabels(t,e,s){if(!s.sublabel)t.append(e).html(s.label).attr("for",s.id);else{const r=t.append("div").style("display","inline-block").style("vertical-align","middle");r.append(e).style("display","block").style("padding-top","3px").html(s.label).attr("for",s.id);r.append("span").style("display","block").style("font-size","0.75em").html(s.sublabel)}}}class G{constructor(t){var e,r,i;this.holder=t.holder;this.genome=t.genome;this.callback=t.callback;this.vocabApi=t.vocabApi;this.customInputs=t.customInputs;this.geneList=structuredClone(t.geneList||[]);this.tip2=new s({padding:"0px",parent_menu:t.holder.node(),test:"test"});this.minNumGenes=t.minNumGenes||0;if("mode"in t)this.mode=t.mode;if("titleText"in t)this.titleText=t.titleText;this.origLst=structuredClone(this.geneList);this.origNames=JSON.stringify(this.geneList.map((t=>t.gene)).sort());this.holder.selectAll("*").remove();const o=this.holder.append("div").style("padding","5px");if(this.titleText){o.append("div").style("margin-bottom","10px").html(this.titleText)}const a=o.append("div");const n=a.append("label");n.append("span").html("Search");const l=n.append("div").style("display","inline-flex").style("align-items","center").style("margin","8px 0px -5px 0px");const p=a.append("div").style("display","inline-flex").style("align-items","center").style("float","right").style("gap","5px");const c=this.addGene.bind(this);this.geneSearch=k({tip:this.tip2,genome:this.genome,row:l,searchOnly:"gene",callback:c,hideHelp:true,focusOff:true});this.menuList=[];this.api={dom:{holder:o,textControlDiv:p.append("div"),clearBtn:P({div:p,text:"Clear",disabled:!((e=this.geneList)===null||e===void 0?void 0:e.length),callback:()=>{this.geneList=[];this.renderGenes()}}),restoreBtn:((r=this.geneList)===null||r===void 0?void 0:r.length)?P({div:p,disabled:true,text:"Restore",callback:()=>{this.geneList=this.origLst;this.renderGenes()}}):null,geneHoldingDiv:this.renderGeneHoldingDiv(o),statLegendDiv:o.append("div"),submitBtn:P({div:o.append("div").style("margin-top","10px"),text:"Submit",disabled:!((i=this.geneList)===null||i===void 0?void 0:i.length),callback:()=>{this.callback({geneList:this.geneList})}})},topMutatedGenesParams:[],topVariablyExpressedGenesParams:[],statColor2label:new Map,destroy(){t.holder.remove()}};this.getParams();this.createMenuList();this.renderTextControls(this.api.dom.textControlDiv);this.renderGenes()}getParams(){var t,e,s,i;if(this.mode==h.GENE_VARIANT&&((e=(t=this.vocabApi.termdbConfig)===null||t===void 0?void 0:t.queries)===null||e===void 0?void 0:e.topMutatedGenes)){if(this.vocabApi.termdbConfig.queries.topMutatedGenes.arguments){for(const t of this.vocabApi.termdbConfig.queries.topMutatedGenes.arguments)this.api.topMutatedGenesParams.push({param:t})}}if(this.mode==h.GENE_EXPRESSION&&((i=(s=this.vocabApi.termdbConfig)===null||s===void 0?void 0:s.queries)===null||i===void 0?void 0:i.topVariablyExpressedGenes)){if(this.vocabApi.termdbConfig.queries.topVariablyExpressedGenes.arguments){for(const t of this.vocabApi.termdbConfig.queries.topVariablyExpressedGenes.arguments){if(t.type=="radio"){if(!t.options||t.options.length==0)throw"Radio button must have options";for(const e of t.options){if(e.type=="tree"){e.callback=s=>T(this,void 0,void 0,(function*(){const r=yield import("./app-d215327f.js");const i=s.append("div");yield r.appInit({holder:i,state:{dslabel:e.value,genome:this.genome.name,nav:{header_mode:"search_only"}},tree:{click_term:r=>{s.append("div").classed("ts_pill sja_filter_tag_btn sja_tree_click_term termlabel",true).style("margin","5px").text(`${r.id}`);t.value={type:e.value,geneList:r._geneset.map((t=>t.symbol))};i.selectAll("*").remove()}}})}))}if(e.type=="text"){e.callback=s=>T(this,void 0,void 0,(function*(){s.append("span").style("display","block").style("font-size","0.8em").style("opacity",.75).text("Enter genes separated by spaces or commas");s.append("textarea").style("display","block").on("keyup",r.debounce((function(){const s=this.value.split(/[\s,]+/).map((t=>t.trim())).filter((t=>t!==""));t.value={type:e.value,geneList:s}})),500)}))}if(e.type=="boolean"){e.callback=()=>{t.value={type:e.value,geneList:null}}}}}this.api.topVariablyExpressedGenesParams.push({param:t})}}}}baseGeneMenuArgs(t){t=this.removeDuplicates(t);return{tip:this.tip2,params:t,addOptionalParams:({param:e,input:s})=>{t.push({param:e,input:s})}}}removeDuplicates(t){var e;for(const s of t){if((e=s.param)===null||e===void 0?void 0:e.options){s.param.options.forEach((e=>{if(!e.id)return;const s=t.findIndex((t=>t.param.id==e.id));if(s!=-1)t.splice(s,1)}))}}return t}createMenuList(){var t,e,s,r;if(((t=this.api)===null||t===void 0?void 0:t.topMutatedGenesParams.length)>0){this.menuList.push({label:"Top mutated genes",callback:t=>T(this,void 0,void 0,(function*(){this.tip2.clear().showunder(t.target);const e=()=>T(this,void 0,void 0,(function*(){const t={filter0:this.vocabApi.state.termfilter.filter0};for(const{param:e,input:s}of this.api.topMutatedGenesParams){const r=s.attr("id");t[r]=this.getInputValue({param:e,input:s})}const e=yield this.vocabApi.getTopMutatedGenes(t);this.geneList=[];this.geneList.push(...e.genes);this.renderGenes()}));const s=Object.assign(this.baseGeneMenuArgs(this.api.topMutatedGenesParams),{callback:e});new B(s)}))})}if(((e=this.api)===null||e===void 0?void 0:e.topVariablyExpressedGenesParams.length)>0){this.menuList.push({label:"Top variably expressed genes",callback:t=>{this.api.topVariablyExpressedGenesParams.filter((t=>{var e;return t.param.type=="radio"&&((e=t.param)===null||e===void 0?void 0:e.options)})).forEach((t=>{if(typeof t.param.options[0].value==="string"){t.param.value={type:t.param.options[0].value,value:null}}else{console.error(`Unexpected radio button value type: ${typeof t.param.options[0].value}`)}}));this.tip2.clear().showunder(t.target);const e=()=>T(this,void 0,void 0,(function*(){const t={genome:this.vocabApi.state.vocab.genome,dslabel:this.vocabApi.state.vocab.dslabel};if(this.vocabApi.state.termfilter){if(this.vocabApi.state.termfilter.filter)t.filter=this.vocabApi.state.termfilter.filter;if(this.vocabApi.state.termfilter.filter0)t.filter0=this.vocabApi.state.termfilter.filter0}for(const{param:e,input:s}of this.api.topVariablyExpressedGenesParams){const r=s.attr("id");t[r]=this.getInputValue({param:e,input:s})}const e=yield this.vocabApi.getTopVariablyExpressedGenes(t);this.geneList=[];if(e.genes){for(const t of e.genes)this.geneList.push({gene:t})}this.renderGenes()}));const s=Object.assign(this.baseGeneMenuArgs(this.api.topVariablyExpressedGenesParams),{callback:e});new B(s)}})}if((r=(s=this.genome)===null||s===void 0?void 0:s.termdbs)===null||r===void 0?void 0:r.msigdb){for(const t in this.genome.termdbs){const e=this.genome.termdbs[t];this.menuList.push({label:`${e.label} gene set`,callback:()=>T(this,void 0,void 0,(function*(){this.tip2.clear().showunder(this.api.dom.textControlDiv.node());const e=yield import("./app-d215327f.js");e.appInit({holder:this.tip2.d,state:{dslabel:t,genome:this.genome.name,nav:{header_mode:"search_only"}},tree:{click_term:t=>{this.geneList=[];const e=t._geneset;if(e){for(const t of e)this.geneList.push({gene:t.symbol});this.renderGenes()}this.tip2.hide();this.api.dom.submitBtn.node().focus()}}})}))})}}if(this.customInputs){for(const t of this.customInputs){this.menuList.push({label:t.label,callback:()=>{t.showInput({callback:({geneList:t})=>{this.geneList=t;this.renderGenes()}})},tagName:"button"})}}}renderTextControls(t){for(const e of this.menuList){if(e.tagName=="button")P({div:t,text:e.label,callback:e.callback});else t.append("a").style("text-decoration","underline").style("padding","0px 10px").style("color","black").html(`${e.label} ▼`).on("click",(t=>T(this,void 0,void 0,(function*(){yield e.callback(t)}))))}}getInputValue({param:t,input:e}){if(t.type=="radio")return t.value;const s=e.node().value;if(e.attr("type")=="number")return Number(s);if(e.attr("type")=="checkbox"){if(t.type=="string")return e.node().checked?t.value:"";if(t.type=="boolean")return e.node().checked?1:0}}renderGeneHoldingDiv(t){return t.append("div").append("div").style("display","flex").style("flex-wrap","wrap").style("gap","5px").style("min-height","20px").style("border","solid 1px #aaa").style("margin","15px 0px").style("padding","6px 2px").style("min-height","30px")}renderStatLegend(){if(!this.api.statColor2label||this.api.statColor2label.size==0){this.api.dom.statLegendDiv.style("display","none");return}this.api.dom.statLegendDiv.style("display","block").selectAll("*").remove();for(const[t,e]of this.api.statColor2label){this.api.dom.statLegendDiv.append("div").style("display","inline-block").style("width","12px").style("height","12px").style("background-color",t);this.api.dom.statLegendDiv.append("span").html(` ${e} `)}return this.api.dom.statLegendDiv}addGene(){const t=this.geneSearch.geneSymbol;for(const e of this.geneList){if(e.gene==t){window.alert(`The gene ${t} has already been added`);return}}if(t)this.geneList.push({gene:t});this.renderGenes()}renderGenes(){var t,s,r,i;const o=this.geneList.some((t=>t.mutationStat));if(!o)this.geneList.sort(((t,e)=>{if(t.gene<e.gene)return-1;if(t.gene>e.gene)return 1;return 0}));this.api.dom.geneHoldingDiv.selectAll("*").remove();const a=this.renderGene.bind(this);const n=this.deleteGene.bind(this);this.api.dom.geneHoldingDiv.selectAll("div").data(this.geneList||[]).enter().append("div").attr("aria-label","Click to delete").attr("class","sja_menuoption").attr("tabindex",0).style("position","relative").style("display","inline-block").style("padding","5px 16px 5px 9px").style("margin-left","5px").each((function(t){const s=e(this).style("border-radius","5px");a(s,t);s.on("click",(()=>n(t)))})).on("mouseover",(function(t){const s=e(t.target);s.append("div").style("margin-left","4px").classed("sjpp_deletebt",true).style("display","inline-block").style("position","absolute").style("right","0px").style("top","0px").style("transform","scale(0.6)").style("pointer-events","none").html(`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-x-lg" viewBox="0 0 16 16">\n <path stroke='#f00' d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>\n </svg>`)})).on("mouseout",(function(t){e(t.target).select(".sjpp_deletebt").remove()})).on("focus",(t=>{t.target.dispatchEvent(new PointerEvent("mouseover"))})).on("blur",(t=>{t.target.dispatchEvent(new PointerEvent("mouseout"))})).on("keyup",(t=>{if(t.key=="Enter")t.target.click()}));this.renderStatLegend();this.api.dom.clearBtn.property("disabled",!((t=this.geneList)===null||t===void 0?void 0:t.length));const l=this.origNames!==JSON.stringify(this.geneList.map((t=>t.gene)).sort());(s=this.api.dom.restoreBtn)===null||s===void 0?void 0:s.property("disabled",!l);this.api.dom.submitBtn.property("disabled",!l||((r=this.geneList)===null||r===void 0?void 0:r.length)<this.minNumGenes||!((i=this.geneList)===null||i===void 0?void 0:i.length));if(l)this.api.dom.submitBtn.node().focus()}renderGene(t,e){if(e.mutationStat){t.html(`${e.gene} `);for(const s of e.mutationStat){let e;let r="black";if("class"in s){if(!i[s.class])throw"invalid stat class";e=i[s.class].color;this.api.statColor2label.set(e,i[s.class].label)}else if("dt"in s){if(!o[s["dt"]])throw"invalid stat dt";e=o[s["dt"]];r="white";this.api.statColor2label.set(e,a[s["dt"]])}else{throw"stat missing dt/class"}t.insert("span").style("font-size",".7em").style("background-color",e).style("padding","1px 2px").style("color",r).text(s.count)}}else{t.insert("div").style("display","inline-block").html(e.gene)}}deleteGene(t){const e=this.geneList.findIndex((e=>e.gene===t.gene));if(e!=-1){this.geneList.splice(e,1);this.renderGenes()}}}function L(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-bbfad00d.js");case"../plots/Disco.js":return import("./Disco-b7c9bf72.js");case"../plots/DziViewer.js":return import("./DziViewer-28915c11.js");case"../plots/WSIViewer.js":return import("./WSIViewer-957695a8.js");case"../plots/barchart.data.js":return import("./FilterRxComp-02e68f1b.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-426d737a.js");case"../plots/barchart.js":return import("./barchart-2898d229.js");case"../plots/bars.renderer.js":return import("./bars.renderer-71935d34.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-4c9a5479.js");case"../plots/brainImaging.js":return import("./brainImaging-7716bc66.js");case"../plots/controls.btns.js":return import("./controls.btns-5bf9e7d7.js");case"../plots/controls.config.js":return import("./controls.config-2f0fa061.js");case"../plots/controls.js":return import("./controls-268e40e6.js");case"../plots/cuminc.js":return import("./cuminc-8dffb765.js");case"../plots/dataDownload.js":return import("./dataDownload-452ae3cd.js");case"../plots/dictionary.js":return import("./dictionary-a132a3cc.js");case"../plots/facet.js":return import("./facet-fa4fe49c.js");case"../plots/geneExpression.js":return import("./geneExpression-66208299.js");case"../plots/geneORA.js":return import("./geneORA-9456872c.js");case"../plots/geneset.js":return import("./geneset-0315daf8.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-2601cab5.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-608b924e.js");case"../plots/gsea.js":return import("./gsea-0c0cf8de.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-f4daaf92.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-7f475259.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-7ab62ca5.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-19b79639.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-1ef24562.js");case"../plots/matrix.cells.js":return import("./matrix.cells-a018d731.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-a6e713e8.js");case"../plots/matrix.config.js":return import("./matrix.config-2c550b5d.js");case"../plots/matrix.controls.js":return import("./matrix.controls-42ad4912.js");case"../plots/matrix.data.js":return import("./matrix.data-2b814c9f.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-1e0da5b3.js");case"../plots/matrix.groups.js":return import("./matrix.groups-824a7244.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-1cb56534.js");case"../plots/matrix.js":return import("./matrix-38cd47c3.js");case"../plots/matrix.layout.js":return import("./matrix.layout-47e44357.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-9af0c757.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-337ce240.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-7b7184c9.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-1ac05842.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-1c60c145.js");case"../plots/plot.app.js":return import("./plot.app-2a805759.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-32a484b6.js");case"../plots/plot.disco.js":return import("./plot.disco-1fdfee3c.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-d33113d5.js");case"../plots/profileBarchart.js":return import("./profileBarchart-58f0a8c0.js");case"../plots/profilePlot.js":return import("./profilePlot-4db8ca78.js");case"../plots/profilePolar.js":return import("./profilePolar-50b8e40e.js");case"../plots/profileRadar.js":return import("./profileRadar-fff0b004.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-d6d34c15.js");case"../plots/profileSummary.js":return import("./profileSummary-04b8b15b.js");case"../plots/regression.inputs.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-d79efa9e.js");case"../plots/regression.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-4767144e.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-55d9eb74.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-55d9eb74.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-55d9eb74.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-ef289434.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-1dff3fca.js");case"../plots/scatter.js":return import("./scatter-f8285107.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-eff5760b.js");case"../plots/stattable.js":return import("./stattable-46cde32c.js");case"../plots/summary.js":return import("./summary-a6c15c9e.js");case"../plots/survival.js":return import("./survival-52714cd3.js");case"../plots/table.js":return import("./table-bf40249b.js");case"../plots/variantBrowser.js":return import("./variantBrowser-14d5c3f6.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-bf40ddde.js");case"../plots/violin.js":return import("./violin-74d26b75.js");case"../plots/violin.renderer.js":return import("./violin.renderer-469fa0ff.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}class E{constructor(t={}){this.type="charts";q(this)}async init(t){this.dom={holder:this.opts.holder,tip:new s({padding:"0px"})};this.makeButtons(t)}getState(t){const e=N(t);const s=JSON.parse(JSON.stringify(t.termdbConfig?.supportedChartTypes||{}));const r={vocab:t.vocab,activeCohort:t.activeCohort,termfilter:t.termfilter,supportedChartTypes:s[e]||["summary"],termdbConfig:t.termdbConfig};if(t?.termfilter?.filter){r.filter=j(t.termfilter.filter)}if(!r.supportedChartTypes.includes("dictionary")&&!r.termdbConfig.hiddenChartTypes?.includes("dictionary")){if(r.vocab.dslabel=="ProfileFull"||r.vocab.dslabel=="ProfileAbbrev")r.supportedChartTypes.push(...t.termdbConfig.allowedChartTypes);r.supportedChartTypes.push("dictionary");r.supportedChartTypes.push("facet")}return r}main(){this.dom.btns.style("display",(t=>this.state.supportedChartTypes.includes(t.chartType)?"":"none"))}}const R=n(E);function N(t){if(t?.termdbConfig?.selectCohort?.values){if(!Number.isInteger(t.activeCohort))throw"appState.activeCohort is not integer array index";const e=t.termdbConfig.selectCohort.values[t.activeCohort];if(!e)throw"appState.activeCohort array index out of bound";return[...e.keys].sort().join(",")}return""}function M(t,e){const s=[{label:"Data Dictionary",clickTo:t.prepPlot,chartType:"dictionary",config:{chartType:"dictionary"}},{label:"Sample View",clickTo:t.prepPlot,chartType:"sampleView",config:{chartType:"sampleView"}},{label:"Summary Plots",chartType:"summary",clickTo:t.showTree_select1term,usecase:{target:"summary",detail:"term"}},{label:"Scatter Plot",chartType:"sampleScatter",clickTo:t.loadChartSpecificMenu},{label:"Cumulative Incidence",chartType:"cuminc",clickTo:t.showTree_select1term,usecase:{target:"cuminc",detail:"term"}},{label:"Survival",chartType:"survival",clickTo:t.showTree_select1term,usecase:{target:"survival",detail:"term"}},{label:"Regression Analysis",chartType:"regression",clickTo:t.loadChartSpecificMenu},{label:"Sample Matrix",chartType:"matrix",clickTo:t.loadChartSpecificMenu},{label:"Genome Browser",chartType:"genomeBrowser",clickTo:t.loadChartSpecificMenu},{label:"Differential Expression",chartType:"DEanalysis",clickTo:t.loadChartSpecificMenu},{label:"Data Download",clickTo:t.prepPlot,chartType:"dataDownload",config:{chartType:"dataDownload",terms:[]}},{label:"Facet Table",clickTo:t.loadChartSpecificMenu,chartType:"facet",config:{chartType:"facet"}},{label:"Brain Imaging",clickTo:t.loadChartSpecificMenu,chartType:"brainImaging",config:{chartType:"brainImaging"}},{label:"Single Cell Plot",clickTo:t.loadChartSpecificMenu,chartType:"singleCellPlot",config:{chartType:"singleCellPlot"}},{label:"Gene Expression",chartType:"geneExpression",clickTo:t.showGenesetEditUI,usecase:{target:"geneExpression"}},{label:"Metabolite Intensity",chartType:"metaboliteIntensity",clickTo:t.showTree_selectlst,usecase:{target:"metaboliteIntensity",detail:"term"},updateActionBySelectedTerms:(t,e)=>{const s=e.map((t=>({term:structuredClone(t),q:{mode:f.continuous}})));if(s.length==1){t.config.chartType="summary";t.config.term=s[0];return}if(s.length==2){t.config.chartType="summary";t.config.term=s[0];t.config.term2=s[1];return}t.config.chartType="hierCluster";t.config.dataType=h.METABOLITE_INTENSITY;t.config.termgroups=[{name:"Metabolite Intensity Cluster",lst:s,type:"hierCluster"}]}}];if(e.vocab.dslabel=="ProfileFull"||e.vocab.dslabel=="ProfileAbbrev"){const r=O(t,e);s.unshift(...r)}for(const t in e?.termdbConfig.renamedChartTypes||[]){const r=s.find((e=>e.chartType===t));if(r){r.label=e.termdbConfig.renamedChartTypes[t]}}return s}function O(t,e){const s=[{label:"Profile Polar",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profilePolar",header:"Polar Graph",logged:true}}),chartType:"profilePolar"},{label:"Profile Barchart",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profileBarchart",header:"Barchart Graph",logged:true}}),chartType:"profileBarchart"},{label:"Radar 1-Score-based(Site)",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profileRadarFacility",plot:"plot1",header:"Radar 1-Score-based(Site)",logged:true}}),chartType:"profileRadarFacility"},{label:"Radar 2-Impressions",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profileRadar",plot:"plot1",header:"Radar 2-Impressions",logged:true}}),chartType:"profileRadar"}];if(e.vocab.dslabel=="ProfileFull"){s.push({label:"Radar 3-Score-based(SC & POC)s",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profileRadar",plot:"plot2",header:"Radar 3-Score-based(SC & POC)",logged:true}}),chartType:"profileRadar"})}return s}function q(t){t.makeButtons=function(e){const s=M(t,e);t.dom.btns=t.dom.holder.selectAll("button").data(s).enter().append("button").style("margin","10px").style("padding","10px 15px").style("border-radius","20px").style("border-color","#ededed").html((t=>t.label)).on("click",(function(e,s){t.dom.tip.clear().showunder(this);s.clickTo(s)}))};t.showTree_select1term=async e=>{if(e.usecase.label){t.dom.tip.d.append("div").style("margin","3px 5px").style("padding","3px 5px").style("font-weight",600).html(e.usecase.label)}const s={type:"plot_create",id:F(),config:{chartType:e.chartType}};if(e.parentId)s.parentId=e.parentId;const r=await import("./app-d215327f.js");r.appInit({vocabApi:t.app.vocabApi,holder:t.dom.tip.d.append("div"),state:{activeCohort:t.state.activeCohort,nav:{header_mode:"search_only"},tree:{usecase:e.usecase}},tree:{click_term:r=>{const i=r.term?r:{term:r};s.config[e.usecase.detail]=i;t.dom.tip.hide();t.app.dispatch(s)}}})};t.showGenesetEditUI=async e=>{const s=[];const r=t.app;const i=t.dom.tip;const o=t.dom.tip.d;o.selectAll("*").remove();const a=o.append("div").style("padding","5px");const n=a.append("label");n.append("span").text("Create ");let l;const p=n.append("input").style("margin","2px 5px").style("width","210px").attr("placeholder","Group Name").on("input",(()=>{l=p.property("value")}));const c={index:0,name:l,label:l,lst:[],status:"new"};new G({holder:o.append("div"),genome:r.opts.genome,geneList:s,mode:"geneExpression",vocabApi:r.vocabApi,callback:async({geneList:t,groupName:e})=>{if(!c)throw`missing selectedGroup`;i.hide();const s={name:e||l,lst:[],type:"hierCluster"};const a=s.lst.filter((t=>t.term.type!="geneVariant"));const n=await Promise.all(t.map((async t=>{const e={gene:t.symbol||t.gene,name:t.symbol||t.gene,type:"geneExpression"};let r=s.lst.find((e=>e.term.name==t.symbol||e.term.name==t.gene));if(!r){r={term:e,q:{}}}return r})));if(n.length==1){const t=n[0];r.dispatch({type:"plot_create",config:{chartType:"summary",term:t}});return}if(n.length==2){const t=n[0];const e=n[1];r.dispatch({type:"plot_create",config:{chartType:"summary",term:t,term2:e}});return}s.lst=[...a,...n];if(!s.lst.length)tg.splice(c.index,1);o.selectAll("*").remove();r.dispatch({type:"plot_create",config:{chartType:"hierCluster",termgroups:[s],dataType:h.GENE_EXPRESSION}})}})};t.showTree_selectlst=async e=>{t.dom.tip.clear();if(e.usecase?.label){t.dom.tip.d.append("div").style("margin","3px 5px").style("padding","3px 5px").style("font-weight",600).html(e.usecase.label)}const s={type:"plot_create",id:F(),config:{chartType:e.chartType}};const r=await import("./app-d215327f.js");t.dom.submenu=t.dom.tip.d.append("div");r.appInit({holder:t.dom.submenu,vocabApi:t.app.vocabApi,state:{activeCohort:t.state.activeCohort,nav:{header_mode:"search_only"},tree:{usecase:e.usecase}},tree:{submit_lst:r=>{const i=e.processSelection?e.processSelection(r):r;s.config[e.usecase.detail]=i;if(e.updateActionBySelectedTerms)e.updateActionBySelectedTerms(s,r);t.dom.tip.hide();t.app.dispatch(s)}}})};t.loadChartSpecificMenu=async e=>{t.dom.tip.clear();const s=await L(`../plots/${e.chartType}.js`);s.makeChartBtnMenu(t.dom.tip.d,t)};t.prepPlot=function(e){const s={type:"plot_prep",config:e.config,id:F()};t.app.dispatch(s)}}const V="_CHART_AUTOID_";let $=Date.now();function F(){return V+$++}const H=l(5);class U{constructor(t={}){this.type="groups";this.selectedGroupsIdx=new Set}async init(){this.dom={holder:this.opts.holder.append("div").style("margin","10px")};W(this);this.tip=new s({padding:"0px"})}getState(t){const e=N(t);const s={termfilter:t.termfilter,groups:Y(t),termdbConfig:t.termdbConfig,customTerms:t.customTerms,supportedChartTypes:t.termdbConfig.supportedChartTypes[e],matrixplots:t.termdbConfig.matrixplots};return s}async main(){await X(this)}getMassFilter(){if(!this.state.termfilter.filter||this.state.termfilter.filter.lst.length==0){return{type:"tvslst",in:true,join:"",lst:[]}}const t=j(structuredClone(this.state.termfilter.filter));return t}async groups2samplelst(t){const e=[];const s=new Set,r=[];for(const i of t){const t=await this.app.vocabApi.getFilteredSampleList(i.filter);const o=[];for(const i of t){const t={sampleId:i.id};if("name"in i){t.sample=i.name}if(!s.has(i.id))o.push(t);else{for(const t of e){const e=t.items.findIndex((t=>t.sampleId===i.id));if(e!==-1)r.push(...t.items.splice(e,1))}}s.add(t.sampleId)}if(o.length)e.push({name:i.name,items:o,color:i.color})}if(r.length){const t=confirm('Overlap detected: 1 or more samples belong to >1 groups. A new group will be created for these "overlap" samples.');if(!t)return;e.push({name:"Group overlap",items:r})}const i=e.length==1?e[0].name:"Sample groups";const o=lt(e,i,this.app.vocabApi);if(t.length==1){const t=await this.app.vocabApi.getCohortSampleCount(this.activeCohortName);const e=parseInt(t,10);const s=Object.values(o.term.values).find((t=>t.key.startsWith("Not in")));s.othersGroupSampleNum=e-s.list.length}for(const t of o.q.groups){o.term.values[t.name].list=t.values;o.term.values[t.name].inuse=t.inuse}return o}updateLaunchButton(){this.dom.newTermSpan.style("display","none");this.dom.noGroupSelected.style("display","none");if(this.state.groups.length==0)return;if(this.state.groups.length==1){this.dom.newTermSpan.style("display","");this.dom.launchButton.text(`Create variable using "${this.state.groups[0].name}"`);this.dom.newTermNameInput.property("value",this.state.groups[0].name+" vs others");return}const t=[...this.selectedGroupsIdx];if(t.length==0){this.dom.noGroupSelected.style("display","");return}this.dom.newTermSpan.style("display","");if(t.length==1){this.dom.launchButton.text(`Create variable using "${this.state.groups[t[0]]?.name}"`);this.dom.newTermNameInput.property("value",this.state.groups[t[0]].name+" vs others");return}this.dom.launchButton.text(`Create variable using ${t.length} groups`);this.dom.newTermNameInput.property("value",t.map((t=>this.state.groups[t].name)).join(" vs "))}displayCustomTerms(){this.dom.customTermDiv.selectAll("*").remove();if(this.state.customTerms.length==0){this.dom.customTermDiv.append("div").text("No custom variables. Use above controls to create new ones. Custom variables are added to dictionary.").style("font-size",".8em");return}this.dom.customTermDiv.append("div").style("margin-bottom","10px").style("font-size",".8em").text("Following custom variables are available in all charts where variables are used. Click one to delete.");for(const{name:t,tw:e}of this.state.customTerms){const s=this.dom.customTermDiv.append("div");s.text(t).attr("class","sja_filter_tag_btn").style("padding","3px 6px").style("border-radius","6px").style("margin-right","5px").on("click",(s=>{const r=()=>this.app.vocabApi.deleteCustomTerm(t);this.showGroupsMenu(s,e,r)}))}}newId(){this.lastId=g();return this.lastId}showGroupsMenu(t,e,s){const r=structuredClone(e);this.tip.clear();const i=this.tip.d.append("div");const o=this?.lastId;const a=i.append("div");const n=p({holder:a});for(const[t,s]of Object.entries(e.term.values)){const t=s.color?`<span style="display:inline-block; width:12px; height:12px; background-color:${s.color}" ></span>`:`<span style="display:inline-block; width:11px; height:11px; background-color:${"#fff"}; border: 0.1px solid black" ></span>`;const[e,r]=n.addRow();e.html(`${t} ${s.label}:`);r.html(`${s.othersGroupSampleNum||s.list.length} samples`)}i.append("div");it(this.tip,i,r,this.app,o,this.state,(()=>this.newId));if(this.state.supportedChartTypes.includes("DEanalysis")&&r.q.groups.length==2)J(i,this,this.state,r);if(this.state.supportedChartTypes.includes("survival"))st("survival",i,"Compare survival",this.tip,r,o,this,true);if(this.state.supportedChartTypes.includes("geneExpression"))rt("geneExpression",i,"Gene expression",this.tip,r,o,this,true);if(this.state.supportedChartTypes.includes("cuminc"))st("cuminc",i,"Compare cumulative incidence",this.tip,r,o,this,true);const l=i.append("div").attr("class","sja_menuoption sja_sharp_border").html("Summarize");l.insert("div").html("›").style("float","right");l.on("click",(async t=>{et(l,(t=>{Z(t,r,this.app,o,(()=>this.newId))}),this.app,this.tip)}));i.append("div").attr("class","sja_menuoption sja_sharp_border").text("Delete variable").on("click",(t=>{s();this.tip.hide()}));if(this.state.termdbConfig.scatterplots)for(const t of this.state.termdbConfig.scatterplots){if(t.colorTW)i.append("div").attr("class","sja_menuoption sja_sharp_border").text(`Open ${t.name}`).on("click",(()=>{let e={chartType:"sampleScatter",name:t.name};if(t.sampleCategory)e.sampleCategory={tw:structuredClone(t.sampleCategory.tw),order:t.sampleCategory.order,defaultValue:t.sampleCategory.defaultValue};if(t.sampleType)e.sampleType=t.sampleType;e.colorTW=structuredClone(r);if(t.settings)e.settings=structuredClone(t.settings);this.app.dispatch({type:"plot_create",config:e});this.tip.hide()}))}this.tip.showunder(t.target)}}const z=n(U);function J(t,e,s,r,i){t.append("div").attr("class","sja_menuoption sja_sharp_border").text("Differential expression").on("click",(t=>{const i=[];for(const t of r.q.groups){if(t.values&&t.values.length>0){i.push(t)}else{throw"group does not contain samples for DE analysis"}}const o={chartType:"DEanalysis",state:s,samplelst:{groups:i}};e.tip.hide();e.app.dispatch({type:"plot_create",config:o})}))}function W(t){t.dom.filterTableDiv=t.dom.holder.append("div").style("margin-bottom","10px");const e=t.dom.holder.append("div");t.dom.addNewGroupBtnHolder=e.append("span").style("margin-right","20px");t.dom.newTermSpan=e.append("span");t.dom.newTermSpan.append("span").style("padding-left","15px").text("Add variable:");t.dom.newTermNameInput=t.dom.newTermSpan.append("input").attr("type","text");t.dom.launchButton=t.dom.newTermSpan.append("span").attr("class","sja_menuoption").on("click",(()=>Q(t)));t.dom.noGroupSelected=e.append("span").text("No groups selected").style("opacity",.5);t.dom.customTermDiv=t.dom.holder.append("div").style("margin","20px").style("border-left","solid 1px black").style("padding","10px");t.dom.holder.on("click",(t=>{if(tt)tt.hide()}))}async function X(t){if(!t.filterPrompt)t.filterPrompt=await A({holder:t.dom.addNewGroupBtnHolder,vocabApi:t.app.vocabApi,emptyLabel:"Add group",termdbConfig:t.state.termdbConfig,callback:e=>{ot(t.app,e,t.state.groups)},debug:t.opts.debug});t.filterPrompt.main(t.getMassFilter());const e=structuredClone(t.state.groups);if(!e.length){t.updateLaunchButton();t.dom.filterTableDiv.style("display","none");t.displayCustomTerms();return}t.dom.filterTableDiv.style("display","").selectAll("*").remove();const s={div:t.dom.filterTableDiv,columns:[{label:"NAME",editCallback:async(e,s)=>{const r=s.value;const i=t.state.groups.findIndex((t=>t.name==r));if(i!=-1){alert(`Group named ${r} already exists`);X(t)}else await t.app.dispatch({type:"rename_group",index:e,newName:s.value})}},{label:"COLOR",editCallback:async(e,s)=>{await t.app.dispatch({type:"change_color_group",index:e,newColor:s.color})}},{label:"#SAMPLE"},{label:"FILTER"}],columnButtons:[{text:"Delete",callback:(s,r)=>{const i=e[r];t.app.vocabApi.deleteGroup(i.name)}}],rows:[]};for(const r of e){s.rows.push([{value:r.name},{color:r.color},{value:"n="+await t.app.vocabApi.getFilteredSampleCount(r.filter)},{}])}t.selectedGroupsIdx.clear();if(e.length==1){t.selectedGroupsIdx.add(0)}else{s.noButtonCallback=(e,s)=>{if(s.checked)t.selectedGroupsIdx.add(e);else t.selectedGroupsIdx.delete(e);t.updateLaunchButton()};s.selectedRows=[];for(let r=0;r<e.length;r++){s.selectedRows.push(r);t.selectedGroupsIdx.add(r)}}C(s);for(const[r,i]of s.rows.entries()){const s=e[r];x({holder:i[3].__td,vocabApi:t.app.vocabApi,termdbConfig:t.state.termdbConfig,callback:r=>{if(!r||r.lst.length==0){const t=e.findIndex((t=>t.name==s.name));e.splice(t,1)}else{s.filter=r}t.app.dispatch({type:"app_refresh",state:{groups:e}})}}).main(s.filter)}t.updateLaunchButton();t.displayCustomTerms()}async function Q(t){const e=[];for(const s of t.selectedGroupsIdx){const r=t.state.groups[s];if(r)e.push(r)}if(e.length==0)throw"No groups, should not happen";const s=t.dom.newTermNameInput.property("value");const r=await t.groups2samplelst(e);if(!r)return;r.term.name=s;t.app.vocabApi.addCustomTerm({name:s,tw:r});t.dom.newTermSpan.style("display","none")}function Y(t){if(!t.termfilter?.filter||t.termfilter.filter.lst.length==0){return t.groups}const e=[];for(const s of t.groups){const r=j(structuredClone(t.termfilter.filter));const i=y(s.filter,"filterUiRoot");if(!i){e.push(s);continue}r.lst.push(i);r.join=r.lst.length>1?"and":"";const o={name:s.name,filter:r,color:s.color};e.push(o)}return e}async function K(t,e,s,r,i,o){let a={chartType:t,term:e,term2:s};if(i)a.insertBefore=i;if(o)a.id=o();await r.dispatch({type:"plot_create",config:a})}async function Z(t,e,s,r,i){const o=t.term?t:{term:t};let a={chartType:"summary",childType:"barchart",term:o,term2:e};if(r)a.insertBefore=r;if(i)a.id=i();await s.dispatch({type:"plot_create",config:a})}let tt;async function et(t,e,r,i,o={tree:{usecase:{target:"default",detail:"term"}}},a=true,n=true,l=[]){if(!tt)tt=new s({padding:0,offsetX:162,offsetY:-34,parent_menu:i.d.node()});tt.clear();if(n)tt.showunderoffset(t.node());else tt.showunder(t.node());w({holder:tt.d,vocabApi:r.vocabApi,state:o,tree:{disable_terms:l,click_term:t=>{e(t);tt.hide();if(a)i.hide()}}})}function st(t,e,s,r,i,o,a,n=false){const l=e.append("div").attr("class","sja_menuoption sja_sharp_border").html(`${s} ›`).on("click",(e=>{const s={tree:{usecase:{target:t,detail:"term"}}};if(t=="survival")s.nav={header_mode:"hide_search"};et(l,(e=>{K(t,e,i,a.app,o,n?()=>a.newId:null)}),a.app,r,s)}))}function rt(t,e,r,i,o,a,n,l=false){const p=e.append("div").attr("class","sja_menuoption sja_sharp_border").html(`${r} ›`).on("click",(()=>{if(!tt)tt=new s({padding:0,offsetX:162,offsetY:-34,parent_menu:i.d.node()});tt.clear();tt.showunderoffset(p.node());new G({holder:tt.d,genome:n.app.opts.genome,geneList:[],vocabApi:n.app.vocabApi,callback:async({geneList:t,groupName:e})=>{i.hide();const s={name:e,lst:[],type:"hierCluster"};const r=s.lst.filter((t=>t.term.type!="geneExpression"));const a=await Promise.all(t.map((async t=>{const e={gene:t.symbol||t.gene,name:t.symbol||t.gene,type:"geneExpression"};let r=s.lst.find((e=>e.term.name==t.symbol||e.term.name==t.gene));if(!r){r={term:e,q:{}}}return r})));tt.d.selectAll("*").remove();if(a.length==1){const t=a[0];n.app.dispatch({type:"plot_create",config:{chartType:"summary",term:t,term2:o}});return}if(a.length==2){const t=a[0];const e=a[1];n.app.dispatch({type:"plot_create",config:{chartType:"summary",term:t,term2:e,colorTW:o}});return}s.lst=[...r,...a];n.app.dispatch({type:"plot_create",config:{chartType:"hierCluster",termgroups:[s],dataType:h.GENE_EXPRESSION,divideBy:o,settings:{hierCluster:{yDendrogramHeight:0,clusterSamples:false}}}})}})}))}function it(t,e,s,r,i,o,a){if(o.matrixplots){for(const n of o.matrixplots){e.append("div").attr("class","sja_menuoption sja_sharp_border").text(n.name).on("click",(async()=>{const e=await r.vocabApi.getMatrixByName(n.name);e.divideBy=s;e.insertBefore=i;e.settings.matrix.colw=0;if(a)e.id=a();r.dispatch({type:"plot_create",config:e});t.hide()}))}}}function ot(t,e,s){s=JSON.parse(JSON.stringify(s));let r="New group";let i=0;while(1){const t=r+(i==0?"":" "+i);if(!s.find((e=>e.name==t)))break;i++}r=r+(i==0?"":" "+i);const o={name:r,filter:e,color:c(H(s.length)).formatHex()};s.push(o);t.dispatch({type:"app_refresh",state:{groups:s}})}function at(t){let e=0;let s=true;for(const r in t.term.values){const i=t.q.groups[e].values;t.term.values[r].list=i;if(i[0]&&"sample"in i[0])s=false;e++}const r={type:"tvslst",in:true,join:"",lst:[{type:"tvs",tvs:{term:t.term},noEdit:s}]};return r}function nt(t){const e={name:"",index:0,items:[{sampleId:t}]};const s=lt([e],"",false);const r=at(s);return r}function lt(t,e="groups",s=true){const r={};const i=[];let o;for(const e of t){o=n(e);const t={name:e.name,in:true,values:o};i.push(t);r[e.name]={key:e.name,label:e.name,color:e.color,list:o}}if(t.length==1&&s){const e="Not in "+t[0].name;r[e]={key:e,label:e,color:"#aaa",list:o};i.push({name:e,in:false,values:o})}const a={isAtomic:true,term:{name:e,type:"samplelst",values:r},q:{groups:i}};return a;function n(t){const e=[];for(const s of t.items){const t={sampleId:s.sampleId};if("sample"in s){t.sample=s.sample}e.push(t)}return e}}function pt(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-bbfad00d.js");case"../plots/Disco.js":return import("./Disco-b7c9bf72.js");case"../plots/DziViewer.js":return import("./DziViewer-28915c11.js");case"../plots/WSIViewer.js":return import("./WSIViewer-957695a8.js");case"../plots/barchart.data.js":return import("./FilterRxComp-02e68f1b.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-426d737a.js");case"../plots/barchart.js":return import("./barchart-2898d229.js");case"../plots/bars.renderer.js":return import("./bars.renderer-71935d34.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-4c9a5479.js");case"../plots/brainImaging.js":return import("./brainImaging-7716bc66.js");case"../plots/controls.btns.js":return import("./controls.btns-5bf9e7d7.js");case"../plots/controls.config.js":return import("./controls.config-2f0fa061.js");case"../plots/controls.js":return import("./controls-268e40e6.js");case"../plots/cuminc.js":return import("./cuminc-8dffb765.js");case"../plots/dataDownload.js":return import("./dataDownload-452ae3cd.js");case"../plots/dictionary.js":return import("./dictionary-a132a3cc.js");case"../plots/facet.js":return import("./facet-fa4fe49c.js");case"../plots/geneExpression.js":return import("./geneExpression-66208299.js");case"../plots/geneORA.js":return import("./geneORA-9456872c.js");case"../plots/geneset.js":return import("./geneset-0315daf8.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-2601cab5.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-608b924e.js");case"../plots/gsea.js":return import("./gsea-0c0cf8de.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-f4daaf92.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-7f475259.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-7ab62ca5.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-19b79639.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-1ef24562.js");case"../plots/matrix.cells.js":return import("./matrix.cells-a018d731.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-a6e713e8.js");case"../plots/matrix.config.js":return import("./matrix.config-2c550b5d.js");case"../plots/matrix.controls.js":return import("./matrix.controls-42ad4912.js");case"../plots/matrix.data.js":return import("./matrix.data-2b814c9f.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-1e0da5b3.js");case"../plots/matrix.groups.js":return import("./matrix.groups-824a7244.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-1cb56534.js");case"../plots/matrix.js":return import("./matrix-38cd47c3.js");case"../plots/matrix.layout.js":return import("./matrix.layout-47e44357.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-9af0c757.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-337ce240.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-7b7184c9.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-1ac05842.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-1c60c145.js");case"../plots/plot.app.js":return import("./plot.app-2a805759.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-32a484b6.js");case"../plots/plot.disco.js":return import("./plot.disco-1fdfee3c.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-d33113d5.js");case"../plots/profileBarchart.js":return import("./profileBarchart-58f0a8c0.js");case"../plots/profilePlot.js":return import("./profilePlot-4db8ca78.js");case"../plots/profilePolar.js":return import("./profilePolar-50b8e40e.js");case"../plots/profileRadar.js":return import("./profileRadar-fff0b004.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-d6d34c15.js");case"../plots/profileSummary.js":return import("./profileSummary-04b8b15b.js");case"../plots/regression.inputs.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-d79efa9e.js");case"../plots/regression.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-4767144e.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-55d9eb74.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-55d9eb74.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-55d9eb74.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-ef289434.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-1dff3fca.js");case"../plots/scatter.js":return import("./scatter-f8285107.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-eff5760b.js");case"../plots/stattable.js":return import("./stattable-46cde32c.js");case"../plots/summary.js":return import("./summary-a6c15c9e.js");case"../plots/survival.js":return import("./survival-52714cd3.js");case"../plots/table.js":return import("./table-bf40249b.js");case"../plots/variantBrowser.js":return import("./variantBrowser-14d5c3f6.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-bf40ddde.js");case"../plots/violin.js":return import("./violin-74d26b75.js");case"../plots/violin.renderer.js":return import("./violin.renderer-469fa0ff.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}function ct(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-bbfad00d.js");case"../plots/Disco.js":return import("./Disco-b7c9bf72.js");case"../plots/DziViewer.js":return import("./DziViewer-28915c11.js");case"../plots/WSIViewer.js":return import("./WSIViewer-957695a8.js");case"../plots/barchart.data.js":return import("./FilterRxComp-02e68f1b.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-426d737a.js");case"../plots/barchart.js":return import("./barchart-2898d229.js");case"../plots/bars.renderer.js":return import("./bars.renderer-71935d34.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-4c9a5479.js");case"../plots/brainImaging.js":return import("./brainImaging-7716bc66.js");case"../plots/controls.btns.js":return import("./controls.btns-5bf9e7d7.js");case"../plots/controls.config.js":return import("./controls.config-2f0fa061.js");case"../plots/controls.js":return import("./controls-268e40e6.js");case"../plots/cuminc.js":return import("./cuminc-8dffb765.js");case"../plots/dataDownload.js":return import("./dataDownload-452ae3cd.js");case"../plots/dictionary.js":return import("./dictionary-a132a3cc.js");case"../plots/facet.js":return import("./facet-fa4fe49c.js");case"../plots/geneExpression.js":return import("./geneExpression-66208299.js");case"../plots/geneORA.js":return import("./geneORA-9456872c.js");case"../plots/geneset.js":return import("./geneset-0315daf8.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-2601cab5.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-608b924e.js");case"../plots/gsea.js":return import("./gsea-0c0cf8de.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-f4daaf92.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-7f475259.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-7ab62ca5.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-19b79639.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-1ef24562.js");case"../plots/matrix.cells.js":return import("./matrix.cells-a018d731.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-a6e713e8.js");case"../plots/matrix.config.js":return import("./matrix.config-2c550b5d.js");case"../plots/matrix.controls.js":return import("./matrix.controls-42ad4912.js");case"../plots/matrix.data.js":return import("./matrix.data-2b814c9f.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-1e0da5b3.js");case"../plots/matrix.groups.js":return import("./matrix.groups-824a7244.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-1cb56534.js");case"../plots/matrix.js":return import("./matrix-38cd47c3.js");case"../plots/matrix.layout.js":return import("./matrix.layout-47e44357.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-9af0c757.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-337ce240.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-7b7184c9.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-1ac05842.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-1c60c145.js");case"../plots/plot.app.js":return import("./plot.app-2a805759.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-32a484b6.js");case"../plots/plot.disco.js":return import("./plot.disco-1fdfee3c.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-d33113d5.js");case"../plots/profileBarchart.js":return import("./profileBarchart-58f0a8c0.js");case"../plots/profilePlot.js":return import("./profilePlot-4db8ca78.js");case"../plots/profilePolar.js":return import("./profilePolar-50b8e40e.js");case"../plots/profileRadar.js":return import("./profileRadar-fff0b004.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-d6d34c15.js");case"../plots/profileSummary.js":return import("./profileSummary-04b8b15b.js");case"../plots/regression.inputs.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-d79efa9e.js");case"../plots/regression.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-4767144e.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-55d9eb74.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-55d9eb74.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-55d9eb74.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-ef289434.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-1dff3fca.js");case"../plots/scatter.js":return import("./scatter-f8285107.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-eff5760b.js");case"../plots/stattable.js":return import("./stattable-46cde32c.js");case"../plots/summary.js":return import("./summary-a6c15c9e.js");case"../plots/survival.js":return import("./survival-52714cd3.js");case"../plots/table.js":return import("./table-bf40249b.js");case"../plots/variantBrowser.js":return import("./variantBrowser-14d5c3f6.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-bf40ddde.js");case"../plots/violin.js":return import("./violin-74d26b75.js");case"../plots/violin.renderer.js":return import("./violin.renderer-469fa0ff.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}function dt(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-bbfad00d.js");case"../plots/Disco.js":return import("./Disco-b7c9bf72.js");case"../plots/DziViewer.js":return import("./DziViewer-28915c11.js");case"../plots/WSIViewer.js":return import("./WSIViewer-957695a8.js");case"../plots/barchart.data.js":return import("./FilterRxComp-02e68f1b.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-426d737a.js");case"../plots/barchart.js":return import("./barchart-2898d229.js");case"../plots/bars.renderer.js":return import("./bars.renderer-71935d34.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-4c9a5479.js");case"../plots/brainImaging.js":return import("./brainImaging-7716bc66.js");case"../plots/controls.btns.js":return import("./controls.btns-5bf9e7d7.js");case"../plots/controls.config.js":return import("./controls.config-2f0fa061.js");case"../plots/controls.js":return import("./controls-268e40e6.js");case"../plots/cuminc.js":return import("./cuminc-8dffb765.js");case"../plots/dataDownload.js":return import("./dataDownload-452ae3cd.js");case"../plots/dictionary.js":return import("./dictionary-a132a3cc.js");case"../plots/facet.js":return import("./facet-fa4fe49c.js");case"../plots/geneExpression.js":return import("./geneExpression-66208299.js");case"../plots/geneORA.js":return import("./geneORA-9456872c.js");case"../plots/geneset.js":return import("./geneset-0315daf8.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-2601cab5.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-608b924e.js");case"../plots/gsea.js":return import("./gsea-0c0cf8de.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-f4daaf92.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-7f475259.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-7ab62ca5.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-19b79639.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-1ef24562.js");case"../plots/matrix.cells.js":return import("./matrix.cells-a018d731.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-a6e713e8.js");case"../plots/matrix.config.js":return import("./matrix.config-2c550b5d.js");case"../plots/matrix.controls.js":return import("./matrix.controls-42ad4912.js");case"../plots/matrix.data.js":return import("./matrix.data-2b814c9f.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-1e0da5b3.js");case"../plots/matrix.groups.js":return import("./matrix.groups-824a7244.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-1cb56534.js");case"../plots/matrix.js":return import("./matrix-38cd47c3.js");case"../plots/matrix.layout.js":return import("./matrix.layout-47e44357.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-9af0c757.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-337ce240.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-7b7184c9.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-1ac05842.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-1c60c145.js");case"../plots/plot.app.js":return import("./plot.app-2a805759.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-32a484b6.js");case"../plots/plot.disco.js":return import("./plot.disco-1fdfee3c.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-d33113d5.js");case"../plots/profileBarchart.js":return import("./profileBarchart-58f0a8c0.js");case"../plots/profilePlot.js":return import("./profilePlot-4db8ca78.js");case"../plots/profilePolar.js":return import("./profilePolar-50b8e40e.js");case"../plots/profileRadar.js":return import("./profileRadar-fff0b004.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-d6d34c15.js");case"../plots/profileSummary.js":return import("./profileSummary-04b8b15b.js");case"../plots/regression.inputs.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-d79efa9e.js");case"../plots/regression.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-4767144e.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-55d9eb74.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-55d9eb74.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-55d9eb74.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-ef289434.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-1dff3fca.js");case"../plots/scatter.js":return import("./scatter-f8285107.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-eff5760b.js");case"../plots/stattable.js":return import("./stattable-46cde32c.js");case"../plots/summary.js":return import("./summary-a6c15c9e.js");case"../plots/survival.js":return import("./survival-52714cd3.js");case"../plots/table.js":return import("./table-bf40249b.js");case"../plots/variantBrowser.js":return import("./variantBrowser-14d5c3f6.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-bf40ddde.js");case"../plots/violin.js":return import("./violin-74d26b75.js");case"../plots/violin.renderer.js":return import("./violin.renderer-469fa0ff.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}const mt="_MASS_AUTOID_"+Math.random().toString().slice(-6);let ut=(+new Date).toString().slice(-8);function ht(){return mt+"_"+ut++}const ft=new Set(["with_tabs","hidden","search_only","hide_search","only_buttons","with_cohortHtmlSelect"]);const gt={nav:{header_mode:"with_tabs",activeTab:0},activeCohort:0,search:{isVisible:true},plots:[],termfilter:{filter:{type:"tvslst",in:true,join:"",lst:[]}},reuse:{customTermQ:{byId:{},byName:{}}},groups:[],customTerms:[],autoSave:true};class bt{constructor(t){this.type="store";this.defaultState=gt;this.prevGeneratedId=0}validateOpts(t){const e=t.state;if(e.vocab.dslabel){if(!e.vocab.genome)throw".state[.vocab].genome missing"}else{if(!Array.isArray(e.vocab.terms))throw"vocab.terms must be an array of objects"}}validateState(){if(!ft.has(this.state.nav.header_mode))throw"invalid state.nav.header_mode"}async init(){try{this.state.termdbConfig=await this.app.vocabApi.getTermdbConfig();await this.setTermfilter();await this.rehydrateGroups();await this.app.vocabApi.main({termfilter:JSON.parse(JSON.stringify(this.state.termfilter)),termdbConfig:this.state.termdbConfig});const t=[];for(const[e,s]of this.state.plots.entries()){let r;try{const t=await dt(`../plots/${s.chartType}.js`);r=await t.getPlotConfig(s,this.app)}catch(t){this.app.printError(t);console.error(`getPlotConfig() failed: ${t}`)}if(!r){t.push(e);continue}this.state.plots[e]=r;if(!("id"in r))r.id=`_AUTOID_${ut++}_${e}`;if(r.mayAdjustConfig)r.mayAdjustConfig(r)}if(t.length){for(const e of t){this.state.plots.splice(e,1)}}}catch(t){throw t}}setId(t){t.$id=this.prevGeneratedId++;if(t.$lst){for(const e of t.$lst){this.setId(e)}}}async setTermfilter(){let t=y(this.state.termfilter.filter,"filterUiRoot");if(!t){this.state.termfilter.filter.tag="filterUiRoot";t=this.state.termfilter.filter}await Promise.all(_(this.state.termfilter.filter,this.app.vocabApi));if(!this.state.termdbConfig.selectCohort){this.state.activeCohort=-1;if(this.state.activeTab===0)this.state.activeTab=1;if(this.state.nav.header_mode==="with_cohortHtmlSelect"){console.warn(`no termdbConfig.selectCohort to use for nav.header_mode = 'with_cohortHtmlSelect'`);this.state.nav.header_mode="search_only"}}else{let e=y(this.state.termfilter.filter,"cohortFilter");if(!e){e={tag:"cohortFilter",type:"tvs",tvs:{term:JSON.parse(JSON.stringify(this.state.termdbConfig.selectCohort.term)),values:this.state.activeCohort==-1?[]:this.state.termdbConfig.selectCohort.values[this.state.activeCohort].keys.map((t=>({key:t,label:t})))}};this.state.termfilter.filter={type:"tvslst",in:true,join:"and",lst:[e,t]}}else{const t=(t,e)=>t<e?-1:1;e.tvs.values.sort(((t,e)=>t.key<e.key?-1:1));const s=JSON.stringify(e.tvs.values.map((t=>t.key)).sort(t));const r=this.state.termdbConfig.selectCohort.values.findIndex((e=>s==JSON.stringify(e.keys.sort(t))));if(this.state.activeCohort!==-1&&this.state.activeCohort!==0&&r!==this.state.activeCohort){console.log("Warning: cohortFilter will override the state.activeCohort due to mismatch")}this.state.activeCohort=r}}}async rehydrateGroups(){const t=[];for(const e of this.state.groups){t.push(..._(e.filter,this.app.vocabApi))}await Promise.all(t)}}bt.prototype.actions={app_refresh(t={}){this.state=this.copyMerge(this.toJson(this.state),t.state||{});const e=new Set;if(t.subactions){for(const s of t.subactions){this.actions[s.type].call(this,s);if(s.type.startsWith("plot_"))e.add(s.id)}}for(const s in this.state.plots){if(s.mayAdjustConfig&&!e.has(s.id)){s.mayAdjustConfig(s,t.config)}}},tab_set(t){this.state.nav.activeTab=t.activeTab},cohort_set(t){this.state.activeCohort=t.activeCohort;const e=this.state.termdbConfig.selectCohort.values[t.activeCohort];const s=y(this.state.termfilter.filter,"cohortFilter");if(!s)throw`No item tagged with 'cohortFilter'`;s.tvs.values=e.keys.map((t=>({key:t,label:t})))},async plot_prep(t){const e={id:"id"in t?t.id:ht()};if(!t.config)throw".config{} missing for plot_prep";if(t.config.chartType&&Object.keys(t.config).length==1){const e=await ct(`../plots/${t.config.chartType}.js`);const s=await e.getPlotConfig(t.config,this.app);t.config=Object.assign(s,t.config)}Object.assign(e,t.config);this.state.plots.push(e)},async plot_create(t){const e=await pt(`../plots/${t.config.chartType}.js`);const s=await e.getPlotConfig(t.config,this.app);if(!("id"in t))t.id=ht();s.id=t.id;if(s.mayAdjustConfig){s.mayAdjustConfig(s,t.config)}this.state.plots.push(s)},plot_edit(t){const e=this.state.plots.find((e=>e.id===t.id));if(!e)throw`missing plot id='${t.id}' in store.plot_edit()`;this.copyMerge(e,t.config,t.opts?t.opts:{});if(e.mayAdjustConfig){e.mayAdjustConfig(e,t.config)}if(t.config&&"cutoff"in t.config){e.cutoff=t.config.cutoff}else{delete e.cutoff}},plot_delete(t){const e=this.state.plots.findIndex((e=>e.id===t.id));if(e!==-1)this.state.plots.splice(e,1)},plot_nestedEdits(t){const e=this.state.plots.find((e=>e.id===t.id));if(!e)throw`missing plot id='${t.id}' in store.plot_edit_nested`;for(const s of t.edits){const t=s.nestedKeys.pop();const r=s.nestedKeys.reduce(((t,e)=>t[e]),e);r[t]=s.value}},async plot_splice(t){for(const e of t.subactions){await this.actions[e.type].call(this,e)}},filter_replace(t){if("filter0"in t){this.state.termfilter.filter0=t.filter0;return}const e=t.filter?t.filter:{type:"tvslst",join:"",in:1,lst:[]};if(!t.filter.tag){this.state.termfilter.filter=e}else{const s=y(this.state.termfilter.filter,t.filter.tag);if(!s)throw`cannot replace missing filter with tag '${t.filter.tag}'`;const r=v(this.state.termfilter.filter,s.$id);if(r==s){this.state.termfilter.filter=e}else{const t=r.lst.indexOf(s);r.lst[t]=e}}},cache_termq({termId:t,q:e}){if(!t)throw`missing termId for caching custom term.q`;if(!e?.reuseId)throw`missing or empty tw.q.reuseId as cache identifier for term='${t}'`;const s=this.state.reuse.customTermQ.byId;if(!s[t])s[t]={};s[t][e.reuseId]=e;for(const t of this.state.plots){if(!(t.chartType in yt))continue;const s=yt[t.chartType](t);for(const t of s){if(t?.q?.reuseId===e.reuseId)t.q=e}}},uncache_termq({term:t,q:e}){if(!t.id)throw`missing term.id for uncaching custom term.q`;if(!e.reuseId)throw`missing qname as uncache identifier for term.id='${t.id}'`;const s=this.state.reuse.customTermQ.byId[t.id];if(!s)throw`missing term.q cache for term.id='${t.id}`;if(!(e.reuseId in s))console.warn(`q.reuseId='${e.cacheid}' not cached for term.id='${t.id}'`);else{delete s[e.reuseId];for(const t of this.state.plots){if(!(t.chartType in yt))continue;const s=yt[t.chartType](t);for(const t of s){if(t.q.reuseId===e.reuseId){delete t.q.reuseId;delete t.q.name}}}}},add_customTerm(t){this.state.customTerms.push(t.obj)},delete_customTerm({name:t}){const e=this.state.customTerms.findIndex((e=>e.name==t));if(e!=-1)this.state.customTerms.splice(e,1)},add_group(t){if(this.state.nav.header_mode!="hidden"){const e=t.obj;const s=`Group ${this.state.groups.length+1}`;const r=lt([e]);const i={name:s,filter:at(r),plotId:e.plotId};this.state.groups.push(i);this.state.nav.activeTab=1}else if("plotId"in t.obj){const e=this.state.plots.find((e=>e.id==t.obj.plotId));if(e.groups){t.obj.index=e.groups.length;t.obj.name=`Group ${e.groups.length+1}`;e.groups.push(t.obj)}}},rename_group(t){const e=t.index;const s=t.newName;if(this.state.nav.header_mode!="hidden"){this.state.groups[e].name=s}else{for(const t of this.state.plots){if(t?.groups){t.groups[e].name=s}}}},change_color_group(t){const e=t.index;const s=t.newColor;if(this.state.nav.header_mode!="hidden"){this.state.groups[e].color=s}else{for(const t of this.state.plots){if(t?.groups){t.groups[e].color=s}}}},delete_group({name:t}){if(this.state.nav.header_mode!="hidden"){const e=this.state.groups.findIndex((e=>e.name==t));if(e!=-1)this.state.groups.splice(e,1)}else{for(const e of this.state.plots){if(e?.groups){const s=e.groups.findIndex((e=>e.name==t));if(s!=-1)e.groups.splice(s,1)}}}}};const jt=t=>[t.term0,t.term,t.term2].filter((t=>!!t));const yt={summary:jt,survival:jt,cuminc:jt,regression:t=>[t.outcome,...t.independent].filter((t=>!!t)),matrix:t=>t.termgroups.reduce(((t,e)=>{t.push(...e.lst);return t}),[])};const vt=d(bt);class xt{constructor(t={}){this.type="recover";this.initialHolderDisplay=t.holder.style("display");this.dom={holder:t.holder,btnDiv:t.holder.append("div").style("position","sticky").style("top","12px").style("right","20px").style("margin",t.margin?t.margin:"10px").style("text-align","right")};this.hasStatePreMain=true;this.reactsTo=t.reactsTo||(()=>true);this.getState=t.getState||(t=>t);this.debouncedTrack=()=>{this.trackPending=true;this.trackState();this.render()};this.wait="wait"in t?t.wait:800;this.maxHistoryLen=t.maxHistoryLen||10}preApiFreeze(t){t.replaceLastState=t=>{if(this.isRecovering)return;this.state=this.getState(t);if(!this.trackPending)this.history[this.currIndex]=this.state}}init(){this.app.register(this.api);this.currIndex=-1;this.history=[];this.isActive=!isNaN(this.maxHistoryLen)&&+this.maxHistoryLen>0;if(this.isActive){Ct(this);this.initUi()}this.eventTypes=["postInit","postRender"]}async main(){if(!this.isActive)return;if(this.opts.hide?.(this.state)){this.dom.holder.style("display","none");return}this.dom.holder.style("display",this.initialHolderDisplay||"");if(!this.timedTrack){this.trackState();this.trackPending=true;this.timedTrack=setTimeout((()=>{}),this.wait);return}clearTimeout(this.timedTrack);this.trackPending=true;this.timedTrack=setTimeout(this.debouncedTrack,this.wait)}trackState(){if(this.isRecovering){this.isRecovering=false;return}if(this.state._scope_=="none")return;this.isRecovering=false;const t=this.opts.adjustTrackedState?this.opts.adjustTrackedState(this.state):this.state;if(!t){console.error("no state to track");return}if(!Object.isFrozen(t))m(t);if(this.currIndex==-1)this.origState=t;if(this.currIndex<this.history.length-1){this.history.splice(this.currIndex,this.history.length-(this.currIndex+1))}if(u(t,this.history[this.history.length-1]))return;this.history.push(t);this.currIndex+=1;if(this.history.length>this.maxHistoryLen){this.history.splice(1,1);this.currIndex+=-1}this.trackPending=false}goto(t){if(t<0&&this.currIndex+t>-1)this.currIndex+=t;else if(t>0&&this.currIndex+t<this.history.length)this.currIndex+=t;else return;this.isRecovering=true;const e=this.history[this.currIndex];this.render();if(this.opts.plot_id){const t=structuredClone(e);this.app.dispatch({type:"plot_edit",id:this.opts.plot_id,config:t.config,_scope_:t._scope_})}else{this.app.dispatch({type:"app_refresh",state:e})}}reset(){this.currIndex=0;this.isRecovering=true;const t=this.origState;if(this.opts.plot_id){const e=t.plots.find((t=>t.id===this.opts.plot_id));this.app.dispatch({type:"plot_edit",id:this.opts.plot_id,config:structuredClone(e)})}else this.app.dispatch({type:"app_refresh",state:t})}}const wt=n(xt);function Ct(t){t.initUi=function(){t.dom.undoBtn=t.dom.btnDiv.append("button").attr("aria-label","undo the previous action").property("disabled",true).style("margin","0 0 0 4px").style("border","1px solid #ccc").style("vertical-align","middle").html(t.opts.undoHtml||`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-arrow-counterclockwise" viewBox="0 0 16 16" style='vertical-align: middle'>\n\t\t\t <path stroke='#000' stroke-width='0.25' fill-rule="evenodd" d="M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2v1z"/>\n\t\t\t <path d="M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466z"/>\n\t\t\t</svg>`).on("click",(()=>t.goto(-1)));t.dom.redoBtn=t.dom.btnDiv.append("button").attr("aria-label","redo a subsequent action").property("disabled",true).style("margin",t.opts.resetHtml?"0":"0 4px 0 0").style("border","1px solid #ccc").style("vertical-align","middle").html(t.opts.redoHtml||`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-arrow-clockwise" viewBox="0 0 16 16" style='vertical-align: middle'>\n\t\t\t <path stroke='#000' stroke-width='0.25' fill-rule="evenodd" d="M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2v1z"/>\n\t\t\t <path d="M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 4.658A.25.25 0 0 1 8 4.466z"/>\n\t\t\t</svg>`).on("click",(()=>t.goto(1)));if(t.opts.resetHtml)t.dom.resetBtn=t.dom.btnDiv.append("button").attr("aria-label","Restore the initial rendered state").property("disabled",true).style("margin","0 4px 0 0").style("border","1px solid #ccc").style("vertical-align","middle").html(t.opts.resetHtml).on("click",(()=>t.reset()))};t.render=function(){if(t.dom.undoBtn)t.dom.undoBtn.property("disabled",t.currIndex<1||t.history.length===1);if(t.dom.redoBtn)t.dom.redoBtn.property("disabled",t.history.length<2||t.currIndex>=t.history.length-1);if(t.dom.resetBtn)t.dom.resetBtn.property("disabled",t.currIndex===0)}}export{G,lt as a,at as b,R as c,ot as d,it as e,st as f,z as g,et as h,N as i,Y as j,nt as k,Z as o,wt as r,vt as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as t,h as e,b as i}from"./termsetting-ad8c4f3a.js";import{h as s,P as n,y as r,M as o,d as a}from"./app-2cd97738.js";import"./FilterRxComp-0f35b322.js";import{g as p}from"./termdb.bins-01e8cce6.js";import{InputValuesTable as c}from"./regression.inputs.values.table-1753d56b.js";import{mayRunSnplstTask as d}from"./snplst.sampleSum-e47d05f0.js";import{R as l}from"./regression.results-6f85a5dc.js";class m{constructor(t){this.type="regression";this.genomeObj=t.app.opts.genome}async init(t){this.dom={header:this.opts.header,errordiv:this.opts.holder.append("div"),inputs:this.opts.holder.append("div").style("margin","20px 10px"),results:this.opts.holder.append("div").style("margin-left","40px")};const e=t.plots.find((t=>t.id===this.id));this.inputs=new O({app:this.app,parent:this,id:this.id,holder:this.dom.inputs,regressionType:e.regressionType});this.results=new l({app:this.app,parent:this,id:this.id,holder:this.dom.results,regressionType:e.regressionType})}getState(t,e){const i=t.plots.find((t=>t.id===this.id));if(!i){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}if(!i.regressionType)throw"regressionType is required";return{vocab:t.vocab,formIsComplete:i.outcome&&i.independent.length,activeCohort:t.activeCohort,termfilter:t.termfilter,config:i,allowedTermTypes:t.termdbConfig.allowedTermTypes,minTimeSinceDx:t.termdbConfig.minTimeSinceDx}}async main(){try{this.config=JSON.parse(JSON.stringify(this.state.config));this.mayUpdateSandboxHeader();this.getFilter();await this.inputs.main();await this.results.main();this.inputs.resetSubmitButton()}catch(t){if(this.inputs.hasError){this.results.main()}r(this.dom.errordiv,"Error: "+(t.error||t));if(t.stack)console.log(t.stack)}}mayUpdateSandboxHeader(){if(!this.dom.header)return;const t=this.config.outcome;this.dom.header.html((t?t.term.name:"")+'<span style="opacity:.6;font-size:.7em;margin-left:10px;">'+this.config.regressionType.toUpperCase()+" REGRESSION</span>")}getFilter(){const t=[];if(this.state.termfilter?.filter)t.push(this.state.termfilter.filter);const e=[this.config.outcome,...this.config.independent];const i=e.filter((t=>t?.q.restrictAncestry));if(i.length){if(i.length>1){const t=new Set(i.map((t=>t.q.restrictAncestry.name)));if(t.size>1)throw"samples cannot be restricted to more than 1 ancestry"}const e=i[0];t.push({type:"tvs",tvs:e.q.restrictAncestry.tvs});this.inputs.dom.submitMsg.style("display","block").text(`restricting analysis to samples of ${e.q.restrictAncestry.name}`)}else{this.inputs.dom.submitMsg.style("display","none")}this.filter={type:"tvslst",join:"and",lst:t}}}const u=s(m);const f=u;let h=1;async function g(e,i){if(!e.outcome)e.outcome={};{await t(e.outcome,i.vocabApi,y(e.regressionType,"outcome"))}const s="id"in e?e.id:`_REGRESSION_${h++}`;const r={id:s};r.outcome=e.outcome;if(e.independent){if(!Array.isArray(e.independent))throw".independent[] is not array";for(const s of e.independent){const e=!s.q?.mode?{numeric:{mode:"continuous"}}:undefined;await t(s,i.vocabApi,e)}r.independent=e.independent}else{r.independent=[]}return n(r,e)}function y(t,e=""){const i={};i["numeric"]=t=="logistic"&&e=="outcome"?{mode:"binary"}:{mode:"discrete"};i["categorical"]=t=="logistic"&&e=="outcome"?{mode:"binary"}:{mode:"discrete"};if(e=="outcome"){if(t=="cox"){i.condition={mode:"cox"}}if(t=="logistic"){i.condition={mode:"binary"}}}return i}function b(t,e){const i=[{label:"Linear",type:"linear"},{label:"Logistic",type:"logistic"},{label:"Cox",type:"cox"}];for(const{label:s,type:n}of i){t.append("div").attr("class","sja_menuoption sja_sharp_border").text(s).on("click",(()=>{e.dom.tip.hide();e.prepPlot({config:{chartType:"regression",regressionType:n,independent:[]}})}))}}var v=Object.freeze({__proto__:null,regressionInit:u,componentInit:f,getPlotConfig:g,get_defaultQ4fillTW:y,makeChartBtnMenu:b});class x{constructor(t){this.opts=t;this.section=t.section;this.term=t.term;this.parent=t.parent}async init(t){const i=t.append("div");const s=i.append("span").style("display","inline-block");const n=i.append("span").style("margin-left","20px");this.dom={holder:t,termRow:i,pillDiv:s,interactionDiv:n,err_div:t.append("div").style("display","none").style("padding","5px").style("background-color","rgba(255,100,100,0.2)"),infoDiv:t.append("div"),tip:new o};try{const{app:t,config:i,state:s,disable_terms:n}=this.parent;const r={placeholder:this.section.selectPrompt,placeholderIcon:this.section.placeholderIcon,holder:this.dom.pillDiv,vocabApi:t.vocabApi,noTermPromptOptions:this.opts.noTermPromptOptions,activeCohort:s.activeCohort,debug:t.opts.debug,menuOptions:this.section.configKey=="outcome"?"{edit,reuse,replace}":"{edit,reuse,remove}",usecase:{target:"regression",detail:this.section.configKey,regressionType:i.regressionType},disable_terms:n,abbrCutoff:50,genomeObj:this.parent.parent.genomeObj,defaultQ4fillTW:y(i.regressionType,this.section.configKey),callback:t=>{this.parent.editConfig(this,t)}};this.furbishTsConstructorArg(r);this.pill=await e(r);if(this.section.configKey=="outcome"){this.setQ=S(i.regressionType)}this.valuesTable=new c({holder:this.dom.infoDiv,input:this,callback:t=>{this.parent.editConfig(this,t)}})}catch(t){this.displayError([t])}}furbishTsConstructorArg(t){const e=this.parent.config.regressionType;if(this.section.configKey=="outcome"){if(e=="logistic"){t.numericEditMenuVersion=["binary"];return}if(e=="linear"){t.numericEditMenuVersion=["continuous"];return}if(e=="cox"){return}throw"unknown regressionType"}if(this.section.configKey=="independent"){t.numericEditMenuVersion=["continuous","discrete","spline"];t.defaultQ4fillTW["geneVariant"]={type:"predefined-groupset"};t.geneVariantEditMenuOnlyGrp=true;return}throw"unknown section.configKey: "+this.section.configKey}displayError(t){this.hasError=true;this.dom.err_div.selectAll("*").remove();this.dom.err_div.style("display","block").selectAll("div").data(Array.isArray(t)?t:[t]).enter().append("div").text((t=>t));this.parent.handleError();console.error(t)}async main(){const t=this.term;if(t){delete t.error}this.dom.err_div.style("display","none").text("");this.hasError=false;const e=[];try{if(t&&this.setQ){const{app:e,state:i}=this.parent;await this.setQ[t.term.type](t,e.vocabApi,this.parent.parent.filter,i)}try{await this.updateTerm()}catch(t){e.push(t)}await this.pill.main(this.getPillArgs());this.renderInteractionPrompt();await this.valuesTable.main();const i=t&&t.error||this.pill.error;if(i)e.push(i);if(e.length)throw e}catch(e){this.displayError(e)}}async updateTerm(){const t=this.term;if(!t)return;if(!t.q)throw".term.q missing on this input";if(!t.q.mode&&i(t.term.type)){if(t.term.type=="categorical"||t.term.type=="condition"||t.term.type=="survival"||t.term.type=="samplelst")t.q.mode="discrete";else t.q.mode="continuous"}const e=t.term.type=="snplst"||t.term.type=="snplocus"?{cacheid:t.q.cacheid}:{term1_q:t.q};const s=await this.parent.app.vocabApi.getCategories(t.term,this.parent.parent.filter,e);if(!s)throw`no data for term.id='${t.term.id}'`;if(s.error)throw s.error;d(t,s);this.termStatus={topInfoStatus:[],bottomSummaryStatus:undefined,sampleCounts:undefined,excludeCounts:undefined,allowToSelectRefGrp:false};if(t.q.numOfSampleWithAnyValidGT){const e=t.term.snps.reduce(((t,e)=>t+(e.invalid?1:0)),0);this.termStatus.topInfoStatus.push(`${t.q.numOfSampleWithAnyValidGT} samples with valid genotypes`+(e>0?` ${e} invalid SNP${e>1?"s":""}.`:""))}if("geneticModel"in t.q){this.termStatus.topInfoStatus.push("Genetic model: "+(t.q.geneticModel==0?"Additive":t.q.geneticModel==1?"Dominant":t.q.geneticModel==2?"Recessive":"By genotype"))}if(t.q.restrictAncestry){this.termStatus.topInfoStatus.push("Analyzing "+t.q.restrictAncestry.name);if(t.q.restrictAncestry.PCcount){this.termStatus.topInfoStatus.push(`Adjusting for top ${t.q.restrictAncestry.PCcount} ancestry principal components`)}}if(t.term.reachedVariantLimit){this.termStatus.topInfoStatus.push(`<span class=sja_mcdot style="background:#aaa;font-size:1em">\n\t\t\t\t ⚠ Restricted to first ${t.term.snps.length}\n\t\t\t\tvariants of this region. </span> Try zooming in.`)}this.orderedLabels=s.orderedLabels;if(s.lst){this.summarizeSample(t,s.lst);if(t.term.type=="float"||t.term.type=="integer"){if(t.q.mode!="continuous"&&t.q.mode!="spline"){this.termStatus.allowToSelectRefGrp=true}if(t.q.scale&&t.q.scale!=1)this.termStatus.topInfoStatus.push(`Scale: Per ${t.q.scale}`);if(t.q.mode=="discrete"){this.termStatus.topInfoStatus.push(`Discrete variable with ${this.termStatus.sampleCounts.length} bins`)}if(t.q.mode=="spline"){this.termStatus.topInfoStatus.push(`Cubic spline variable with ${t.q.knots.length} knots: ${t.q.knots.map((t=>Number(t.value))).sort(((t,e)=>t-e)).join(", ")}`)}}else if(t.term.type=="categorical"||t.term.type=="geneVariant"||t.term.type=="samplelst"){this.termStatus.allowToSelectRefGrp=true}else if(t.term.type=="condition"){if(this.section.configKey=="outcome"&&this.parent.opts.regressionType=="logistic"){this.termStatus.allowToSelectRefGrp=true}if(this.section.configKey=="outcome"&&this.parent.opts.regressionType=="cox"){if(!["age","time"].includes(t.q.timeScale))throw"invalid q.timeScale";const e=this.parent.app.vocabApi.termdbConfig;this.termStatus.topInfoStatus.push(`Time axis: ${t.q.timeScale=="time"?e.timeUnit:"age"}`);this.termStatus.topInfoStatus.push(`<span style="padding-left: 10px;">-start: ${t.q.timeScale=="time"?" ":"age at "}entry into the cohort (i.e., ${e.cohortStartTimeMsg})</span>`);this.termStatus.topInfoStatus.push(`<span style="padding-left: 10px;">-end: ${t.q.timeScale=="time"?" ":"age at "}event or censoring/death</span>`);const i=Object.keys(t.term.values).map(Number);const s=Math.max(...i);this.termStatus.topInfoStatus.push(`<div style="padding-top: 8px;">Event: first occurrence of grade ${t.q.breaks[0]===s?t.q.breaks[0]:`${t.q.breaks[0]}-${s}</div>`}`)}}this.maySet_refGrp(t)}}summarizeSample(t,e){const i=new Set;if(t.term.values){for(const e in t.term.values){if(t.term.values[e].uncomputable)i.add(t.term.values[e].label)}}if(t.q.mode=="cox"){const t=e.find((t=>t.key==-1));if(t)i.add(t.label)}const s=this.termStatus.sampleCounts=e.filter((t=>!i.has(t.label)));const n=this.termStatus.excludeCounts=e.filter((t=>i.has(t.label)));const r={included:0,excluded:0,total:0};s.forEach((t=>r.included+=t.samplecount));n.forEach((t=>r.excluded+=t.samplecount));r.total=r.included+r.excluded;if(t.term.type=="condition"&&r.total){r.excluded=r.total-r.included}this.termStatus.bottomSummaryStatus=`${r.included} samples included`+(r.excluded?`. ${r.excluded} samples excluded:`:"");if(t&&t.q.mode!=="continuous"&&s.length<2)throw`there should be two or more discrete values with samples for variable='${t.term.name}'`}maySet_refGrp(t){if(this.section.configKey=="outcome"&&this.parent.config.regressionType=="cox"){return}if(t.q.mode=="continuous"){t.refGrp="NA";return}const e=this.termStatus.sampleCounts;if(!("refGrp"in t)||!e.find((e=>e.key==t.refGrp))){const i=this.orderedLabels;if(i&&i.length)e.sort(((t,e)=>i.indexOf(t.key)-i.indexOf(e.key)));else e.sort(((t,e)=>t.samplecount<e.samplecount?1:-1));t.refGrp=e[0].key}}getPillArgs(){const t=this.section;const{config:e,state:i,disable_terms:s}=this.parent;const n=Object.assign({activeCohort:i.activeCohort,disable_terms:s,usecase:{target:"regression",detail:t.configKey,regressionType:e.regressionType}},this.term);n.filter=this.parent.parent.filter;return n}remove(){this.dom.termRow.transition().duration(500).style("opacity",0).remove();for(const t in this.dom){delete this.dom[t]}}renderInteractionPrompt(){this.dom.interactionDiv.style("display","none");if(!this.term)return;if(this.section.configKey!="independent")return;if(this.term.q.mode=="spline")return;if(this.parent.app.vocabApi.termdbConfig.neuroOncRegression)return;{let t=0;for(const e of this.section.inputLst){if(e.term&&e.term.q.mode!="spline"){t++}}if(t<2)return}const t=this.term.interactions.length;this.dom.interactionDiv.style("display","inline").html(t==0?"Add interactions":`${t} interaction${t>1?"s":""}`).style("padding","5px").style("background-color",t==0?null:"#ececec").style("border-radius",t==0?null:"6px").style("color",t==0?"rgb(153, 153, 153)":"#000").style("font-size",t==0?"0.8em":"").style("cursor","pointer").on("click",(()=>this.renderInteractionOptions()))}renderInteractionOptions(){const t=this;t.dom.tip.clear().showunder(t.dom.interactionDiv.node());t.dom.tip.d.append("div").style("padding","5px").style("font-size","0.8em").style("color","rgb(153, 153, 153)").html(`Selected variables will each form pairwise interaction with ${this.term.term.name}`);t.dom.tip.d.append("div").selectAll("div").data(t.parent.config.independent.filter((e=>e&&e.term.id!==t.term.term.id&&e.term.name!==t.term.term.name&&e.q.mode!="spline"))).enter().append("div").style("margin","5px").each((function(e){const i=a(this).append("label");i.append("input").attr("type","checkbox").property("checked",t.term.interactions.includes(e.term.id||e.term.name));i.append("span").text(" "+e.term.name)}));t.dom.tip.d.append("button").text("Apply").style("margin","5px").on("click",(()=>{t.dom.tip.hide();t.term.interactions=[];t.dom.tip.d.selectAll("input").each((function(e){if(a(this).property("checked"))t.term.interactions.push(e.term.id||e.term.name)}));for(const e of t.parent.config.independent){const i=e.interactions.indexOf(t.term.term.id||t.term.term.name);if(t.term.interactions.includes(e.term.id||e.term.name)){if(i==-1)e.interactions.push(t.term.term.id||t.term.term.name)}else if(i!=-1){e.interactions.splice(i,1)}}t.parent.editConfig(t,t.term)}))}}function S(t){return{integer:t=="logistic"?T:k,float:t=="logistic"?T:k,geneExpression:t=="logistic"?T:k,categorical:q,condition:w,survival:w}}async function T(t,e,i,s){if(t.q.mode=="binary"&&t.q.lst&&t.q.lst.length==2){t.q.mode="binary";return}const n=await e.getPercentile(t.term.id,[50],i);if(n.error||!n.values.length||!Number.isFinite(n.values[0]))throw"cannot get median value: "+(n.error||"no data");const r=t.term.type=="integer"?Math.round(n.values[0]):Number(n.values[0].toFixed(2));t.q={mode:"binary",type:"custom-bin",lst:[{startunbounded:true,stopinclusive:true,stop:r},{stopunbounded:true,startinclusive:false,start:r}]};t.q.lst.forEach((e=>{e.label=p(e,t.q)}));t.refGrp=t.q.lst[0].label}function w(t,e,i,s){if(s.config.regressionType=="logistic"){if(!t.refGrp)t.refGrp=t.q.groups[0].name}if(s.config.regressionType=="cox"){if(!t.q.timeScale)t.q.timeScale="time"}}async function q(t,e,i,s){const{term:n,q:r}=t;if(r.mode=="binary"){if(r.type=="values"&&Object.keys(n.values).length==2)return;if(r.type=="predefined-groupset"){const t=r.predefined_groupset_idx;const e=n.groupsetting;if(e[t]&&Object.keys(e[t]).length==2)return}if(r.type=="custom-groupset"){const t=r.customset;if(t.groups.length==2)return}}const o=await e.getCategories(n,i);if(o.error)throw"cannot get categories: "+o.error;const a=new Map;const p=[];for(const t of o.lst){a.set(t.key,t.samplecount);if(n.values&&n.values[t.key]&&n.values[t.key].uncomputable)continue;p.push(t.key)}if(p.length<2){r.type="values";t.error="less than 2 categories/grades - cannot create separate groups";return}if(p.length==2){r.type="values";return}const c=n.groupsetting;if(r.customset&&r.customset.groups&&r.customset.groups.length==2&&_(r.customset,a)){r.type="custom-groupset";return}if(c&&c.lst){if(r.predefined_groupset_idx>=0&&c.lst[r.predefined_groupset_idx]&&c.lst[r.predefined_groupset_idx].groups.length==2&&_(c.lst[r.predefined_groupset_idx],a)){r.type="predefined-groupset";return}const t=c.lst.findIndex((t=>t.groups.length==2));if(t!=-1&&_(c.lst[t],a)){r.predefined_groupset_idx=t;r.type="predefined-groupset";return}}const d={activeCohort:s.activeCohort,groups:[{name:"Group 1",type:"values",values:[]},{name:"Group 2",type:"values",values:[]}]};const l=Math.round(p.length/2);for(const[t,e]of p.entries()){if(t<l)d.groups[0].values.push({key:e});else d.groups[1].values.push({key:e})}r.customset=d;r.type="custom-groupset"}function k(t){if(!t.q.type){console.log("may not happen: why is input.term.q not yet set for numeric term at this point")}t.q.mode="continuous"}function _(t,e){for(const i of t.groups){let t=0;if(i.type=="values"){for(const s of i.values)t+=e.get(s.key)||0;if(t==0)return false}}return true}var A=Object.freeze({__proto__:null,InputTerm:x});const C=[{termtype:"snplst",html:"A list of variants"},{termtype:"snplocus",html:"Variants in a locus"},{termtype:"prs",text:"Polygenic risk score"}];class O{constructor(t){this.opts=t;this.app=t.app;this.parent=t.parent;E(this);I(this);this.createSectionConfigs();this.initUI()}createSectionConfigs(){this.outcome={heading:"Outcome variable",selectPrompt:this.opts.regressionType=="linear"?"Select continuous outcome variable":"Select outcome variable",placeholderIcon:"",configKey:"outcome",limit:1,usecase:{target:"regression",regressionType:this.opts.regressionType,detail:"outcome"},inputLst:[],dom:{}};this.independent={heading:"Independent variable(s)",selectPrompt:"Add independent variable",placeholderIcon:"",configKey:"independent",limit:10,usecase:{target:"regression",regressionType:this.opts.regressionType,detail:"independent"},inputLst:[],dom:{}};this.sections=[this.outcome,this.independent]}async main(){try{this.config=this.parent.config;this.state=this.parent.state;this.hasError=false;this.setDisableTerms();const t=[];for(const e of this.sections){await this.renderSection(e);for(const i of e.inputLst){i.dom.holder.style("border-left",i.term?"1px solid #bbb":"");t.push(i.main())}}await Promise.all(t);for(const t of this.sections){for(const e of t.inputLst){if(e.term&&e.term.error||e.hasError){this.hasError=true}}}}catch(t){this.hasError=true;throw t}}setDisableTerms(){this.disable_terms=[];if(this.config.outcome&&this.config.outcome.term)this.disable_terms.push(this.config.outcome.term);if(this.config.independent){for(const t of this.config.independent){this.disable_terms.push(t.term)}}}handleError(){this.hasError=true;this.dom.submitBtn.property("disabled",true)}getNoTermPromptOptions(t){if(t.configKey!="independent")return;const e=[];for(const i of C){if(!this.state.allowedTermTypes.includes(i.termtype)){continue}if(t.inputLst.find((t=>t.term&&t.term.term.type==i.termtype))){continue}e.push(i)}if(e.length){e.unshift({isDictionary:true,text:"Dictionary variable"})}return e}}function I(t){t.initUI=()=>{const e=t.opts.holder.append("div").style("display","block");t.dom={div:t.opts.holder,controls:e,body:e.append("div"),foot:e.append("div").style("margin","0px 20px").style("display","flex").style("align-items","center").style("gap","20px")};t.dom.submitBtn=t.dom.foot.append("div").append("button").style("display","none").style("padding","5px 15px").style("border-radius","15px").style("cursor","pointer").text("Run analysis").on("click",t.submit);t.dom.submitMsg=t.dom.foot.append("div").style("display","none").style("color","#cc0000").style("font-style","italic").style("font-size","0.8em");for(const e of t.sections){const i=t.dom.body.append("div");t.addSection(e,i)}};t.addSection=function(t,e){e.style("display","none").style("margin","3px 5px").style("padding","3px 5px");t.dom={holder:e,headingDiv:e.append("div").style("margin","3px 5px 20px 5px").style("font-size","17px").style("color","#bbb").text(t.heading),inputsDiv:e.append("div")}};t.renderSection=function(n){n.dom.holder.style("display",n.configKey=="outcome"||t.config.outcome?"block":"none");e(n);const r=n.dom.inputsDiv.selectAll(":scope > div").data(n.inputLst,(t=>t.term&&(t.term.term.id||t.term.term.name)));r.exit().each(s);r.enter().append("div").each(i)};function e(e){const i=t.config[e.configKey];const s=Array.isArray(i)?i:i?[i]:[];for(const n of s){if(e.configKey=="independent"){if(!n.interactions)n.interactions=[];for(const t of n.interactions){const e=i.find((e=>(e.term.id||e.term.name)==t));if(!e)throw"interacting partner not found in independents: "+t;if(!e.interactions)e.interactions=[];if(!e.interactions.includes(n.term.id||n.term.name))e.interactions.push(n.term.id||n.term.name)}}const s=e.inputLst.find((t=>t.term?.term.id==n.term.id||t.term?.term.name==n.term.name));if(!s){e.inputLst.push(new x({section:e,term:n,parent:t}))}else{s.term=n}}$(e,t)}async function i(t){await t.init(a(this).style("width","fit-content").style("margin","0px 15px 35px 25px").style("padding","0px 5px"))}function s(t){t.remove();for(const e in t.dom){delete t.dom[e]}const e=a(this);e.transition().duration(500).style("opacity",0).remove()}t.resetSubmitButton=()=>{t.dom.submitBtn.text("Run analysis").style("display",t.config.outcome&&t.config.independent.length?"block":"none").property("disabled",t.hasError)}}function E(t){t.editConfig=async(e,i)=>{if(!i){const t=e.section.inputLst.findIndex((t=>t===e));if(t==-1)throw`deleting an unknown input`;e.section.inputLst.splice(t,1);if(e.term){for(const t of e.section.inputLst){if(!t.term||!t.term.interactions)continue;const i=t.term.interactions.indexOf(e.term.term.id||e.term.term.name);if(i!=-1)t.term.interactions.splice(i,1)}}}else{const t=e.term;if(t&&i.term.id===t.term.id){for(const e in t){if(!(e in i))i[e]=t[e]}}e.term=i;if(i.q.mode=="spline"&&i.interactions){for(const t of e.section.inputLst){if(!t.term||!t.term.interactions)continue;const i=t.term.interactions.indexOf(e.term.term.id||e.term.term.name);if(i!=-1)t.term.interactions.splice(i,1)}i.interactions=[]}}const s=[];for(const t of e.section.inputLst){if(t.term)s.push(t.term)}const n=e.section.configKey;const r=Array.isArray(t.config[n])?s:s[0];t.app.dispatch({type:"plot_edit",id:t.parent.id,chartType:"regression",config:{hasUnsubmittedEdits:true,[n]:JSON.parse(JSON.stringify(r))}})};t.submit=()=>{t.dom.submitBtn.property("disabled",true);if(t.hasError){alert("Please fix the input variable errors (highlighted in red background).");return}const e=JSON.parse(JSON.stringify(t.config));e.hasUnsubmittedEdits=false;t.app.dispatch({type:"plot_edit",id:t.parent.id,chartType:"regression",config:e})}}function $(t,e){if(t.inputLst.length>=t.limit){return}const i=t.inputLst.find((t=>!t.term));if(i){const s=e.getNoTermPromptOptions(t);if(s){i.pill.main({noTermPromptOptions:s})}return}t.inputLst.push(new x({section:t,parent:e,noTermPromptOptions:e.getNoTermPromptOptions(t)}))}var P=Object.freeze({__proto__:null,RegressionInputs:O});export{A as a,P as b,v as r};
|
|
1
|
+
import{f as t,h as e,b as i}from"./termsetting-492eefa7.js";import{h as s,P as n,y as r,M as o,d as a}from"./app-6fb77603.js";import"./FilterRxComp-02e68f1b.js";import{g as p}from"./termdb.bins-39d11f24.js";import{InputValuesTable as c}from"./regression.inputs.values.table-d79efa9e.js";import{mayRunSnplstTask as d}from"./snplst.sampleSum-e47d05f0.js";import{R as l}from"./regression.results-4767144e.js";class m{constructor(t){this.type="regression";this.genomeObj=t.app.opts.genome}async init(t){this.dom={header:this.opts.header,errordiv:this.opts.holder.append("div"),inputs:this.opts.holder.append("div").style("margin","20px 10px"),results:this.opts.holder.append("div").style("margin-left","40px")};const e=t.plots.find((t=>t.id===this.id));this.inputs=new O({app:this.app,parent:this,id:this.id,holder:this.dom.inputs,regressionType:e.regressionType});this.results=new l({app:this.app,parent:this,id:this.id,holder:this.dom.results,regressionType:e.regressionType})}getState(t,e){const i=t.plots.find((t=>t.id===this.id));if(!i){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}if(!i.regressionType)throw"regressionType is required";return{vocab:t.vocab,formIsComplete:i.outcome&&i.independent.length,activeCohort:t.activeCohort,termfilter:t.termfilter,config:i,allowedTermTypes:t.termdbConfig.allowedTermTypes,minTimeSinceDx:t.termdbConfig.minTimeSinceDx}}async main(){try{this.config=JSON.parse(JSON.stringify(this.state.config));this.mayUpdateSandboxHeader();this.getFilter();await this.inputs.main();await this.results.main();this.inputs.resetSubmitButton()}catch(t){if(this.inputs.hasError){this.results.main()}r(this.dom.errordiv,"Error: "+(t.error||t));if(t.stack)console.log(t.stack)}}mayUpdateSandboxHeader(){if(!this.dom.header)return;const t=this.config.outcome;this.dom.header.html((t?t.term.name:"")+'<span style="opacity:.6;font-size:.7em;margin-left:10px;">'+this.config.regressionType.toUpperCase()+" REGRESSION</span>")}getFilter(){const t=[];if(this.state.termfilter?.filter)t.push(this.state.termfilter.filter);const e=[this.config.outcome,...this.config.independent];const i=e.filter((t=>t?.q.restrictAncestry));if(i.length){if(i.length>1){const t=new Set(i.map((t=>t.q.restrictAncestry.name)));if(t.size>1)throw"samples cannot be restricted to more than 1 ancestry"}const e=i[0];t.push({type:"tvs",tvs:e.q.restrictAncestry.tvs});this.inputs.dom.submitMsg.style("display","block").text(`restricting analysis to samples of ${e.q.restrictAncestry.name}`)}else{this.inputs.dom.submitMsg.style("display","none")}this.filter={type:"tvslst",join:"and",lst:t}}}const u=s(m);const f=u;let h=1;async function g(e,i){if(!e.outcome)e.outcome={};{await t(e.outcome,i.vocabApi,y(e.regressionType,"outcome"))}const s="id"in e?e.id:`_REGRESSION_${h++}`;const r={id:s};r.outcome=e.outcome;if(e.independent){if(!Array.isArray(e.independent))throw".independent[] is not array";for(const s of e.independent){const e=!s.q?.mode?{numeric:{mode:"continuous"}}:undefined;await t(s,i.vocabApi,e)}r.independent=e.independent}else{r.independent=[]}return n(r,e)}function y(t,e=""){const i={};i["numeric"]=t=="logistic"&&e=="outcome"?{mode:"binary"}:{mode:"discrete"};i["categorical"]=t=="logistic"&&e=="outcome"?{mode:"binary"}:{mode:"discrete"};if(e=="outcome"){if(t=="cox"){i.condition={mode:"cox"}}if(t=="logistic"){i.condition={mode:"binary"}}}return i}function b(t,e){const i=[{label:"Linear",type:"linear"},{label:"Logistic",type:"logistic"},{label:"Cox",type:"cox"}];for(const{label:s,type:n}of i){t.append("div").attr("class","sja_menuoption sja_sharp_border").text(s).on("click",(()=>{e.dom.tip.hide();e.prepPlot({config:{chartType:"regression",regressionType:n,independent:[]}})}))}}var v=Object.freeze({__proto__:null,regressionInit:u,componentInit:f,getPlotConfig:g,get_defaultQ4fillTW:y,makeChartBtnMenu:b});class x{constructor(t){this.opts=t;this.section=t.section;this.term=t.term;this.parent=t.parent}async init(t){const i=t.append("div");const s=i.append("span").style("display","inline-block");const n=i.append("span").style("margin-left","20px");this.dom={holder:t,termRow:i,pillDiv:s,interactionDiv:n,err_div:t.append("div").style("display","none").style("padding","5px").style("background-color","rgba(255,100,100,0.2)"),infoDiv:t.append("div"),tip:new o};try{const{app:t,config:i,state:s,disable_terms:n}=this.parent;const r={placeholder:this.section.selectPrompt,placeholderIcon:this.section.placeholderIcon,holder:this.dom.pillDiv,vocabApi:t.vocabApi,noTermPromptOptions:this.opts.noTermPromptOptions,activeCohort:s.activeCohort,debug:t.opts.debug,menuOptions:this.section.configKey=="outcome"?"{edit,reuse,replace}":"{edit,reuse,remove}",usecase:{target:"regression",detail:this.section.configKey,regressionType:i.regressionType},disable_terms:n,abbrCutoff:50,genomeObj:this.parent.parent.genomeObj,defaultQ4fillTW:y(i.regressionType,this.section.configKey),callback:t=>{this.parent.editConfig(this,t)}};this.furbishTsConstructorArg(r);this.pill=await e(r);if(this.section.configKey=="outcome"){this.setQ=S(i.regressionType)}this.valuesTable=new c({holder:this.dom.infoDiv,input:this,callback:t=>{this.parent.editConfig(this,t)}})}catch(t){this.displayError([t])}}furbishTsConstructorArg(t){const e=this.parent.config.regressionType;if(this.section.configKey=="outcome"){if(e=="logistic"){t.numericEditMenuVersion=["binary"];return}if(e=="linear"){t.numericEditMenuVersion=["continuous"];return}if(e=="cox"){return}throw"unknown regressionType"}if(this.section.configKey=="independent"){t.numericEditMenuVersion=["continuous","discrete","spline"];t.defaultQ4fillTW["geneVariant"]={type:"predefined-groupset"};t.geneVariantEditMenuOnlyGrp=true;return}throw"unknown section.configKey: "+this.section.configKey}displayError(t){this.hasError=true;this.dom.err_div.selectAll("*").remove();this.dom.err_div.style("display","block").selectAll("div").data(Array.isArray(t)?t:[t]).enter().append("div").text((t=>t));this.parent.handleError();console.error(t)}async main(){const t=this.term;if(t){delete t.error}this.dom.err_div.style("display","none").text("");this.hasError=false;const e=[];try{if(t&&this.setQ){const{app:e,state:i}=this.parent;await this.setQ[t.term.type](t,e.vocabApi,this.parent.parent.filter,i)}try{await this.updateTerm()}catch(t){e.push(t)}await this.pill.main(this.getPillArgs());this.renderInteractionPrompt();await this.valuesTable.main();const i=t&&t.error||this.pill.error;if(i)e.push(i);if(e.length)throw e}catch(e){this.displayError(e)}}async updateTerm(){const t=this.term;if(!t)return;if(!t.q)throw".term.q missing on this input";if(!t.q.mode&&i(t.term.type)){if(t.term.type=="categorical"||t.term.type=="condition"||t.term.type=="survival"||t.term.type=="samplelst")t.q.mode="discrete";else t.q.mode="continuous"}const e=t.term.type=="snplst"||t.term.type=="snplocus"?{cacheid:t.q.cacheid}:{term1_q:t.q};const s=await this.parent.app.vocabApi.getCategories(t.term,this.parent.parent.filter,e);if(!s)throw`no data for term.id='${t.term.id}'`;if(s.error)throw s.error;d(t,s);this.termStatus={topInfoStatus:[],bottomSummaryStatus:undefined,sampleCounts:undefined,excludeCounts:undefined,allowToSelectRefGrp:false};if(t.q.numOfSampleWithAnyValidGT){const e=t.term.snps.reduce(((t,e)=>t+(e.invalid?1:0)),0);this.termStatus.topInfoStatus.push(`${t.q.numOfSampleWithAnyValidGT} samples with valid genotypes`+(e>0?` ${e} invalid SNP${e>1?"s":""}.`:""))}if("geneticModel"in t.q){this.termStatus.topInfoStatus.push("Genetic model: "+(t.q.geneticModel==0?"Additive":t.q.geneticModel==1?"Dominant":t.q.geneticModel==2?"Recessive":"By genotype"))}if(t.q.restrictAncestry){this.termStatus.topInfoStatus.push("Analyzing "+t.q.restrictAncestry.name);if(t.q.restrictAncestry.PCcount){this.termStatus.topInfoStatus.push(`Adjusting for top ${t.q.restrictAncestry.PCcount} ancestry principal components`)}}if(t.term.reachedVariantLimit){this.termStatus.topInfoStatus.push(`<span class=sja_mcdot style="background:#aaa;font-size:1em">\n\t\t\t\t ⚠ Restricted to first ${t.term.snps.length}\n\t\t\t\tvariants of this region. </span> Try zooming in.`)}this.orderedLabels=s.orderedLabels;if(s.lst){this.summarizeSample(t,s.lst);if(t.term.type=="float"||t.term.type=="integer"){if(t.q.mode!="continuous"&&t.q.mode!="spline"){this.termStatus.allowToSelectRefGrp=true}if(t.q.scale&&t.q.scale!=1)this.termStatus.topInfoStatus.push(`Scale: Per ${t.q.scale}`);if(t.q.mode=="discrete"){this.termStatus.topInfoStatus.push(`Discrete variable with ${this.termStatus.sampleCounts.length} bins`)}if(t.q.mode=="spline"){this.termStatus.topInfoStatus.push(`Cubic spline variable with ${t.q.knots.length} knots: ${t.q.knots.map((t=>Number(t.value))).sort(((t,e)=>t-e)).join(", ")}`)}}else if(t.term.type=="categorical"||t.term.type=="geneVariant"||t.term.type=="samplelst"){this.termStatus.allowToSelectRefGrp=true}else if(t.term.type=="condition"){if(this.section.configKey=="outcome"&&this.parent.opts.regressionType=="logistic"){this.termStatus.allowToSelectRefGrp=true}if(this.section.configKey=="outcome"&&this.parent.opts.regressionType=="cox"){if(!["age","time"].includes(t.q.timeScale))throw"invalid q.timeScale";const e=this.parent.app.vocabApi.termdbConfig;this.termStatus.topInfoStatus.push(`Time axis: ${t.q.timeScale=="time"?e.timeUnit:"age"}`);this.termStatus.topInfoStatus.push(`<span style="padding-left: 10px;">-start: ${t.q.timeScale=="time"?" ":"age at "}entry into the cohort (i.e., ${e.cohortStartTimeMsg})</span>`);this.termStatus.topInfoStatus.push(`<span style="padding-left: 10px;">-end: ${t.q.timeScale=="time"?" ":"age at "}event or censoring/death</span>`);const i=Object.keys(t.term.values).map(Number);const s=Math.max(...i);this.termStatus.topInfoStatus.push(`<div style="padding-top: 8px;">Event: first occurrence of grade ${t.q.breaks[0]===s?t.q.breaks[0]:`${t.q.breaks[0]}-${s}</div>`}`)}}this.maySet_refGrp(t)}}summarizeSample(t,e){const i=new Set;if(t.term.values){for(const e in t.term.values){if(t.term.values[e].uncomputable)i.add(t.term.values[e].label)}}if(t.q.mode=="cox"){const t=e.find((t=>t.key==-1));if(t)i.add(t.label)}const s=this.termStatus.sampleCounts=e.filter((t=>!i.has(t.label)));const n=this.termStatus.excludeCounts=e.filter((t=>i.has(t.label)));const r={included:0,excluded:0,total:0};s.forEach((t=>r.included+=t.samplecount));n.forEach((t=>r.excluded+=t.samplecount));r.total=r.included+r.excluded;if(t.term.type=="condition"&&r.total){r.excluded=r.total-r.included}this.termStatus.bottomSummaryStatus=`${r.included} samples included`+(r.excluded?`. ${r.excluded} samples excluded:`:"");if(t&&t.q.mode!=="continuous"&&s.length<2)throw`there should be two or more discrete values with samples for variable='${t.term.name}'`}maySet_refGrp(t){if(this.section.configKey=="outcome"&&this.parent.config.regressionType=="cox"){return}if(t.q.mode=="continuous"){t.refGrp="NA";return}const e=this.termStatus.sampleCounts;if(!("refGrp"in t)||!e.find((e=>e.key==t.refGrp))){const i=this.orderedLabels;if(i&&i.length)e.sort(((t,e)=>i.indexOf(t.key)-i.indexOf(e.key)));else e.sort(((t,e)=>t.samplecount<e.samplecount?1:-1));t.refGrp=e[0].key}}getPillArgs(){const t=this.section;const{config:e,state:i,disable_terms:s}=this.parent;const n=Object.assign({activeCohort:i.activeCohort,disable_terms:s,usecase:{target:"regression",detail:t.configKey,regressionType:e.regressionType}},this.term);n.filter=this.parent.parent.filter;return n}remove(){this.dom.termRow.transition().duration(500).style("opacity",0).remove();for(const t in this.dom){delete this.dom[t]}}renderInteractionPrompt(){this.dom.interactionDiv.style("display","none");if(!this.term)return;if(this.section.configKey!="independent")return;if(this.term.q.mode=="spline")return;if(this.parent.app.vocabApi.termdbConfig.neuroOncRegression)return;{let t=0;for(const e of this.section.inputLst){if(e.term&&e.term.q.mode!="spline"){t++}}if(t<2)return}const t=this.term.interactions.length;this.dom.interactionDiv.style("display","inline").html(t==0?"Add interactions":`${t} interaction${t>1?"s":""}`).style("padding","5px").style("background-color",t==0?null:"#ececec").style("border-radius",t==0?null:"6px").style("color",t==0?"rgb(153, 153, 153)":"#000").style("font-size",t==0?"0.8em":"").style("cursor","pointer").on("click",(()=>this.renderInteractionOptions()))}renderInteractionOptions(){const t=this;t.dom.tip.clear().showunder(t.dom.interactionDiv.node());t.dom.tip.d.append("div").style("padding","5px").style("font-size","0.8em").style("color","rgb(153, 153, 153)").html(`Selected variables will each form pairwise interaction with ${this.term.term.name}`);t.dom.tip.d.append("div").selectAll("div").data(t.parent.config.independent.filter((e=>e&&e.term.id!==t.term.term.id&&e.term.name!==t.term.term.name&&e.q.mode!="spline"))).enter().append("div").style("margin","5px").each((function(e){const i=a(this).append("label");i.append("input").attr("type","checkbox").property("checked",t.term.interactions.includes(e.term.id||e.term.name));i.append("span").text(" "+e.term.name)}));t.dom.tip.d.append("button").text("Apply").style("margin","5px").on("click",(()=>{t.dom.tip.hide();t.term.interactions=[];t.dom.tip.d.selectAll("input").each((function(e){if(a(this).property("checked"))t.term.interactions.push(e.term.id||e.term.name)}));for(const e of t.parent.config.independent){const i=e.interactions.indexOf(t.term.term.id||t.term.term.name);if(t.term.interactions.includes(e.term.id||e.term.name)){if(i==-1)e.interactions.push(t.term.term.id||t.term.term.name)}else if(i!=-1){e.interactions.splice(i,1)}}t.parent.editConfig(t,t.term)}))}}function S(t){return{integer:t=="logistic"?T:k,float:t=="logistic"?T:k,geneExpression:t=="logistic"?T:k,categorical:q,condition:w,survival:w}}async function T(t,e,i,s){if(t.q.mode=="binary"&&t.q.lst&&t.q.lst.length==2){t.q.mode="binary";return}const n=await e.getPercentile(t.term.id,[50],i);if(n.error||!n.values.length||!Number.isFinite(n.values[0]))throw"cannot get median value: "+(n.error||"no data");const r=t.term.type=="integer"?Math.round(n.values[0]):Number(n.values[0].toFixed(2));t.q={mode:"binary",type:"custom-bin",lst:[{startunbounded:true,stopinclusive:true,stop:r},{stopunbounded:true,startinclusive:false,start:r}]};t.q.lst.forEach((e=>{e.label=p(e,t.q)}));t.refGrp=t.q.lst[0].label}function w(t,e,i,s){if(s.config.regressionType=="logistic"){if(!t.refGrp)t.refGrp=t.q.groups[0].name}if(s.config.regressionType=="cox"){if(!t.q.timeScale)t.q.timeScale="time"}}async function q(t,e,i,s){const{term:n,q:r}=t;if(r.mode=="binary"){if(r.type=="values"&&Object.keys(n.values).length==2)return;if(r.type=="predefined-groupset"){const t=r.predefined_groupset_idx;const e=n.groupsetting;if(e[t]&&Object.keys(e[t]).length==2)return}if(r.type=="custom-groupset"){const t=r.customset;if(t.groups.length==2)return}}const o=await e.getCategories(n,i);if(o.error)throw"cannot get categories: "+o.error;const a=new Map;const p=[];for(const t of o.lst){a.set(t.key,t.samplecount);if(n.values&&n.values[t.key]&&n.values[t.key].uncomputable)continue;p.push(t.key)}if(p.length<2){r.type="values";t.error="less than 2 categories/grades - cannot create separate groups";return}if(p.length==2){r.type="values";return}const c=n.groupsetting;if(r.customset&&r.customset.groups&&r.customset.groups.length==2&&_(r.customset,a)){r.type="custom-groupset";return}if(c&&c.lst){if(r.predefined_groupset_idx>=0&&c.lst[r.predefined_groupset_idx]&&c.lst[r.predefined_groupset_idx].groups.length==2&&_(c.lst[r.predefined_groupset_idx],a)){r.type="predefined-groupset";return}const t=c.lst.findIndex((t=>t.groups.length==2));if(t!=-1&&_(c.lst[t],a)){r.predefined_groupset_idx=t;r.type="predefined-groupset";return}}const d={activeCohort:s.activeCohort,groups:[{name:"Group 1",type:"values",values:[]},{name:"Group 2",type:"values",values:[]}]};const l=Math.round(p.length/2);for(const[t,e]of p.entries()){if(t<l)d.groups[0].values.push({key:e});else d.groups[1].values.push({key:e})}r.customset=d;r.type="custom-groupset"}function k(t){if(!t.q.type){console.log("may not happen: why is input.term.q not yet set for numeric term at this point")}t.q.mode="continuous"}function _(t,e){for(const i of t.groups){let t=0;if(i.type=="values"){for(const s of i.values)t+=e.get(s.key)||0;if(t==0)return false}}return true}var A=Object.freeze({__proto__:null,InputTerm:x});const C=[{termtype:"snplst",html:"A list of variants"},{termtype:"snplocus",html:"Variants in a locus"},{termtype:"prs",text:"Polygenic risk score"}];class O{constructor(t){this.opts=t;this.app=t.app;this.parent=t.parent;E(this);I(this);this.createSectionConfigs();this.initUI()}createSectionConfigs(){this.outcome={heading:"Outcome variable",selectPrompt:this.opts.regressionType=="linear"?"Select continuous outcome variable":"Select outcome variable",placeholderIcon:"",configKey:"outcome",limit:1,usecase:{target:"regression",regressionType:this.opts.regressionType,detail:"outcome"},inputLst:[],dom:{}};this.independent={heading:"Independent variable(s)",selectPrompt:"Add independent variable",placeholderIcon:"",configKey:"independent",limit:10,usecase:{target:"regression",regressionType:this.opts.regressionType,detail:"independent"},inputLst:[],dom:{}};this.sections=[this.outcome,this.independent]}async main(){try{this.config=this.parent.config;this.state=this.parent.state;this.hasError=false;this.setDisableTerms();const t=[];for(const e of this.sections){await this.renderSection(e);for(const i of e.inputLst){i.dom.holder.style("border-left",i.term?"1px solid #bbb":"");t.push(i.main())}}await Promise.all(t);for(const t of this.sections){for(const e of t.inputLst){if(e.term&&e.term.error||e.hasError){this.hasError=true}}}}catch(t){this.hasError=true;throw t}}setDisableTerms(){this.disable_terms=[];if(this.config.outcome&&this.config.outcome.term)this.disable_terms.push(this.config.outcome.term);if(this.config.independent){for(const t of this.config.independent){this.disable_terms.push(t.term)}}}handleError(){this.hasError=true;this.dom.submitBtn.property("disabled",true)}getNoTermPromptOptions(t){if(t.configKey!="independent")return;const e=[];for(const i of C){if(!this.state.allowedTermTypes.includes(i.termtype)){continue}if(t.inputLst.find((t=>t.term&&t.term.term.type==i.termtype))){continue}e.push(i)}if(e.length){e.unshift({isDictionary:true,text:"Dictionary variable"})}return e}}function I(t){t.initUI=()=>{const e=t.opts.holder.append("div").style("display","block");t.dom={div:t.opts.holder,controls:e,body:e.append("div"),foot:e.append("div").style("margin","0px 20px").style("display","flex").style("align-items","center").style("gap","20px")};t.dom.submitBtn=t.dom.foot.append("div").append("button").style("display","none").style("padding","5px 15px").style("border-radius","15px").style("cursor","pointer").text("Run analysis").on("click",t.submit);t.dom.submitMsg=t.dom.foot.append("div").style("display","none").style("color","#cc0000").style("font-style","italic").style("font-size","0.8em");for(const e of t.sections){const i=t.dom.body.append("div");t.addSection(e,i)}};t.addSection=function(t,e){e.style("display","none").style("margin","3px 5px").style("padding","3px 5px");t.dom={holder:e,headingDiv:e.append("div").style("margin","3px 5px 20px 5px").style("font-size","17px").style("color","#bbb").text(t.heading),inputsDiv:e.append("div")}};t.renderSection=function(n){n.dom.holder.style("display",n.configKey=="outcome"||t.config.outcome?"block":"none");e(n);const r=n.dom.inputsDiv.selectAll(":scope > div").data(n.inputLst,(t=>t.term&&(t.term.term.id||t.term.term.name)));r.exit().each(s);r.enter().append("div").each(i)};function e(e){const i=t.config[e.configKey];const s=Array.isArray(i)?i:i?[i]:[];for(const n of s){if(e.configKey=="independent"){if(!n.interactions)n.interactions=[];for(const t of n.interactions){const e=i.find((e=>(e.term.id||e.term.name)==t));if(!e)throw"interacting partner not found in independents: "+t;if(!e.interactions)e.interactions=[];if(!e.interactions.includes(n.term.id||n.term.name))e.interactions.push(n.term.id||n.term.name)}}const s=e.inputLst.find((t=>t.term?.term.id==n.term.id||t.term?.term.name==n.term.name));if(!s){e.inputLst.push(new x({section:e,term:n,parent:t}))}else{s.term=n}}$(e,t)}async function i(t){await t.init(a(this).style("width","fit-content").style("margin","0px 15px 35px 25px").style("padding","0px 5px"))}function s(t){t.remove();for(const e in t.dom){delete t.dom[e]}const e=a(this);e.transition().duration(500).style("opacity",0).remove()}t.resetSubmitButton=()=>{t.dom.submitBtn.text("Run analysis").style("display",t.config.outcome&&t.config.independent.length?"block":"none").property("disabled",t.hasError)}}function E(t){t.editConfig=async(e,i)=>{if(!i){const t=e.section.inputLst.findIndex((t=>t===e));if(t==-1)throw`deleting an unknown input`;e.section.inputLst.splice(t,1);if(e.term){for(const t of e.section.inputLst){if(!t.term||!t.term.interactions)continue;const i=t.term.interactions.indexOf(e.term.term.id||e.term.term.name);if(i!=-1)t.term.interactions.splice(i,1)}}}else{const t=e.term;if(t&&i.term.id===t.term.id){for(const e in t){if(!(e in i))i[e]=t[e]}}e.term=i;if(i.q.mode=="spline"&&i.interactions){for(const t of e.section.inputLst){if(!t.term||!t.term.interactions)continue;const i=t.term.interactions.indexOf(e.term.term.id||e.term.term.name);if(i!=-1)t.term.interactions.splice(i,1)}i.interactions=[]}}const s=[];for(const t of e.section.inputLst){if(t.term)s.push(t.term)}const n=e.section.configKey;const r=Array.isArray(t.config[n])?s:s[0];t.app.dispatch({type:"plot_edit",id:t.parent.id,chartType:"regression",config:{hasUnsubmittedEdits:true,[n]:JSON.parse(JSON.stringify(r))}})};t.submit=()=>{t.dom.submitBtn.property("disabled",true);if(t.hasError){alert("Please fix the input variable errors (highlighted in red background).");return}const e=JSON.parse(JSON.stringify(t.config));e.hasUnsubmittedEdits=false;t.app.dispatch({type:"plot_edit",id:t.parent.id,chartType:"regression",config:e})}}function $(t,e){if(t.inputLst.length>=t.limit){return}const i=t.inputLst.find((t=>!t.term));if(i){const s=e.getNoTermPromptOptions(t);if(s){i.pill.main({noTermPromptOptions:s})}return}t.inputLst.push(new x({section:t,parent:e,noTermPromptOptions:e.getNoTermPromptOptions(t)}))}var P=Object.freeze({__proto__:null,RegressionInputs:O});export{A as a,P as b,v as r};
|