@sjcrh/proteinpaint-client 2.74.2 → 2.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{2dmaf-b2d78c57.js → 2dmaf-74b99126.js} +1 -1
- package/dist/AppHeader-cecb39c2.js +1 -0
- package/dist/{ColorScale-9c76aef3.js → ColorScale-21cab8d2.js} +1 -1
- package/dist/DEanalysis-95bad59a.js +1 -0
- package/dist/Disco-a6e921a0.js +1 -0
- package/dist/Disco.UI-9ad999ed.js +1 -0
- package/dist/{DragControls-586f72db.js → DragControls-e3b6a937.js} +1 -1
- package/dist/{DziViewer-6311327c.js → DziViewer-354a790d.js} +1 -1
- package/dist/FilterRxComp-701a1480.js +1 -0
- package/dist/{FilterStateless-046081c2.js → FilterStateless-54c0b763.js} +1 -1
- package/dist/{HicApp-40e44cba.js → HicApp-d5a946bf.js} +1 -1
- package/dist/{OrbitControls-0cda1772.js → OrbitControls-694652cd.js} +1 -1
- package/dist/WSIViewer-dc7f8eb0.js +1 -0
- package/dist/adSandbox-f438e388.js +1 -0
- package/dist/app-3320ab6f.js +1 -0
- package/dist/app-649f8357.js +1 -0
- package/dist/app-b369b169.js +1 -0
- package/dist/app.js +1 -1
- package/dist/bam-431875ef.js +1 -0
- package/dist/barchart-8277ed43.js +1 -0
- package/dist/barchart.events-da29c90d.js +1 -0
- package/dist/{bars.renderer-5f7a4174.js → bars.renderer-dcfdd59b.js} +1 -1
- package/dist/block-6aedd569.js +1 -0
- package/dist/block.lazyload-87b12654.js +1 -0
- package/dist/block.legend-d3f61ef7.js +1 -0
- package/dist/{block.mds-effc078d.js → block.mds-3ad17dfa.js} +1 -1
- package/dist/{block.mds.cnv-ec861a26.js → block.mds.cnv-857ba868.js} +1 -1
- package/dist/{block.mds.expressionrank-a2ad7c80.js → block.mds.expressionrank-7e3b208c.js} +1 -1
- package/dist/{block.mds.expressionstat-31dc5595.js → block.mds.expressionstat-f2d31c86.js} +1 -1
- package/dist/{block.mds.geneboxplot-3ca857ce.js → block.mds.geneboxplot-f0fbaf12.js} +1 -1
- package/dist/{block.mds.junction-debba938.js → block.mds.junction-7f87f48f.js} +1 -1
- package/dist/{block.mds.svcnv-8dc5abdf.js → block.mds.svcnv-ac035c12.js} +1 -1
- package/dist/{block.mds.svcnv.share-81e62600.js → block.mds.svcnv.share-886d9479.js} +1 -1
- package/dist/block.mds2-7852c1ee.js +1 -0
- package/dist/{block.svg-9121e8e7.js → block.svg-9b916fa6.js} +1 -1
- package/dist/{block.tk.aicheck-c1b478e9.js → block.tk.aicheck-6770e333.js} +1 -1
- package/dist/{block.tk.ase-0f6ded48.js → block.tk.ase-ee807e59.js} +1 -1
- package/dist/{block.tk.bam-7cd06aee.js → block.tk.bam-00fba6e8.js} +1 -1
- package/dist/{block.tk.bedgraphdot-3ef8b94e.js → block.tk.bedgraphdot-7fda78e9.js} +1 -1
- package/dist/{block.tk.bigwig.ui-d1248810.js → block.tk.bigwig.ui-cc1a42f3.js} +1 -1
- package/dist/{block.tk.hicstraw-ee731e55.js → block.tk.hicstraw-526470e3.js} +1 -1
- package/dist/{block.tk.junction-4d8cab4d.js → block.tk.junction-b43a4cda.js} +1 -1
- package/dist/{block.tk.junction.textmatrixui-a6430b27.js → block.tk.junction.textmatrixui-a60ed78a.js} +1 -1
- package/dist/{block.tk.ld-8429a18b.js → block.tk.ld-d15bde41.js} +1 -1
- package/dist/{block.tk.menu-3f31f958.js → block.tk.menu-3aeb93c6.js} +1 -1
- package/dist/{block.tk.pgv-07e46705.js → block.tk.pgv-9af2bd64.js} +1 -1
- package/dist/boxplot-e17a17b7.js +1 -0
- package/dist/brainImaging-bf2ceee9.js +1 -0
- package/dist/{brush-c386fe3d.js → brush-aa175142.js} +1 -1
- package/dist/categorical-a52014a1.js +1 -0
- package/dist/condition-c646e357.js +1 -0
- package/dist/controls-287e6efa.js +1 -0
- package/dist/{controls.btns-1cb2bfab.js → controls.btns-79b805dd.js} +1 -1
- package/dist/controls.config-28d6d6a8.js +1 -0
- package/dist/cuminc-9e275854.js +1 -0
- package/dist/{customdata.inputui-cbd712ea.js → customdata.inputui-dc49d94b.js} +1 -1
- package/dist/dataDownload-3a3d4f33.js +1 -0
- package/dist/databrowser.ui-d8d3f8fd.js +1 -0
- package/dist/{density-19266ebf.js → density-a82a8b1c.js} +1 -1
- package/dist/dictionary-c5a19d90.js +1 -0
- package/dist/{drag-0b968811.js → drag-7b30ba17.js} +1 -1
- package/dist/{e2pca-b8752945.js → e2pca-82765817.js} +1 -1
- package/dist/{ep-a86b185a.js → ep-d017ec2f.js} +1 -1
- package/dist/facet-a9b44ef3.js +1 -0
- package/dist/{fusion.parse-244b2b97.js → fusion.parse-d40d0b9d.js} +1 -1
- package/dist/geneExpClustering-34c3f518.js +1 -0
- package/dist/geneExpression-0d1b7244.js +1 -0
- package/dist/{geneExpression-e0430f2e.js → geneExpression-589f485b.js} +1 -1
- package/dist/{geneExpression-387205bf.js → geneExpression-7d14983f.js} +1 -1
- package/dist/geneORA-903a780f.js +1 -0
- package/dist/{geneVariant-7de021b6.js → geneVariant-89601b34.js} +1 -1
- package/dist/geneVariant-92c4e870.js +1 -0
- package/dist/{genefusion.ui-a331de19.js → genefusion.ui-7e22e811.js} +1 -1
- package/dist/{genesearch-ea59f5d4.js → genesearch-a4e19f0d.js} +1 -1
- package/dist/geneset-108a39d2.js +1 -0
- package/dist/genomeBrowser-12f86a36.js +1 -0
- package/dist/genomeBrowser.controls-d5067811.js +1 -0
- package/dist/{groupsetting-20ffef77.js → groupsetting-b4416a96.js} +1 -1
- package/dist/gsea-543dab25.js +1 -0
- package/dist/hierCluster-26e14090.js +1 -0
- package/dist/hierCluster.config-98e82dff.js +1 -0
- package/dist/{hierCluster.interactivity-9b433033.js → hierCluster.interactivity-e56f6542.js} +1 -1
- package/dist/hierCluster.renderers-74a64cf5.js +1 -0
- package/dist/{html.legend-abb5452e.js → html.legend-a3f4ebfe.js} +1 -1
- package/dist/imagePlot-b9eae4ae.js +1 -0
- package/dist/{lasso-55cf4057.js → lasso-f767f634.js} +1 -1
- package/dist/launch.adhoc-abca6af3.js +1 -0
- package/dist/leftlabel.sample-24c2388d.js +1 -0
- package/dist/legacyDataset-e0e201ab.js +1 -0
- package/dist/{log-cf45fcf2.js → log-99af3443.js} +1 -1
- package/dist/{lollipop-c5b6e615.js → lollipop-806f8fa4.js} +1 -1
- package/dist/{maf-7535f1f9.js → maf-b06579e4.js} +1 -1
- package/dist/{maftimeline-1292ab62.js → maftimeline-4840a380.js} +1 -1
- package/dist/matrix-00bb50ff.js +1 -0
- package/dist/matrix.cells-914dd0c6.js +1 -0
- package/dist/{matrix.cluster-168bc96b.js → matrix.cluster-783ceab0.js} +1 -1
- package/dist/matrix.config-6ce74dfe.js +1 -0
- package/dist/matrix.controls-7b2a6f95.js +1 -0
- package/dist/{matrix.data-b1d0febe.js → matrix.data-dac4f1b7.js} +1 -1
- package/dist/{matrix.dom-00defa30.js → matrix.dom-4e10bbe9.js} +1 -1
- package/dist/matrix.groups-b9fca14a.js +1 -0
- package/dist/matrix.interactivity-84169b43.js +1 -0
- package/dist/{matrix.layout-c2345231.js → matrix.layout-dd5a44fd.js} +1 -1
- package/dist/matrix.legend-ac6d45e6.js +1 -0
- package/dist/matrix.renderers-78010275.js +1 -0
- package/dist/matrix.serieses-9b4fd744.js +1 -0
- package/dist/matrix.sort-014d798d.js +1 -0
- package/dist/{matrix.sorterUi-a741ba2e.js → matrix.sorterUi-9bf7e6f9.js} +1 -1
- package/dist/{mavb-92136d17.js → mavb-c6be46fc.js} +1 -1
- package/dist/{mds.fimo-c03115b4.js → mds.fimo-bff6a1ed.js} +1 -1
- package/dist/mds.samplescatterplot-9a02b9fb.js +1 -0
- package/dist/{mds.survivalplot-366db380.js → mds.survivalplot-055549f4.js} +1 -1
- package/dist/{metaboliteIntensity-ddb6e480.js → metaboliteIntensity-fac92f8b.js} +1 -1
- package/dist/niceNumLabels-238aabce.js +1 -0
- package/dist/{nodrag-2c046d31.js → nodrag-16ad4b03.js} +1 -1
- package/dist/{notify-44ebc0df.js → notify-224cccbd.js} +1 -1
- package/dist/{numeric-918d4686.js → numeric-b0b17185.js} +1 -1
- package/dist/numeric.binary-1f9e93f2.js +1 -0
- package/dist/numeric.continuous-ebcd0567.js +1 -0
- package/dist/numeric.discrete-7b97044a.js +1 -0
- package/dist/numeric.spline-1be88f3d.js +1 -0
- package/dist/numeric.toggle-7fa2a770.js +1 -0
- package/dist/oncomatrix-351af2a0.js +1 -0
- package/dist/{parseData-e66308cd.js → parseData-21fe9822.js} +1 -1
- package/dist/partjson.esm-b3f1fc21.js +1 -0
- package/dist/{plot.2dvaf-73dbfbd1.js → plot.2dvaf-18a35e4b.js} +1 -1
- package/dist/plot.app-30c4b8e5.js +1 -0
- package/dist/plot.barplot-7c4865a2.js +1 -0
- package/dist/{plot.boxplot-641da058.js → plot.boxplot-fe3046c6.js} +1 -1
- package/dist/plot.brainImaging-2ceb6023.js +1 -0
- package/dist/plot.disco-6011f87f.js +1 -0
- package/dist/{plot.dzi-41ea26e5.js → plot.dzi-6728a7c8.js} +1 -1
- package/dist/plot.ssgq-5581dc56.js +1 -0
- package/dist/{plot.vaf2cov-80e58833.js → plot.vaf2cov-b2284c64.js} +1 -1
- package/dist/{plot.wsi-51cc48ef.js → plot.wsi-9a9d4034.js} +1 -1
- package/dist/profileBarchart-0476f1f8.js +1 -0
- package/dist/profileHome-32eb9b50.js +1 -0
- package/dist/profilePlot-c7e099e8.js +1 -0
- package/dist/profilePolar-6b981e63.js +1 -0
- package/dist/profileRadar-bca1cc03.js +1 -0
- package/dist/profileRadarFacility-bbb1ecd8.js +1 -0
- package/dist/profileSummary-b114204f.js +1 -0
- package/dist/recover-49e09de0.js +1 -0
- package/dist/regression.inputs-a761f40d.js +1 -0
- package/dist/regression.inputs.values.table-5929d25a.js +1 -0
- package/dist/regression.results-69bc42d0.js +1 -0
- package/dist/{renderPvalueTable-895a72c2.js → renderPvalueTable-dc5d15f2.js} +1 -1
- package/dist/sampleScatter-2d0ed680.js +1 -0
- package/dist/{sampleScatter.rendererThree-5e686004.js → sampleScatter.rendererThree-0b12ac61.js} +2 -2
- package/dist/sampleView-484ab133.js +1 -0
- package/dist/samplelst-689796e6.js +1 -0
- package/dist/{samplematrix-2a1d7d82.js → samplematrix-2b137a05.js} +1 -1
- package/dist/scatter-205e013f.js +1 -0
- package/dist/{select2Terms-b4fffc50.js → select2Terms-b21e184a.js} +1 -1
- package/dist/{selectGenomeWithTklst-acf7e568.js → selectGenomeWithTklst-466995b4.js} +1 -1
- package/dist/singleCellCellType-5db730bb.js +1 -0
- package/dist/{singleCellGeneExpression-6de17162.js → singleCellGeneExpression-7147a2d0.js} +1 -1
- package/dist/singleCellPlot-73b2738f.js +1 -0
- package/dist/{singlecell-f76c856a.js → singlecell-24409b72.js} +1 -1
- package/dist/singlecell-bca774ed.js +1 -0
- package/dist/{snp-9590a1b4.js → snp-37d06246.js} +1 -1
- package/dist/snp-a8388ce4.js +1 -0
- package/dist/snplocus-7a1ea8c9.js +1 -0
- package/dist/{snplst-007a1926.js → snplst-6865d7c7.js} +1 -1
- package/dist/{spliceevent.a53ss.diagram-63dfef69.js → spliceevent.a53ss.diagram-e2eab72b.js} +1 -1
- package/dist/{spliceevent.exonskip.diagram-76fa9af8.js → spliceevent.exonskip.diagram-4d5df3a1.js} +1 -1
- package/dist/spliceevent.exonskip.getdefault-a94aad6e.js +1 -0
- package/dist/{spliceevent.noeventdiagram-64a099e0.js → spliceevent.noeventdiagram-ea97b0fb.js} +1 -1
- package/dist/{spliceevent.phrase-770c8cac.js → spliceevent.phrase-c5832470.js} +1 -1
- package/dist/{stattable-f1189f0f.js → stattable-7c5ecc2f.js} +1 -1
- package/dist/{style.gdc-89cfdb0f.js → style.gdc-131f3c77.js} +1 -1
- package/dist/summary-5ec455d3.js +1 -0
- package/dist/{sunburst-d5379952.js → sunburst-533902a7.js} +1 -1
- package/dist/survival-92250664.js +1 -0
- package/dist/survival-e16e068f.js +1 -0
- package/dist/{svg.download-86850940.js → svg.download-35926549.js} +1 -1
- package/dist/{svg.legend-a94b0697.js → svg.legend-8d490df2.js} +1 -1
- package/dist/{svgraph-c57b9ae3.js → svgraph-6fac8cbc.js} +1 -1
- package/dist/{svmr-cf6f1b27.js → svmr-d07ff695.js} +1 -1
- package/dist/table-29d5a973.js +1 -0
- package/dist/table-ad744310.js +1 -0
- package/dist/termInfo-bf99a37e.js +1 -0
- package/dist/{termdb.bins-9faa5170.js → termdb.bins-8b656cc3.js} +1 -1
- package/dist/termsetting-33ea66f1.js +1 -0
- package/dist/tk-071a7550.js +1 -0
- package/dist/{toggleButtons-002aeda1.js → toggleButtons-dbdbad01.js} +1 -1
- package/dist/tp.ui-9c2e9fc5.js +1 -0
- package/dist/tslib.es6-c3c2d88f.js +1 -0
- package/dist/tvs.density-f6128793.js +1 -0
- package/dist/{tvs.geneVariant-3a65ad94.js → tvs.geneVariant-ca4bdbb1.js} +1 -1
- package/dist/tvs.numeric-0260a825.js +1 -0
- package/dist/{tvs.samplelst-1eeb586b.js → tvs.samplelst-cb71b3bf.js} +1 -1
- package/dist/{uiUtils-1336bad7.js → uiUtils-f1bd2bcc.js} +1 -1
- package/dist/{variantBrowser-f0c812c1.js → variantBrowser-7c540224.js} +1 -1
- package/dist/{vcf-c4a23924.js → vcf-5cc55588.js} +1 -1
- package/dist/violin-2ba509eb.js +1 -0
- package/dist/violin.interactivity-4da6d7a9.js +1 -0
- package/dist/{violin.renderer-dafd89fa.js → violin.renderer-ce024265.js} +1 -1
- package/dist/{violinRenderer-8215f40d.js → violinRenderer-f7c96a60.js} +1 -1
- package/dist/{viridis-ffd14c4d.js → viridis-01ab20c5.js} +1 -1
- package/dist/{y-dd197cc9.js → y-67939f83.js} +1 -1
- package/dist/{zoom-9c63e74c.js → zoom-25dce8b9.js} +1 -1
- package/package.json +6 -4
- package/dist/AppHeader-a2a7e518.js +0 -1
- package/dist/DEanalysis-a6b50e49.js +0 -1
- package/dist/Disco-1c71b7dd.js +0 -1
- package/dist/Disco.UI-4c16ee50.js +0 -1
- package/dist/FilterRxComp-242f4615.js +0 -1
- package/dist/WSIViewer-d90032d7.js +0 -1
- package/dist/adSandbox-3528c372.js +0 -1
- package/dist/app-07dee349.js +0 -1
- package/dist/app-a8c4854a.js +0 -1
- package/dist/app-ade9c62a.js +0 -1
- package/dist/bam-92483a98.js +0 -1
- package/dist/barchart-3e69d094.js +0 -1
- package/dist/barchart.events-9b11d97e.js +0 -1
- package/dist/block-dcb130fb.js +0 -1
- package/dist/block.lazyload-9f031cac.js +0 -1
- package/dist/block.legend-b2987cd9.js +0 -1
- package/dist/block.mds2-de6e0986.js +0 -1
- package/dist/boxplot-1178fffc.js +0 -1
- package/dist/brainImaging-98ed7aa2.js +0 -1
- package/dist/categorical-26528ce8.js +0 -1
- package/dist/condition-b0d74550.js +0 -1
- package/dist/controls-0bacec22.js +0 -1
- package/dist/controls.config-0ccc9d79.js +0 -1
- package/dist/controls.divide-a9fe9466.js +0 -1
- package/dist/controls.overlay-fe20d41d.js +0 -1
- package/dist/controls.term1-faa2efcf.js +0 -1
- package/dist/cuminc-7e2cac2d.js +0 -1
- package/dist/dataDownload-ade8d840.js +0 -1
- package/dist/databrowser.ui-716f0519.js +0 -1
- package/dist/dictionary-3f83ce63.js +0 -1
- package/dist/facet-6850cfed.js +0 -1
- package/dist/geneExpClustering-7fd3c87e.js +0 -1
- package/dist/geneExpression-6462537d.js +0 -1
- package/dist/geneORA-7eb818c4.js +0 -1
- package/dist/geneVariant-b58e924a.js +0 -1
- package/dist/geneset-9f69ad3f.js +0 -1
- package/dist/genomeBrowser-1b2b83f7.js +0 -1
- package/dist/genomeBrowser.controls-cd8ddeb1.js +0 -1
- package/dist/gsea-36376589.js +0 -1
- package/dist/hierCluster-f1e30c19.js +0 -1
- package/dist/hierCluster.config-da3510b1.js +0 -1
- package/dist/hierCluster.renderers-610d8860.js +0 -1
- package/dist/imagePlot-7089bdff.js +0 -1
- package/dist/launch.adhoc-d229fd55.js +0 -1
- package/dist/leftlabel.sample-a919168c.js +0 -1
- package/dist/legacyDataset-1cbcb67d.js +0 -1
- package/dist/matrix-0614794d.js +0 -1
- package/dist/matrix.cells-819d4991.js +0 -1
- package/dist/matrix.config-c54ca273.js +0 -1
- package/dist/matrix.controls-5eca7822.js +0 -1
- package/dist/matrix.groups-4660dd70.js +0 -1
- package/dist/matrix.interactivity-23d83183.js +0 -1
- package/dist/matrix.legend-2e647224.js +0 -1
- package/dist/matrix.renderers-43445f4f.js +0 -1
- package/dist/matrix.serieses-972fbe5d.js +0 -1
- package/dist/matrix.sort-80d9b788.js +0 -1
- package/dist/mds.samplescatterplot-1623e6d0.js +0 -1
- package/dist/niceNumLabels-6cfc1508.js +0 -1
- package/dist/numeric.binary-80467e8b.js +0 -1
- package/dist/numeric.continuous-69a62a15.js +0 -1
- package/dist/numeric.discrete-86181905.js +0 -1
- package/dist/numeric.spline-1b07fd13.js +0 -1
- package/dist/numeric.toggle-37c4bee8.js +0 -1
- package/dist/oncomatrix-475271da.js +0 -1
- package/dist/plot.app-aa916e0e.js +0 -1
- package/dist/plot.barplot-8b440a2b.js +0 -1
- package/dist/plot.brainImaging-2f796b0c.js +0 -1
- package/dist/plot.disco-43e18d2f.js +0 -1
- package/dist/plot.ssgq-e49cb70b.js +0 -1
- package/dist/profileBarchart-91463ab6.js +0 -1
- package/dist/profileHome-d37a6821.js +0 -1
- package/dist/profilePlot-9ca577cb.js +0 -1
- package/dist/profilePolar-19c7da5b.js +0 -1
- package/dist/profileRadar-8bf094e3.js +0 -1
- package/dist/profileRadarFacility-f9fd8971.js +0 -1
- package/dist/profileSummary-93999c14.js +0 -1
- package/dist/recover-36ada47f.js +0 -1
- package/dist/regression.inputs-cb57ece6.js +0 -1
- package/dist/regression.inputs.values.table-908bb37a.js +0 -1
- package/dist/regression.results-c186a8dc.js +0 -1
- package/dist/roundValue-b0d0517c.js +0 -1
- package/dist/sampleScatter-9d5b3630.js +0 -1
- package/dist/sampleView-2d895023.js +0 -1
- package/dist/samplelst-9f8343ff.js +0 -1
- package/dist/scatter-b4992f64.js +0 -1
- package/dist/singleCellCellType-84a0c2cf.js +0 -1
- package/dist/singleCellPlot-2f2b8619.js +0 -1
- package/dist/singlecell-90567dde.js +0 -1
- package/dist/snp-79ec95ba.js +0 -1
- package/dist/snplocus-cb629be1.js +0 -1
- package/dist/spliceevent.exonskip.getdefault-31d2950c.js +0 -1
- package/dist/summary-b77bef3c.js +0 -1
- package/dist/survival-61ab375a.js +0 -1
- package/dist/survival-80a0ade9.js +0 -1
- package/dist/table-79e3e776.js +0 -1
- package/dist/table-eee91e14.js +0 -1
- package/dist/termInfo-f851b415.js +0 -1
- package/dist/tk-75566002.js +0 -1
- package/dist/tp.ui-02911b56.js +0 -1
- package/dist/tslib.es6-1f85f553.js +0 -1
- package/dist/tvs.density-026fca97.js +0 -1
- package/dist/tvs.numeric-3f3d9919.js +0 -1
- package/dist/violin-1515c3e6.js +0 -1
- package/dist/violin.interactivity-8e2f480d.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as t}from"./legacy-d3-polyfill-bdb2d792.js";import{ah as e,aM as a,aL as s,r as i,I as o,d as r,a9 as n,a8 as h,Z as l,M as d,c1 as p,bY as c,ag as f,p as g,ac as m,U as x,ab as u}from"./app-a8c4854a.js";import{d as b}from"./arc-3d6751aa.js";import{p as y}from"./partition-db811f6b.js";import{p as v}from"./pointer-c7475677.js";import{l as w}from"./log-cf45fcf2.js";import{c as k}from"./axis-747c801e.js";import"./constant-426a1483.js";import"./math-2fb199c6.js";function _(t,n,h){if(!t.p.cohort){return}t.grab.min=Math.min(n,h);t.grab.max=Math.max(n,h);let l=t.data.filter((e=>e.value>=t.grab.min&&e.value<=t.grab.max));if(l.length==0){if(t.grab.sun){t.grab.sun.g.remove()}return}if(t.p.cohort.annotation){const e=[];for(const a of l){const s={};for(const t in a){if(t!="circle"){s[t]=a[t]}}const i=t.p.cohort.annotation[a[t.p.sampletype]];if(i){for(const t in i){s[t]=i[t]}}e.push(s)}l=e}const d=t.grab;if(d.sun){d.sun.g.remove()}else{d.sun={x:0,y:0}}const p=d.sun;p.g=d.holder.append("g").attr("transform","translate("+p.x+","+p.y+")").on("mouseover",(()=>{t.dottip.hide()}));let c=0;for(const e of l){if(e[t.p.cohort.levels[0].k]!=undefined){c++}}if(c==0){p.g.append("text").text("0/"+l.length).attr("font-size",40).attr("font-family",e).attr("stroke","white").attr("stroke-width",3).attr("text-anchor","middle");p.g.append("text").text("0/"+l.length).attr("font-size",40).attr("font-family",e).attr("fill",t.p.hlcolor).attr("text-anchor","middle").attr("fill-opacity",.8).on("click",(()=>{M(p,d,t)}));return}if(t.samplecart){d.selectedsamples=l.map((t=>t.sample_name?t.sample_name:t.sample));t.samplecart.setBtns({samplelst:d.selectedsamples,basket:"Gene Expression",id:t.genename+(!t.grab||!l.length?"":" FPKM:"+t.grab.min+"-"+t.grab.max),container:t.samplecartWrapper,reselectable:true})}const f=Math.min(t.width,t.height)*.3;const g=p.g.append("g");let m;let x;const u=b().startAngle((t=>t.x0)).endAngle((t=>t.x1)).innerRadius((t=>{if(!t.parent){x=Math.sqrt(t.y1)-f/15;return x}return Math.sqrt(t.y0)})).outerRadius((t=>{t.outradius=Math.sqrt(t.y1);if(t.parent&&!t.parent.parent){m=t.outradius}return t.outradius}));const v=a(l,t.p.cohort.levels);const w=s()(v);w.sum((t=>t.value));w.sort(((t,e)=>e.value-t.value));y().size([Math.PI*2,f*f])(w);p.ring=p.g.selectAll().data(w.descendants()).enter().append("path").attr("d",u).attr("stroke","white").attr("fill-opacity",1).attr("fill-rule","evenodd").attr("fill",(e=>{if(!e.parent)return"white";let a;if(e.children){a=e.id}else{if(!e.parent.parent){a=e.id}else{a=e.parent.id}}e._color=t.p.cohort.suncolor(a);return e._color})).on("mouseover",((t,e)=>{if(!e.parent)return;D.text(e.data.name);C.text(e.data.name);L.text(e.value);Y.text(e.data.full||"");t.target.setAttribute("fill",i(e._color).darker(.5).toString())})).on("mouseout",((e,a)=>{D.text(d.min+" - "+d.max).attr("font-size",X);C.text(d.min+" - "+d.max).attr("font-size",X);L.text(c==l.length?l.length:c+"/"+l.length);Y.text(t.p.datatype);e.target.setAttribute("fill",a._color)})).on("click",((e,a)=>{if(!t.samplecart){return}const s=[];for(const t of a.data.lst){s.push(t.sample_name?t.sample_name:t.sample)}t.samplecart.setBtns({samplelst:s,basket:"Gene Expression",note:a.data.name+" samples with "+t.genename+" "+t.p.datatype+" between "+t.grab.min+" and "+t.grab.max,id:t.genename+(!t.grab||!a.data.lst.length||!a.data.lst[0]?"":" FPKM:"+t.grab.min+"-"+t.grab.max)+" "+a.data.lst[0].ancestor_dx,container:t.samplecartWrapper,reselectable:true})}));g.append("circle").attr("r",m).attr("fill","white").attr("fill-opacity",.7);const k=[],_=[],z=[],F=[];for(const t of w.leaves()){const e=(t.x0+t.x1)/2;if(e<=Math.PI/2)k.push(t);else if(e<=Math.PI)_.push(t);else if(e<=Math.PI*1.5)z.push(t);else F.push(t)}k.sort(((t,e)=>e.x0-t.x0));_.sort(((t,e)=>t.x0-e.x0));z.sort(((t,e)=>e.x0-t.x0));F.sort(((t,e)=>t.x0-e.x0));const j=[...k,..._,...z,...F];const B=[];const P=[];const A=Math.max(13,t.dotsize*.7);p.g.selectAll().data(j).enter().append("text").text((t=>(t.parent.data.name?t.parent.data.name=="root"?"":t.parent.data.name+", ":"")+t.data.name)).attr("font-size",A).attr("font-family",e).attr("stroke","white").attr("stroke-width",3).attr("fill","none").each((function(t){const e=this.getBBox().height;const a=(t.x0+t.x1)/2;let s=f+5;let i=-s*Math.cos(a);if(a<=Math.PI){let t=true;for(const o of P){if(i>=o[0]&&i<=o[1]){t=false;if(a<=Math.PI/2){i=o[0]-2;s=-i/Math.cos(a);o[0]=i-e}else{i=2+o[1];s=-i/Math.cos(a);o[1]=i+e}break}}if(t){if(a<=Math.PI/2){P.push([i-e,i])}else{P.push([i,i+e])}}}else{let t=true;for(const o of B){if(i>=o[0]&&i<=o[1]){t=false;if(a<=Math.PI*1.5){i=2+o[1];s=-i/Math.cos(a);o[1]=i+e}else{i=o[0]-2;s=-i/Math.cos(a);o[0]=i-e}break}}if(t){if(a<=Math.PI*1.5){B.push([i,i+e])}else{B.push([i-e,i])}}}t.labely=i;t.labelx=s*Math.sin(a)})).attr("x",(t=>t.labelx)).attr("y",(t=>t.labely)).attr("text-anchor",(t=>(t.x0+t.x1)/2<=Math.PI?"start":"end")).attr("dominant-baseline",(t=>{var e=(t.x0+t.x1)/2;if(e<=Math.PI/2||e>=Math.PI*1.5)return"";return"hanging"}));p.g.selectAll().data(j).enter().append("text").text((t=>(t.parent.parent?t.parent.data.name+", ":"")+t.data.name)).attr("font-size",A).attr("font-family",e).attr("fill","#858585").attr("x",(t=>t.labelx)).attr("y",(t=>t.labely)).attr("text-anchor",(t=>(t.x0+t.x1)/2<=Math.PI?"start":"end")).attr("dominant-baseline",(t=>{var e=(t.x0+t.x1)/2;if(e<=Math.PI/2||e>=Math.PI*1.5)return"";return"hanging"}));p.g.selectAll().data(j).enter().append("line").attr("x1",(t=>t.outradius*Math.sin((t.x0+t.x1)/2))).attr("y1",(t=>-t.outradius*Math.cos((t.x0+t.x1)/2))).attr("x2",(t=>t.labelx)).attr("y2",(t=>t.labely)).attr("stroke","#858585");const I=Math.max(18,x*.6);const R=Math.max(14,x*.2);let N=-3;let X;p.g.append("text").text(t.p.sampletype.toUpperCase()).attr("font-size",R).attr("font-family",e).attr("y",-I).attr("fill",t.p.hlcolor).attr("text-anchor","middle");const L=p.g.append("text").text(c==l.length?l.length:c+"/"+l.length).attr("font-size",I).attr("font-family",e).attr("y",N).attr("fill",t.p.hlcolor).attr("text-anchor","middle").attr("fill-opacity",.8);N=5;const Y=p.g.append("text").text(t.p.datatype).attr("font-size",R).attr("font-family",e).attr("y",N).attr("dominant-baseline","hanging").attr("text-anchor","middle").attr("fill","#b5b5b5");const U=d.min+" - "+d.max;const S=o().domain([5,15]).range([x,x*2]);const C=p.g.append("text").text(U).attr("font-size",1).each((function(){var t=this.getBBox();X=Math.min(S(U.length)/t.width,x*.4/t.height)})).attr("font-size",X).attr("font-family",e).attr("y",N+R).attr("dominant-baseline","hanging").attr("text-anchor","middle").attr("stroke","white").attr("stroke-width",3).attr("fill","none");const D=p.g.append("text").text(U).attr("font-size",X).attr("font-family",e).attr("y",N+R).attr("dominant-baseline","hanging").attr("text-anchor","middle").attr("fill","#858585");p.g.append("circle").attr("r",x+f/15).attr("fill","white").attr("fill-opacity",0).on("click",(()=>{if(p.busy)return;M(p,d,t)})).on("mousedown",(t=>{const e=p.x,a=p.y,s=t.clientX,i=t.clientY,o=r(document.body);o.on("mousemove",(t=>{t.preventDefault();p.busy=true;p.x=e+t.clientX-s;p.y=a+t.clientY-i;p.g.attr("transform","translate("+p.x+","+p.y+")")})).on("mouseup",(()=>{o.on("mousemove",null).on("mouseup",null);setTimeout((()=>p.busy=false),10)}))}))}function M(t,e,a){if(t.ring){t.ring.transition().attr("fill-opacity",0)}t.g.transition().attr("transform","scale(.5,.5)").on("end",(()=>{t.g.remove();e.shade.attr("transform","translate(0,1000)")}));e.shadebox.transition().duration(500).attr("stroke-opacity",0).attr("fill-opacity",0);e.shadehandle1.transition().duration(500).attr("fill-opacity",0);e.shadehandle2.transition().duration(500).attr("fill-opacity",0);delete e.x;if(a.selectsample_button){a.selectsample_button.style("display","none").text("")}}function z(t,a,s,i,o){for(const e of t.boxplots){if(e.id==i)return}o.style("border-color",t.boxcolor);for(const e of t.boxplots){e.highlight=false;e.label.attr("fill",t.boxcolor);e.label2.attr("fill",t.boxcolor)}let r=[[0,t.height]];for(const e of t.boxplots){const t=e.yoff;const a=e.height;for(const e of r){if(Math.max(t,e[0])<Math.min(t+a,e[1])){if(t+a<e[1]){r.push([t+a+1,e[1]])}e[1]=t-1}}}const h=t.sf_boxlabelfontsize(Math.log(a.length));const l=t.sf_boxheight(a.length);let d=0;for(const t of r){if(t[1]-t[0]>Math.max(l,h)){d=t[0]+3;break}}const p=t.boxbag.append("g").attr("transform","translate(0,"+d+")");const c={labeltext:s,lst:a,holder:p,yoff:d,highlight:false,id:i,handle:o,height:Math.max(l,h),lookuphash:{}};for(const e of a){c.lookuphash[e[t.p.sampletype]]=1}t.boxplots.push(c);const f=a[Math.floor((a.length-1)*.91)].value,g=a[Math.floor((a.length-1)*.75)].value,m=a[Math.floor((a.length-1)*.5)].value,x=a[Math.floor((a.length-1)*.25)].value,u=a[Math.floor((a.length-1)*.09)].value;c.percentile={9:f==0?1e-4:f,25:g==0?1e-4:g,50:m==0?1e-4:m,75:x==0?1e-4:x,91:u==0?1e-4:u};c.hline=p.append("line").attr("y1",l/2).attr("y2",l/2).attr("stroke",t.boxcolor).attr("stroke-dasharray","5,3").attr("shape-rendering","crispEdges");c.hline.transition().duration(t.dur).attr("x1",Math.max(0,t.x_scale(f))).attr("x2",Math.max(0,t.x_scale(u)));c.label=p.append("text").attr("y",l/2).attr("font-size",h).attr("font-family",e).attr("text-anchor","end").attr("dominant-baseline","middle").attr("fill",c.highlight?t.p.hlcolor:t.boxcolor).style("cursor","default").text(s).on("mousedown",(e=>B(t,c,e))).on("click",(()=>j(t,c))).each((function(){c.labelwidth=this.getBBox().width})).attr("x",t.width+t.width2+c.labelwidth);c.label.transition().duration(t.dur).attr("x",t.width+t.width2-t.width2_-3);c.label2=p.append("text").attr("x",t.width+t.width2+c.labelwidth).attr("y",l/2).attr("font-size",h).attr("font-family",e).attr("dominant-baseline","middle").attr("fill",c.highlight?t.p.hlcolor:t.boxcolor).style("cursor","default").text(a.length).on("mousedown",(()=>B(t,c))).on("click",(()=>j(t,c)));c.label2.transition().duration(t.dur).attr("x",t.width+t.width2-t.width2_+3);c.connline=p.append("line").attr("y1",l/2).attr("y2",l/2).attr("stroke",t.boxcolor).attr("stroke-dasharray","1,3").attr("shape-rendering","crispEdges");c.connline.transition().duration(t.dur).attr("x1",Math.max(0,t.x_scale(c.percentile[91]))).attr("x2",Math.max(0,t.width+t.width2-c.labelwidth-t.width2_-3));c.box=p.append("rect").attr("height",l).attr("shape-rendering","crispEdges").attr("fill","white").attr("stroke",t.boxcolor).on("click",(()=>F(t,c))).on("mousedown",(t=>{const e=t.target;e.setAttribute("fill","#FFeeee");e.setAttribute("stroke","#D10000")})).on("mouseover",(e=>{t.dottip.show(e.clientX,e.clientY).clear();const a=[{k:"Group",v:c.labeltext||"All samples"},{k:"1st quartile",v:c.percentile[25]},{k:"Median",v:c.percentile[50]},{k:"3rd quartile",v:c.percentile[75]}];n(t.dottip.d.append("div"),a)})).on("mouseout",(()=>{t.dottip.hide()}));c.box.transition().duration(t.dur).attr("x",Math.max(0,t.x_scale(c.percentile[25]))).attr("width",Math.max(0,t.x_scale(c.percentile[75]))-Math.max(0,t.x_scale(c.percentile[25])));c.vlines=p.selectAll().data([c.percentile[9],c.percentile[25],c.percentile[50],c.percentile[75],c.percentile[91]]).enter().append("line").attr("x1",0).attr("x2",0).attr("y1",0).attr("y2",l).attr("stroke",t.boxcolor).attr("shape-rendering","crispEdges");c.vlines.transition().duration(t.dur).attr("x1",(e=>Math.max(0,t.x_scale(e)))).attr("x2",(e=>Math.max(0,t.x_scale(e))));if(s!=""){j(t,c)}}function F(t,e){let a=null;if(typeof e=="object"){a=e}else{for(const s of t.boxplots){if(s.id==e)a=s}}if(!a){console.log("cannot remove boxplot");return}a.handle.style("border-color","transparent");if(a.label.attr("fill")==t.p.hlcolor){j(t,a)}a.holder.transition().attr("transform","translate("+(t.width+20)+","+a.yoff+")").each((()=>a.holder.remove()));for(let e=0;e<t.boxplots.length;e++){if(t.boxplots[e].id==a.id){t.boxplots.splice(e,1);return}}}function j(t,e){if(t.busy)return;for(const a of t.boxplots){if(a.id!=e.id)a.highlight=false}e.highlight=!e.highlight;t.epdot.transition().duration(1e3).attr("r",(a=>{if(a[t.p.sampletype]in e.lookuphash)return e.highlight?t.dotsize*.7:t.dotsize/2;return e.highlight?t.dotsize*.2:t.dotsize/2})).attr("stroke",(a=>{if(a[t.p.sampletype]in e.lookuphash)return e.highlight?t.p.hlcolor:"black";return"black"})).attr("stroke-opacity",(a=>{if(a[t.p.sampletype]in e.lookuphash)return e.highlight?.4:.2;return e.highlight?.1:.2}));for(const e of t.boxplots){e.label.attr("fill",e.highlight?t.p.hlcolor:t.boxcolor);e.label2.attr("fill",e.highlight?t.p.hlcolor:t.boxcolor)}}function B(t,e,a){a.preventDefault();const s=a.clientY,i=e.yoff;const o=r(document.body);o.on("mousemove",(a=>{t.busy=true;e.yoff=i+a.clientY-s;e.holder.attr("transform","translate(0,"+e.yoff+")")})).on("mouseup",(()=>{o.on("mousemove",null).on("mouseup",null);setTimeout((()=>t.busy=false),100)}))}const P=300,A=500,I=400,R=700;const N=.6;const X=.2;class L{constructor(i){this.p=i.expp;if(this.p.cohort){if(!this.p.cohort.suncolor){this.p.cohort.suncolor=h(t)}}this.boxcolor="#006600";this.boxplots=[];this.const_all="All "+this.p.sampletype+"s";this.uselog=false;this.dotmoved=false;this.genename=i.genename;this.presize=i.presize;this.dsname=i.dsname;this.genome=i.genome;this.hostURL=i.block?i.block.hostURL:i.hostURL;this.samplecart=i.samplecart;if(i.block){const t=i.block.holder.node().getBoundingClientRect();this.presize={x:t.left+i.block.leftheadw+i.block.width+20,y:t.top,width:Math.min(A,Math.max(P,document.body.scrollWidth-t.left-t.width-100)),height:Math.min(R,Math.max(I,document.body.clientHeight-270))}}this.source=i.source;this.data=i.data;this.data.sort(((t,e)=>e.value-t.value));this.minvalue=0;this.maxvalue=0;if(this.data.length>0){this.minvalue=this.maxvalue=this.data[0].value}this.sampletype2value={};for(const t of this.data){const e=t.value;this.minvalue=Math.min(this.minvalue,e);this.maxvalue=Math.max(this.maxvalue,e);this.sampletype2value[t[this.p.sampletype]]=e}if(this.p.scaleminvalue!=undefined){this.minvalue=this.p.scaleminvalue}this.pane=l({x:this.presize.x,y:this.presize.y});this.pane.pane.classed("sja_ep_pane",true);this.dottip=new d({padding:"10px"});if(i.block){const t=r(this.pane.header.node().previousSibling);t.on("click",(()=>{this.epaintfold(i.block)}))}this.pane.body.style("padding","10px");const c=t=>{this.pane.body.append("p").text(t)};if(this.data.length==0){this.pane.header.text(this.p.name);c("No expression data for "+this.genename);return}this.pane.header.text(this.genename+" "+this.p.name+(this.dsname?" from "+this.dsname:""));S(this);this.treediv=this.pane.body.append("div").style("display","none").style("margin","20px 0px 30px 0px").style("padding","10px").style("background-color","#FFFFE8");this.treediv.append("div").style("font-size",".7em").style("color","#858585").style("text-align","center").text("Click on a row to show/hide boxplot");this.svg=this.pane.body.append("svg");if(this.samplecart){this.samplecartWrapper=this.pane.body.append("div");this.samplecart.setBtns({samplelst:this.grab&&this.grab.selectedsamples?this.grab.selectedsamples:[],basket:"Gene Expression",id:this.genename+(!this.grab?"":" FPKM:"+this.grab.min+"-"+this.grab.max),container:this.samplecartWrapper,reselectable:true,replaceable:false})}this.pane.body.append("div").style("text-align","right").append("span").text("drag to resize").attr("font-size",".8em").attr("font-family",e).attr("class","sja_clbtext").on("mousedown",(t=>{t.preventDefault();const e=t.clientX;const a=t.clientY;const s=this.width;const i=this.height;const o=r(document.body);o.on("mousemove",(t=>{this.render(s+t.clientX-e,i+t.clientY-a)}));o.on("mouseup",(()=>{o.on("mousemove",null).on("mouseup",null)}))}));this.sf_boxheight=o().domain([0,this.data.length]);this.sf_boxlabelfontsize=o();this.boxplots=[];if(this.svgg){this.svgg.remove()}this.svgg=this.svg.append("g");this.axisg=this.svgg.append("g");this.grabbar=this.svgg.append("rect").attr("x",0).attr("y",0).attr("fill","white").attr("fill-opacity",0).on("mousedown",(t=>{if(!this.p.cohort){console.log("no .p.cohort");return}this.busy=true;const e=v(t,this.grabbar.node())[0];const a=Number.parseFloat(this.x_scale.invert(e).toFixed(1));this.grab.x=e;this.grab.width=1;this.grab.shade.attr("transform","translate("+e+","+this.grab.y+")");this.grab.shadebox.attr("width",2).attr("height",this.grab.height).attr("stroke-opacity",.7).attr("fill-opacity",.1);this.grab.shadehandle1.attr("fill-opacity",.5);this.grab.shadehandle2.attr("x",2).attr("fill-opacity",.5);_(this,a,Number.parseFloat(this.x_scale.invert(e+1).toFixed(1)));const s=r(document.body);s.on("mousemove",(t=>{t.preventDefault();let s=v(t,this.grabbar.node())[0];s=Math.max(-this.dotsize,s);s=Math.min(this.width+this.dotsize,s);this.grab.width=Math.max(1,Math.abs(s-e));this.grab.shadebox.attr("width",this.grab.width);this.grab.shadehandle2.attr("x",this.grab.width);if(s<e){this.grab.x=s;this.grab.shade.attr("transform","translate("+this.grab.x+","+this.grab.y+")")}_(this,a,Number.parseFloat(this.x_scale.invert(s).toFixed(1)))}));s.on("mouseup",(()=>{this.busy=false;s.on("mousemove",null).on("mouseup",null)}))}));this.verticalline=this.svgg.append("line").attr("stroke",this.boxcolor).attr("stroke-opacity",.1).attr("shape-rendering","crispEdges");this.dur=2e3;this.boxbag=this.svgg.append("g");this.graph=this.svgg.append("g");this.sung=this.svgg.append("g");this.grab={shade:this.sung.append("g"),holder:this.sung.append("g")};this.grab.shadebox=this.grab.shade.append("rect").attr("stroke",this.p.hlcolor).attr("stroke-width",1).attr("fill",this.p.hlcolor).style("cursor","move").on("mousedown",(t=>{if(!this.p.cohort){return}this.busy=true;let e=t.clientX;const a=r(document.body);a.on("mousemove",(t=>{t.preventDefault();const a=t.clientX;this.grab.x+=a-e;e=a;this.grab.shade.attr("transform","translate("+this.grab.x+","+this.grab.y+")");_(this,Number.parseFloat(this.x_scale.invert(this.grab.x).toFixed(1)),Number.parseFloat(this.x_scale.invert(this.grab.x+this.grab.width).toFixed(1)))})).on("mouseup",(()=>{this.busy=false;a.on("mousemove",null).on("mouseup",null)}))}));this.grab.shadehandle1=this.grab.shade.append("rect").attr("x",-5).attr("width",5).attr("height",40).attr("fill",this.p.hlcolor).attr("fill-opacity",0).style("cursor","ew-resize").on("mousedown",(t=>{this.busy=true;let e=t.clientX;const a=r(document.body);a.on("mousemove",(t=>{t.preventDefault();const a=t.clientX;this.grab.width+=e-a;if(this.grab.width<=0){this.grab.width-=e-a;return}this.grab.x+=a-e;e=a;this.grab.shade.attr("transform","translate("+this.grab.x+","+this.grab.y+")");this.grab.shadebox.attr("width",this.grab.width);this.grab.shadehandle2.attr("x",this.grab.width);_(this,Number.parseFloat(this.x_scale.invert(this.grab.x).toFixed(1)),Number.parseFloat(this.x_scale.invert(this.grab.x+this.grab.width).toFixed(1)))})).on("mouseup",(()=>{this.busy=false;a.on("mousemove",null).on("mouseup",null)}))}));this.grab.shadehandle2=this.grab.shade.append("rect").attr("x",0).attr("width",5).attr("height",40).attr("fill",this.p.hlcolor).attr("fill-opacity",0).style("cursor","ew-resize").on("mousedown",(t=>{let e=t.clientX;const a=r(document.body);a.on("mousemove",(t=>{t.preventDefault();const a=t.clientX;this.grab.width+=a-e;if(this.grab.width<=0){this.grab.width-=a-e;return}e=a;this.grab.shadebox.attr("width",this.grab.width);this.grab.shadehandle2.attr("x",this.grab.width);_(this,Number.parseFloat(this.x_scale.invert(this.grab.x).toFixed(1)),Number.parseFloat(this.x_scale.invert(this.grab.x+this.grab.width).toFixed(1)))})).on("mouseup",(()=>{this.busy=false;a.on("mousemove",null).on("mouseup",null)}))}));this.epdotg=this.graph.selectAll().data(this.data).enter().append("g");this.epdot=this.epdotg.append("circle").attr("fill",this.p.hlcolor).attr("fill-opacity",0).attr("stroke","black").attr("stroke-width",2).attr("stroke-opacity",X).each((function(t){t.circle=this})).on("mouseover",((t,e)=>{if(this.busy)return;e.circle.setAttribute("transform","scale(1.5)");this.dottip.clear();const a=[{k:this.p.datatype,v:'<span style="font-size:150%">'+e.value+"</span>"}];if(this.p.attrlst){for(const t of this.p.attrlst){a.push({k:t.label||t.k,v:e[t.k]})}}const s=this.getsampleinfo(e,a);n(this.dottip.d,a).style("zoom",.7);this.dottip.show(t.clientX,t.clientY);if(s){this.dottip.d.append("div").text("Full details").attr("class","sja_menuoption").on("click",(()=>{U(e,this.p.cohort,t.clientX-100,t.clientY-100)}))}})).on("mouseout",((t,e)=>{e.circle.setAttribute("transform","scale(1)")})).on("mousedown",((t,e)=>{t.preventDefault();const a=t.clientY;const s=r(document.body);const i=this.data[Math.floor(this.data.length/2)].value;if(e.value<i){const t=this.dotgraph_y;s.on("mousemove",(e=>{this.busy=true;this.dotmoved=true;this.dotgraph_y=t+e.clientY-a;this.graph.attr("transform","translate(0,"+this.dotgraph_y+")")}))}else{const t=this.heightmove;s.on("mousemove",(e=>{this.dotmoved=true;this.heightmove=t+a-e.clientY;const s=this.heightmove/this.data.length;this.epdotg.attr("transform",((t,e)=>{t._y=this.height-this.heightmove+e*s;return"translate("+Math.max(0,this.x_scale(t.value))+","+t._y+")"}))}))}s.on("mouseup",(()=>{setTimeout((()=>this.busy=false),50);s.on("mousemove",null).on("mouseup",null)}))}));this.render();const f=this.treediv.append("div").style("margin","10px").style("padding","2px").style("border","solid 1px transparent").html("All samples "+this.data.length).attr("class","sja_clb").on("click",(()=>{let t=true;for(const e of this.boxplots){if(e.id=="all")t=false}if(t){z(this,this.data,"","all",f)}else{F(this,"all")}}));if(this.p.cohort){if(this.p.cohort&&this.p.cohort.annotation&&this.p.cohort.key4annotation){for(const t of this.data){const e=t[this.p.cohort.key4annotation];if(e){const a=this.p.cohort.annotation[e];if(a){if(this.p.cohort.levels){for(const e of this.p.cohort.levels){t[e.k]=a[e.k];if(e.full){t[e.full]=a[e.full]}}}else{for(const e in a){t[e]=a[e]}}}}}}const t=this.treediv.append("div").style("margin","10px").style("height","400px").style("overflow-y","scroll").style("resize","vertical");const e=a(this.data,this.p.cohort.levels);const i=p(s()(e));i.sum((t=>t.value));i.eachBefore((e=>{if(!e.parent)return;const a=t.append("div").style("margin","2px").style("padding","2px").style("border","solid 1px transparent").attr("class","sja_clb");for(let t=1;t<e.depth;t++){a.append("span").style("color","#ccc").style("padding","0px 15px").text("|")}const s=e.data.data;a.append("span").html(s.name+" ");if(s.full){a.append("span").html(s.full+" ").style("font-size",".7em").style("color","#858585")}if(s.lst&&s.lst.length){a.append("span").text(s.lst.length);a.on("click",(()=>{let t=true;for(const e of this.boxplots){if(e.id==s.id)t=false}if(t){z(this,s.lst,s.name,s.id,a)}else{F(this,s.id)}}))}}))}else{this.treediv.append("div").style("margin","10px").text("Cannot stratify sample: no cohort information.")}z(this,this.data,"","all",f)}epaintfold(t){if(!this.handle){const e=this.genome.datasets[this.dsname];if(!e){alert("invalid dataset name: "+this.dsname);return}this.handle=t.ds2handle[this.dsname].handle.append("div").classed("sja_opaque8",true).style("background-color","#999").style("color","white").style("padding","2px 4px").style("margin-left","1px").text("e");this.handle.on("click",(()=>{this.pane.pane.style("display","block");c(this.handle,this.pane.pane);this.handle.style("display","none")}))}this.handle.style("display","inline-block");c(this.pane.pane,this.handle);this.pane.pane.style("display","none")}makescale_ep(){const t=this.axish-2;if(this.uselog){this.x_scale=w().domain([1,this.maxvalue]).range([0,this.width])}else{this.x_scale=o().domain([this.minvalue,this.maxvalue]).range([0,this.width])}const e=k().scale(this.x_scale).tickSizeInner(this.tickh);if(this.uselog){e.ticks(6,",.0f")}else{let a;this.axisg.append("text").text(Math.ceil(this.maxvalue)).attr("font-size",t-this.tickh).each((function(){a=this.getBBox().width})).remove();e.ticks(Math.floor(this.width/(a+20)))}if(this.axis){this.axis.remove()}this.axis=this.axisg.append("g").attr("transform","translate(0,"+t+")").call(e);f({axis:this.axis,fontsize:t-this.tickh,showline:true})}render(t,a){if(!t){t=this.presize.width;a=this.presize.height}this.width=t;this.width2=t*.05;this.dotsize=Math.max(13,t/30);this.height=a;this.sf_boxheight.range([10,this.height/8]);const s=Math.min(this.data.length*.7,300);this.sf_boxlabelfontsize.domain([0,Math.log(s),Math.log(this.data.length)]).range([8,this.sf_boxheight(s)/2,1+this.sf_boxheight(s)/2]);this.heightmove=this.height;this.rowheight_reset();this.svgg.attr("transform","translate("+this.dotsize+",0)");this.axish=Math.max(18,this.width*.04);this.tickh=this.axish*.3;this.makescale_ep();this.grabbar.attr("width",this.width);this.grabbar.attr("height",this.axish);const i=this.svgg.append("text").text(this.data.length).attr("font-family",e).attr("font-size",this.sf_boxlabelfontsize(Math.log(this.data.length)));this.width2_=i.node().getBBox().width+3;i.remove();const o=this.svgg.append("text").text("COUNT").attr("font-size",1).attr("font-family",e);const r=Math.max(8,(this.width2_-3)/o.node().getBBox().width);o.remove();this.axispad=5+r+this.dotsize/2;this.verticalline.attr("x1",this.width+this.width2-this.width2_).attr("y1",this.axish+5).attr("x2",this.width+this.width2-this.width2_).attr("y2",this.axish+this.height+this.axispad);this.dotgraph_y=this.axish+this.axispad;this.dotgraph_y_default=this.dotgraph_y;this.boxbag.attr("transform","translate(0,"+this.dotgraph_y+")");this.graph.attr("transform","translate(0,"+this.dotgraph_y+")");this.sung.attr("transform","translate(0,"+this.dotgraph_y+")");this.grab.y=-this.dotgraph_y-10;this.grab.height=this.height+this.dotgraph_y+30;this.grab.holder.attr("transform","translate("+this.width/2+","+this.height/2+")");this.grab.shadehandle1.attr("y",12+this.axish);this.grab.shadehandle2.attr("y",12+this.axish);this.epdotg.attr("transform",((t,e)=>{t._y=e*this.rowheight;return"translate(0,"+t._y+")"}));this.epdot.attr("r",this.dotsize/2);this.epdotg.attr("transform",(t=>"translate("+Math.max(0,this.x_scale(t.value))+","+t._y+")"));if(this.grab.x){let t=this.x_scale(this.grab.min),e=this.x_scale(this.grab.max);this.grab.x=t;this.grab.width=e-t;this.grab.shade.attr("transform","translate("+t+","+this.grab.y+")");this.grab.shadebox.attr("width",this.grab.width).attr("height",this.grab.height);this.grab.shadehandle2.attr("x",this.grab.width);_(this,this.grab.min,this.grab.max)}for(const t of this.boxplots){const e=this.sf_boxlabelfontsize(Math.log(t.lst.length));const a=this.sf_boxheight(t.lst.length);t.holder.attr("transform","translate(0,"+t.yoff+")");t.hline.attr("y1",a/2).attr("y2",a/2).attr("x1",Math.max(0,this.x_scale(t.percentile[9]))).attr("x2",Math.max(0,this.x_scale(t.percentile[91])));t.label.attr("x",this.width+this.width2-this.width2_-3).attr("y",a/2).attr("font-size",e);t.label2.attr("x",this.width+this.width2-this.width2_+3).attr("y",a/2).attr("font-size",e);t.connline.attr("y1",a/2).attr("y2",a/2).attr("x1",Math.max(0,this.x_scale(t.percentile[91]))).attr("x2",Math.max(0,this.width+this.width2-t.labelwidth-this.width2_-3));t.box.attr("height",a).attr("x",Math.max(0,this.x_scale(t.percentile[25]))).attr("width",Math.max(0,this.x_scale(t.percentile[75]))-Math.max(0,this.x_scale(t.percentile[25])));t.vlines.attr("x1",(t=>Math.max(0,this.x_scale(t)))).attr("x2",(t=>Math.max(0,this.x_scale(t)))).attr("y1",0).attr("y2",a)}this.svg.attr("width",this.width+this.width2+this.dotsize).attr("height",this.height+this.axish+this.axispad+this.dotsize/2)}getsampleinfo(t,e){if(this.p.cohort){if(this.p.cohort.annotation&&this.p.cohort.key4annotation){const a=t[this.p.cohort.key4annotation];if(a){e.push({k:this.p.cohort.key4annotation,v:a});const t=this.p.cohort.annotation[a];if(t){let a=0;for(const e in t)a++;if(this.p.cohort.levels){for(const a of this.p.cohort.levels){e.push({k:a.label||a.k,v:t[a.k]==undefined?"":t[a.k]})}return a>this.p.cohort.levels.length}let s=0;for(const i in t){e.push({k:i,v:t[i]});if(++s==a)return true}return false}}}else if(this.p.cohort.levels){for(const a of this.p.cohort.levels){const s=t[a.k];if(!s)continue;e.push({k:a.label||a.k,v:t[a.k]+(a.full?t[a.full]?' <span style="font-size:.8em;color:#858585">'+t[a.full]+"</span>":"":"")})}return false}}for(const a in t){if(a=="circle"||a=="_y")continue;if(typeof a=="string"){const s=t[a];if(s){e.push({k:a,v:s})}}}return false}rowheight_reset(){if(this.data){this.rowheight=this.height/this.data.length;return}this.rowheight=0}dot_appendtext(t,a){const s=[];t.append("text").text((t=>a.get(t[this.p.sampletype]))).attr("font-family",e).attr("font-size",this.dotsize).each((function(t){t.bb=this.getBBox()})).each((t=>{const e=this.x_scale(t.value);const a=e-this.dotsize>t.bb.width;let i=t._y-t.bb.height/2,o=i+t.bb.height;for(const e of s){if(e.onleft==a&&Math.max(e.y1,i)<Math.min(e.y2,o)){i=e.y2;o=i+t.bb.height}}delete t.bb;t.mafrect={y1:i,y2:o,onleft:a};s.push(t.mafrect)})).attr("class","sja_svgtext").attr("dominant-baseline","central").attr("fill",this.p.hlcolor).attr("text-anchor",(t=>t.mafrect.onleft?"end":"start")).attr("x",(t=>(t.mafrect.onleft?-1:1)*this.dotsize)).attr("y",(t=>t.mafrect.y1-t._y+this.dotsize/2)).on("click",((t,e)=>{r(e.circle).attr("stroke-width",1).attr("stroke-opacity",X).attr("stroke","black").attr("r",this.dotsize/2);e.showtext=false;r(t.target).remove()})).attr("font-size",1).transition().attr("font-size",this.dotsize)}may_hl(t,e){if(!this.data)return;const a=new Set;let s=true;for(const e of t){const t=e[this.p.sampletype];if(!t)continue;a.add(t);if(this.sampletype2value[t]){s=false}}if(s)return;this.epdot.filter((t=>a.has(t[this.p.sampletype]))).attr("r",e?this.dotsize*.8:this.dotsize/2).attr("stroke",e?this.p.hlcolor:"black").attr("stroke-opacity",e?N:X);const i=this.p.maf;if(!i)return;const o=new Map;for(const e of t){const t=e[this.p.sampletype];const a=this.p.maf.get(e);if(!a)continue;if(typeof a=="string"){o.set(t,a)}else{o.set(t,a.v2==0?"No "+this.p.maf.label+": site not covered":this.p.maf.label+": "+(a.f*100).toFixed(0)+"% ("+a.v1+"/"+a.v2+")")}}const r=this.epdotg.filter((t=>o.has(t[this.p.sampletype])&&!t.showtext));if(e){this.dot_appendtext(r,o)}else{r.select("text").remove()}}}function Y(t,e){const a=t.genome.datasets[t.dsname];if(a.dbexpression){const s={db:a.dbexpression.dbfile,tablename:a.dbexpression.tablename,keyname:a.dbexpression.keyname,key:e};fetch(new Request(t.hostURL+"/dbdata",{method:"POST",body:JSON.stringify(s)})).then((t=>t.json())).then((s=>{if(s.error)throw{message:s.error};if(a.dbexpression.tidy){a.dbexpression.tidy(s.rows)}const i=t.pane.pane.node().getBoundingClientRect();new L({hostURL:t.hostURL,data:s.rows,expp:t.p,presize:{x:i.left+30,y:i.top+50,width:t.width,height:t.height},genome:t.genome,dsname:t.dsname,genename:e,samplecart:t.samplecart})})).catch((t=>{window.alert(t.message);if(t.stack)console.log(t.stack)}));return}fetch(new Request(t.hostURL+"/dsdata",{method:"POST",body:JSON.stringify({genome:t.genome.name,dsname:t.dsname,expressiononly:1,genename:e})})).then((t=>t.json())).then((a=>{if(a.error)throw{message:a.error};const s=t.pane.pane.node().getBoundingClientRect();new L({hostURL:t.hostURL,data:a.data[0].lst,expp:t.p,presize:{x:s.left+30,y:s.top+50,width:t.width,height:t.height},genome:t.genome,dsname:t.dsname,genename:e,samplecart:t.samplecart})})).catch((t=>{window.alert(t.message);if(t.stack)console.log(t.stack)}))}function U(t,e,a,s){const i=l({x:a,y:s});const o=t[e.key4annotation];i.header.text(o);const r=[];const h=e.annotation[o];for(const t in h){r.push({k:t,v:h[t]})}n(i.body,r)}function S(t){const e=t.pane.body.append("div").style("margin-bottom","10px");e.append("button").text("Cohort").on("click",(()=>{if(t.treediv.style("display")=="none"){g(t.treediv)}else{m(t.treediv)}}));e.append("button").text("Log10").on("click",(()=>{const e=700;t.uselog=!t.uselog;t.makescale_ep();t.epdotg.transition().duration(e).attr("transform",((e,a)=>"translate("+(t.uselog&&e.value==0?0:Math.max(0,t.x_scale(e.value)))+","+e._y+")"));for(const a of t.boxplots){a.vlines.transition().duration(e).attr("x1",(e=>Math.max(0,t.x_scale(e)))).attr("x2",(e=>Math.max(0,t.x_scale(e))));a.box.transition().duration(e).attr("x",Math.max(0,t.x_scale(a.percentile[25]))).attr("width",Math.max(0,t.x_scale(a.percentile[75]))-Math.max(0,t.x_scale(a.percentile[25])));a.hline.transition().duration(e).attr("x1",Math.max(0,t.x_scale(a.percentile[9]))).attr("x2",Math.max(0,t.x_scale(a.percentile[91])));a.connline.transition().duration(e).attr("x1",Math.max(0,t.x_scale(a.percentile[91]))).attr("x2",t.width+t.width2-a.labelwidth-t.width2_-3)}if(t.grab.x){let a=t.x_scale(t.grab.min),s=t.x_scale(t.grab.max);t.grab.x=a;t.grab.width=s-a;t.grab.shade.transition().duration(e).attr("transform","translate("+a+","+t.grab.y+")");t.grab.shadebox.transition().duration(e).attr("width",t.grab.width);t.grab.shadehandle2.transition().duration(e).attr("x",t.grab.width)}}));e.append("button").text("SVG").on("click",(()=>{x(t.svg.node(),t.genename+"_expression")}));e.append("button").text("Data").on("click",(()=>{const e=[t.p.sampletype,t.p.datatype];const a=[];if(t.p.attrlst){for(const s of t.p.attrlst){e.push(s.k);a.push(s.k)}}if(t.p.cohort){for(const s of t.p.cohort.levels){e.push(s.k);a.push(s.k)}}const s=[];for(const e of t.data){const i=[e[t.p.sampletype],e.value];for(const t of a){i.push(e[t]||"")}s.push(i.join("\t"))}u(t.genename+" "+t.p.name+" data",[{text:e.join("\t")+"\n"+s.join("\n")}])}));e.append("input").attr("placeholder","Sample").style("width","60px").style("margin-left","5px").on("keyup",(e=>{const a=e.target.value;if(a==""){t.epdot.attr("r",t.dotsize/2).attr("stroke","black").attr("stroke-opacity",X);return}const s=a.toLowerCase();const i=new Set;for(const e in t.sampletype2value){if(e.toLowerCase().indexOf(s)!=-1){i.add(e)}}t.epdot.filter((e=>i.has(e[t.p.sampletype]))).attr("r",t.dotsize).attr("stroke",t.p.hlcolor).attr("stroke-opacity",N);t.epdot.filter((e=>!i.has(e[t.p.sampletype]))).attr("r",t.dotsize/2).attr("stroke","black").attr("stroke-opacity",X)}));e.append("input").attr("placeholder","Gene").style("width","60px").style("margin-left","5px").on("keyup",(e=>{const a=e.target.value;if(e.code=="Enter"){Y(t,a);e.target.value="";return}}));if(t.p.gtexlink){e.append("span").html(" <a target=_blank href=https://www.gtexportal.org/home/gene/"+t.genename+">GTeX normal</a>")}}export{L as default};
|
|
1
|
+
import{s as t}from"./legacy-d3-polyfill-bdb2d792.js";import{ah as e,aM as a,aL as s,r as i,I as o,d as r,a9 as n,a8 as h,Z as l,M as d,c1 as p,bY as c,ag as f,p as g,ac as m,U as x,ab as u}from"./app-b369b169.js";import{d as b}from"./arc-3d6751aa.js";import{p as y}from"./partition-db811f6b.js";import{p as v}from"./pointer-c7475677.js";import{l as w}from"./log-99af3443.js";import{c as k}from"./axis-747c801e.js";import"./constant-426a1483.js";import"./math-2fb199c6.js";function _(t,n,h){if(!t.p.cohort){return}t.grab.min=Math.min(n,h);t.grab.max=Math.max(n,h);let l=t.data.filter((e=>e.value>=t.grab.min&&e.value<=t.grab.max));if(l.length==0){if(t.grab.sun){t.grab.sun.g.remove()}return}if(t.p.cohort.annotation){const e=[];for(const a of l){const s={};for(const t in a){if(t!="circle"){s[t]=a[t]}}const i=t.p.cohort.annotation[a[t.p.sampletype]];if(i){for(const t in i){s[t]=i[t]}}e.push(s)}l=e}const d=t.grab;if(d.sun){d.sun.g.remove()}else{d.sun={x:0,y:0}}const p=d.sun;p.g=d.holder.append("g").attr("transform","translate("+p.x+","+p.y+")").on("mouseover",(()=>{t.dottip.hide()}));let c=0;for(const e of l){if(e[t.p.cohort.levels[0].k]!=undefined){c++}}if(c==0){p.g.append("text").text("0/"+l.length).attr("font-size",40).attr("font-family",e).attr("stroke","white").attr("stroke-width",3).attr("text-anchor","middle");p.g.append("text").text("0/"+l.length).attr("font-size",40).attr("font-family",e).attr("fill",t.p.hlcolor).attr("text-anchor","middle").attr("fill-opacity",.8).on("click",(()=>{M(p,d,t)}));return}if(t.samplecart){d.selectedsamples=l.map((t=>t.sample_name?t.sample_name:t.sample));t.samplecart.setBtns({samplelst:d.selectedsamples,basket:"Gene Expression",id:t.genename+(!t.grab||!l.length?"":" FPKM:"+t.grab.min+"-"+t.grab.max),container:t.samplecartWrapper,reselectable:true})}const f=Math.min(t.width,t.height)*.3;const g=p.g.append("g");let m;let x;const u=b().startAngle((t=>t.x0)).endAngle((t=>t.x1)).innerRadius((t=>{if(!t.parent){x=Math.sqrt(t.y1)-f/15;return x}return Math.sqrt(t.y0)})).outerRadius((t=>{t.outradius=Math.sqrt(t.y1);if(t.parent&&!t.parent.parent){m=t.outradius}return t.outradius}));const v=a(l,t.p.cohort.levels);const w=s()(v);w.sum((t=>t.value));w.sort(((t,e)=>e.value-t.value));y().size([Math.PI*2,f*f])(w);p.ring=p.g.selectAll().data(w.descendants()).enter().append("path").attr("d",u).attr("stroke","white").attr("fill-opacity",1).attr("fill-rule","evenodd").attr("fill",(e=>{if(!e.parent)return"white";let a;if(e.children){a=e.id}else{if(!e.parent.parent){a=e.id}else{a=e.parent.id}}e._color=t.p.cohort.suncolor(a);return e._color})).on("mouseover",((t,e)=>{if(!e.parent)return;D.text(e.data.name);C.text(e.data.name);L.text(e.value);Y.text(e.data.full||"");t.target.setAttribute("fill",i(e._color).darker(.5).toString())})).on("mouseout",((e,a)=>{D.text(d.min+" - "+d.max).attr("font-size",X);C.text(d.min+" - "+d.max).attr("font-size",X);L.text(c==l.length?l.length:c+"/"+l.length);Y.text(t.p.datatype);e.target.setAttribute("fill",a._color)})).on("click",((e,a)=>{if(!t.samplecart){return}const s=[];for(const t of a.data.lst){s.push(t.sample_name?t.sample_name:t.sample)}t.samplecart.setBtns({samplelst:s,basket:"Gene Expression",note:a.data.name+" samples with "+t.genename+" "+t.p.datatype+" between "+t.grab.min+" and "+t.grab.max,id:t.genename+(!t.grab||!a.data.lst.length||!a.data.lst[0]?"":" FPKM:"+t.grab.min+"-"+t.grab.max)+" "+a.data.lst[0].ancestor_dx,container:t.samplecartWrapper,reselectable:true})}));g.append("circle").attr("r",m).attr("fill","white").attr("fill-opacity",.7);const k=[],_=[],z=[],F=[];for(const t of w.leaves()){const e=(t.x0+t.x1)/2;if(e<=Math.PI/2)k.push(t);else if(e<=Math.PI)_.push(t);else if(e<=Math.PI*1.5)z.push(t);else F.push(t)}k.sort(((t,e)=>e.x0-t.x0));_.sort(((t,e)=>t.x0-e.x0));z.sort(((t,e)=>e.x0-t.x0));F.sort(((t,e)=>t.x0-e.x0));const j=[...k,..._,...z,...F];const B=[];const P=[];const A=Math.max(13,t.dotsize*.7);p.g.selectAll().data(j).enter().append("text").text((t=>(t.parent.data.name?t.parent.data.name=="root"?"":t.parent.data.name+", ":"")+t.data.name)).attr("font-size",A).attr("font-family",e).attr("stroke","white").attr("stroke-width",3).attr("fill","none").each((function(t){const e=this.getBBox().height;const a=(t.x0+t.x1)/2;let s=f+5;let i=-s*Math.cos(a);if(a<=Math.PI){let t=true;for(const o of P){if(i>=o[0]&&i<=o[1]){t=false;if(a<=Math.PI/2){i=o[0]-2;s=-i/Math.cos(a);o[0]=i-e}else{i=2+o[1];s=-i/Math.cos(a);o[1]=i+e}break}}if(t){if(a<=Math.PI/2){P.push([i-e,i])}else{P.push([i,i+e])}}}else{let t=true;for(const o of B){if(i>=o[0]&&i<=o[1]){t=false;if(a<=Math.PI*1.5){i=2+o[1];s=-i/Math.cos(a);o[1]=i+e}else{i=o[0]-2;s=-i/Math.cos(a);o[0]=i-e}break}}if(t){if(a<=Math.PI*1.5){B.push([i,i+e])}else{B.push([i-e,i])}}}t.labely=i;t.labelx=s*Math.sin(a)})).attr("x",(t=>t.labelx)).attr("y",(t=>t.labely)).attr("text-anchor",(t=>(t.x0+t.x1)/2<=Math.PI?"start":"end")).attr("dominant-baseline",(t=>{var e=(t.x0+t.x1)/2;if(e<=Math.PI/2||e>=Math.PI*1.5)return"";return"hanging"}));p.g.selectAll().data(j).enter().append("text").text((t=>(t.parent.parent?t.parent.data.name+", ":"")+t.data.name)).attr("font-size",A).attr("font-family",e).attr("fill","#858585").attr("x",(t=>t.labelx)).attr("y",(t=>t.labely)).attr("text-anchor",(t=>(t.x0+t.x1)/2<=Math.PI?"start":"end")).attr("dominant-baseline",(t=>{var e=(t.x0+t.x1)/2;if(e<=Math.PI/2||e>=Math.PI*1.5)return"";return"hanging"}));p.g.selectAll().data(j).enter().append("line").attr("x1",(t=>t.outradius*Math.sin((t.x0+t.x1)/2))).attr("y1",(t=>-t.outradius*Math.cos((t.x0+t.x1)/2))).attr("x2",(t=>t.labelx)).attr("y2",(t=>t.labely)).attr("stroke","#858585");const I=Math.max(18,x*.6);const R=Math.max(14,x*.2);let N=-3;let X;p.g.append("text").text(t.p.sampletype.toUpperCase()).attr("font-size",R).attr("font-family",e).attr("y",-I).attr("fill",t.p.hlcolor).attr("text-anchor","middle");const L=p.g.append("text").text(c==l.length?l.length:c+"/"+l.length).attr("font-size",I).attr("font-family",e).attr("y",N).attr("fill",t.p.hlcolor).attr("text-anchor","middle").attr("fill-opacity",.8);N=5;const Y=p.g.append("text").text(t.p.datatype).attr("font-size",R).attr("font-family",e).attr("y",N).attr("dominant-baseline","hanging").attr("text-anchor","middle").attr("fill","#b5b5b5");const U=d.min+" - "+d.max;const S=o().domain([5,15]).range([x,x*2]);const C=p.g.append("text").text(U).attr("font-size",1).each((function(){var t=this.getBBox();X=Math.min(S(U.length)/t.width,x*.4/t.height)})).attr("font-size",X).attr("font-family",e).attr("y",N+R).attr("dominant-baseline","hanging").attr("text-anchor","middle").attr("stroke","white").attr("stroke-width",3).attr("fill","none");const D=p.g.append("text").text(U).attr("font-size",X).attr("font-family",e).attr("y",N+R).attr("dominant-baseline","hanging").attr("text-anchor","middle").attr("fill","#858585");p.g.append("circle").attr("r",x+f/15).attr("fill","white").attr("fill-opacity",0).on("click",(()=>{if(p.busy)return;M(p,d,t)})).on("mousedown",(t=>{const e=p.x,a=p.y,s=t.clientX,i=t.clientY,o=r(document.body);o.on("mousemove",(t=>{t.preventDefault();p.busy=true;p.x=e+t.clientX-s;p.y=a+t.clientY-i;p.g.attr("transform","translate("+p.x+","+p.y+")")})).on("mouseup",(()=>{o.on("mousemove",null).on("mouseup",null);setTimeout((()=>p.busy=false),10)}))}))}function M(t,e,a){if(t.ring){t.ring.transition().attr("fill-opacity",0)}t.g.transition().attr("transform","scale(.5,.5)").on("end",(()=>{t.g.remove();e.shade.attr("transform","translate(0,1000)")}));e.shadebox.transition().duration(500).attr("stroke-opacity",0).attr("fill-opacity",0);e.shadehandle1.transition().duration(500).attr("fill-opacity",0);e.shadehandle2.transition().duration(500).attr("fill-opacity",0);delete e.x;if(a.selectsample_button){a.selectsample_button.style("display","none").text("")}}function z(t,a,s,i,o){for(const e of t.boxplots){if(e.id==i)return}o.style("border-color",t.boxcolor);for(const e of t.boxplots){e.highlight=false;e.label.attr("fill",t.boxcolor);e.label2.attr("fill",t.boxcolor)}let r=[[0,t.height]];for(const e of t.boxplots){const t=e.yoff;const a=e.height;for(const e of r){if(Math.max(t,e[0])<Math.min(t+a,e[1])){if(t+a<e[1]){r.push([t+a+1,e[1]])}e[1]=t-1}}}const h=t.sf_boxlabelfontsize(Math.log(a.length));const l=t.sf_boxheight(a.length);let d=0;for(const t of r){if(t[1]-t[0]>Math.max(l,h)){d=t[0]+3;break}}const p=t.boxbag.append("g").attr("transform","translate(0,"+d+")");const c={labeltext:s,lst:a,holder:p,yoff:d,highlight:false,id:i,handle:o,height:Math.max(l,h),lookuphash:{}};for(const e of a){c.lookuphash[e[t.p.sampletype]]=1}t.boxplots.push(c);const f=a[Math.floor((a.length-1)*.91)].value,g=a[Math.floor((a.length-1)*.75)].value,m=a[Math.floor((a.length-1)*.5)].value,x=a[Math.floor((a.length-1)*.25)].value,u=a[Math.floor((a.length-1)*.09)].value;c.percentile={9:f==0?1e-4:f,25:g==0?1e-4:g,50:m==0?1e-4:m,75:x==0?1e-4:x,91:u==0?1e-4:u};c.hline=p.append("line").attr("y1",l/2).attr("y2",l/2).attr("stroke",t.boxcolor).attr("stroke-dasharray","5,3").attr("shape-rendering","crispEdges");c.hline.transition().duration(t.dur).attr("x1",Math.max(0,t.x_scale(f))).attr("x2",Math.max(0,t.x_scale(u)));c.label=p.append("text").attr("y",l/2).attr("font-size",h).attr("font-family",e).attr("text-anchor","end").attr("dominant-baseline","middle").attr("fill",c.highlight?t.p.hlcolor:t.boxcolor).style("cursor","default").text(s).on("mousedown",(e=>B(t,c,e))).on("click",(()=>j(t,c))).each((function(){c.labelwidth=this.getBBox().width})).attr("x",t.width+t.width2+c.labelwidth);c.label.transition().duration(t.dur).attr("x",t.width+t.width2-t.width2_-3);c.label2=p.append("text").attr("x",t.width+t.width2+c.labelwidth).attr("y",l/2).attr("font-size",h).attr("font-family",e).attr("dominant-baseline","middle").attr("fill",c.highlight?t.p.hlcolor:t.boxcolor).style("cursor","default").text(a.length).on("mousedown",(()=>B(t,c))).on("click",(()=>j(t,c)));c.label2.transition().duration(t.dur).attr("x",t.width+t.width2-t.width2_+3);c.connline=p.append("line").attr("y1",l/2).attr("y2",l/2).attr("stroke",t.boxcolor).attr("stroke-dasharray","1,3").attr("shape-rendering","crispEdges");c.connline.transition().duration(t.dur).attr("x1",Math.max(0,t.x_scale(c.percentile[91]))).attr("x2",Math.max(0,t.width+t.width2-c.labelwidth-t.width2_-3));c.box=p.append("rect").attr("height",l).attr("shape-rendering","crispEdges").attr("fill","white").attr("stroke",t.boxcolor).on("click",(()=>F(t,c))).on("mousedown",(t=>{const e=t.target;e.setAttribute("fill","#FFeeee");e.setAttribute("stroke","#D10000")})).on("mouseover",(e=>{t.dottip.show(e.clientX,e.clientY).clear();const a=[{k:"Group",v:c.labeltext||"All samples"},{k:"1st quartile",v:c.percentile[25]},{k:"Median",v:c.percentile[50]},{k:"3rd quartile",v:c.percentile[75]}];n(t.dottip.d.append("div"),a)})).on("mouseout",(()=>{t.dottip.hide()}));c.box.transition().duration(t.dur).attr("x",Math.max(0,t.x_scale(c.percentile[25]))).attr("width",Math.max(0,t.x_scale(c.percentile[75]))-Math.max(0,t.x_scale(c.percentile[25])));c.vlines=p.selectAll().data([c.percentile[9],c.percentile[25],c.percentile[50],c.percentile[75],c.percentile[91]]).enter().append("line").attr("x1",0).attr("x2",0).attr("y1",0).attr("y2",l).attr("stroke",t.boxcolor).attr("shape-rendering","crispEdges");c.vlines.transition().duration(t.dur).attr("x1",(e=>Math.max(0,t.x_scale(e)))).attr("x2",(e=>Math.max(0,t.x_scale(e))));if(s!=""){j(t,c)}}function F(t,e){let a=null;if(typeof e=="object"){a=e}else{for(const s of t.boxplots){if(s.id==e)a=s}}if(!a){console.log("cannot remove boxplot");return}a.handle.style("border-color","transparent");if(a.label.attr("fill")==t.p.hlcolor){j(t,a)}a.holder.transition().attr("transform","translate("+(t.width+20)+","+a.yoff+")").each((()=>a.holder.remove()));for(let e=0;e<t.boxplots.length;e++){if(t.boxplots[e].id==a.id){t.boxplots.splice(e,1);return}}}function j(t,e){if(t.busy)return;for(const a of t.boxplots){if(a.id!=e.id)a.highlight=false}e.highlight=!e.highlight;t.epdot.transition().duration(1e3).attr("r",(a=>{if(a[t.p.sampletype]in e.lookuphash)return e.highlight?t.dotsize*.7:t.dotsize/2;return e.highlight?t.dotsize*.2:t.dotsize/2})).attr("stroke",(a=>{if(a[t.p.sampletype]in e.lookuphash)return e.highlight?t.p.hlcolor:"black";return"black"})).attr("stroke-opacity",(a=>{if(a[t.p.sampletype]in e.lookuphash)return e.highlight?.4:.2;return e.highlight?.1:.2}));for(const e of t.boxplots){e.label.attr("fill",e.highlight?t.p.hlcolor:t.boxcolor);e.label2.attr("fill",e.highlight?t.p.hlcolor:t.boxcolor)}}function B(t,e,a){a.preventDefault();const s=a.clientY,i=e.yoff;const o=r(document.body);o.on("mousemove",(a=>{t.busy=true;e.yoff=i+a.clientY-s;e.holder.attr("transform","translate(0,"+e.yoff+")")})).on("mouseup",(()=>{o.on("mousemove",null).on("mouseup",null);setTimeout((()=>t.busy=false),100)}))}const P=300,A=500,I=400,R=700;const N=.6;const X=.2;class L{constructor(i){this.p=i.expp;if(this.p.cohort){if(!this.p.cohort.suncolor){this.p.cohort.suncolor=h(t)}}this.boxcolor="#006600";this.boxplots=[];this.const_all="All "+this.p.sampletype+"s";this.uselog=false;this.dotmoved=false;this.genename=i.genename;this.presize=i.presize;this.dsname=i.dsname;this.genome=i.genome;this.hostURL=i.block?i.block.hostURL:i.hostURL;this.samplecart=i.samplecart;if(i.block){const t=i.block.holder.node().getBoundingClientRect();this.presize={x:t.left+i.block.leftheadw+i.block.width+20,y:t.top,width:Math.min(A,Math.max(P,document.body.scrollWidth-t.left-t.width-100)),height:Math.min(R,Math.max(I,document.body.clientHeight-270))}}this.source=i.source;this.data=i.data;this.data.sort(((t,e)=>e.value-t.value));this.minvalue=0;this.maxvalue=0;if(this.data.length>0){this.minvalue=this.maxvalue=this.data[0].value}this.sampletype2value={};for(const t of this.data){const e=t.value;this.minvalue=Math.min(this.minvalue,e);this.maxvalue=Math.max(this.maxvalue,e);this.sampletype2value[t[this.p.sampletype]]=e}if(this.p.scaleminvalue!=undefined){this.minvalue=this.p.scaleminvalue}this.pane=l({x:this.presize.x,y:this.presize.y});this.pane.pane.classed("sja_ep_pane",true);this.dottip=new d({padding:"10px"});if(i.block){const t=r(this.pane.header.node().previousSibling);t.on("click",(()=>{this.epaintfold(i.block)}))}this.pane.body.style("padding","10px");const c=t=>{this.pane.body.append("p").text(t)};if(this.data.length==0){this.pane.header.text(this.p.name);c("No expression data for "+this.genename);return}this.pane.header.text(this.genename+" "+this.p.name+(this.dsname?" from "+this.dsname:""));S(this);this.treediv=this.pane.body.append("div").style("display","none").style("margin","20px 0px 30px 0px").style("padding","10px").style("background-color","#FFFFE8");this.treediv.append("div").style("font-size",".7em").style("color","#858585").style("text-align","center").text("Click on a row to show/hide boxplot");this.svg=this.pane.body.append("svg");if(this.samplecart){this.samplecartWrapper=this.pane.body.append("div");this.samplecart.setBtns({samplelst:this.grab&&this.grab.selectedsamples?this.grab.selectedsamples:[],basket:"Gene Expression",id:this.genename+(!this.grab?"":" FPKM:"+this.grab.min+"-"+this.grab.max),container:this.samplecartWrapper,reselectable:true,replaceable:false})}this.pane.body.append("div").style("text-align","right").append("span").text("drag to resize").attr("font-size",".8em").attr("font-family",e).attr("class","sja_clbtext").on("mousedown",(t=>{t.preventDefault();const e=t.clientX;const a=t.clientY;const s=this.width;const i=this.height;const o=r(document.body);o.on("mousemove",(t=>{this.render(s+t.clientX-e,i+t.clientY-a)}));o.on("mouseup",(()=>{o.on("mousemove",null).on("mouseup",null)}))}));this.sf_boxheight=o().domain([0,this.data.length]);this.sf_boxlabelfontsize=o();this.boxplots=[];if(this.svgg){this.svgg.remove()}this.svgg=this.svg.append("g");this.axisg=this.svgg.append("g");this.grabbar=this.svgg.append("rect").attr("x",0).attr("y",0).attr("fill","white").attr("fill-opacity",0).on("mousedown",(t=>{if(!this.p.cohort){console.log("no .p.cohort");return}this.busy=true;const e=v(t,this.grabbar.node())[0];const a=Number.parseFloat(this.x_scale.invert(e).toFixed(1));this.grab.x=e;this.grab.width=1;this.grab.shade.attr("transform","translate("+e+","+this.grab.y+")");this.grab.shadebox.attr("width",2).attr("height",this.grab.height).attr("stroke-opacity",.7).attr("fill-opacity",.1);this.grab.shadehandle1.attr("fill-opacity",.5);this.grab.shadehandle2.attr("x",2).attr("fill-opacity",.5);_(this,a,Number.parseFloat(this.x_scale.invert(e+1).toFixed(1)));const s=r(document.body);s.on("mousemove",(t=>{t.preventDefault();let s=v(t,this.grabbar.node())[0];s=Math.max(-this.dotsize,s);s=Math.min(this.width+this.dotsize,s);this.grab.width=Math.max(1,Math.abs(s-e));this.grab.shadebox.attr("width",this.grab.width);this.grab.shadehandle2.attr("x",this.grab.width);if(s<e){this.grab.x=s;this.grab.shade.attr("transform","translate("+this.grab.x+","+this.grab.y+")")}_(this,a,Number.parseFloat(this.x_scale.invert(s).toFixed(1)))}));s.on("mouseup",(()=>{this.busy=false;s.on("mousemove",null).on("mouseup",null)}))}));this.verticalline=this.svgg.append("line").attr("stroke",this.boxcolor).attr("stroke-opacity",.1).attr("shape-rendering","crispEdges");this.dur=2e3;this.boxbag=this.svgg.append("g");this.graph=this.svgg.append("g");this.sung=this.svgg.append("g");this.grab={shade:this.sung.append("g"),holder:this.sung.append("g")};this.grab.shadebox=this.grab.shade.append("rect").attr("stroke",this.p.hlcolor).attr("stroke-width",1).attr("fill",this.p.hlcolor).style("cursor","move").on("mousedown",(t=>{if(!this.p.cohort){return}this.busy=true;let e=t.clientX;const a=r(document.body);a.on("mousemove",(t=>{t.preventDefault();const a=t.clientX;this.grab.x+=a-e;e=a;this.grab.shade.attr("transform","translate("+this.grab.x+","+this.grab.y+")");_(this,Number.parseFloat(this.x_scale.invert(this.grab.x).toFixed(1)),Number.parseFloat(this.x_scale.invert(this.grab.x+this.grab.width).toFixed(1)))})).on("mouseup",(()=>{this.busy=false;a.on("mousemove",null).on("mouseup",null)}))}));this.grab.shadehandle1=this.grab.shade.append("rect").attr("x",-5).attr("width",5).attr("height",40).attr("fill",this.p.hlcolor).attr("fill-opacity",0).style("cursor","ew-resize").on("mousedown",(t=>{this.busy=true;let e=t.clientX;const a=r(document.body);a.on("mousemove",(t=>{t.preventDefault();const a=t.clientX;this.grab.width+=e-a;if(this.grab.width<=0){this.grab.width-=e-a;return}this.grab.x+=a-e;e=a;this.grab.shade.attr("transform","translate("+this.grab.x+","+this.grab.y+")");this.grab.shadebox.attr("width",this.grab.width);this.grab.shadehandle2.attr("x",this.grab.width);_(this,Number.parseFloat(this.x_scale.invert(this.grab.x).toFixed(1)),Number.parseFloat(this.x_scale.invert(this.grab.x+this.grab.width).toFixed(1)))})).on("mouseup",(()=>{this.busy=false;a.on("mousemove",null).on("mouseup",null)}))}));this.grab.shadehandle2=this.grab.shade.append("rect").attr("x",0).attr("width",5).attr("height",40).attr("fill",this.p.hlcolor).attr("fill-opacity",0).style("cursor","ew-resize").on("mousedown",(t=>{let e=t.clientX;const a=r(document.body);a.on("mousemove",(t=>{t.preventDefault();const a=t.clientX;this.grab.width+=a-e;if(this.grab.width<=0){this.grab.width-=a-e;return}e=a;this.grab.shadebox.attr("width",this.grab.width);this.grab.shadehandle2.attr("x",this.grab.width);_(this,Number.parseFloat(this.x_scale.invert(this.grab.x).toFixed(1)),Number.parseFloat(this.x_scale.invert(this.grab.x+this.grab.width).toFixed(1)))})).on("mouseup",(()=>{this.busy=false;a.on("mousemove",null).on("mouseup",null)}))}));this.epdotg=this.graph.selectAll().data(this.data).enter().append("g");this.epdot=this.epdotg.append("circle").attr("fill",this.p.hlcolor).attr("fill-opacity",0).attr("stroke","black").attr("stroke-width",2).attr("stroke-opacity",X).each((function(t){t.circle=this})).on("mouseover",((t,e)=>{if(this.busy)return;e.circle.setAttribute("transform","scale(1.5)");this.dottip.clear();const a=[{k:this.p.datatype,v:'<span style="font-size:150%">'+e.value+"</span>"}];if(this.p.attrlst){for(const t of this.p.attrlst){a.push({k:t.label||t.k,v:e[t.k]})}}const s=this.getsampleinfo(e,a);n(this.dottip.d,a).style("zoom",.7);this.dottip.show(t.clientX,t.clientY);if(s){this.dottip.d.append("div").text("Full details").attr("class","sja_menuoption").on("click",(()=>{U(e,this.p.cohort,t.clientX-100,t.clientY-100)}))}})).on("mouseout",((t,e)=>{e.circle.setAttribute("transform","scale(1)")})).on("mousedown",((t,e)=>{t.preventDefault();const a=t.clientY;const s=r(document.body);const i=this.data[Math.floor(this.data.length/2)].value;if(e.value<i){const t=this.dotgraph_y;s.on("mousemove",(e=>{this.busy=true;this.dotmoved=true;this.dotgraph_y=t+e.clientY-a;this.graph.attr("transform","translate(0,"+this.dotgraph_y+")")}))}else{const t=this.heightmove;s.on("mousemove",(e=>{this.dotmoved=true;this.heightmove=t+a-e.clientY;const s=this.heightmove/this.data.length;this.epdotg.attr("transform",((t,e)=>{t._y=this.height-this.heightmove+e*s;return"translate("+Math.max(0,this.x_scale(t.value))+","+t._y+")"}))}))}s.on("mouseup",(()=>{setTimeout((()=>this.busy=false),50);s.on("mousemove",null).on("mouseup",null)}))}));this.render();const f=this.treediv.append("div").style("margin","10px").style("padding","2px").style("border","solid 1px transparent").html("All samples "+this.data.length).attr("class","sja_clb").on("click",(()=>{let t=true;for(const e of this.boxplots){if(e.id=="all")t=false}if(t){z(this,this.data,"","all",f)}else{F(this,"all")}}));if(this.p.cohort){if(this.p.cohort&&this.p.cohort.annotation&&this.p.cohort.key4annotation){for(const t of this.data){const e=t[this.p.cohort.key4annotation];if(e){const a=this.p.cohort.annotation[e];if(a){if(this.p.cohort.levels){for(const e of this.p.cohort.levels){t[e.k]=a[e.k];if(e.full){t[e.full]=a[e.full]}}}else{for(const e in a){t[e]=a[e]}}}}}}const t=this.treediv.append("div").style("margin","10px").style("height","400px").style("overflow-y","scroll").style("resize","vertical");const e=a(this.data,this.p.cohort.levels);const i=p(s()(e));i.sum((t=>t.value));i.eachBefore((e=>{if(!e.parent)return;const a=t.append("div").style("margin","2px").style("padding","2px").style("border","solid 1px transparent").attr("class","sja_clb");for(let t=1;t<e.depth;t++){a.append("span").style("color","#ccc").style("padding","0px 15px").text("|")}const s=e.data.data;a.append("span").html(s.name+" ");if(s.full){a.append("span").html(s.full+" ").style("font-size",".7em").style("color","#858585")}if(s.lst&&s.lst.length){a.append("span").text(s.lst.length);a.on("click",(()=>{let t=true;for(const e of this.boxplots){if(e.id==s.id)t=false}if(t){z(this,s.lst,s.name,s.id,a)}else{F(this,s.id)}}))}}))}else{this.treediv.append("div").style("margin","10px").text("Cannot stratify sample: no cohort information.")}z(this,this.data,"","all",f)}epaintfold(t){if(!this.handle){const e=this.genome.datasets[this.dsname];if(!e){alert("invalid dataset name: "+this.dsname);return}this.handle=t.ds2handle[this.dsname].handle.append("div").classed("sja_opaque8",true).style("background-color","#999").style("color","white").style("padding","2px 4px").style("margin-left","1px").text("e");this.handle.on("click",(()=>{this.pane.pane.style("display","block");c(this.handle,this.pane.pane);this.handle.style("display","none")}))}this.handle.style("display","inline-block");c(this.pane.pane,this.handle);this.pane.pane.style("display","none")}makescale_ep(){const t=this.axish-2;if(this.uselog){this.x_scale=w().domain([1,this.maxvalue]).range([0,this.width])}else{this.x_scale=o().domain([this.minvalue,this.maxvalue]).range([0,this.width])}const e=k().scale(this.x_scale).tickSizeInner(this.tickh);if(this.uselog){e.ticks(6,",.0f")}else{let a;this.axisg.append("text").text(Math.ceil(this.maxvalue)).attr("font-size",t-this.tickh).each((function(){a=this.getBBox().width})).remove();e.ticks(Math.floor(this.width/(a+20)))}if(this.axis){this.axis.remove()}this.axis=this.axisg.append("g").attr("transform","translate(0,"+t+")").call(e);f({axis:this.axis,fontsize:t-this.tickh,showline:true})}render(t,a){if(!t){t=this.presize.width;a=this.presize.height}this.width=t;this.width2=t*.05;this.dotsize=Math.max(13,t/30);this.height=a;this.sf_boxheight.range([10,this.height/8]);const s=Math.min(this.data.length*.7,300);this.sf_boxlabelfontsize.domain([0,Math.log(s),Math.log(this.data.length)]).range([8,this.sf_boxheight(s)/2,1+this.sf_boxheight(s)/2]);this.heightmove=this.height;this.rowheight_reset();this.svgg.attr("transform","translate("+this.dotsize+",0)");this.axish=Math.max(18,this.width*.04);this.tickh=this.axish*.3;this.makescale_ep();this.grabbar.attr("width",this.width);this.grabbar.attr("height",this.axish);const i=this.svgg.append("text").text(this.data.length).attr("font-family",e).attr("font-size",this.sf_boxlabelfontsize(Math.log(this.data.length)));this.width2_=i.node().getBBox().width+3;i.remove();const o=this.svgg.append("text").text("COUNT").attr("font-size",1).attr("font-family",e);const r=Math.max(8,(this.width2_-3)/o.node().getBBox().width);o.remove();this.axispad=5+r+this.dotsize/2;this.verticalline.attr("x1",this.width+this.width2-this.width2_).attr("y1",this.axish+5).attr("x2",this.width+this.width2-this.width2_).attr("y2",this.axish+this.height+this.axispad);this.dotgraph_y=this.axish+this.axispad;this.dotgraph_y_default=this.dotgraph_y;this.boxbag.attr("transform","translate(0,"+this.dotgraph_y+")");this.graph.attr("transform","translate(0,"+this.dotgraph_y+")");this.sung.attr("transform","translate(0,"+this.dotgraph_y+")");this.grab.y=-this.dotgraph_y-10;this.grab.height=this.height+this.dotgraph_y+30;this.grab.holder.attr("transform","translate("+this.width/2+","+this.height/2+")");this.grab.shadehandle1.attr("y",12+this.axish);this.grab.shadehandle2.attr("y",12+this.axish);this.epdotg.attr("transform",((t,e)=>{t._y=e*this.rowheight;return"translate(0,"+t._y+")"}));this.epdot.attr("r",this.dotsize/2);this.epdotg.attr("transform",(t=>"translate("+Math.max(0,this.x_scale(t.value))+","+t._y+")"));if(this.grab.x){let t=this.x_scale(this.grab.min),e=this.x_scale(this.grab.max);this.grab.x=t;this.grab.width=e-t;this.grab.shade.attr("transform","translate("+t+","+this.grab.y+")");this.grab.shadebox.attr("width",this.grab.width).attr("height",this.grab.height);this.grab.shadehandle2.attr("x",this.grab.width);_(this,this.grab.min,this.grab.max)}for(const t of this.boxplots){const e=this.sf_boxlabelfontsize(Math.log(t.lst.length));const a=this.sf_boxheight(t.lst.length);t.holder.attr("transform","translate(0,"+t.yoff+")");t.hline.attr("y1",a/2).attr("y2",a/2).attr("x1",Math.max(0,this.x_scale(t.percentile[9]))).attr("x2",Math.max(0,this.x_scale(t.percentile[91])));t.label.attr("x",this.width+this.width2-this.width2_-3).attr("y",a/2).attr("font-size",e);t.label2.attr("x",this.width+this.width2-this.width2_+3).attr("y",a/2).attr("font-size",e);t.connline.attr("y1",a/2).attr("y2",a/2).attr("x1",Math.max(0,this.x_scale(t.percentile[91]))).attr("x2",Math.max(0,this.width+this.width2-t.labelwidth-this.width2_-3));t.box.attr("height",a).attr("x",Math.max(0,this.x_scale(t.percentile[25]))).attr("width",Math.max(0,this.x_scale(t.percentile[75]))-Math.max(0,this.x_scale(t.percentile[25])));t.vlines.attr("x1",(t=>Math.max(0,this.x_scale(t)))).attr("x2",(t=>Math.max(0,this.x_scale(t)))).attr("y1",0).attr("y2",a)}this.svg.attr("width",this.width+this.width2+this.dotsize).attr("height",this.height+this.axish+this.axispad+this.dotsize/2)}getsampleinfo(t,e){if(this.p.cohort){if(this.p.cohort.annotation&&this.p.cohort.key4annotation){const a=t[this.p.cohort.key4annotation];if(a){e.push({k:this.p.cohort.key4annotation,v:a});const t=this.p.cohort.annotation[a];if(t){let a=0;for(const e in t)a++;if(this.p.cohort.levels){for(const a of this.p.cohort.levels){e.push({k:a.label||a.k,v:t[a.k]==undefined?"":t[a.k]})}return a>this.p.cohort.levels.length}let s=0;for(const i in t){e.push({k:i,v:t[i]});if(++s==a)return true}return false}}}else if(this.p.cohort.levels){for(const a of this.p.cohort.levels){const s=t[a.k];if(!s)continue;e.push({k:a.label||a.k,v:t[a.k]+(a.full?t[a.full]?' <span style="font-size:.8em;color:#858585">'+t[a.full]+"</span>":"":"")})}return false}}for(const a in t){if(a=="circle"||a=="_y")continue;if(typeof a=="string"){const s=t[a];if(s){e.push({k:a,v:s})}}}return false}rowheight_reset(){if(this.data){this.rowheight=this.height/this.data.length;return}this.rowheight=0}dot_appendtext(t,a){const s=[];t.append("text").text((t=>a.get(t[this.p.sampletype]))).attr("font-family",e).attr("font-size",this.dotsize).each((function(t){t.bb=this.getBBox()})).each((t=>{const e=this.x_scale(t.value);const a=e-this.dotsize>t.bb.width;let i=t._y-t.bb.height/2,o=i+t.bb.height;for(const e of s){if(e.onleft==a&&Math.max(e.y1,i)<Math.min(e.y2,o)){i=e.y2;o=i+t.bb.height}}delete t.bb;t.mafrect={y1:i,y2:o,onleft:a};s.push(t.mafrect)})).attr("class","sja_svgtext").attr("dominant-baseline","central").attr("fill",this.p.hlcolor).attr("text-anchor",(t=>t.mafrect.onleft?"end":"start")).attr("x",(t=>(t.mafrect.onleft?-1:1)*this.dotsize)).attr("y",(t=>t.mafrect.y1-t._y+this.dotsize/2)).on("click",((t,e)=>{r(e.circle).attr("stroke-width",1).attr("stroke-opacity",X).attr("stroke","black").attr("r",this.dotsize/2);e.showtext=false;r(t.target).remove()})).attr("font-size",1).transition().attr("font-size",this.dotsize)}may_hl(t,e){if(!this.data)return;const a=new Set;let s=true;for(const e of t){const t=e[this.p.sampletype];if(!t)continue;a.add(t);if(this.sampletype2value[t]){s=false}}if(s)return;this.epdot.filter((t=>a.has(t[this.p.sampletype]))).attr("r",e?this.dotsize*.8:this.dotsize/2).attr("stroke",e?this.p.hlcolor:"black").attr("stroke-opacity",e?N:X);const i=this.p.maf;if(!i)return;const o=new Map;for(const e of t){const t=e[this.p.sampletype];const a=this.p.maf.get(e);if(!a)continue;if(typeof a=="string"){o.set(t,a)}else{o.set(t,a.v2==0?"No "+this.p.maf.label+": site not covered":this.p.maf.label+": "+(a.f*100).toFixed(0)+"% ("+a.v1+"/"+a.v2+")")}}const r=this.epdotg.filter((t=>o.has(t[this.p.sampletype])&&!t.showtext));if(e){this.dot_appendtext(r,o)}else{r.select("text").remove()}}}function Y(t,e){const a=t.genome.datasets[t.dsname];if(a.dbexpression){const s={db:a.dbexpression.dbfile,tablename:a.dbexpression.tablename,keyname:a.dbexpression.keyname,key:e};fetch(new Request(t.hostURL+"/dbdata",{method:"POST",body:JSON.stringify(s)})).then((t=>t.json())).then((s=>{if(s.error)throw{message:s.error};if(a.dbexpression.tidy){a.dbexpression.tidy(s.rows)}const i=t.pane.pane.node().getBoundingClientRect();new L({hostURL:t.hostURL,data:s.rows,expp:t.p,presize:{x:i.left+30,y:i.top+50,width:t.width,height:t.height},genome:t.genome,dsname:t.dsname,genename:e,samplecart:t.samplecart})})).catch((t=>{window.alert(t.message);if(t.stack)console.log(t.stack)}));return}fetch(new Request(t.hostURL+"/dsdata",{method:"POST",body:JSON.stringify({genome:t.genome.name,dsname:t.dsname,expressiononly:1,genename:e})})).then((t=>t.json())).then((a=>{if(a.error)throw{message:a.error};const s=t.pane.pane.node().getBoundingClientRect();new L({hostURL:t.hostURL,data:a.data[0].lst,expp:t.p,presize:{x:s.left+30,y:s.top+50,width:t.width,height:t.height},genome:t.genome,dsname:t.dsname,genename:e,samplecart:t.samplecart})})).catch((t=>{window.alert(t.message);if(t.stack)console.log(t.stack)}))}function U(t,e,a,s){const i=l({x:a,y:s});const o=t[e.key4annotation];i.header.text(o);const r=[];const h=e.annotation[o];for(const t in h){r.push({k:t,v:h[t]})}n(i.body,r)}function S(t){const e=t.pane.body.append("div").style("margin-bottom","10px");e.append("button").text("Cohort").on("click",(()=>{if(t.treediv.style("display")=="none"){g(t.treediv)}else{m(t.treediv)}}));e.append("button").text("Log10").on("click",(()=>{const e=700;t.uselog=!t.uselog;t.makescale_ep();t.epdotg.transition().duration(e).attr("transform",((e,a)=>"translate("+(t.uselog&&e.value==0?0:Math.max(0,t.x_scale(e.value)))+","+e._y+")"));for(const a of t.boxplots){a.vlines.transition().duration(e).attr("x1",(e=>Math.max(0,t.x_scale(e)))).attr("x2",(e=>Math.max(0,t.x_scale(e))));a.box.transition().duration(e).attr("x",Math.max(0,t.x_scale(a.percentile[25]))).attr("width",Math.max(0,t.x_scale(a.percentile[75]))-Math.max(0,t.x_scale(a.percentile[25])));a.hline.transition().duration(e).attr("x1",Math.max(0,t.x_scale(a.percentile[9]))).attr("x2",Math.max(0,t.x_scale(a.percentile[91])));a.connline.transition().duration(e).attr("x1",Math.max(0,t.x_scale(a.percentile[91]))).attr("x2",t.width+t.width2-a.labelwidth-t.width2_-3)}if(t.grab.x){let a=t.x_scale(t.grab.min),s=t.x_scale(t.grab.max);t.grab.x=a;t.grab.width=s-a;t.grab.shade.transition().duration(e).attr("transform","translate("+a+","+t.grab.y+")");t.grab.shadebox.transition().duration(e).attr("width",t.grab.width);t.grab.shadehandle2.transition().duration(e).attr("x",t.grab.width)}}));e.append("button").text("SVG").on("click",(()=>{x(t.svg.node(),t.genename+"_expression")}));e.append("button").text("Data").on("click",(()=>{const e=[t.p.sampletype,t.p.datatype];const a=[];if(t.p.attrlst){for(const s of t.p.attrlst){e.push(s.k);a.push(s.k)}}if(t.p.cohort){for(const s of t.p.cohort.levels){e.push(s.k);a.push(s.k)}}const s=[];for(const e of t.data){const i=[e[t.p.sampletype],e.value];for(const t of a){i.push(e[t]||"")}s.push(i.join("\t"))}u(t.genename+" "+t.p.name+" data",[{text:e.join("\t")+"\n"+s.join("\n")}])}));e.append("input").attr("placeholder","Sample").style("width","60px").style("margin-left","5px").on("keyup",(e=>{const a=e.target.value;if(a==""){t.epdot.attr("r",t.dotsize/2).attr("stroke","black").attr("stroke-opacity",X);return}const s=a.toLowerCase();const i=new Set;for(const e in t.sampletype2value){if(e.toLowerCase().indexOf(s)!=-1){i.add(e)}}t.epdot.filter((e=>i.has(e[t.p.sampletype]))).attr("r",t.dotsize).attr("stroke",t.p.hlcolor).attr("stroke-opacity",N);t.epdot.filter((e=>!i.has(e[t.p.sampletype]))).attr("r",t.dotsize/2).attr("stroke","black").attr("stroke-opacity",X)}));e.append("input").attr("placeholder","Gene").style("width","60px").style("margin-left","5px").on("keyup",(e=>{const a=e.target.value;if(e.code=="Enter"){Y(t,a);e.target.value="";return}}));if(t.p.gtexlink){e.append("span").html(" <a target=_blank href=https://www.gtexportal.org/home/gene/"+t.genename+">GTeX normal</a>")}}export{L as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as t,P as e,M as s}from"./app-b369b169.js";import{f as o,i as a}from"./termsetting-33ea66f1.js";import{controlsInit as i}from"./controls-287e6efa.js";import{s as r}from"./select2Terms-b21e184a.js";import{b as l,a as n,d as c}from"./recover-49e09de0.js";import"./tslib.es6-c3c2d88f.js";import"path";import"./controls.btns-79b805dd.js";import"./controls.config-28d6d6a8.js";import"./FilterRxComp-701a1480.js";import"./table-29d5a973.js";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-8b656cc3.js";import"./FilterStateless-54c0b763.js";import"./app-3320ab6f.js";import"./termInfo-bf99a37e.js";import"./toggleButtons-dbdbad01.js";import"./genesearch-a4e19f0d.js";import"./checkbox-96437f4d.js";import"./rehydrateFilter-12d118cb.js";class p{constructor(t){this.type="facet";const e=t.holder;const o=e.append("div").style("display","inline-block");const a=e.append("div").style("display","inline-block");this.dom={holder:t.holder.style("padding","20px"),header:t.header,controlsHolder:o,mainDiv:a,tip:t.tip||new s}}async init(t){await this.setControls()}getState(t){const e=t.plots.find((t=>t.id===this.id));if(this.dom.header)this.dom.header.html(`${e.columnTw.term.name} <span style="font-size:.8em">(COLUMN)</span> ${e.rowTw.term.name} <span style="font-size:.8em">(ROW) FACET TABLE</span>`);return{config:e,vocab:t.vocab,termfilter:t.termfilter,groups:t.groups}}async main(){this.config=JSON.parse(JSON.stringify(this.state.config));await this.renderTable()}async renderTable(){const t=this.config;this.dom.mainDiv.selectAll("*").remove();this.dom.tip.clear().hide();const e=this.dom.mainDiv.append("table");const s=e.append("tbody");const o=s.append("tr").style("text-align","center");o.append("th");const a=this.app.vocabApi.hasVerifiedToken();if(a){e.style("border-spacing","0px");const{result:a,categories:i,categories2:r}=await this.getSampleTableData(t);if(!i.length||!r.length){this.showNoSampleMessage(this.dom.mainDiv);return}for(const e of i){const s=t.columnTw.term.values?.[e]?.label||e;this.addHeader(o,s)}this.renderSampleTable(s,t,a,i,r)}else{e.style("border-spacing","5px");const{rows:a,filteredCols:i}=await this.getStaticTableData(t);if(!a.size||!i.length){this.showNoSampleMessage(this.dom.mainDiv);return}for(const e of i){const s=t.columnTw.term.values?.[e.seriesId]?.label||e.seriesId;this.addHeader(o,s)}this.renderStaticTable(s,t,a,i)}}renderSampleTable(t,e,s,o,a){const i={};for(const n of a){i[n]={};const c=t.append("tr");const p=e.rowTw.term.values?.[n]?.label||n;this.addRowLabel(c,p);for(const p of o){const d=s.lst.filter((t=>t[e.columnTw.$id]?.key==p&&t[e.rowTw.$id]?.key==n));i[n][p]={samples:d,selected:false};const m=c.append("td");if(!d.length)m.classed("highlightable-cell",true);if(d.length>0){const e=o.indexOf(p)+2;m.classed("sja_menuoption",true).style("text-align","center").style("border","2.5px solid white").text(d.length).on("mouseover",(()=>{this.highlightColRow(t,c,e,"#fffec8")})).on("mouseout",(()=>{this.highlightColRow(t,c,e,"transparent")})).on("click",(()=>{const t=i[n][p].selected=!i[n][p].selected;if(t){m.style("border","1px solid blue")}else{m.style("border","2.5px solid white")}for(const t of a){for(const e of o){if(i[t][e].selected){l.style("display","");r.text("Choose how to use samples:");return}}}l.style("display","none");r.text("Click on cells to select samples")}))}}}const r=this.dom.mainDiv.append("div").attr("data-testid","sjpp-facet-start-prompt").style("margin","20px 0px 0px 15px").style("opacity","0.7").text("Click on cells to select samples");const l=this.dom.mainDiv.append("div").style("margin","20px 0px 0px 25px").style("display","none");const n=[{text:"Show samples view",callback:()=>{const t=this.getSelectedSamples(o,a,i);this.app.dispatch({type:"plot_create",config:{chartType:"sampleView",samples:t.map((t=>({sampleId:t.sample,sampleName:s.refs.bySampleId[t.sample].label})))}})}},{text:"List samples",callback:()=>{const t=this.getSelectedSamples(o,a,i);const r=t.map((t=>[s.refs.bySampleId[t.sample].label,t[e.columnTw.$id].key,t[e.rowTw.$id].key]));this.dom.tip.clear().showunder(l.node());const n=this.dom.tip.d.append("table").append("tbody");const c=n.append("tr").style("text-align","center");c.append("th").text("Sample");c.append("th").text(e.columnTw.term.name);c.append("th").text(e.rowTw.term.name);for(const t of r){const e=n.append("tr");e.append("td").text(t[0]);e.append("td").text(t[1]);e.append("td").text(t[2])}}},{text:"Create group",callback:()=>{this.addGroup(o,a,i)}}];for(const t of n){this.addBtn(l,t)}}highlightColRow=(t,e,s,o)=>{t.selectAll(`td.highlightable-cell:nth-child(${s})`).style("background-color",`${o}`).style("border",`2.5px solid ${o}`);t.select(`th:nth-child(${s})`).style("background-color",`${o}`).style("border",`2.5px solid ${o}`);e.style("background-color",`${o}`)};addBtn(t,e){return t.append("button").classed("sja_menuoption",true).style("padding","0px 10px").style("margin","0px 5px").text(e.text).on("click",e.callback)}addGroup(t,e,s){const o={name:"Group",items:this.getSelectedSamples(t,e,s)};const a=l(n([o]));c(this.app,a,this.state.groups);return a}getSelectedSamples(t,e,s){const o=[];for(const a of e){for(const e of t){if(s[a][e].selected){o.push(...s[a][e].samples)}}}return o}async getSampleTableData(t){const e=await this.app.vocabApi.getAnnotatedSampleData({filter:this.state.termfilter.filter,terms:[t.columnTw,t.rowTw]});const s=this.getCategories(t.columnTw,e.lst);const o=this.getCategories(t.rowTw,e.lst);return{result:e,categories:s,categories2:o}}getCategories(t,e){let s=[];for(const o of e){let e=o[t.$id]?.key;if(e){if(!isNaN(e))e=Number(e);s.push(e)}}const o=new Set(s);s=Array.from(o).sort();if(a(t.term)){Object.values(t.term.values).forEach((t=>{if(t?.uncomputable){const e=s.indexOf(t.label);if(e>-1)s.splice(e,1)}}));s=this.orderColNames(s)}return s}orderColNames(t){const e=[];const s=[];for(const o of t){const t=o.split(" to ");const a=t[0].replace(/[\>\≥\<\≤]/g,"");const i=Number(a);if(!isNaN(i)){const s=!t[1]&&(o.includes("<")||o.includes("≤"))?i-1:!t[1]&&(o.includes("≥")||o.includes(">"))?i+1:i;e.push({key:s,label:o})}else s.push(a)}return[...e.sort(((t,e)=>t.key-e.key)).map((t=>t.label)),...s.sort()]}renderStaticTable(t,e,s){for(const o of s){const s=t.append("tr");const a=e.rowTw.term.values?.[o[0]]?.label||o[0];this.addRowLabel(s,a);for(const t of o[1]){const e=t[1].value>0?t[1].value:"";s.append("td").style("background-color","#FAFAFA").style("text-align","center").text(e)}}}async getStaticTableData(t){const e={term:t.columnTw,term2:t.rowTw,filter:this.state.termfilter.filter};if(this.state.termfilter.filter0)e.filter0=this.state.termfilter.filter0;await this.getDescrStats(e.term);await this.getDescrStats(e.term2);const s=await this.app.vocabApi.getNestedChartSeriesData(e);const o=new Map;const a=s.data.refs.cols.map((t=>s.data.charts[0].serieses.find((e=>e.seriesId==t))));s.data.refs.rows.forEach((t=>{o.set(t,new Map);for(const e of a){o.get(t).set(e.seriesId,{value:e.data.find((e=>e.dataId==t))?.total||0,selected:false})}}));return{rows:o,filteredCols:a}}async getDescrStats(t){if(a(t.term)){const e=await this.app.vocabApi.getDescrStats(t,this.state.termfilter);if(e.error)throw e.error;t.q.descrStats=e.values}}showNoSampleMessage(t){t.append("div").style("padding","0px 50px").style("font-size","1.15em").text("No overlapping samples");return}addHeader(t,e){t.append("th").attr("data-testid","sjpp-facet-col-header").style("border","2.5px solid white").style("padding","0px 25px").text(e)}addRowLabel(t,e){t.append("td").attr("data-testid","sjpp-facet-row-label").style("border","2.5px solid white").style("font-weight","bold").text(e)}async setControls(){const t=[{type:"term",configKey:"columnTw",chartType:this.type,usecase:{target:this.type},title:"Facet column categories",label:"Columns",vocabApi:this.app.vocabApi,numericEditMenuVersion:["discrete"]},{type:"term",configKey:"rowTw",chartType:this.type,usecase:{target:this.type},title:"Facet row categories",label:"Rows",vocabApi:this.app.vocabApi,numericEditMenuVersion:["discrete"]}];this.components={controls:await i({app:this.app,id:this.id,holder:this.dom.controlsHolder,inputs:t})}}}function d(t,e){const s=(t,s)=>{const o={chartType:"facet",columnTw:{term:t},rowTw:{term:s}};if(a(t))o.columnTw.term.q={mode:"discrete"};if(a(s))o.rowTw.term.q={mode:"discrete"};e.app.dispatch({type:"plot_create",config:o})};r(e.dom.tip,e.app,"facet","",s)}const m=t(p);const h=m;async function f(t,s){const a={settings:{}};if(!t.columnTw)throw".columnTw{} missing";await o(t.columnTw,s.vocabApi);if(!t.rowTw)throw".rowTw{} missing";await o(t.rowTw,s.vocabApi);const i=e(a,t);return i}export{h as componentInit,m as facetInit,f as getPlotConfig,d as makeChartBtnMenu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as i}from"./app-
|
|
1
|
+
import{x as i}from"./app-b369b169.js";async function o({line:o,genome:t,positionType:r}){const n=o.split(",");let e=null,s=null,m=null,p=null,a=null,l=null,N=null,c=null;if(r=="codon"){e=Number.parseInt(n[2].trim());if(Number.isNaN(e))throw"N-term codon position is not integer";s=Number.parseInt(n[5].trim());if(Number.isNaN(s))throw"C-term codon position is not integer"}else if(r=="rna"){m=Number.parseInt(n[2].trim());if(Number.isNaN(m))throw"N-term RNA position is not integer";p=Number.parseInt(n[5].trim());if(Number.isNaN(p))throw"C-term RNA position is not integer"}else if(r=="genomic"){let o=n[2].trim().split(":");if(o.length!=2)throw"N-term genomic position format is not chr:position";a=o[0];N=Number.parseInt(o[1]);if(Number.isNaN(N))throw"invalid N-term genomic position";N--;const r=i(t,a,N,N);if(r)throw"N-term genomic position error: "+r;o=n[5].trim().split(":");if(o.length!=2)throw"C-term genomic position format is not chr:position";l=o[0];c=Number.parseInt(o[1]);if(Number.isNaN(c))throw": invalid C-term genomic position";c--;const e=i(block.genome,l,c,c);if(e)throw"C-term genomic position error: "+e}else{throw"unknown positionType"}const u=n[1].trim().toUpperCase();const f=n[4].trim().toUpperCase();const b={class:"Fuserna",dt:2,isoform:u,pairlst:[{a:{name:n[0].trim(),isoform:u,codon:e,rnaposition:m,chr:a,position:N},b:{name:n[3].trim(),isoform:f,codon:s,rnaposition:p,chr:l,position:c}}]};if(n[6]){const i=Number.parseInt(n[6].trim());if(!Number.isNaN(i)){b.pairlst[0].interstitial={aalen:i}}}return b}export{o as parseFusion};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{appInit as e}from"./plot.app-30c4b8e5.js";import{d as t,P as r}from"./app-b369b169.js";import{T as s,f as i}from"./termsetting-33ea66f1.js";import{v as o}from"./FilterRxComp-701a1480.js";import"./recover-49e09de0.js";import"./FilterStateless-54c0b763.js";import"./app-3320ab6f.js";import"./termInfo-bf99a37e.js";import"./tslib.es6-c3c2d88f.js";import"./toggleButtons-dbdbad01.js";import"path";import"./table-29d5a973.js";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-8b656cc3.js";import"./genesearch-a4e19f0d.js";import"./checkbox-96437f4d.js";import"./rehydrateFilter-12d118cb.js";const n="hg38";const p="GDC";async function a(a,l,d){try{const l=d[n];if(!l)throw n+" missing";const c=a.settings||{};if(typeof c!="object")throw"arg.settings{} not object";if(!c.hierCluster)c.hierCluster={};if(typeof c.hierCluster!="object")throw"arg.settings.hierCluster{} not object";if(!Number.isInteger(c.hierCluster.maxGenes))c.hierCluster.maxGenes=1e3;if(a.filter0&&typeof a.filter0!="object")throw"arg.filter0 not object";const f=await o({state:{vocab:{genome:n,dslabel:p}}});f.getTermdbConfig();const m=await e({debug:a.debug,holder:t(a.holder).select(".sja_root_holder"),genome:l,state:{genome:n,dslabel:p,termfilter:{filter0:a.filter0},plots:[{chartType:"geneset",toolName:"Gene Expression Clustering",settings:{maxGenes:c.hierCluster.maxGenes}}]},app:a.opts?.app||{},hierCluster:r({reactsTo(e){if(e.type.startsWith("plot_"))return e.id===this.id;if(e.type.startsWith("filter"))return true;if(e.type=="app_refresh")return true},callbacks:{"firstRender.gdcHierCluster":async e=>{e.on("firstRender.gdcHierCluster",null);if(!g)return;m.dispatch({type:"plot_delete",id:g.id});g=undefined}}},a.opts?.hierCluster||{}),matrix:a.opts?.matrix||{},geneset:{mode:"geneExpression",genome:l,genes:a.genes,reactsTo(e){if(e.type.startsWith("plot_"))return e.id===this.id;if(e.type.startsWith("filter"))return true;if(e.type=="app_refresh")return true},showWaitMessage(e){e.style("margin","20px");e.append("div").text("Loading genes that are top variably expressed in current cohort...");e.append("div").style("font-size",".8em").html(`\n\t\t\t\t\t\tOnly up to 1000 cases with gene expression data will be used to select genes.<br>\n\t\t\t\t\t\tGenes are selected from all protein-coding genes, may take over 1 minute.\n\t\t\t\t\t`)},async callback(e,t){if(!e)return;g=e;if(!u){const e=m.getState().plots.find((e=>e.chartType=="hierCluster"));if(e)u=m.getComponents(`plots.${e.id}`)}const r=[{name:"Gene Expression",type:"hierCluster",lst:t},...a.termgroups||[]];if(u){m.dispatch({type:"plot_edit",id:u.id,config:{termgroups:r}})}else{m.dispatch({type:"plot_create",config:{chartType:"hierCluster",termgroups:r,divideBy:a.divideBy||undefined,settings:c,dataType:s.GENE_EXPRESSION}})}}},recover:{undoHtml:"Undo",redoHtml:"Redo",resetHtml:"Restore",hide(e){return e.plots[0]?.chartType!="hierCluster"},adjustTrackedState:e=>{const t=structuredClone(e);delete t.termfilter.filter0;if(t.plots){for(const e of t.plots){if(!e.termgroups)continue;for(const t of e.termgroups){if(!t.lst)continue;for(const e of t.lst){if(!e?.term)continue;delete e.term.category2samplecount;delete e.term.values}}}}return t}}});let u,g;const h={type:"hierCluster",update:async e=>{const t=m.getState().plots.find((e=>e.chartType=="hierCluster"));if(!u){if(t)u=m.getComponents(`plots.${t.id}`)}if(e.genes){const r=t.termgroups.find((e=>e.type=="hierCluster"));m.dispatch({type:"plot_edit",id:u.id,config:{termgroups:[{name:r.name,type:"hierCluster",lst:await Promise.all(e.genes.map((async e=>await i({term:{gene:e.gene,type:"geneExpression",name:e.gene}},f))))}]}})}else if("filter0"in e){m.dispatch({type:"filter_replace",filter0:e.filter0})}else if(u){m.dispatch({type:"plot_edit",id:u.id,config:e})}}};return h}catch(e){throw e}}export{a as init};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e}from"./tslib.es6-c3c2d88f.js";import{M as t}from"./app-b369b169.js";import{a}from"./genesearch-a4e19f0d.js";import{T as s}from"./termsetting-33ea66f1.js";import"path";class o{init(e){this.callback=e.callback;this.app=e.app;const s=a({tip:new t({padding:"0px"}),genome:e.genomeObj,row:e.holder,searchOnly:"gene",callback:()=>this.selectGene(s.geneSymbol)})}selectGene(t){return e(this,void 0,void 0,(function*(){if(!t)throw new Error("No gene selected");this.callback({gene:t,type:s.GENE_EXPRESSION,name:t})}))}}export{o as SearchHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as t,h as e,b as o,bL as n}from"./app-
|
|
1
|
+
import{P as t,h as e,b as o,bL as n}from"./app-b369b169.js";const r={clusterMethod:"average",distanceMethod:"euclidean"};const i=["average","complete","mcquitty"];const a=["euclidean","maximum","manhattan","canberra"];class d{constructor(){this.type="geneExpression"}async init(t){const e=this.opts.holder.append("div");this.dom={holder:e,controlsDiv:e.append("div"),canvas:e.append("canvas"),colorScaleDiv:e.append("div")};this.makeControls();this.components={}}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found`}return{config:e}}async main(){const t=this.getParam();const e=await o("mds3",{body:t});g(e,this)}getParam(){console.log(this.state.config.genes);const t={genome:this.app.opts.state.vocab.genome,dslabel:this.app.opts.state.vocab.dslabel,geneExpression:1,genes:this.state.config.genes,clusterMethod:this.state.config.clusterMethod};return t}makeControls(){const t=this.dom.controlsDiv.append("select");for(const e of i)t.append("option").text(e);this.dom.clusterMethodSelect=t;t.on("change",(()=>{this.app.dispatch({type:"plot_edit",id:this.id,config:{clusterMethod:i[t.property("selectedIndex")]}})}))}}async function s(e,o){try{const o=structuredClone(r);return t(o,e)}catch(t){throw`${t} [geneExpression getPlotConfig()]`}}const c=e(d);const l=c;function h(t,e){t.append("div").attr("class","sja_menuoption sja_sharp_border").text("Clustering analysis").on("click",(()=>{e.dom.tip.hide();e.prepPlot({config:{chartType:"geneExpression"}})}))}function g(t,e){e.dom.clusterMethodSelect.property("selectedIndex",i.indexOf(e.state.config.clusterMethod));e.dom.distanceMethodSelect.property("selectedIndex",a.indexOf(e.state.config.distanceMethod));const o=t.clustering;console.log(o);o.d={minColor:"#0c306b",maxColor:"#ffcc00",xDendrogramHeight:150,yDendrogramHeight:150};o.d.colorScale=n(o.d.minColor,o.d.maxColor);const r=e.dom.canvas.node().getContext("2d");o.d.rowHeight=y(o);o.d.colWidth=u(o);w(r,o);e.dom.canvas.attr("width",o.d.xDendrogramHeight+o.d.xLabHeight+o.d.colWidth*o.matrix[0].length).attr("height",o.d.yDendrogramHeight+o.d.yLabHeight+o.d.rowHeight*o.matrix.length);f(o,r);p(o,r);x(r,o);b(e,o)}function x(t,e){try{e.row_dendro.map(m)}catch(t){throw"row_dendro error: "+t}try{e.col_dendro.map(m)}catch(t){throw"col_dendro error: "+t}for(const t of e.row_dendro){let e=t.x1;t.x1=t.y1;t.y1=e;e=t.x2;t.x2=t.y2;t.y2=e}{let t=0;for(const o of e.row_dendro)t=Math.max(t,o.x1,o.x2);const o=e.d.xDendrogramHeight/t;for(const n of e.row_dendro){n.x1=o*(t-n.x1);n.x2=o*(t-n.x2);n.y1*=e.d.rowHeight;n.y2*=e.d.rowHeight}}{let t=0;for(const o of e.col_dendro)t=Math.max(t,o.y1,o.y2);const o=e.d.yDendrogramHeight/t;for(const n of e.col_dendro){n.y1=o*(t-n.y1);n.y2=o*(t-n.y2);n.x1*=e.d.colWidth;n.x2*=e.d.colWidth}}t.strokeStyle="black";let o=e.d.yDendrogramHeight+e.d.yLabHeight;for(const n of e.row_dendro){t.beginPath();const e=Math.min(n.x1,n.x2),r=Math.max(n.x1,n.x2),i=Math.min(n.y1,n.y2),a=Math.max(n.y1,n.y2);t.moveTo(e,i+o);t.lineTo(e,a+o);if(n.x1>n.x2&&n.y1>n.y2||n.x1<n.x2&&n.y1<n.y2){t.lineTo(r,a+o)}else{t.moveTo(e,i+o);t.lineTo(r,i+o)}t.stroke();t.closePath()}o=e.d.xDendrogramHeight+e.d.xLabHeight;for(const n of e.col_dendro){t.beginPath();const e=Math.min(n.x1,n.x2),r=Math.max(n.x1,n.x2),i=Math.min(n.y1,n.y2),a=Math.max(n.y1,n.y2);t.moveTo(o+e,i);t.lineTo(o+r,i);if(n.x1>n.x2&&n.y1>n.y2||n.x1<n.x2&&n.y1<n.y2){t.lineTo(o+r,a)}else{t.moveTo(o+e,i);t.lineTo(o+e,a)}t.stroke();t.closePath()}}function m(t){if(t.r1<0)throw`r.r1<0 ${t.r1}`;if(t.r2<0)throw`r.r2<0 ${t.r2}`;if(t.x1<1)throw`r.x1<1 ${t.x1}`;if(t.x2<1)throw`r.x2<1 ${t.x2}`;t.x1-=.5;t.x2-=.5;if(t.y1<0)throw`r.y1<0 ${t.y1}`;if(t.y2<0)throw`r.y2<0 ${t.y2}`}function f(t,e){if(t.d.xLabHeight){e.font=t.d.rowHeight+"px Arial";e.textAlign="end";e.fillStyle="black";for(const[o,n]of t.row_names_index.entries()){e.fillText(t.geneNameLst[n-1],t.d.xDendrogramHeight+t.d.xLabHeight,t.d.yDendrogramHeight+t.d.yLabHeight+t.d.rowHeight*(o+1))}}}function p(t,e){for(let o=0;o<t.row_names_index.length;o++){const n=t.matrix[t.row_names_index[o]-1];const[r,i]=H(n);for(let a=0;a<t.col_names_index.length;a++){const d=n[t.col_names_index[a]-1];e.fillStyle=t.d.colorScale((d-r)/(i-r));e.fillRect(t.d.xDendrogramHeight+t.d.xLabHeight+t.d.colWidth*a,t.d.yDendrogramHeight+t.d.yLabHeight+t.d.rowHeight*o,t.d.colWidth,t.d.rowHeight)}}}function y(t){const e=500/t.matrix.length;if(e>20)return 20;if(e<10)return 10;return Math.ceil(e)}function u(t){const e=2e3/t.matrix[0].length;if(e>10)return 10;return Math.ceil(e)}function w(t,e){if(e.geneNameLst&&e.d.rowHeight>=7){t.font=e.d.rowHeight+"px Arial";let o=0;for(const n of e.geneNameLst){o=Math.max(o,t.measureText(n).width)}e.d.xLabHeight=o}else{e.d.xLabHeight=0}if(e.sampleNameLst&&e.d.colWidth>=7){t.font=e.d.colWidth+"px Arial";let o=0;for(const n of e.sampleNameLst){o=Math.max(o,t.measureText(n).width)}e.d.yLabHeight=o}else{e.d.yLabHeight=0}}function H(t){let e=null,o;for(const n of t){if(e==null){e=n;o=n}else{e=Math.min(e,n);o=Math.max(o,n)}}return[e,o]}function b(t,e){t.dom.colorScaleDiv.selectAll("*").remove();const o=100,n=20;t.dom.colorScaleDiv.append("span").text("Min");const r=t.dom.colorScaleDiv.append("svg");t.dom.colorScaleDiv.append("span").text("Max");const i=r.append("defs").append("linearGradient").attr("id","grad");i.append("stop").attr("offset","0%").attr("stop-color",e.d.minColor);i.append("stop").attr("offset","100%").attr("stop-color",e.d.maxColor);r.append("rect").attr("width",o).attr("height",n).attr("fill","url(#grad)");r.attr("width",o).attr("height",n)}export{l as componentInit,c as geneExpressionInit,s as getPlotConfig,h as makeChartBtnMenu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./tslib.es6-
|
|
1
|
+
import{_ as e}from"./tslib.es6-c3c2d88f.js";import{P as t}from"./app-b369b169.js";function n(e){switch(e){case"./numeric.binary.ts":return import("./numeric.binary-1f9e93f2.js");case"./numeric.continuous.ts":return import("./numeric.continuous-ebcd0567.js");case"./numeric.discrete.ts":return import("./numeric.discrete-7b97044a.js");case"./numeric.spline.ts":return import("./numeric.spline-1be88f3d.js");case"./numeric.toggle.ts":return import("./numeric.toggle-7fa2a770.js");default:return new Promise((function(t,n){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(n.bind(null,new Error("Unknown variable dynamic import: "+e)))}))}}function r(t){return e(this,void 0,void 0,(function*(){const e=t.opts.numericEditMenuVersion;const n=e.length>1?"toggle":e[0];const r=yield o(n);return yield r.getHandler(t)}))}function i(n,r,i=null){var o;return e(this,void 0,void 0,(function*(){if(typeof n.term!=="object")throw"tw.term is not an object";if(!n.term.gene&&!n.term.name)throw"no gene or name present";if(!n.term.gene)n.term.gene=n.term.name;if(!n.term.gene||typeof n.term.gene!="string")throw"geneExpression tw.term.gene must be non-empty string";if(!n.term.name)n.term.name=n.term.gene;if(!((o=n.q)===null||o===void 0?void 0:o.mode))n.q={mode:"continuous"};if(i)t(n.q,i);if(n.q.mode!=="continuous"&&!n.term.bins){yield r.setTermBins(n)}return n}))}function o(t){return e(this,void 0,void 0,(function*(){try{return yield n(`./numeric.${t}.ts`)}catch(e){if(e.stack)console.log(e.stack);throw`Type numeric.${t} does not exist [handlers/numeric.ts importSubtype()]`}}))}export{i as fillTW,r as getHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./table-29d5a973.js";import{M as t,P as s,h as a,n as i,d as n,D as l,b as o}from"./app-b369b169.js";import{controlsInit as r}from"./controls-287e6efa.js";import"./tslib.es6-c3c2d88f.js";import"./controls.btns-79b805dd.js";import"./controls.config-28d6d6a8.js";import"./termsetting-33ea66f1.js";import"path";new t;class p{constructor(){this.type="geneORA"}async init(e){if(!this.opts.holder||!this.opts.header){const e=i(n(this.opts.holder.node().parentNode));this.opts.header=e.header;this.opts.holder=e.body}const t=this.opts.holder.append("div").style("display","inline-block");const s=this.opts.holder.append("div").style("display","inline-block").style("margin-left","50px");const a=s.append("div").style("display","inline-block");const l=s.append("div").style("display","inline-block").style("vertical-align","top").style("margin-top","50px");const o=this.opts.holder.append("div").style("margin-left","50px");this.dom={holder:a,header:this.opts.header,controlsDiv:t,detailsDiv:l,tableDiv:o}}async setControls(){this.dom.controlsDiv.selectAll("*").remove();const e=[{label:"P-value filter cutoff (linear scale)",type:"number",chartType:"geneORA",settingsKey:"pvalue",title:"P-value significance",min:0,max:1},{label:"P-value filter type",type:"radio",chartType:"geneORA",settingsKey:"adjusted_original_pvalue",title:"Toggle between original and adjusted pvalues for volcano plot",options:[{label:"adjusted",value:"adjusted"},{label:"original",value:"original"}]},{label:"Gene set size filter cutoff",type:"number",chartType:"geneORA",settingsKey:"gene_set_size_cutoff",title:"Gene set size cutoff",min:0,max:2e4}];const t={label:"Gene set group",type:"dropdown",chartType:"geneORA",settingsKey:"pathway",title:"Display table showing original and adjusted pvalues corresponding to each significant pathway",boxLabel:"",options:[{label:"BP: subset of GO",value:"BP: subset of GO"},{label:"MF: subset of GO",value:"MF: subset of GO"},{label:"CC: subset of GO",value:"CC: subset of GO"},{label:"WikiPathways subset of CP",value:"WikiPathways subset of CP"},{label:"REACTOME subset of CP",value:"REACTOME subset of CP"},{label:"H: hallmark gene sets",value:"H: hallmark gene sets"}]};if(!this.settings.pathway){t.options.unshift({label:"-",value:"-"});this.settings.pathway="-"}e.push(t);this.components={controls:await r({app:this.app,id:this.id,holder:this.dom.controlsDiv,inputs:e})};this.components.controls.on("downloadClick.geneORA",(()=>{downloadTable(this.table_rows,this.table_cols)}))}getState(e){const t=e.plots.find((e=>e.id===this.id));if(!t)throw`No plot with id='${this.id}' found`;return{config:t}}async main(){this.config=JSON.parse(JSON.stringify(this.state.config));this.settings=this.config.settings.geneORA;await this.setControls();this.dom.header.style("opacity",.6).style("padding-left","10px").style("font-size","0.75em").text("GENE SET OVERREPRESENTATION ANALYSIS");d(this)}}async function d(t){if(t.settings.pathway!="-"){t.dom.detailsDiv.selectAll("*").remove();t.dom.tableDiv.selectAll("*").remove();t.config.geneORAparams.geneSetGroup=t.settings.pathway;const s=t.dom.detailsDiv.append("div").text("Loading...");let a;try{a=await f(t.config.geneORAparams);s.remove();if(a.error){throw a.error}}catch(e){alert("Error: "+e);return}const i=l({holder:t.dom.detailsDiv});const[n,o]=i.addRow();o.style("text-align","center").style("font-size","0.8em").style("opacity","0.8").text("COUNT");const r=[{label:"Sample genes",values:t.config.geneORAparams.sample_genes.split(",").length},{label:"Gene sets analyzed",values:a.num_pathways}];if(t.config.geneORAparams.background_genes){r.push({label:"Background genes",values:t.config.geneORAparams.background_genes.split(",").length})}for(const e of r){const[t,s]=i.addRow();t.text(e.label);s.style("text-align","end").text(e.values)}t.gene_ora_table_cols=[{label:"Gene set group"},{label:"Original p-value (linear scale)"},{label:"Adjusted p-value (linear scale)"},{label:"Gene set hits"},{label:"Gene set size"}];t.gene_ora_table_rows=[];for(const e of a.pathways){if(t.settings.adjusted_original_pvalue=="adjusted"&&t.settings.pvalue>=e.p_value_adjusted&&t.settings.gene_set_size_cutoff>e.gene_set_size){t.gene_ora_table_rows.push([{value:e.pathway_name},{value:e.p_value_original.toPrecision(4)},{value:e.p_value_adjusted.toPrecision(4)},{value:e.gene_set_hits},{value:e.gene_set_size}])}else if(t.settings.adjusted_original_pvalue=="original"&&t.settings.pvalue>=e.p_value_original&&t.settings.gene_set_size_cutoff>e.gene_set_size){t.gene_ora_table_rows.push([{value:e.pathway_name},{value:e.p_value_original.toPrecision(4)},{value:e.p_value_adjusted.toPrecision(4)},{value:e.gene_set_hits},{value:e.gene_set_size}])}}const p=t.dom.tableDiv.append("div");e({columns:t.gene_ora_table_cols,rows:t.gene_ora_table_rows,div:p,showLines:true,maxHeight:"30vh",resize:true})}}async function g(e,t){try{const t={settings:{geneORA:{pvalue:1,adjusted_original_pvalue:"adjusted",pathway:undefined,gene_set_size_cutoff:2e3},controls:{isOpen:true}}};return s(t,e)}catch(e){throw`${e} [geneORA getPlotConfig()]`}}const c=a(p);const u=c;function h(e,t){t.prepPlot({config:{chartType:"geneORA"}})}async function f(e){return await o("genesetOverrepresentation",{body:e})}export{u as componentInit,c as geneORAInit,g as getPlotConfig,h as makeChartBtnMenu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./tslib.es6-
|
|
1
|
+
import{_ as e}from"./tslib.es6-c3c2d88f.js";import{M as t}from"./app-b369b169.js";import{a as n}from"./genesearch-a4e19f0d.js";class o{init(e){this.callback=e.callback;const o=n({tip:new t({padding:"0px"}),genome:e.genomeObj,row:e.holder,callback:()=>this.selectGene(o)})}selectGene(t){return e(this,void 0,void 0,(function*(){if(t.geneSymbol){this.callback({kind:"gene",id:t.geneSymbol,gene:t.geneSymbol,name:t.geneSymbol,type:"geneVariant"})}else if(t.chr&&t.start&&t.stop){const{chr:e,start:n,stop:o}=t;const s=`${e}:${n+1}-${o}`;this.callback({kind:"coord",id:s,chr:e,start:n,stop:o,name:s,type:"geneVariant"})}else{throw"no gene or position specified"}}))}}export{o as SearchHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,c as t}from"./tslib.es6-c3c2d88f.js";import{B as i,P as n,bT as o,ak as s,z as r,ap as d,at as p}from"./app-b369b169.js";import{o as l,s as a}from"./termsetting-33ea66f1.js";import{m as u}from"./radiobutton-09bff425.js";import{GroupSettingMethods as c}from"./groupsetting-b4416a96.js";import"path";function f(t){return{getPillName(e){return l(t,e)},getPillStatus(){var e,n,o,s;if(t.q.type=="predefined-groupset"||t.q.type=="custom-groupset"){const s=[];s.push(i[t.q.dt]);const r=(n=(e=t.vocabApi.termdbConfig.assayAvailability)===null||e===void 0?void 0:e.byDt[t.q.dt])===null||n===void 0?void 0:n.byOrigin;if(r)s.push(((o=r[t.q.origin])===null||o===void 0?void 0:o.label)||t.q.origin);if(t.q.type=="predefined-groupset"){const e=t.term.groupsetting.lst[t.q.predefined_groupset_idx];s.push(e.name)}else if(t.q.type=="custom-groupset"){const e=t.q.customset.groups.length;s.push(`Divided into ${e} groups`)}else{throw"unknown setting for groupsetting"}return{text:s.join(" - ")}}else{return{text:((s=t.q.exclude)===null||s===void 0?void 0:s.length)?"matching variants":"any variant class"}}},showEditMenu(i){return e(this,void 0,void 0,(function*(){yield v(t,i)}))},postMain(){var i,n;return e(this,void 0,void 0,(function*(){const e=((n=(i=t.opts).getBodyParams)===null||n===void 0?void 0:n.call(i))||{};const o=yield t.vocabApi.getCategories(t.term,t.filter,e);t.category2samplecount=o.lst}))}}}function g(e,t,i=null){var s,r,d,p;if(!e.term.id)e.term.id=e.term.name;if(!e.term.kind){const t=e.term;if(t.gene||t.name&&!t.chr)t.kind="gene";else if(t.chr)t.kind="coord";else throw"unable to assign geneVariant term.kind"}if(e.term.kind=="gene"){if(!e.term.gene)e.term.gene=e.term.name;if(!e.term.name)e.term.name=e.term.gene;if(!e.term.gene||!e.term.name)throw"missing gene/name"}else if(e.term.kind=="coord"){if(!e.term.chr||!Number.isInteger(e.term.start)||!Number.isInteger(e.term.stop))throw"no position specified";if(!e.term.name){e.term.name=`${e.term.chr}:${e.term.start+1}-${e.term.stop}`}}else{throw"cannot recognize tw.term.kind"}if(!Object.keys(e.q).includes("type"))e.q.type="values";if(i){i.isAtomic=true;n(e.q,i)}if(!e.term.groupsetting)e.term.groupsetting=o;if(e.q.type=="predefined-groupset"||e.q.type=="custom-groupset"){if(!e.q.dt){const i=m(t.termdbConfig.queries);e.q.dt=i[0]}const i=(r=(s=t.termdbConfig.assayAvailability)===null||s===void 0?void 0:s.byDt[e.q.dt])===null||r===void 0?void 0:r.byOrigin;if(i&&!e.q.origin)e.q.origin="somatic";if(e.q.type=="predefined-groupset"){if(!Number.isInteger(e.q.predefined_groupset_idx)){const t=y(e.q.dt);e.q.predefined_groupset_idx=t[0]}}}{const i=(d=t.termdbConfig.customTwQByType)===null||d===void 0?void 0:d.geneVariant;if(i&&e.term.name){Object.assign(e.q,i.default||{},((p=i.byGene)===null||p===void 0?void 0:p[e.term.name])||{},e.q)}}if("cnvMaxLength"in e.q){if(!Number.isInteger(e.q.cnvMaxLength))throw"cnvMaxLength is not integer"}else{e.q.cnvMaxLength=2e6}if("cnvGainCutoff"in e.q){if(!Number.isFinite(e.q.cnvGainCutoff))throw"cnvGainCutoff is not finite";if(e.q.cnvGainCutoff&&e.q.cnvGainCutoff<0)throw"cnvGainCutoff is not positive"}else{e.q.cnvGainCutoff=.2}if("cnvLossCutoff"in e.q){if(!Number.isFinite(e.q.cnvLossCutoff))throw"cnvLossCutoff is not finite";if(e.q.cnvLossCutoff&&e.q.cnvLossCutoff>0)throw"cnvLossCutoff is not negative"}else{e.q.cnvLossCutoff=-.2}a(e.q,e.term)}function v(n,o){var d,p;return e(this,void 0,void 0,(function*(){const l=o.append("div").style("padding","8px");l.append("div").style("font-size","1.2rem").text(n.term.name);const a=l.append("div").style("margin-top","10px");const f=l.append("div").style("display","none").style("margin","5px 0px 0px 30px").style("vertical-align","top");const g=f.append("div");const v=f.append("div").style("margin-top","15px");const b=f.append("div").style("margin-top","15px");const h=l.append("div").style("display","none").style("margin-left","20px").style("vertical-align","top");a.append("div").style("font-weight","bold").text("Group variants");const x=n.q.type=="predefined-groupset"||n.q.type=="custom-groupset";const k=u({holder:a,options:[{label:"No variant grouping",value:"noGroup",checked:!x},{label:"Assign variants to groups",value:"group",checked:x}],callback:t=>e(this,void 0,void 0,(function*(){if(t=="group"){yield C()}else{q(n);delete n.q.dt;delete n.q.origin;f.style("display","none");h.style("display","none")}}))});if(((d=n.usecase)===null||d===void 0?void 0:d.detail)=="term0"||((p=n.usecase)===null||p===void 0?void 0:p.detail)=="term2"){a.style("display","none");f.style("margin","10px 0px 0px 00px")}const _=k.inputs.filter((e=>e.checked));if(_.property("value")=="group")yield C();function C(){return e(this,void 0,void 0,(function*(){f.style("display","inline-block");w();j();const e=y(n.q.dt);if(n.q.dt==s){O(e);yield I()}else{A(e)}}))}function w(){g.selectAll("*").remove();g.append("div").style("font-weight","bold").text("Variant type");const t=m(n.vocabApi.termdbConfig.queries);if(!n.q.dt)n.q.dt=t[0];u({holder:g,options:t.map((e=>({label:i[e],value:e,checked:e==n.q.dt}))),callback:t=>e(this,void 0,void 0,(function*(){n.q.dt=t;q(n);yield C()}))})}function j(){var t,i;const o=(i=(t=n.vocabApi.termdbConfig.assayAvailability)===null||t===void 0?void 0:t.byDt[n.q.dt])===null||i===void 0?void 0:i.byOrigin;if(!o){delete n.q.origin;v.style("display","none");return}if(!n.q.origin)n.q.origin="somatic";v.style("display","block");v.selectAll("*").remove();v.append("div").style("font-weight","bold").text("Variant origin");u({holder:v,options:["somatic","germline"].map((e=>({label:o[e].label,value:e,checked:e==n.q.origin}))),callback:t=>e(this,void 0,void 0,(function*(){n.q.origin=t;q(n);yield C()}))})}function O(t){b.selectAll("*").remove();b.append("div").style("font-weight","bold").text("Variant grouping");if(n.q.type!="predefined-groupset"&&n.q.type!="custom-groupset"){n.q=Object.assign(Object.assign({},G(n.q)),{type:"predefined-groupset",predefined_groupset_idx:t[0]})}const i=u({holder:b,options:[{label:"Predefined groups",value:"predefined",checked:n.q.type=="predefined-groupset"},{label:"Custom groups",value:"custom",checked:n.q.type=="custom-groupset"}],callback:i=>e(this,void 0,void 0,(function*(){if(i=="predefined"){n.q=Object.assign(Object.assign({},G(n.q)),{type:"predefined-groupset",predefined_groupset_idx:t[0]})}else{o.style("display","none");L()}yield C()}))});const o=i.divs.filter((e=>e.value=="predefined")).append("div").style("margin","5px 0px 0px 30px");const s=i.inputs.filter((e=>e.checked));if(s.property("value")=="predefined"){const i=n.q;u({holder:o,options:t.map((e=>{const t=n.term.groupsetting.lst[e];return{label:t.name,value:e,checked:e==i.predefined_groupset_idx}})),callback:t=>e(this,void 0,void 0,(function*(){i.predefined_groupset_idx=t;yield C()}))})}else{o.style("display","none")}}function A(e){h.style("display","none");delete n.groupSettingInstance;b.selectAll("*").remove();b.append("div").style("font-weight","bold").text("Variant grouping");n.q=Object.assign(Object.assign({},G(n.q)),{type:"predefined-groupset",predefined_groupset_idx:e[0]});const t=n.term.groupsetting.lst[n.q.predefined_groupset_idx];b.append("div").style("margin","5px 0px 0px 10px").text(t.name)}function G(e){if(e.type=="values"){const i=t(e,["type"]);return i}else if(e.type=="predefined-groupset"){const i=t(e,["type","predefined_groupset_idx"]);return i}else{const i=t(e,["type","customset"]);return i}}function L(){const e=n.category2samplecount.find((e=>e.dt==n.q.dt));const t=e.classes.byOrigin?e.classes.byOrigin[n.q.origin]:e.classes;const i=[{name:"Group 1",type:"values",values:Object.keys(t).map((e=>({key:e,label:r[e].label})))},{name:"Group 2",type:"values",values:[]}];n.q=Object.assign(Object.assign({},G(n.q)),{type:"custom-groupset",customset:{groups:i}})}function I(){return e(this,void 0,void 0,(function*(){h.style("display","inline-block");h.selectAll("*").remove();n.groupSettingInstance=new c(n,{holder:h,hideApply:true});yield n.groupSettingInstance.main()}))}l.append("button").style("margin-top","20px").style("display","block").text("Apply").on("click",(()=>{if((n.q.type=="predefined-groupset"||n.q.type=="custom-groupset")&&n.groupSettingInstance)n.groupSettingInstance.processDraggables();n.runCallback()}))}))}function m(e){const t=[];for(const i of Object.keys(e)){if(i=="snvindel")t.push(s);else if(i=="cnv")t.push(d);else if(i=="svfusion")t.push(p);else continue}return t}function y(e){const t=e==s?[0,1,2]:e==d?[3]:e==p?[4]:[];if(!t.length)throw"groupset_idxs is empty";return t}function q(e){e.q.type="values";delete e.q.predefined_groupset_idx;delete e.q.customset;delete e.groupSettingInstance}export{g as fillTW,f as getHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,e as t,b as n,c as s}from"./uiUtils-
|
|
1
|
+
import{a as e,e as t,b as n,c as s}from"./uiUtils-f1bd2bcc.js";import{j as o,d as a,aT as p}from"./app-b369b169.js";import{T as i}from"./toggleButtons-dbdbad01.js";import"./tslib.es6-c3c2d88f.js";function r(t,n){const s=t.append("div").style("margin","20px 20px 20px 40px").style("font-family","'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif").style("place-items","center left").style("overflow","hidden").classed("sjpp-app-ui",true);const o={};l(s,o);const a=s.append("div").style("display","flex").style("align-items","center").style("margin","10px");d(a,n,o);c(a,o);const p=s.append("div").style("display","flex").style("align-items","center").style("margin","40px 0px 40px 130px");m(p,o,t);e(p,o,".genefusion_input").style("margin","0px 10px");y(s);return o}function l(e,n){const s=t({div:e,cols:50,placeholder:"Example: PAX5,chr9,37002646,-::JAK2,chr9,5081726,+"}).style("border","1px solid rgb(138, 177, 212)").style("margin","0px 0px 0px 20px").classed("genefusion_input",true).on("keyup",(async()=>{n.data=s.property("value").trim()}))}async function d(e,t,s){const o=e.append("div").style("margin-left","40px");const a=n(o,t).style("border","1px solid rgb(138, 177, 212)");s.genome=a.node()}async function c(e,t){const n=e.append("div");const s=n.append("select").style("border-radius","5px").style("padding","5px 10px").style("margin","1px 10px 1px 10px");s.append("option").text("Codon position").property("value","codon");s.append("option").text("RNA position").property("value","rna");s.append("option").text("Genomic position").property("value","genomic").attr("selected",true);t.posType=s.node()}function m(e,t,n){const p=s({div:e,text:"Submit"});const i=e.append("div");p.style("display","block").on("click",(()=>{if(!t.data||t.data==undefined){const e=i.append("div").style("display","inline-block").style("max-width","20vw");o(e,"Please provide data");setTimeout((()=>e.remove()),3e3)}else{a(".sjpp-app-ui").remove();const e={host:sessionStorage.getItem("hostURL"),nobox:true,noheader:true,parseurl:false,genome:t.genome.options[t.genome.selectedIndex].text};u(t,n,e)}}))}function y(e){e.append("div").style("margin","10px").style("opacity","0.65").html(`Limited to two-gene fusion products.<br>\n\t\tOne product per line.<br>\n\t\tEach line has eight fields. four fields for each gene. For each gene join the following fields separated by a comma:\n\t\t<ol><li>Gene symbol</li>\n\t\t<li>Chromosome</li>\n\t\t<li>Position</li>\n\t\t<li>Strand</li>\n\t\t</ol>\n\t\tSeparate the two genes by a double colon (::). <br><br>\n\t\tExample: <br>\n\t\t<p style="margin-left: 10px">\n\t\tPAX5,chr9,37002646,-::JAK2,chr9,5081726,+<br>\n\t\tZCCHC7,chr9,37257786,-::PAX5,chr9,37024824,-<br>\n\t\tBCR,chr22,23524427,+::ABL1,chr9,133729449,+<p>`)}function u(e,t,n){if(e.data.split(/[\r\n]/).length==1){const s=e.data.trim().split("::");const o=s[0].split(",");const a=s[1].split(",");return x(t,n,o,a)}const s=t.append("div").append("select").style("border-radius","5px").style("padding","5px 10px").style("margin","1px 10px 1px 10px");s.append("option").text(`Select Fusion (${e.data.split(/[\r\n]/).length})`);const o=t.append("div").style("margin","20px");const a=new Map;for(const t of e.data.split(/[\r\n]/)){const e=t.trim().split("::");const n=e[0].split(",");const s=e[1].split(",");a.set(`${n[0]}-${s[0]}`,[n,s])}for(const e of a){s.append("option").property("value",e[0]).text(e[0])}s.on("change",(()=>{o.selectAll("*").remove();const e=a.get(s.property("value"));x(o,n,e[0],e[1])}))}function x(e,t,n,s){const o=[{label:n[0],callback:async(e,o)=>{p(o.contentHolder);const a={holder:o.contentHolder.append("div").style("margin","20px").node(),gene:n[0],tracks:[{type:"mds3",name:n[0],custom_variants:[{gene1:n[0],chr1:n[1],pos1:parseInt(n[2]),strand1:n[3],gene2:s[0],chr2:s[1],pos2:parseInt(s[2]),strand2:s[3],dt:2,class:"Fuserna"}]}]};runproteinpaint(Object.assign(t,a));delete o.callback}},{label:s[0],callback:async(e,o)=>{p(o.contentHolder);const a={holder:o.contentHolder.append("div").style("margin","20px").node(),gene:s[0],tracks:[{type:"mds3",name:s[0],custom_variants:[{gene1:n[0],chr1:n[1],pos1:parseInt(n[2]),strand1:n[3],gene2:s[0],chr2:s[1],pos2:parseInt(s[2]),strand2:s[3],dt:2,class:"Fuserna"}]}]};runproteinpaint(Object.assign(t,a));delete o.callback}}];new i({holder:e,tabs:o}).main()}export{r as init_geneFusionUI};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./tslib.es6-
|
|
1
|
+
import{_ as e}from"./tslib.es6-c3c2d88f.js";import{k as t,c as n,a as r,b as o,w as i,x as s}from"./app-b369b169.js";function l(s){const l=s.tip,c=s.row;const u={};if((s===null||s===void 0?void 0:s.searchOnly)=="snp"&&!s.genome.hasSNP){c.append("span").text('Cannot support .searchOnly = "snp". Genome lacks SNP');return u}let d,f=150;if("placeholder"in s){d=s.placeholder}else if((s===null||s===void 0?void 0:s.searchOnly)=="gene"){d="Gene";f=100}else{d=(s===null||s===void 0?void 0:s.searchOnly)=="snp"?"Position":"Gene, position";if(s.genome.hasSNP){d+=", dbSNP";f+=40}if(s.allowVariant){d+=", variant";f+=40}}const p=c.append("input").attr("type","text").attr("placeholder",d).attr("aria-label","Gene symbol, position, or alias").attr("class","sja_genesearchinput").style("width",f+"px").on("focus",(e=>{e.target.select()})).on("keyup",(r=>e(this,void 0,void 0,(function*(){const e=r.target;const o=e.value.trim();if(s.emptyInputCallback&&o.length==0&&t(r)){l.hide();s.emptyInputCallback();m.word.text("");m.mark.html("");return}if(o.length<=1)return l.hide();m.mark.html("");m.word.style("font-size","0.7em");if(s.hideHelp){m.word.text("")}else{m.word.text("Press ENTER to search, ESC to cancel")}if(t(r)){e.blur();l.hide();if((s===null||s===void 0?void 0:s.searchOnly)!="snp"){const e=l.d.select(".sja_menuoption[isgene='1']");if(e.size()){const t=e.datum();(s===null||s===void 0?void 0:s.searchOnly)=="gene"?b({geneSymbol:t},t):yield v(t);return}}if((s===null||s===void 0?void 0:s.searchOnly)=="gene"){b(null,"Gene not found");return}if(s.allowVariant){const e=yield a(o,s.genome);if(e){b(e,o);return}}const t=l.d.select(".sja_menuoption[issnp='1']");if(t.size()){const e=t.datum();b({chr:e.chrom,start:e.chromStart,stop:e.chromEnd,ref:e.ref,alt:e.alt},e.name||o);return}if((s===null||s===void 0?void 0:s.searchOnly)=="snp"){b(null,"Variant not found");return}const r=n(o,s.genome);if(r){b(r,"Valid coordinate");return}b(null,"No match");return}if(r.code=="Escape"){l.hide();if(u.chr){b(u,u.fromWhat)}else if(s.defaultCoord){const t=s.defaultCoord;e.value=t.chr+(t.isVariant?"."+t.pos+"."+t.ref+"."+t.alt:":"+t.start+"-"+t.stop)}e.blur();return}if(r.key=="ArrowDown"){l.d.selectAll(".sja_menuoption").attr("tabindex",0).on("keyup",(e=>{if(e.key=="Enter"){e.target.click()}else if(e.key=="ArrowDown"){if(e.target.nextSibling)e.target.nextSibling.focus()}else if(e.key=="ArrowUp"){if(e.target.previousSibling)e.target.previousSibling.focus()}}));l.d.select(".sja_menuoption").node().focus();return}g()}))));if(!s.focusOff)p.node().focus();const m={mark:c.append("span").style("margin-left","5px"),word:c.append("span").style("margin-left","5px").style("font-size",".8em").style("opacity",.6)};function h(){var t,r;return e(this,void 0,void 0,(function*(){const i=p.property("value").trim();if(!i)return;l.showunder(p.node()).clear();if((s===null||s===void 0?void 0:s.searchOnly)!="snp"){const n=yield o("genelookup",{body:{genome:s.genome.name,input:i}});if(n.error)throw n.error;if((t=n.hits)===null||t===void 0?void 0:t.length){l.d.selectAll("div").data(n.hits).join("div").text((e=>e)).attr("class","sja_menuoption").style("border-radius","0px").attr("isgene",1).on("click",((t,n)=>e(this,void 0,void 0,(function*(){if((s===null||s===void 0?void 0:s.searchOnly)=="gene"){b({geneSymbol:n},n);l.hide()}else{yield v(n)}}))));return}}if((s===null||s===void 0?void 0:s.searchOnly)=="gene")return;if(s.allowVariant){const e=yield a(i,s.genome);if(e)return}const c=yield o("snp",{body:{byName:true,genome:s.genome.name,lst:[i]}});if(c.error)throw c.error;if(c.results.length){y(l,c.results);return}const u=n(i,s.genome,true);if(u){if((s===null||s===void 0?void 0:s.searchOnly)=="snp"){if(!((r=u.actualposition)===null||r===void 0?void 0:r.len))return;const e=u.chr;const t=u.actualposition.position-1;const n=t+u.actualposition.len;const i=[{start:t,stop:n}];const a=yield o("snp",{body:{byCoord:true,genome:s.genome.name,chr:e,ranges:i}});if(a.error)throw a.error;if(a.results.length){const e=u.actualposition.len==1?a.results.filter((e=>e.chromStart==t)):a.results;y(l,e)}}return}}))}const g=r.debounce(h,500);function y(e,t){e.d.selectAll("div").data(t).join("div").text((e=>{const t=`${e.chrom}:${e.chromStart+1}`;const n=`${e.ref}>${e.alt.join(",")}`;return`${e.name} (${t} ${n})`})).attr("class","sja_menuoption").style("border-radius","0px").attr("issnp",1).on("click",((t,n)=>{b({chr:n.chrom,start:n.chromStart,stop:n.chromEnd,ref:n.ref,alt:n.alt},n.name);e.hide()}))}function v(t){var n;return e(this,void 0,void 0,(function*(){l.hide();const e=yield o("genelookup",{body:{genome:s.genome.name,input:t,deep:1}});if(e.error)throw e.error;if(!((n=e.gmlst)===null||n===void 0?void 0:n.length))throw"cannot retrieve gene coordinates";const r=i(e.gmlst);if(r.length==1){b(r[0],t,t);return}l.showunder(p.node()).clear();l.d.selectAll("div").data(r).join("div").attr("class","sja_menuoption").style("border-radius","0px").text((e=>e.name+" "+e.chr+":"+e.start+"-"+e.stop)).on("click",((e,n)=>{l.hide();b(n,t+", "+n.name,n.name)}))}))}if(s.defaultCoord){const e=s.defaultCoord;if(e.isVariant){p.property("value",e.chr+"."+e.pos+"."+e.ref+"."+e.alt);u.pos=e.pos;u.ref=e.ref;u.alt=e.alt}else{p.property("value",e.chr+":"+e.start+"-"+e.stop);u.start=e.start;u.stop=e.stop}u.chr=e.chr}function b(t,n,r){return e(this,void 0,void 0,(function*(){if(t){for(const e in u)delete u[e];if(t.isVariant){u.chr=t.chr;u.pos=t.pos;u.ref=t.ref;u.alt=t.alt}else if(t.chr){p.property("value",t.chr+":"+t.start+"-"+t.stop);u.chr=t.chr;u.start=t.start;u.stop=t.stop;if(t.ref)u.ref=t.ref;if(t.alt)u.alt=t.alt}else if(t.geneSymbol){p.property("value",t.geneSymbol);u.geneSymbol=t.geneSymbol}m.mark.style("color","green").html("✓");if(r){u.geneSymbol=r}}else{m.mark.style("color","red").html("✗")}m.word.text(n||"");u.fromWhat=n;if(t&&s.callback){yield s.callback()}}))}if(s.geneSymbol){p.property("value",s.geneSymbol);setTimeout((()=>b({geneSymbol:s.geneSymbol},s.geneSymbol)),10)}return u}function a(t,n){return e(this,void 0,void 0,(function*(){const e=c(t,n);if(e){return e}return yield u(t,n)}))}function c(e,t){const n=e.split(".");if(n.length!=4)return;const r=n[0];const o=Number(n[1]);const i=s(t,r,o,o);if(i)return;return{isVariant:true,chr:r,pos:o,ref:n[2],alt:n[3]}}function u(t,n){return e(this,void 0,void 0,(function*(){const e=t.split(":g.");if(e.length!=2){return}const r=e[0];if(e[1].includes("delins")){return yield m(r,e[1],n)}if(e[1].includes("del")){return yield p(r,e[1],n)}if(e[1].includes("ins")){return f(r,e[1])}return d(r,e[1])}))}function d(e,t){const n=t.match(/^(\d+)([ATCG])>([ATCG])$/);if(!n||n.length!=4){return}const r=Number(n[1]);if(!Number.isInteger(r))return;return{isVariant:true,chr:e,pos:r,ref:n[2],alt:n[3]}}function f(e,t){const[n,r]=t.split("ins");if(!r)return;const o=Number(n.split("_")[0]);if(!Number.isInteger(o))return;return{isVariant:true,chr:e,pos:o+1,ref:"-",alt:r}}function p(t,n,r){return e(this,void 0,void 0,(function*(){const[e,o]=n.split("del");if(o){const n=Number(e.split("_")[0]);if(!Number.isInteger(n))return;return{isVariant:true,chr:t,pos:n,ref:o,alt:"-"}}const[i,s]=e.split("_");const l=Number(i);const a=s?Number(s):l+1;if(!Number.isInteger(l)||!Number.isInteger(a))return;const c=yield h(t,l,a,r);return{isVariant:true,chr:t,ref:c,alt:"-"}}))}function m(t,n,r){return e(this,void 0,void 0,(function*(){const e=n.match(/^(\d+)_(\d+)delins([ATCG]+)$/);if(!e||e.length!=4){return}const o=Number(e[1]),i=Number(e[2]),s=e[3];if(!Number.isInteger(o)||!Number.isInteger(i))return;const l=yield h(t,o,i,r);return{isVariant:true,chr:t,pos:o,ref:l,alt:s}}))}function h(t,n,r,i){return e(this,void 0,void 0,(function*(){const e={coord:t+":"+n+"-"+r,genome:i.name};const s=yield o("ntseq",{body:e});return s.seq}))}export{l as a,a as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e,P as t,b as s}from"./app-b369b169.js";import{G as i}from"./recover-49e09de0.js";import{f as o}from"./termsetting-33ea66f1.js";import"./FilterRxComp-701a1480.js";import"./table-29d5a973.js";import"./tslib.es6-c3c2d88f.js";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-8b656cc3.js";import"./FilterStateless-54c0b763.js";import"./app-3320ab6f.js";import"./termInfo-bf99a37e.js";import"./toggleButtons-dbdbad01.js";import"path";import"./genesearch-a4e19f0d.js";import"./checkbox-96437f4d.js";import"./rehydrateFilter-12d118cb.js";class a{constructor(e){this.type="geneset";this.dom={holder:e.holder.style("position","relative").style("min-height","300px"),body:e.holder.append("div"),loadingOverlay:e.holder.append("div").attr("class","sjpp-spinner").style("display","none").style("position","absolute").style("background-color","#fff").style("z-index",10).style("opacity","0.5")}}init(){if(this.opts.reactsTo)this.reactsTo=this.opts.reactsTo}getState(e){const t=e.plots.find((e=>e.id===this.id));return{vocab:e.vocab,filter0:e.termfilter.filter0,config:t}}async main(){this.dom.body.selectAll("*").remove();this.dom.loadingOverlay.style("display","");this.noWait().catch(console.warn)}async noWait(){const e=new AbortController;try{const[t,s]=await this.api.detectStale((()=>this.getGenes({signal:e.signal})),{abortCtrl:e});if(s)return;if(!t?.length)this.render();else this.opts.callback(this.api,t)}catch(e){if(e=="stale sequenceId"||e.name=="AbortError")return;else{if(this.opts.showWaitMessage){this.dom.body.style("margin","20px").html(e)}throw e}}}async getGenes({signal:e}){this.opts.genes;const t=this.state.config.settings;if(this.opts.genes){if(!Array.isArray(this.opts.genes)||this.opts.genes.length==0)throw".genes[] is not non-empty array";return await this.getTwLst(this.opts.genes)}let i;if(this.opts.showWaitMessage){i=this.dom.body.append("div").style("margin","20px");this.opts.showWaitMessage(i)}let o;if(this.opts.mode=="geneVariant"){const i={};if(t.maxGenes)i.maxGenes=t.maxGenes;if(t.geneFilter)i.geneFilter=t.geneFilter;if(this.state.filter0)i.filter0=this.state.filter0;o=await s("gdc/topMutatedGenes",{body:i,signal:e},{cacheAs:"decoded"})}else if(this.opts.mode=="geneExpression"){const i={genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,maxGenes:t.maxGenes};if(this.state.filter0)i.filter0=this.state.filter0;o=await s("termdb/topVariablyExpressedGenes",{body:i,signal:e},{cacheAs:"decoded"})}else{throw"unknown opts.mode [geneset.js]"}if(!o)throw"invalid server response";if(o.error)throw o.error;if(!o.genes)return[];i.remove();this.dom.loadingOverlay?.style("display","none");return await this.getTwLst(o.genes)}async getTwLst(e){return await Promise.all(e.map((async e=>typeof e=="string"?await o({term:{gene:e,type:this.opts.mode}},this.app.vocabApi):await o({term:{gene:e.gene||e.name,type:this.opts.mode}},this.app.vocabApi))))}async render(){if(!this.dom?.holder)return;this.dom.body.append("p").text(`No default genes. Please change the cohort or define a gene set to launch ${this.state.config.toolName}.`);new i({holder:this.dom.body.append("div"),genome:this.opts.genome,mode:this.opts.mode,vocabApi:this.app.vocabApi,callback:async e=>{const t=await Promise.all(e.geneList.map((async e=>o({term:{gene:e.gene||e.name||e,type:"geneVariant"}},this.app.vocabApi))));this.opts.callback(this.api,t)}});this.dom.loadingOverlay?.style("display","none")}destroy(){this.dom.holder.selectAll("*").remove();this.dom.holder.remove();for(const e in this.dom){delete this.dom[e]}}}const n=e(a);const r=n;async function l(e={},s){const i=t({chartType:"geneset"},e);return i}export{r as componentInit,n as genesetInit,l as getPlotConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{M as t,h as e,P as s,y as a,b as o,f as i}from"./app-b369b169.js";import{a as n}from"./genesearch-a4e19f0d.js";import"./termsetting-33ea66f1.js";import{g as r}from"./FilterRxComp-701a1480.js";import{mayUpdateGroupTestMethodsIdx as l,gbControlsInit as c}from"./genomeBrowser.controls-d5067811.js";import"./tslib.es6-c3c2d88f.js";import"path";import"./table-29d5a973.js";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-8b656cc3.js";import"./checkbox-96437f4d.js";import"./FilterStateless-54c0b763.js";import"./toggleButtons-dbdbad01.js";import"./app-3320ab6f.js";import"./termInfo-bf99a37e.js";const p=new t({padding:"0px"});class f{constructor(){this.type="genomeBrowser"}async init(){const e=this.opts.holder.append("div");this.opts.header.append("div").style("opacity",.6).style("padding-left","10px").style("font-size","0.75em").text("GENOME BROWSER");const s=e.append("div");const a=e.append("div").style("margin-left","25px");a.append("span").html(" ");this.dom={tip:new t,holder:e,errDiv:s,loadingDiv:a.append("span").text("Loading..."),controlsDiv:e.append("div").style("margin-left","25px"),blockHolder:e.append("div")};this.components={gbControls:await c({app:this.app,id:this.id,holder:this.dom.controlsDiv})}}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e)throw`No plot with id='${this.id}' found`;return{config:e,termdbConfig:t.termdbConfig,filter:r(t.termfilter.filter)}}async main(){this.dom.loadingDiv.style("display","inline");try{if(this.state.config?.snvindel?.details){await this.launchCustomMds3tk()}else if(this.state.config?.trackLst){await this.launchBlockWithTracks(this.state.config.trackLst)}else{const t={type:"mds3",dslabel:this.app.opts.state.vocab.dslabel,newChartHolder:this.opts.plotDiv};if(this.state.filter?.lst?.length>0){t.filterObj=structuredClone(this.state.filter)}await this.launchBlockWithTracks([t])}this.updateLDtrack()}catch(t){a(this.dom.errDiv,t.message||t);if(t.stack)console.log(t.stack)}this.dom.loadingDiv.style("display","none")}async launchCustomMds3tk(){const t=await this.preComputeData();this.mayDisplaySampleCountInControls(t);if(this.blockInstance){const e=this.blockInstance.tklst.find((t=>t.type=="mds3"));e.custom_variants=t.mlst;b(this,e.skewer.viewModes.find((t=>t.type=="numeric")));e.load();return}const e={type:"numeric",inuse:true,byAttribute:"nm_axis_value"};b(this,e);const s={type:"mds3",dslabel:this.app.opts.state.vocab.dslabel,name:"Variants",custom_variants:t.mlst,skewerModes:[e]};await this.launchBlockWithTracks([s])}mayDisplaySampleCountInControls(t){if(Number.isInteger(t.totalSampleCount_group1)||Number.isInteger(t.totalSampleCount_group2)){const e={appState:{plots:[{id:this.components.gbControls.id,_partialData:{groupSampleCounts:[t.totalSampleCount_group1,t.totalSampleCount_group2],pop2average:t.pop2average}}]}};this.components.gbControls.update(e)}}async preComputeData(){const t={genome:this.app.opts.state.vocab.genome,dslabel:this.app.opts.state.vocab.dslabel,for:"mds3variantData",chr:this.state.config.geneSearchResult.chr,start:this.state.config.geneSearchResult.start,stop:this.state.config.geneSearchResult.stop,details:this.state.config.snvindel.details,filter:this.state.filter,variantFilter:this.state.config.variantFilter?.filter};const e=await o("termdb",{body:t});if(e.error)throw e.error;return e}async launchBlockWithTracks(t){this.dom.blockHolder.selectAll("*").remove();const e={holder:this.dom.blockHolder,genome:this.app.opts.genome,nobox:true,tklst:await this.getTracks2show(t),debugmode:true};if(this.state.termdbConfig?.queries.defaultBlock2GeneMode&&this.state.config.geneSearchResult.geneSymbol){e.query=this.state.config.geneSearchResult.geneSymbol;const t=await import("./app-b369b169.js").then((function(t){return t.c3}));await t.default(e);this.blockInstance=e.__blockInstance;this.opts.header.text(e.query);return}e.chr=this.state.config.geneSearchResult.chr;e.start=this.state.config.geneSearchResult.start;e.stop=this.state.config.geneSearchResult.stop;i(this.app.opts.genome,e.tklst);e.onCoordinateChange=async t=>{await this.app.dispatch({type:"plot_edit",id:this.id,config:{geneSearchResult:{chr:t[0].chr,start:t[0].start,stop:t[0].stop}}})};const s=await import("./block-6aedd569.js").then((function(t){return t.c}));this.blockInstance=new s.Block(e)}async getTracks2show(t){const e=[];for(const s of t){if(s.isfacet){const t=JSON.parse(JSON.stringify(s));if(!this.app.opts.genome.tkset)this.app.opts.genome.tkset=[];if(!t.tklst)throw".tklst[] missing from a facet table";if(!Array.isArray(t.tklst))throw".tklst[] not an array from a facet table";for(const s of t.tklst){if(!s.assay)throw".assay missing from a facet track";if(!s.sample)throw".sample missing from a facet track";s.tkid=Math.random().toString();if(s.defaultShown)e.push(s)}this.app.opts.genome.tkset.push(t)}else{e.push(s)}}return e}updateLDtrack(){if(!this.state.config.ld)return;if(!this.blockInstance)return;for(const t of this.state.config.ld.tracks){const e=this.blockInstance.tklst.findIndex((e=>e.file==t.file0));if(t.shown){if(e==-1){const e={type:"ld",name:t.name,file:t.file0};const s=this.blockInstance.block_addtk_template(e);this.blockInstance.tk_load(s)}continue}if(e==-1)continue;this.blockInstance.tk_remove(e)}}}const d=e(f);const h=d;async function m(t,e){try{return await g(e.vocabApi,t)}catch(t){throw`${t} [genomeBrowser getPlotConfig()]`}}function u(t,e){const s=e.app.opts.genome;if(typeof s!="object")throw"chartsInstance.app.opts.genome not an object and needed for gene search box";const a={tip:p,genome:s,row:t.append("div").style("margin","10px"),callback:async()=>{try{const t=await g(e.app.vocabApi);t.chartType="genomeBrowser";t.geneSearchResult=o;const s={config:t};e.prepPlot(s)}catch(e){t.append("div").text("Error: "+(e.message||e));console.log(e)}}};if(!e.state.termdbConfig.queries.defaultBlock2GeneMode){a.defaultCoord=e.state.termdbConfig.queries.defaultCoord}else{a.searchOnly="gene"}const o=n(a)}async function g(t,e){const a=await t.getMds3queryDetails();const o=await t.get_variantFilter();if(o?.filter){a.variantFilter=o}const i=e?s(a,e):a;if(i.snvindel?.details){l({state:{config:i}},i.snvindel.details)}return i}function b(t,e){delete e.tooltipPrintValue;const[s,a]=t.state.config.snvindel.details.groups;if(s&&a){if(s.type=="info"||a.type=="info"){e.label="Value difference";return}const o=t.state.config.snvindel.details.groupTestMethods[t.state.config.snvindel.details.groupTestMethodsIdx];e.label=o.axisLabel||o.name;if(o.name=="Allele frequency difference"){e.tooltipPrintValue=t=>[{k:"AF diff",v:t.nm_axis_value}]}else if(o.name=="Fisher's exact test"){e.tooltipPrintValue=t=>[{k:"p-value",v:t.p_value}]}else;return}if(s.type=="info"){const a=t.state.config.variantFilter?.terms?.find((t=>t.id==s.infoKey));e.label=a?.name||s.infoKey;e.tooltipPrintValue=t=>[{k:e.label,v:t.info[s.infoKey]}];return}if(s.type=="filter"){e.label="Allele frequency";e.tooltipPrintValue=t=>[{k:"Allele frequency",v:t.nm_axis_value}];return}if(s.type=="population"){e.label="Allele frequency";e.tooltipPrintValue=t=>[{k:"Allele frequency",v:t.nm_axis_value}];return}throw"unknown type of the only group"}export{h as componentInit,d as genomeBrowserInit,m as getPlotConfig,u as makeChartBtnMenu};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{M as t,h as e}from"./app-b369b169.js";import{m as i}from"./checkbox-96437f4d.js";import{f as n}from"./FilterStateless-54c0b763.js";import{g as s,a as o}from"./FilterRxComp-701a1480.js";import"./termsetting-33ea66f1.js";import{T as a}from"./toggleButtons-dbdbad01.js";import{appInit as r}from"./app-3320ab6f.js";import"./table-29d5a973.js";import"./tslib.es6-c3c2d88f.js";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-8b656cc3.js";import"path";import"./termInfo-bf99a37e.js";const l=new t({padding:"0px"});class p{constructor(t){this.type="gbControls";this.filterUI={}}async init(t){this.initUI(this.getState(t))}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e)throw`No plot with id='${this.id}' found`;if(e._partialData){this._partialData=e._partialData;return}return{config:e,termdbConfig:t.termdbConfig,filter:s(t.termfilter.filter)}}async main(){const t=this.state.config.snvindel?.details?.groups;if(t){this.render1group(0);this.render1group(1);if(this.state.config.snvindel.details.groupTestMethods){this.renderTestMethod()}}if(this.state.config.variantFilter){if(!this.variantFilterRendered){this.variantFilterRendered=true;this.makeVariantFilter()}}}async makeVariantFilter(){n({joinWith:this.state.config.variantFilter.opts.joinWith,emptyLabel:"+Add Filter",holder:this.dom.variantFilterHolder,vocab:{terms:this.state.config.variantFilter.terms},callback:async t=>{await this.app.dispatch({type:"plot_edit",id:this.id,config:{variantFilter:{filter:t}}})}}).main(this.state.config.variantFilter.filter)}render1group(t){const e=this.state.config.snvindel.details.groups[t];const i=t==0?this.dom.group1div:this.dom.group2div;let n=false;if(e?.type=="filter"&&this.filterUI[t]){n=true}else{delete this.filterUI[t];i.selectAll("*").remove()}if(!e){h(this,t,i);return}if(!n)m(this,t,i);if(e.type=="info")return c(this,t,e,i);if(e.type=="population")return f(this,t,e,i);if(e.type=="filter")return u(this,t,e,i);throw"render1group: unknown group type"}renderTestMethod(){const t=this.dom.testMethodDiv;t.selectAll("*").remove();const[e,i]=this.state.config.snvindel.details.groups;if(!i){return}t.append("span").text("TEST METHOD").style("font-size",".8em").style("opacity",.6);if(e.type!="filter"&&i.type!="filter"){t.append("span").style("padding-left","10px").text("Value difference").style("opacity",.6);return}const n=t.append("select").style("margin-left","10px").on("change",(()=>{this.app.dispatch({type:"plot_edit",id:this.id,config:{snvindel:{details:{groupTestMethodsIdx:n.property("selectedIndex")}}}})}));for(const t of this.state.config.snvindel.details.groupTestMethods){n.append("option").text(t.name)}n.property("selectedIndex",this.state.config.snvindel.details.groupTestMethodsIdx)}initUI(t){this.dom={};const e=[];if(t.config.snvindel?.details){e.push({label:"Variant values",active:true})}if(t.config.variantFilter){e.push({label:"Variant filter"})}if(t.config.ld){e.push({label:"LD map"})}if(e.length==0){return}const n=new a({holder:this.opts.holder.append("div").style("border-bottom","solid 1px #ccc").style("padding-bottom","20px"),tabs:e});n.main();{const t=e[0].contentHolder.append("div");this.dom.group1div=t.append("div");this.dom.group2div=t.append("div");this.dom.testMethodDiv=t.append("div").style("margin-top","3px")}let s=1;if(t.config.variantFilter){this.dom.variantFilterHolder=e[s++].contentHolder.append("div").style("white-space","normal")}if(t.config.ld){const n=structuredClone(t.config.ld.tracks);const o=e[s++].contentHolder.append("div");o.append("div").text("Show/hide linkage disequilibrium map from an ancestry:").style("opacity",.5);for(const[t,e]of n.entries()){i({labeltext:e.name,checked:e.shown,holder:o,callback:()=>{n[t].shown=!n[t].shown;this.app.dispatch({type:"plot_edit",id:this.id,config:{ld:{tracks:n}}})}})}}}}const d=e(p);function c(t,e,i,n){let s=i.infoKey;if(t.state.config.variantFilter?.terms){const e=t.state.config.variantFilter.terms.find((t=>t.id==i.infoKey));if(e&&e.name)s=e.name}n.append("span").text(s).attr("class","sja_menuoption").on("click",(n=>{if(t.state.config.variantFilter.terms.length<=1){return}l.clear().showunder(n.target).d.append("div").text("Replace with:").style("margin","10px").style("font-size",".8em");for(const n of t.state.config.variantFilter.terms){if(n.type!="integer"&&n.type!="float")continue;if(n.id==i.infoKey)continue;l.d.append("div").text(n.name).attr("class","sja_menuoption").on("click",(()=>{l.hide();const i=structuredClone(t.state.config.snvindel.details.groups);i[e].infoKey=n.id;i[e].type="info";t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:{groups:i}}}})}))}}));n.append("span").text("PER-VARIANT NUMERICAL VALUES").style("font-size",".7em").style("opacity",.6).style("margin-left","10px")}function f(t,e,i,n){n.append("span").text(i.label).attr("class","sja_menuoption").on("click",(n=>{if(t.state.config.snvindel.populations.length<=1){return}l.clear().showunder(n.target).d.append("div").text("Replace with:").style("margin","10px").style("font-size",".8em");for(const n of t.state.config.snvindel.populations){if(n.key==i.key)continue;l.d.append("div").text(n.label).attr("class","sja_menuoption").on("click",(()=>{l.hide();const i=structuredClone(t.state.config.snvindel.details.groups);i[e]=structuredClone(n);i[e].type="population";t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:{groups:i}}}})}))}}));n.append("span").text(`POPULATION${i.adjust_race?", RACE ADJUSTED":""}`).style("font-size",".7em").style("margin-left","10px").style("opacity",.6);if(t._partialData?.pop2average){if(t.state.config.snvindel.details.groups[e==1?0:1]?.type=="filter"){const s=[];for(const e in t._partialData.pop2average){const i=t._partialData.pop2average[e];if(!Number.isFinite(i))continue;s.push(`${e}=${i.toFixed(2)}`)}if(s.length){n.append("span").text(`Group ${e==1?1:2} average admixture: ${s.join(", ")}`).style("margin-left","20px").attr("class","sja_clbtext").on("click",(t=>{l.clear().showunder(t.target).d.append("div").style("margin","10px").style("width","500px").html(`These are average admixture coefficients based on current Group ${e==1?1:2} samples.\n\t\t\t\t\t\tThey are used to adjust variant allele counts of matching ancestries from <span class=sja_menuoption style="padding:2px 5px">${i.label}</span>,\n\t\t\t\t\t\tso that the adjusted allele counts can be compared against Group ${e==1?1:2} allele counts.\n\t\t\t\t\t\tThis allows to account for ancestry composition difference between the two groups.\n\t\t\t\t\t\t`)}))}}}}async function u(t,e,i,s){if(!t.filterUI[e]){t.filterUI[e]=await n({holder:s,vocab:t.app.opts.state.vocab,emptyLabel:"Entire cohort",termdbConfig:t.state.termdbConfig,callback:async i=>{const n=JSON.parse(JSON.stringify(t.state.config.snvindel.details.groups));n[e].filter=i;t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:{groups:n}}}})}})}t.filterUI[e].main(g(t,i));s.select(".sjpp-gb-filter-count").remove();const o=t._partialData?.groupSampleCounts?.[e];if(Number.isInteger(o)){s.append("span").attr("class","sjpp-gb-filter-count").style("margin-left","10px").style("opacity",.5).style("font-size",".9em").text("n="+o)}}function g(t,e){const i=structuredClone(t.state.filter||{type:"tvslst",in:true,join:"",lst:[]});const n=structuredClone(e.filter);n.tag="filterUiRoot";i.lst.push(n);i.join="and";return i}function h(t,e,i){i.append("div").style("display","inline-block").text("Create Group 2").attr("class","sja_clbtext").style("margin","10px").on("click",(i=>{l.showunder(i.target).clear();y(t,e,l.d)}))}function m(t,e,i){i.append("div").style("display","inline-block").text("Group "+(e+1)).attr("class","sja_menuoption").style("margin-right","10px").on("click",(i=>{l.showunder(i.target).clear();if(e==0){y(t,0,l.d);return}l.d.append("div").text("Change").attr("class","sja_menuoption").style("border-radius","0px").on("click",(()=>{y(t,1,l.clear().d)}));l.d.append("div").text("Delete").attr("class","sja_menuoption").style("border-radius","0px").on("click",(()=>{l.hide();const e=[t.state.config.snvindel.details.groups[0]];t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:{groups:e}}}})}))}))}function y(t,e,i){const n={holder:i.append("div").style("margin","5px"),tabs:t.state.config.snvindel.details.groupTypes.map((t=>({label:t.name}))),tabsPosition:"vertical",linePosition:"right"};new a(n).main();for(const[i,s]of t.state.config.snvindel.details.groupTypes.entries()){const o=n.tabs[i];o.contentHolder.style("margin","10px");if(s.type=="info"){if(!t.state.config.variantFilter?.terms)throw"looking for snvindel info fields but self.state.config.variantFilter.terms[] missing";for(const i of t.state.config.variantFilter.terms){if(i.type!="integer"&&i.type!="float")continue;o.contentHolder.append("div").text(i.name).attr("class","sja_menuoption").on("click",(()=>{l.hide();const n={type:"info",infoKey:i.id};const s=v(t,n,e);b(t,s);t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:s}}})}))}continue}if(s.type=="population"){if(!t.state.config.snvindel.populations)throw"state.config.snvindel.populations missing";for(const i of t.state.config.snvindel.populations){o.contentHolder.append("div").text(i.label).attr("class","sja_menuoption").on("click",(()=>{l.hide();const n={type:"population",key:i.key,label:i.label,allowto_adjust_race:i.allowto_adjust_race,adjust_race:i.adjust_race};const s=v(t,n,e);b(t,s);t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:s}}})}))}continue}if(s.type=="filter"){const i={holder:o.contentHolder,vocabApi:t.app.vocabApi,state:{termfilter:{filter:t.state.filter}},tree:{click_term2select_tvs:i=>{l.hide();const n={type:"filter",filter:{in:true,join:"",type:"tvslst",lst:[{type:"tvs",tvs:i}]}};const s=v(t,n,e);b(t,s);t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:s}}})}}};const n=x(t);if(Number.isInteger(n))i.state.activeCohort=n;r(i);continue}throw"unknown group type"}}function v(t,e,i){const n={groups:JSON.parse(JSON.stringify(t.state.config.snvindel.details.groups))};n.groups[i]=e;return n}function b(t,e){if(e.groups.length!=2)return;const[i,n]=e.groups;if(i.type=="info"||n.type=="info"||i.type=="population"&&n.type=="population"){const i=t.state.config.snvindel.details.groupTestMethods.findIndex((t=>t.name=="Allele frequency difference"));if(i==-1)throw"Allele frequency difference not found";e.groupTestMethodsIdx=i}}function x(t){if(!t.state.config.filter)return;const e=o(t.config.filter,"cohortFilter");if(e&&t.state.termdbConfig.selectCohort){const i=e.tvs.values.map((t=>t.key)).sort().join(",");const n=t.state.termdbConfig.selectCohort.values.findIndex((t=>t.keys.sort().join(",")==i));if(n==-1)throw"subcohort key is not in selectCohort.values[]";return n}}export{d as gbControlsInit,b as mayUpdateGroupTestMethodsIdx};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./tslib.es6-1f85f553.js";import{t,z as s,d as a,a as n}from"./app-a8c4854a.js";class r{constructor(e,t={}){this.tsInstance=e;this.opts=t;this.dom={menuWrapper:t.holder||e.dom.tip.d.append("div")};this.minGrpNum=3;this.defaultMaxGrpNum=5;this.data={groups:[],values:[]};o(this)}processInput(e){const a=new Set([0,1,2]);const n=structuredClone(e);if(this.tsInstance.q.type=="values"){for(const e of Object.values(n)){if(e.uncomputable)return;if((e===null||e===void 0?void 0:e.group)>this.defaultMaxGrpNum)t(`The maximum number of groups is ${this.defaultMaxGrpNum}. The group index for value = ${e.label} is ${e.group}`);const s={key:e.key,label:e.label,group:e.group||1,samplecount:e.samplecount};this.data.values.push(s);a.add(s.group)}}else if(this.tsInstance.q.type=="custom-groupset"){this.formatCustomset(a,n)}else if(this.tsInstance.q.type=="predefined-groupset"){if(this.tsInstance.term.type=="geneVariant"){const e=this.tsInstance.q;const t=this.tsInstance.term;const r=n.find((t=>t.dt==e.dt));const o=r.classes.byOrigin?r.classes.byOrigin[e.origin]:r.classes;const i=t.groupsetting.lst[e.predefined_groupset_idx];let p=0;for(const e of i.groups){const t=e;const n=t.uncomputable?0:++p;this.data.groups.push({currentIdx:n,type:"values",name:n===0?"Excluded categories":t.name});a.delete(n);for(const[e,a]of Object.entries(o)){if(t.values.some((t=>t.key==e))){this.data.values.push({key:e,label:s[e].label,group:n,samplecount:a})}}}}}else{throw"q.type not recognized"}if(this.data.values.length==0)t(`Missing values`);this.data.values.forEach((e=>{var t;if(!e.samplecount){if(this.tsInstance.term.type=="geneVariant"){const t=this.tsInstance.q;const s=this.tsInstance.category2samplecount.find((e=>e.dt==t.dt));const a=s.classes.byOrigin&&t.origin?s.classes.byOrigin[t.origin]:s.classes;e.samplecount=a[e.key]}else{e.samplecount=this.tsInstance.category2samplecount?(t=this.tsInstance.category2samplecount.find((t=>t.key==e.key)))===null||t===void 0?void 0:t.samplecount:"n/a"}}}));for(const e of Array.from(a)){this.data.groups.push({currentIdx:e,type:"values",name:e===0?`Excluded categories`:`Group ${e.toString()}`})}this.data.groups.sort(((e,t)=>e.currentIdx-t.currentIdx))}formatCustomset(e,t){var a;const n=this.tsInstance.q;for(const[t,s]of n.customset.groups.entries()){const n=s;if(n.uncomputable)return;this.data.groups.push({currentIdx:Number(t)+1,type:"values",name:n.name});e.delete(t+1);for(const e of n.values){const s=e.label?e.label:this.tsInstance.category2samplecount?(a=this.tsInstance.category2samplecount.find((t=>t.key==e.key)))===null||a===void 0?void 0:a.label:e.key;this.data.values.push({key:e.key,label:s,group:t+1,samplecount:null})}}if(this.tsInstance.term.type=="geneVariant"){const e=this.tsInstance.q;const t=this.tsInstance.category2samplecount.find((t=>t.dt==e.dt));const a=t.classes.byOrigin&&e.origin?t.classes.byOrigin[e.origin]:t.classes;if(this.data.values.length!==Object.keys(a).length){for(const[e,t]of Object.entries(a)){if(!this.data.values.some((t=>t.key==e))){this.data.values.push({key:e,label:s[e].label,group:0,samplecount:t})}}}}else if(this.data.values.length!==Object.keys(t).length&&this.tsInstance.q.type!="predefined-groupset"&&this.tsInstance.q.type!="custom-groupset"){Object.entries(t).filter((e=>!this.data.values.some((t=>t.key==e[1].label)))).forEach((e=>{var t;this.data.values.push({key:e[0],label:e[1].label,group:0,samplecount:this.tsInstance.category2samplecount?(t=this.tsInstance.category2samplecount.find((t=>t.key==e[0])))===null||t===void 0?void 0:t.samplecount:"n/a"})}))}else if(this.data.values.length!==this.tsInstance.category2samplecount.length){this.tsInstance.category2samplecount.filter((e=>!this.data.values.some((t=>t.key==e.key)))).forEach((e=>{this.data.values.push({key:e.key,label:e.label,group:0,samplecount:e.samplecount})}))}}main(){return e(this,void 0,void 0,(function*(){try{const e=this.tsInstance.q.type=="custom-groupset"&&this.tsInstance.q.customset||this.tsInstance.category2samplecount||this.tsInstance.term.values;this.processInput(e);yield this.initGrpSetUI()}catch(e){if(e.stack)console.log(e.stack);else t(e)}}))}}function o(t){t.initGrpSetUI=function(){return e(this,void 0,void 0,(function*(){t.maxGrpNum=t.data.values.length>=t.defaultMaxGrpNum?t.defaultMaxGrpNum+1:t.data.values.length;t.tsInstance.dom.tip.showunder(t.tsInstance.dom.holder.node());yield t.showDraggables()}))};t.showDraggables=function(){return e(this,void 0,void 0,(function*(){t.dom.actionDiv=t.dom.menuWrapper.append("div").attr("class","sjpp-group-actions").style("padding","10px");const s=t.data.groups.filter((e=>e.name.startsWith("New Group")));let n=s.length>0?s[s.length-1].name.replace(`New Group `,""):0;t.dom.actionDiv.addGroup=t.dom.actionDiv.append("button").classed("sjpp_grpset_addGrp_btn",true).style("display","inline-block").style("text-align","center").style("cursor",t.tsInstance.q.mode=="binary"?"default":"pointer").property("disabled",t.tsInstance.q.mode=="binary"?true:t.data.groups.length>=t.maxGrpNum).text("Add Group").on("click",(()=>e(this,void 0,void 0,(function*(){n++;t.data.groups.push({currentIdx:t.data.groups.length,type:"values",name:`New Group${n!=1?` ${n}`:""}`});const e=t.data.groups[t.data.groups.length-1];yield o(e);yield t.update()}))));t.dom.actionDiv.applyBtn=t.dom.actionDiv.append("button").classed("sjpp_grpset_apply_btn",true).style("display",t.opts.hideApply?"none":"inline-block").style("text-align","center").style("float","right").style("cursor","pointer").text("Apply").on("click",(()=>{t.processDraggables();t.tsInstance.dom.tip.hide();t.tsInstance.runCallback()}));t.dom.menuWrapper.append("div").style("margin","5px 2px").style("font-size",".6em").style("color","#999").text("Drag-and-drop to assign categories to groups.");t.dom.grpsWrapper=t.dom.menuWrapper.append("div").classed("sjpp-groups-wrapper",true);t.dom.includedWrapper=t.dom.grpsWrapper.append("div").classed("sjpp-groups-include",true).classed("sjpp-group-edit-div",true).style("display","flex");t.dom.excludedWrapper=t.dom.grpsWrapper.append("div").classed("sjpp-groups-exclude",true).classed("sjpp-group-edit-div",true).classed("sjpp-drag-drop-div",true);yield o(t.data.groups.find((e=>e.currentIdx===0)));yield t.dom.includedWrapper.selectAll("div").data(t.data.groups.filter((e=>e.currentIdx!=0))).enter().append("div").classed("sjpp-drag-drop-div",true).style("border","1px solid #efefef").style("display","block").style("padding","10px").style("vertical-align","top").each((function(t){return e(this,void 0,void 0,(function*(){t.wrapper=a(this);yield o(t)}))}))}))};t.processDraggables=()=>{if(!s&&!r)return;const e={groups:[]};for(const s of t.data.groups){if(s.currentIdx===0)continue;const a=t.data.values.filter((e=>e.group==s.currentIdx)).map((e=>({key:e.key,label:e.label})));if(a.length==0)continue;e.groups.push({name:s.name,type:s.type,values:a})}t.tsInstance.q.type="custom-groupset";t.tsInstance.q.customset=e;delete t.tsInstance.q.predefined_groupset_idx};let s;let r;function o(a){return e(this,void 0,void 0,(function*(){const r=a.currentIdx===0?t.dom.excludedWrapper:t.dom.includedWrapper;a.type="values";if(!a.wrapper)a.wrapper=r.append("div").classed("sjpp-drag-drop-div",true).style("border","1px solid #efefef").style("display","block").style("padding","10px").style("vertical-align","top");a.wrapper.on("drop",(function(e){const n=s.node().__data__;if(n.group===a.currentIdx)return;a.draggables.node().appendChild(s.node());s.style("transition-property","background-color").style("transition-duration","1s").style("background-color","#fff2cc");t.data.values.find((e=>e===n)).group=a.currentIdx;e.preventDefault();e.stopPropagation()})).on("dragleave",(function(e){e.preventDefault();e.stopPropagation();a.wrapper.style("background-color","#fff")})).on("dragend",(function(e){e.preventDefault();e.stopPropagation();a.wrapper.style("background-color","#fff")})).on("dragover",(function(e){e.preventDefault();e.stopPropagation();a.wrapper.style("background-color",a.currentIdx!==s.node().__data__.group?"#cfe2f3":"#fff")})).on("dragenter",(function(e){if(s.node().__data__.group===a.currentIdx)return;e.preventDefault();e.stopPropagation();a.wrapper.style("background-color",a.currentIdx!==s.node().__data__.group?"#cfe2f3":"#fff")}));if(a.currentIdx===0){a.title=a.wrapper.append("div").style("display","inline-block").style("padding","3px 10px").style("text-align","left").style("font-size",".6em").style("text-transform","uppercase").style("color","#999").text(a.name)}else{a.dragActionDiv=a.wrapper.append("div").style("display","flex").style("align-items","center");a.input=a.dragActionDiv.append("input").attr("size",12).attr("value",a.name).style("margin","5px").style("margin-left","8px").style("display","inline-block").style("font-size",".8em").style("width","87%").on("keyup",(()=>{n.debounce(t.onKeyUp(a),1e3)}));a.inputMessage=a.dragActionDiv.append("span").style("color","red").style("font-size","0.7em").text("NOT unique").style("display","none");a.destroyBtn=a.dragActionDiv.append("button").style("display","inline-block").style("padding","0px 4px").property("disabled",t.data.groups.length<=t.minGrpNum).text("x").on("click",(()=>e(this,void 0,void 0,(function*(){if(t.data.groups.length<=t.minGrpNum)return;t.data.groups=t.data.groups.filter((e=>e.currentIdx!=a.currentIdx));yield t.removeGroup(a)}))))}a.draggables=a.wrapper.append("div").classed("sjpp-drag-list-div",true);yield t.addItems(a)}))}t.onKeyUp=function(s){return e(this,void 0,void 0,(function*(){if(s.name==s.input.node().value)return;r=true;const e=t.data.groups.filter((e=>e.name==s.input.node().value));if(e.length>0){t.dom.actionDiv.applyBtn.property("disabled",true);s.inputMessage.style("display","block")}else{t.dom.actionDiv.applyBtn.property("disabled",false);s.inputMessage.style("display","none");t.data.groups[s.currentIdx].name=s.input.node().value.trim()}}))};t.addItems=function(n){return e(this,void 0,void 0,(function*(){yield n.draggables.selectAll("div").data(t.data.values.filter((e=>e.group==n.currentIdx))).enter().append("div").attr("draggable","true").attr("class","sjpp-drag-item").style("margin","3px").style("cursor","default").style("padding","3px 10px").style("border-radius","5px").style("color",(e=>e.samplecount==0?"#777":"black")).text((e=>`${e.label}${e.samplecount!==undefined?` (n=${e.samplecount})`:""}`)).style("background-color","#eee").each((function(){const e=a(this).on("dragstart",(function(){e.style("background-color","#fff2cc");s=e})).on("mouseenter",(function(){e.style("background-color","#fff2cc")})).on("mouseleave",(function(){e.style("background-color","#eee")}))}))}))};t.removeGroup=function(s){return e(this,void 0,void 0,(function*(){const e=s.wrapper.selectAll(".sjpp-drag-item").nodes();if(e.length===0)s.wrapper.remove();else{s.input.remove();s.destroyBtn.remove();s.wrapper.remove();for(const e of t.data.values){if(e.group==s.currentIdx)e.group=0}}yield t.update()}))};t.update=function(){return e(this,void 0,void 0,(function*(){t.dom.actionDiv.addGroup.property("disabled",t.data.groups.length>=t.maxGrpNum);for(const[e,s]of t.data.groups.entries()){if(e===0)continue;if(s.currentIdx!=e){t.data.values.filter((e=>e.group==s.currentIdx)).forEach((t=>t.group=e));s.currentIdx=e}}t.dom.grpsWrapper.selectAll(".sjpp-drag-drop-div").data(t.data.groups).each((s=>e(this,void 0,void 0,(function*(){if(s.currentIdx!==0){s.input.node().value=s.name;s.destroyBtn.property("disabled",t.data.groups.length<=t.minGrpNum)}yield t.addItems(s)}))))}))}}export{r as GroupSettingMethods};
|
|
1
|
+
import{_ as e}from"./tslib.es6-c3c2d88f.js";import{t,z as s,d as a,a as n}from"./app-b369b169.js";class r{constructor(e,t={}){this.tsInstance=e;this.opts=t;this.dom={menuWrapper:t.holder||e.dom.tip.d.append("div")};this.minGrpNum=3;this.defaultMaxGrpNum=5;this.data={groups:[],values:[]};o(this)}processInput(e){const a=new Set([0,1,2]);const n=structuredClone(e);if(this.tsInstance.q.type=="values"){for(const e of Object.values(n)){if(e.uncomputable)return;if((e===null||e===void 0?void 0:e.group)>this.defaultMaxGrpNum)t(`The maximum number of groups is ${this.defaultMaxGrpNum}. The group index for value = ${e.label} is ${e.group}`);const s={key:e.key,label:e.label,group:e.group||1,samplecount:e.samplecount};this.data.values.push(s);a.add(s.group)}}else if(this.tsInstance.q.type=="custom-groupset"){this.formatCustomset(a,n)}else if(this.tsInstance.q.type=="predefined-groupset"){if(this.tsInstance.term.type=="geneVariant"){const e=this.tsInstance.q;const t=this.tsInstance.term;const r=n.find((t=>t.dt==e.dt));const o=r.classes.byOrigin?r.classes.byOrigin[e.origin]:r.classes;const i=t.groupsetting.lst[e.predefined_groupset_idx];let p=0;for(const e of i.groups){const t=e;const n=t.uncomputable?0:++p;this.data.groups.push({currentIdx:n,type:"values",name:n===0?"Excluded categories":t.name});a.delete(n);for(const[e,a]of Object.entries(o)){if(t.values.some((t=>t.key==e))){this.data.values.push({key:e,label:s[e].label,group:n,samplecount:a})}}}}}else{throw"q.type not recognized"}if(this.data.values.length==0)t(`Missing values`);this.data.values.forEach((e=>{var t;if(!e.samplecount){if(this.tsInstance.term.type=="geneVariant"){const t=this.tsInstance.q;const s=this.tsInstance.category2samplecount.find((e=>e.dt==t.dt));const a=s.classes.byOrigin&&t.origin?s.classes.byOrigin[t.origin]:s.classes;e.samplecount=a[e.key]}else{e.samplecount=this.tsInstance.category2samplecount?(t=this.tsInstance.category2samplecount.find((t=>t.key==e.key)))===null||t===void 0?void 0:t.samplecount:"n/a"}}}));for(const e of Array.from(a)){this.data.groups.push({currentIdx:e,type:"values",name:e===0?`Excluded categories`:`Group ${e.toString()}`})}this.data.groups.sort(((e,t)=>e.currentIdx-t.currentIdx))}formatCustomset(e,t){var a;const n=this.tsInstance.q;for(const[t,s]of n.customset.groups.entries()){const n=s;if(n.uncomputable)return;this.data.groups.push({currentIdx:Number(t)+1,type:"values",name:n.name});e.delete(t+1);for(const e of n.values){const s=e.label?e.label:this.tsInstance.category2samplecount?(a=this.tsInstance.category2samplecount.find((t=>t.key==e.key)))===null||a===void 0?void 0:a.label:e.key;this.data.values.push({key:e.key,label:s,group:t+1,samplecount:null})}}if(this.tsInstance.term.type=="geneVariant"){const e=this.tsInstance.q;const t=this.tsInstance.category2samplecount.find((t=>t.dt==e.dt));const a=t.classes.byOrigin&&e.origin?t.classes.byOrigin[e.origin]:t.classes;if(this.data.values.length!==Object.keys(a).length){for(const[e,t]of Object.entries(a)){if(!this.data.values.some((t=>t.key==e))){this.data.values.push({key:e,label:s[e].label,group:0,samplecount:t})}}}}else if(this.data.values.length!==Object.keys(t).length&&this.tsInstance.q.type!="predefined-groupset"&&this.tsInstance.q.type!="custom-groupset"){Object.entries(t).filter((e=>!this.data.values.some((t=>t.key==e[1].label)))).forEach((e=>{var t;this.data.values.push({key:e[0],label:e[1].label,group:0,samplecount:this.tsInstance.category2samplecount?(t=this.tsInstance.category2samplecount.find((t=>t.key==e[0])))===null||t===void 0?void 0:t.samplecount:"n/a"})}))}else if(this.data.values.length!==this.tsInstance.category2samplecount.length){this.tsInstance.category2samplecount.filter((e=>!this.data.values.some((t=>t.key==e.key)))).forEach((e=>{this.data.values.push({key:e.key,label:e.label,group:0,samplecount:e.samplecount})}))}}main(){return e(this,void 0,void 0,(function*(){try{const e=this.tsInstance.q.type=="custom-groupset"&&this.tsInstance.q.customset||this.tsInstance.category2samplecount||this.tsInstance.term.values;this.processInput(e);yield this.initGrpSetUI()}catch(e){if(e.stack)console.log(e.stack);else t(e)}}))}}function o(t){t.initGrpSetUI=function(){return e(this,void 0,void 0,(function*(){t.maxGrpNum=t.data.values.length>=t.defaultMaxGrpNum?t.defaultMaxGrpNum+1:t.data.values.length;t.tsInstance.dom.tip.showunder(t.tsInstance.dom.holder.node());yield t.showDraggables()}))};t.showDraggables=function(){return e(this,void 0,void 0,(function*(){t.dom.actionDiv=t.dom.menuWrapper.append("div").attr("class","sjpp-group-actions").style("padding","10px");const s=t.data.groups.filter((e=>e.name.startsWith("New Group")));let n=s.length>0?s[s.length-1].name.replace(`New Group `,""):0;t.dom.actionDiv.addGroup=t.dom.actionDiv.append("button").classed("sjpp_grpset_addGrp_btn",true).style("display","inline-block").style("text-align","center").style("cursor",t.tsInstance.q.mode=="binary"?"default":"pointer").property("disabled",t.tsInstance.q.mode=="binary"?true:t.data.groups.length>=t.maxGrpNum).text("Add Group").on("click",(()=>e(this,void 0,void 0,(function*(){n++;t.data.groups.push({currentIdx:t.data.groups.length,type:"values",name:`New Group${n!=1?` ${n}`:""}`});const e=t.data.groups[t.data.groups.length-1];yield o(e);yield t.update()}))));t.dom.actionDiv.applyBtn=t.dom.actionDiv.append("button").classed("sjpp_grpset_apply_btn",true).style("display",t.opts.hideApply?"none":"inline-block").style("text-align","center").style("float","right").style("cursor","pointer").text("Apply").on("click",(()=>{t.processDraggables();t.tsInstance.dom.tip.hide();t.tsInstance.runCallback()}));t.dom.menuWrapper.append("div").style("margin","5px 2px").style("font-size",".6em").style("color","#999").text("Drag-and-drop to assign categories to groups.");t.dom.grpsWrapper=t.dom.menuWrapper.append("div").classed("sjpp-groups-wrapper",true);t.dom.includedWrapper=t.dom.grpsWrapper.append("div").classed("sjpp-groups-include",true).classed("sjpp-group-edit-div",true).style("display","flex");t.dom.excludedWrapper=t.dom.grpsWrapper.append("div").classed("sjpp-groups-exclude",true).classed("sjpp-group-edit-div",true).classed("sjpp-drag-drop-div",true);yield o(t.data.groups.find((e=>e.currentIdx===0)));yield t.dom.includedWrapper.selectAll("div").data(t.data.groups.filter((e=>e.currentIdx!=0))).enter().append("div").classed("sjpp-drag-drop-div",true).style("border","1px solid #efefef").style("display","block").style("padding","10px").style("vertical-align","top").each((function(t){return e(this,void 0,void 0,(function*(){t.wrapper=a(this);yield o(t)}))}))}))};t.processDraggables=()=>{if(!s&&!r)return;const e={groups:[]};for(const s of t.data.groups){if(s.currentIdx===0)continue;const a=t.data.values.filter((e=>e.group==s.currentIdx)).map((e=>({key:e.key,label:e.label})));if(a.length==0)continue;e.groups.push({name:s.name,type:s.type,values:a})}t.tsInstance.q.type="custom-groupset";t.tsInstance.q.customset=e;delete t.tsInstance.q.predefined_groupset_idx};let s;let r;function o(a){return e(this,void 0,void 0,(function*(){const r=a.currentIdx===0?t.dom.excludedWrapper:t.dom.includedWrapper;a.type="values";if(!a.wrapper)a.wrapper=r.append("div").classed("sjpp-drag-drop-div",true).style("border","1px solid #efefef").style("display","block").style("padding","10px").style("vertical-align","top");a.wrapper.on("drop",(function(e){const n=s.node().__data__;if(n.group===a.currentIdx)return;a.draggables.node().appendChild(s.node());s.style("transition-property","background-color").style("transition-duration","1s").style("background-color","#fff2cc");t.data.values.find((e=>e===n)).group=a.currentIdx;e.preventDefault();e.stopPropagation()})).on("dragleave",(function(e){e.preventDefault();e.stopPropagation();a.wrapper.style("background-color","#fff")})).on("dragend",(function(e){e.preventDefault();e.stopPropagation();a.wrapper.style("background-color","#fff")})).on("dragover",(function(e){e.preventDefault();e.stopPropagation();a.wrapper.style("background-color",a.currentIdx!==s.node().__data__.group?"#cfe2f3":"#fff")})).on("dragenter",(function(e){if(s.node().__data__.group===a.currentIdx)return;e.preventDefault();e.stopPropagation();a.wrapper.style("background-color",a.currentIdx!==s.node().__data__.group?"#cfe2f3":"#fff")}));if(a.currentIdx===0){a.title=a.wrapper.append("div").style("display","inline-block").style("padding","3px 10px").style("text-align","left").style("font-size",".6em").style("text-transform","uppercase").style("color","#999").text(a.name)}else{a.dragActionDiv=a.wrapper.append("div").style("display","flex").style("align-items","center");a.input=a.dragActionDiv.append("input").attr("size",12).attr("value",a.name).style("margin","5px").style("margin-left","8px").style("display","inline-block").style("font-size",".8em").style("width","87%").on("keyup",(()=>{n.debounce(t.onKeyUp(a),1e3)}));a.inputMessage=a.dragActionDiv.append("span").style("color","red").style("font-size","0.7em").text("NOT unique").style("display","none");a.destroyBtn=a.dragActionDiv.append("button").style("display","inline-block").style("padding","0px 4px").property("disabled",t.data.groups.length<=t.minGrpNum).text("x").on("click",(()=>e(this,void 0,void 0,(function*(){if(t.data.groups.length<=t.minGrpNum)return;t.data.groups=t.data.groups.filter((e=>e.currentIdx!=a.currentIdx));yield t.removeGroup(a)}))))}a.draggables=a.wrapper.append("div").classed("sjpp-drag-list-div",true);yield t.addItems(a)}))}t.onKeyUp=function(s){return e(this,void 0,void 0,(function*(){if(s.name==s.input.node().value)return;r=true;const e=t.data.groups.filter((e=>e.name==s.input.node().value));if(e.length>0){t.dom.actionDiv.applyBtn.property("disabled",true);s.inputMessage.style("display","block")}else{t.dom.actionDiv.applyBtn.property("disabled",false);s.inputMessage.style("display","none");t.data.groups[s.currentIdx].name=s.input.node().value.trim()}}))};t.addItems=function(n){return e(this,void 0,void 0,(function*(){yield n.draggables.selectAll("div").data(t.data.values.filter((e=>e.group==n.currentIdx))).enter().append("div").attr("draggable","true").attr("class","sjpp-drag-item").style("margin","3px").style("cursor","default").style("padding","3px 10px").style("border-radius","5px").style("color",(e=>e.samplecount==0?"#777":"black")).text((e=>`${e.label}${e.samplecount!==undefined?` (n=${e.samplecount})`:""}`)).style("background-color","#eee").each((function(){const e=a(this).on("dragstart",(function(){e.style("background-color","#fff2cc");s=e})).on("mouseenter",(function(){e.style("background-color","#fff2cc")})).on("mouseleave",(function(){e.style("background-color","#eee")}))}))}))};t.removeGroup=function(s){return e(this,void 0,void 0,(function*(){const e=s.wrapper.selectAll(".sjpp-drag-item").nodes();if(e.length===0)s.wrapper.remove();else{s.input.remove();s.destroyBtn.remove();s.wrapper.remove();for(const e of t.data.values){if(e.group==s.currentIdx)e.group=0}}yield t.update()}))};t.update=function(){return e(this,void 0,void 0,(function*(){t.dom.actionDiv.addGroup.property("disabled",t.data.groups.length>=t.maxGrpNum);for(const[e,s]of t.data.groups.entries()){if(e===0)continue;if(s.currentIdx!=e){t.data.values.filter((e=>e.group==s.currentIdx)).forEach((t=>t.group=e));s.currentIdx=e}}t.dom.grpsWrapper.selectAll(".sjpp-drag-drop-div").data(t.data.groups).each((s=>e(this,void 0,void 0,(function*(){if(s.currentIdx!==0){s.input.node().value=s.name;s.destroyBtn.property("disabled",t.data.groups.length<=t.minGrpNum)}yield t.addItems(s)}))))}))}}export{r as GroupSettingMethods};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./table-29d5a973.js";import{M as t,P as s,h as a,D as l,b as i}from"./app-b369b169.js";import{controlsInit as o}from"./controls-287e6efa.js";import"./tslib.es6-c3c2d88f.js";import"./controls.btns-79b805dd.js";import"./controls.config-28d6d6a8.js";import"./termsetting-33ea66f1.js";import"path";new t;const n=[{label:"Pathway name"},{label:"enrichment score"},{label:"normalized enrichment score"},{label:"Geneset size"},{label:"pvalue"},{label:"sidak"},{label:"FDR"},{label:"Leading edge"}];class r{constructor(){this.type="gsea"}async init(e){e.plots.find((e=>e.id===this.id));const t=this.opts.holder.append("div").style("display","inline-block");const s=this.opts.holder.append("div").style("display","inline-block").style("margin-left","50px");const a=s.append("div").style("display","inline-block");const l=s.append("div").style("display","inline-block").style("vertical-align","top").style("margin-top","50px");const i=this.opts.holder.append("div").style("margin-left","50px");this.dom={holder:a,header:this.opts.header,controlsDiv:t,detailsDiv:l,tableDiv:i}}async setControls(){this.dom.controlsDiv.selectAll("*").remove();const e=[{label:"P-value filter cutoff (linear scale)",type:"number",chartType:"gsea",settingsKey:"pvalue",title:"P-value significance",min:0,max:1},{label:"P-value filter type",type:"radio",chartType:"gsea",settingsKey:"adjusted_original_pvalue",title:"Toggle between original and adjusted pvalues for volcano plot",options:[{label:"adjusted",value:"adjusted"},{label:"original",value:"original"}]}];const t={label:"Gene set group",type:"dropdown",chartType:"gsea",settingsKey:"pathway",title:"Display table showing original and adjusted pvalues corresponding to each significant pathway",boxLabel:"",options:[{label:"BP: subset of GO",value:"BP: subset of GO"},{label:"MF: subset of GO",value:"MF: subset of GO"},{label:"CC: subset of GO",value:"CC: subset of GO"},{label:"WikiPathways subset of CP",value:"WikiPathways subset of CP"},{label:"REACTOME subset of CP",value:"REACTOME subset of CP"},{label:"H: hallmark gene sets",value:"H: hallmark gene sets"}]};if(!this.settings.pathway){t.options.unshift({label:"-",value:"-"});this.settings.pathway="-"}e.push(t);this.components={controls:await o({app:this.app,id:this.id,holder:this.dom.controlsDiv,inputs:e})};this.components.controls.on("downloadClick.gsea",(()=>{downloadTable(this.table_rows,this.table_cols)}))}getState(e){const t=e.plots.find((e=>e.id===this.id));if(!t)throw`No plot with id='${this.id}' found`;return{config:t}}async main(){this.config=structuredClone(this.state.config);this.settings=this.config.settings.gsea;await this.setControls();if(this.dom.header)this.dom.header.style("opacity",.6).style("padding-left","10px").style("font-size","0.75em").text("GENE SET ENRICHMENT ANALYSIS");d(this)}}async function d(t){if(t.settings.pathway!="-"){t.dom.detailsDiv.selectAll("*").remove();t.dom.holder.selectAll("*").remove();t.dom.tableDiv.selectAll("*").remove();t.config.gsea_params.geneSetGroup=t.settings.pathway;const s=t.dom.detailsDiv.append("div").text("Loading...");let a;try{a=await h(t.config.gsea_params);s.remove();if(a.error){throw a.error}}catch(e){alert("Error: "+e);return}const i=l({holder:t.dom.detailsDiv});const[o,r]=i.addRow();r.style("text-align","center").style("font-size","0.8em").style("opacity","0.8").text("COUNT");const d=[{label:"Gene sets analyzed",values:Object.keys(a.data).length}];for(const e of d){const[t,s]=i.addRow();t.text(e.label);s.style("text-align","end").text(e.values)}t.gsea_table_rows=[];for(const e of Object.keys(a.data)){const s=a.data[e];if(t.settings.adjusted_original_pvalue=="adjusted"&&t.settings.pvalue>=s.fdr){let a;if(s.es){a=s.es.toPrecision(4)}else{a=s.es}let l;if(s.nes){l=s.nes.toPrecision(4)}else{l=s.nes}let i;if(s.pval){i=s.pval.toPrecision(4)}else{i=s.pval}let o;if(s.sidak){o=s.sidak.toPrecision(4)}else{o=s.sidak}let n;if(s.fdr){n=s.fdr.toPrecision(4)}else{n=s.fdr}t.gsea_table_rows.push([{value:e},{value:a},{value:l},{value:s.geneset_size},{value:i},{value:o},{value:n},{value:s.leading_edge}])}else if(t.settings.adjusted_original_pvalue=="original"&&t.settings.pvalue>=s.pval){let a;if(s.pval){a=s.pval.toPrecision(4)}else{a=s.pval}let l;if(s.sidak){l=s.sidak.toPrecision(4)}else{l=s.sidak}let i;if(s.fdr){i=s.fdr.toPrecision(4)}else{i=s.fdr}t.gsea_table_rows.push([{value:e},{value:s.es.toPrecision(4)},{value:s.nes.toPrecision(4)},{value:s.geneset_size},{value:a},{value:l},{value:i},{value:s.leading_edge}])}}t.dom.tableDiv.selectAll("*").remove();const c=t.dom.tableDiv.append("div");e({columns:n,rows:t.gsea_table_rows,div:c,showLines:true,maxHeight:"30vh",singleMode:true,resize:true,noButtonCallback:async e=>{const s={genome:t.config.gsea_params.genome,geneset_name:t.gsea_table_rows[e][0].value,genes:t.config.gsea_params.genes,fold_change:t.config.gsea_params.fold_change,geneSetGroup:t.config.gsea_params.geneSetGroup,pickle_file:a.pickle_file};const l=t.dom.holder;l.selectAll("*").remove();const i=l.append("div").text("Loading...");const o=await h(s);i.remove();if(o.error)throw o.error;const n=URL.createObjectURL(o);const r=600;const d=400;l.append("img").attr("width",r).attr("height",d).attr("src",n)}})}}async function c(e,t){try{const t={settings:{gsea:{pvalue:1,adjusted_original_pvalue:"adjusted",pathway:undefined},controls:{isOpen:true}}};return s(t,e)}catch(e){throw`${e} [gsea getPlotConfig()]`}}const p=a(r);const g=p;function u(e,t){t.prepPlot({config:{chartType:"gsea"}})}async function h(e){return await i("genesetEnrichment",{body:e})}export{g as componentInit,c as getPlotConfig,p as gseaInit,u as makeChartBtnMenu};
|