@sjcrh/proteinpaint-client 2.76.2 → 2.77.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-f240211f.js → 2dmaf-acb8cfdd.js} +1 -1
- package/dist/{AppHeader-c9432a24.js → AppHeader-315dbd3a.js} +1 -1
- package/dist/{ColorScale-b991fc9e.js → ColorScale-4b4ea8a2.js} +1 -1
- package/dist/{DEanalysis-bbfad00d.js → DEanalysis-28ddd620.js} +1 -1
- package/dist/{Disco-b7c9bf72.js → Disco-3c427131.js} +1 -1
- package/dist/{Disco.UI-a5296c36.js → Disco.UI-b071cf7a.js} +1 -1
- package/dist/{DragControls-ca3fa0cf.js → DragControls-7961799c.js} +1 -1
- package/dist/{DziViewer-28915c11.js → DziViewer-aa5b5706.js} +1 -1
- package/dist/{FilterRxComp-02e68f1b.js → FilterRxComp-e8de560c.js} +1 -1
- package/dist/FilterStateless-75514d37.js +1 -0
- package/dist/{HicApp-e713aa40.js → HicApp-674a148d.js} +1 -1
- package/dist/{OrbitControls-2466d420.js → OrbitControls-58ca2292.js} +1 -1
- package/dist/{WSIViewer-957695a8.js → WSIViewer-afe97e2e.js} +1 -1
- package/dist/{adSandbox-27d93bc0.js → adSandbox-791d704e.js} +1 -1
- package/dist/{app-6fb77603.js → app-3d14cbe4.js} +1 -1
- package/dist/app-8b5b982a.js +1 -0
- package/dist/{app-d215327f.js → app-bd9f016b.js} +1 -1
- package/dist/app.js +1 -1
- package/dist/{bam-d67e5315.js → bam-fa90bae8.js} +1 -1
- package/dist/{barchart-2898d229.js → barchart-e3dcfc5f.js} +1 -1
- package/dist/{barchart.events-426d737a.js → barchart.events-cecb7bf5.js} +1 -1
- package/dist/{bars.renderer-71935d34.js → bars.renderer-58e38632.js} +1 -1
- package/dist/{block-75d4ff92.js → block-944afb9f.js} +1 -1
- package/dist/block.lazyload-4c4e81ff.js +1 -0
- package/dist/{block.legend-93d85a6e.js → block.legend-3dbc41a8.js} +1 -1
- package/dist/{block.mds-84b9d1c1.js → block.mds-b3967ce5.js} +1 -1
- package/dist/{block.mds.cnv-a991ed79.js → block.mds.cnv-6de3115e.js} +1 -1
- package/dist/{block.mds.expressionrank-33b858de.js → block.mds.expressionrank-553613e8.js} +1 -1
- package/dist/{block.mds.expressionstat-3093599f.js → block.mds.expressionstat-2c396bb9.js} +1 -1
- package/dist/{block.mds.geneboxplot-b8391d18.js → block.mds.geneboxplot-552fe571.js} +1 -1
- package/dist/{block.mds.junction-69708c7f.js → block.mds.junction-1e25c13d.js} +1 -1
- package/dist/{block.mds.svcnv-322baea6.js → block.mds.svcnv-462d762d.js} +1 -1
- package/dist/{block.mds.svcnv.share-c5c38237.js → block.mds.svcnv.share-766e4b22.js} +1 -1
- package/dist/{block.mds2-de4811dd.js → block.mds2-6e04432d.js} +1 -1
- package/dist/{block.svg-ac9fec2d.js → block.svg-40b47da8.js} +1 -1
- package/dist/{block.tk.aicheck-ac4b8d4d.js → block.tk.aicheck-cc42cbaf.js} +1 -1
- package/dist/{block.tk.ase-6dc0f9f1.js → block.tk.ase-da848c5f.js} +1 -1
- package/dist/{block.tk.bam-8f68b41d.js → block.tk.bam-8053c97e.js} +1 -1
- package/dist/{block.tk.bedgraphdot-d8878860.js → block.tk.bedgraphdot-79cb0faf.js} +1 -1
- package/dist/{block.tk.bigwig.ui-f6ed051c.js → block.tk.bigwig.ui-a8decec7.js} +1 -1
- package/dist/{block.tk.hicstraw-725bdc8a.js → block.tk.hicstraw-3d1e9d41.js} +1 -1
- package/dist/{block.tk.junction-f8b0b51d.js → block.tk.junction-81eae755.js} +1 -1
- package/dist/{block.tk.junction.textmatrixui-252e7d7e.js → block.tk.junction.textmatrixui-4c45b69a.js} +1 -1
- package/dist/{block.tk.ld-11acf730.js → block.tk.ld-997fca31.js} +1 -1
- package/dist/{block.tk.menu-5e04436d.js → block.tk.menu-d3e7ccbb.js} +1 -1
- package/dist/{block.tk.pgv-fef17dc4.js → block.tk.pgv-ae1d1f59.js} +1 -1
- package/dist/{boxplot-4c9a5479.js → boxplot-fed0a86b.js} +1 -1
- package/dist/{brainImaging-7716bc66.js → brainImaging-b455fd0c.js} +1 -1
- package/dist/{brush-9faa7ae7.js → brush-06989a5e.js} +1 -1
- package/dist/{categorical-1dea48ba.js → categorical-82722704.js} +1 -1
- package/dist/{condition-ebac4f75.js → condition-f68cc8d1.js} +1 -1
- package/dist/{controls-268e40e6.js → controls-1d99916a.js} +1 -1
- package/dist/{controls.btns-5bf9e7d7.js → controls.btns-237b3154.js} +1 -1
- package/dist/{controls.config-2f0fa061.js → controls.config-00ce9f0b.js} +1 -1
- package/dist/{cuminc-8dffb765.js → cuminc-879690b0.js} +1 -1
- package/dist/{customdata.inputui-b229d3a0.js → customdata.inputui-c563c695.js} +1 -1
- package/dist/{dataDownload-452ae3cd.js → dataDownload-087ac205.js} +1 -1
- package/dist/databrowser.ui-9f98f6b3.js +1 -0
- package/dist/{density-09feb0c9.js → density-e0aff1d0.js} +1 -1
- package/dist/{dictionary-a132a3cc.js → dictionary-fe0ea1d6.js} +1 -1
- package/dist/{drag-2e9c80bb.js → drag-e11d6644.js} +1 -1
- package/dist/{e2pca-4f1648e3.js → e2pca-b3250d5c.js} +1 -1
- package/dist/{ep-1d4c58b4.js → ep-9ca01df0.js} +1 -1
- package/dist/{facet-fa4fe49c.js → facet-397afad5.js} +1 -1
- package/dist/{fusion.parse-7dfd6988.js → fusion.parse-e5312047.js} +1 -1
- package/dist/{geneExpClustering-ed9121b8.js → geneExpClustering-4383ff2c.js} +1 -1
- package/dist/{geneExpression-394672ff.js → geneExpression-2422f66b.js} +1 -1
- package/dist/{geneExpression-66208299.js → geneExpression-52678025.js} +1 -1
- package/dist/{geneExpression-c61e8f1c.js → geneExpression-cfb86b5d.js} +1 -1
- package/dist/{geneORA-9456872c.js → geneORA-81220ec0.js} +1 -1
- package/dist/{geneVariant-beaf9adb.js → geneVariant-18f9591a.js} +1 -1
- package/dist/{geneVariant-f17cda85.js → geneVariant-4d22b146.js} +1 -1
- package/dist/{genefusion.ui-9238ec7f.js → genefusion.ui-e38778dd.js} +1 -1
- package/dist/{genesearch-ffd88bf2.js → genesearch-0587c713.js} +1 -1
- package/dist/{geneset-0315daf8.js → geneset-604d0529.js} +1 -1
- package/dist/{genomeBrowser-608b924e.js → genomeBrowser-9f0e8a60.js} +1 -1
- package/dist/{genomeBrowser.controls-2601cab5.js → genomeBrowser.controls-204f007e.js} +1 -1
- package/dist/{groupsetting-e3a4ecd5.js → groupsetting-53dfd5e5.js} +1 -1
- package/dist/{gsea-0c0cf8de.js → gsea-a1b04406.js} +1 -1
- package/dist/{hierCluster-7ab62ca5.js → hierCluster-edaaacc5.js} +1 -1
- package/dist/{hierCluster.config-f4daaf92.js → hierCluster.config-a84f69a3.js} +1 -1
- package/dist/{hierCluster.interactivity-7f475259.js → hierCluster.interactivity-dd917fd3.js} +1 -1
- package/dist/{hierCluster.renderers-19b79639.js → hierCluster.renderers-4d33e96a.js} +1 -1
- package/dist/{html.legend-80b2b3ec.js → html.legend-6807e9ad.js} +1 -1
- package/dist/{imagePlot-1ef24562.js → imagePlot-f96cdc61.js} +1 -1
- package/dist/{lasso-1a02a545.js → lasso-845446b8.js} +1 -1
- package/dist/launch.adhoc-cb00917b.js +1 -0
- package/dist/leftlabel.sample-3a6037c2.js +1 -0
- package/dist/legacyDataset-c9bab1e6.js +1 -0
- package/dist/{log-c26b6cfd.js → log-0ea548ec.js} +1 -1
- package/dist/{lollipop-3aebe5d3.js → lollipop-75e11e9a.js} +1 -1
- package/dist/{maf-c439c851.js → maf-e4af10d7.js} +1 -1
- package/dist/{maftimeline-0da64e54.js → maftimeline-cc2e866c.js} +1 -1
- package/dist/{matrix-38cd47c3.js → matrix-8b3341c4.js} +1 -1
- package/dist/{matrix.cells-a018d731.js → matrix.cells-4dd055e7.js} +1 -1
- package/dist/{matrix.cluster-a6e713e8.js → matrix.cluster-7ab94fb5.js} +1 -1
- package/dist/{matrix.config-2c550b5d.js → matrix.config-b3b56456.js} +1 -1
- package/dist/{matrix.controls-42ad4912.js → matrix.controls-6e0e9692.js} +1 -1
- package/dist/{matrix.data-2b814c9f.js → matrix.data-baabaf57.js} +1 -1
- package/dist/{matrix.dom-1e0da5b3.js → matrix.dom-cb1f4872.js} +1 -1
- package/dist/{matrix.groups-824a7244.js → matrix.groups-9990aade.js} +1 -1
- package/dist/{matrix.interactivity-1cb56534.js → matrix.interactivity-3f3cf44d.js} +1 -1
- package/dist/{matrix.layout-47e44357.js → matrix.layout-50bc2ea5.js} +1 -1
- package/dist/{matrix.legend-9af0c757.js → matrix.legend-024e2d50.js} +1 -1
- package/dist/{matrix.renderers-337ce240.js → matrix.renderers-1aed44e5.js} +1 -1
- package/dist/{matrix.serieses-7b7184c9.js → matrix.serieses-dc18fcc2.js} +1 -1
- package/dist/{matrix.sort-1ac05842.js → matrix.sort-89b98e83.js} +1 -1
- package/dist/{matrix.sorterUi-1c60c145.js → matrix.sorterUi-0ad98ef0.js} +1 -1
- package/dist/{mavb-da8d1a0a.js → mavb-b2dd74f6.js} +1 -1
- package/dist/{mds.fimo-8604c3f8.js → mds.fimo-f19840cd.js} +1 -1
- package/dist/{mds.samplescatterplot-3f09ae0e.js → mds.samplescatterplot-254f1de6.js} +1 -1
- package/dist/{mds.survivalplot-1d8f2b7e.js → mds.survivalplot-f440db10.js} +1 -1
- package/dist/{metaboliteIntensity-bbb23c76.js → metaboliteIntensity-4d905d93.js} +1 -1
- package/dist/niceNumLabels-ef07b7ad.js +1 -0
- package/dist/{nodrag-b2737073.js → nodrag-f6c0801c.js} +1 -1
- package/dist/{notify-0cb8904f.js → notify-da3afe99.js} +1 -1
- package/dist/{numeric-24dacbee.js → numeric-1d0318e8.js} +1 -1
- package/dist/{numeric.binary-f382cc98.js → numeric.binary-88bf9e0d.js} +1 -1
- package/dist/numeric.continuous-d27197cf.js +1 -0
- package/dist/{numeric.discrete-ed10bbc1.js → numeric.discrete-b826f33b.js} +1 -1
- package/dist/{numeric.spline-a35cfbf0.js → numeric.spline-b3968b77.js} +1 -1
- package/dist/{numeric.toggle-2f98d6e5.js → numeric.toggle-ab8b79be.js} +1 -1
- package/dist/{oncomatrix-c0b2d635.js → oncomatrix-5f4326a8.js} +1 -1
- package/dist/{parseData-292648dd.js → parseData-62083461.js} +1 -1
- package/dist/{plot.2dvaf-6ae22dc1.js → plot.2dvaf-eccd8ef3.js} +1 -1
- package/dist/plot.app-4dc30ebc.js +1 -0
- package/dist/plot.barplot-331715f6.js +1 -0
- package/dist/{plot.boxplot-87ac2ce9.js → plot.boxplot-0c538ebe.js} +1 -1
- package/dist/{plot.brainImaging-32a484b6.js → plot.brainImaging-ee3a0272.js} +1 -1
- package/dist/{plot.disco-1fdfee3c.js → plot.disco-c9249cbd.js} +1 -1
- package/dist/{plot.dzi-e3d0f610.js → plot.dzi-dfd72ddf.js} +1 -1
- package/dist/{plot.ssgq-d33113d5.js → plot.ssgq-b5f68395.js} +1 -1
- package/dist/{plot.vaf2cov-9f4f1776.js → plot.vaf2cov-4081decd.js} +1 -1
- package/dist/{plot.wsi-dea124a7.js → plot.wsi-f6325d95.js} +1 -1
- package/dist/{profileBarchart-58f0a8c0.js → profileBarchart-f4da0483.js} +1 -1
- package/dist/{profileHome-7f404152.js → profileHome-11b7d146.js} +1 -1
- package/dist/{profilePlot-4db8ca78.js → profilePlot-5dd1fe71.js} +1 -1
- package/dist/{profilePolar-50b8e40e.js → profilePolar-996784ad.js} +1 -1
- package/dist/{profileRadar-fff0b004.js → profileRadar-79299186.js} +1 -1
- package/dist/{profileRadarFacility-d6d34c15.js → profileRadarFacility-00e31213.js} +1 -1
- package/dist/{profileSummary-04b8b15b.js → profileSummary-df75e6ff.js} +1 -1
- package/dist/{recover-299ffdb3.js → recover-4888c2a9.js} +1 -1
- package/dist/{regression.inputs-14df7c31.js → regression.inputs-e647b716.js} +1 -1
- package/dist/{regression.inputs.values.table-d79efa9e.js → regression.inputs.values.table-b283619d.js} +1 -1
- package/dist/{regression.results-4767144e.js → regression.results-f61b4a25.js} +1 -1
- package/dist/{renderPvalueTable-002cc8ff.js → renderPvalueTable-0ed37e90.js} +1 -1
- package/dist/sampleScatter-b96546e9.js +1 -0
- package/dist/{sampleScatter.rendererThree-ef289434.js → sampleScatter.rendererThree-aa51e3c8.js} +2 -2
- package/dist/{sampleView-1dff3fca.js → sampleView-e4819da2.js} +1 -1
- package/dist/{samplelst-d2db0f24.js → samplelst-9d9ff205.js} +1 -1
- package/dist/{samplematrix-0841387f.js → samplematrix-3556e5c0.js} +1 -1
- package/dist/{scatter-f8285107.js → scatter-ff17f653.js} +1 -1
- package/dist/select2Terms-eb437c2a.js +1 -0
- package/dist/{selectGenomeWithTklst-9af86d31.js → selectGenomeWithTklst-84f4ff79.js} +1 -1
- package/dist/shapes-21ebfec4.js +1 -0
- package/dist/{singleCellCellType-fd1606b8.js → singleCellCellType-a2ce9bfa.js} +1 -1
- package/dist/{singleCellGeneExpression-537f1157.js → singleCellGeneExpression-a2b45c7a.js} +1 -1
- package/dist/{singleCellPlot-eff5760b.js → singleCellPlot-e7e57b0f.js} +1 -1
- package/dist/{singlecell-38336cbc.js → singlecell-63cb06d8.js} +1 -1
- package/dist/{singlecell-87b4b9a9.js → singlecell-a5b8a39b.js} +1 -1
- package/dist/snp-41aa88d1.js +1 -0
- package/dist/{snp-b81ef740.js → snp-6e312b4c.js} +1 -1
- package/dist/snplocus-0653ba82.js +1 -0
- package/dist/{spliceevent.a53ss.diagram-5f8352eb.js → spliceevent.a53ss.diagram-aa2df5d7.js} +1 -1
- package/dist/{spliceevent.exonskip.diagram-0d30a735.js → spliceevent.exonskip.diagram-0b792984.js} +1 -1
- package/dist/spliceevent.exonskip.getdefault-af1943e3.js +1 -0
- package/dist/{spliceevent.noeventdiagram-df9ce4bc.js → spliceevent.noeventdiagram-e6e29a6e.js} +1 -1
- package/dist/{spliceevent.phrase-a8401d53.js → spliceevent.phrase-5f65a5f4.js} +1 -1
- package/dist/{stattable-46cde32c.js → stattable-775a5af5.js} +1 -1
- package/dist/{style.gdc-72d730f2.js → style.gdc-519a42d8.js} +1 -1
- package/dist/summary-5866c75f.js +1 -0
- package/dist/{sunburst-fe95832e.js → sunburst-f928bfd2.js} +1 -1
- package/dist/survival-10dd3d28.js +1 -0
- package/dist/{survival-52714cd3.js → survival-405514f6.js} +1 -1
- package/dist/{svg.download-f4aa48e4.js → svg.download-cd895635.js} +1 -1
- package/dist/{svg.legend-749348e0.js → svg.legend-812ea603.js} +1 -1
- package/dist/{svgraph-b46f1f92.js → svgraph-037fd7b6.js} +1 -1
- package/dist/{svmr-9a76c6d4.js → svmr-3bd143c3.js} +1 -1
- package/dist/{table-0daf2b89.js → table-be2a9975.js} +1 -1
- package/dist/{table-bf40249b.js → table-e013d8fc.js} +1 -1
- package/dist/{termInfo-491b10af.js → termInfo-e16f90f2.js} +1 -1
- package/dist/termdb.bins-a60aaa77.js +1 -0
- package/dist/{termsetting-492eefa7.js → termsetting-7467350f.js} +1 -1
- package/dist/tk-25ae65c4.js +1 -0
- package/dist/{toggleButtons-c4d6f260.js → toggleButtons-2144daab.js} +1 -1
- package/dist/{tp.ui-0a476325.js → tp.ui-38bc5890.js} +1 -1
- package/dist/{tvs.density-034b506d.js → tvs.density-060d3006.js} +1 -1
- package/dist/{tvs.geneVariant-c59c8b54.js → tvs.geneVariant-f99fe353.js} +1 -1
- package/dist/{tvs.numeric-aa1f892f.js → tvs.numeric-d9108473.js} +1 -1
- package/dist/{tvs.samplelst-515f27b9.js → tvs.samplelst-3b8ee998.js} +1 -1
- package/dist/{uiUtils-ea7dfea2.js → uiUtils-57f4b1ba.js} +1 -1
- package/dist/{variantBrowser-14d5c3f6.js → variantBrowser-56ebc7e1.js} +1 -1
- package/dist/{vcf-d357ce08.js → vcf-e43b533a.js} +1 -1
- package/dist/{violin-74d26b75.js → violin-1352dab2.js} +1 -1
- package/dist/{violin.interactivity-bf40ddde.js → violin.interactivity-2502dcd8.js} +1 -1
- package/dist/{violin.renderer-469fa0ff.js → violin.renderer-4273257d.js} +1 -1
- package/dist/{violinRenderer-14fa200d.js → violinRenderer-7f46e468.js} +1 -1
- package/dist/{viridis-cc59f478.js → viridis-87a8b605.js} +1 -1
- package/dist/{y-59cbff5e.js → y-cac91178.js} +1 -1
- package/dist/{zoom-f445cfef.js → zoom-001c2f01.js} +1 -1
- package/package.json +1 -1
- package/dist/FilterStateless-16a33070.js +0 -1
- package/dist/app-42f69951.js +0 -1
- package/dist/block.lazyload-d2951c91.js +0 -1
- package/dist/databrowser.ui-2197fc73.js +0 -1
- package/dist/downloadTextfile-5723af95.js +0 -1
- package/dist/launch.adhoc-e124c993.js +0 -1
- package/dist/leftlabel.sample-59f99ef5.js +0 -1
- package/dist/legacyDataset-fbaa5ebb.js +0 -1
- package/dist/niceNumLabels-29a7c6ca.js +0 -1
- package/dist/numeric.continuous-6feb34a7.js +0 -1
- package/dist/plot.app-2a805759.js +0 -1
- package/dist/plot.barplot-34841e70.js +0 -1
- package/dist/sampleScatter-55d9eb74.js +0 -1
- package/dist/select2Terms-d48d037e.js +0 -1
- package/dist/snp-f6123244.js +0 -1
- package/dist/snplocus-acafb1ba.js +0 -1
- package/dist/spliceevent.exonskip.getdefault-237c481c.js +0 -1
- package/dist/summary-a6c15c9e.js +0 -1
- package/dist/survival-57ff3c03.js +0 -1
- package/dist/termdb.bins-39d11f24.js +0 -1
- package/dist/tk-ac524564.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as t,h as e,f as s}from"./termsetting-492eefa7.js";import{d as r}from"./app-6fb77603.js";import"./tslib.es6-c3c2d88f.js";import"path";function a(a){a.render=function(){const t=a.settings.matrix;const e=a.layout;const s=a.dimensions;const r=a.dom.svg.attr("width")?t.duration:0;a.dom.clipRect.attr("x",s.xOffset-1).attr("y",0).attr("width",s.mainw+3).attr("height",s.mainh+500);a.renderSerieses(t,e,s,r);a.renderLabels(t,e,s,r);a.renderDivideByLabel(t,e,s,r);a.dom.colBeam.attr("width",s.dx).attr("height",s.mainh).style("stroke",t.beamStroke);a.dom.rowBeam.attr("width",s.zoomedMainW).attr("height",t.rowh).style("stroke",t.beamStroke)};a.renderSerieses=function(t,e,s,r){if(a.prevUseCanvas!=t.useCanvas){a.dom.seriesesG.selectAll("g").remove()}if(t.useCanvas){const e=a.dom.seriesesG.selectAll("g");const n=a.dom.seriesesG.append("g").datum(this.serieses);a.renderCanvas(this.serieses,n,s,t,e,r)}else{a.dom.seriesesG.attr("transform",`translate(${s.xOffset+s.seriesXoffset},${s.yOffset})`);const t=a.dom.seriesesG.selectAll(".sjpp-mass-series-g").data(this.serieses,(t=>t.tw.$id));t.exit().remove();t.each(a.renderSeries);t.enter().append("g").attr("class","sjpp-mass-series-g").style("opacity",.001).each(a.renderSeries);a.mouseout()}a.prevUseCanvas=t.useCanvas};a.renderSeries=async function(t){const e=a.settings.matrix;a.dimensions;const s=r(this);s.attr("transform")?e.duration:0;s.attr("transform",`translate(${t.x},${t.y})`).style("opacity",1);const n=t.cells[t.cells.length-1];t.y+n?.y+e.rowh;const o=s.selectAll("rect").data(t.cells,(t=>t.sample+";;"+t.tw.$id+";;"+t.valueIndex));o.exit().remove();o.each(a.renderCell);o.enter().append("rect").each(a.renderCell)};a.renderCanvas=async function(t,e,s,r,n,o){const i=window.devicePixelRatio<=1?1:window.devicePixelRatio;e.selectAll("*").remove();const l=s.imgW;const c=a.dimensions.mainh;const d=window.OffscreenCanvas?new OffscreenCanvas(l*i,c*i):a.dom.holder.append("canvas").attr("width",i*l).attr("height",i*c).style("opacity",0).node();const m=d.getContext("2d");m.imageSmoothingEnabled=false;m.imageSmoothingQuality="high";m.scale(i,i);for(const e of t){for(const t of e.cells){a.renderCellWithCanvas(m,t,e,r,s,e.y)}}if(window.OffscreenCanvas){const t=new FileReader;t.addEventListener("load",(()=>{n?.remove();a.dom.seriesesG.attr("transform",`translate(${s.xOffset+s.seriesXoffset},${s.yOffset})`);e.selectAll("image").remove();e.append("image").attr("xlink:href",t.result).attr("x",s.xMin).attr("width",l).attr("height",c)}),false);const r=await d.convertToBlob({quality:1});t.readAsDataURL(r)}else{n?.remove();a.dom.seriesesG.attr("transform",`translate(${s.xOffset+s.seriesXoffset},${s.yOffset})`);const t=d.toDataURL();e.append("image").attr("width",l).attr("height",c).attr("xlink:href",t);if(!window.OffscreenCanvas)d.remove()}a.mouseout()};a.renderCellWithCanvas=function(t,e,s,r,o,i){if(!e.fill)e.fill=e.$id in a.colorScaleByTermId?a.colorScaleByTermId[e.$id](e.key):n(e);const l=e.x?e.x-o.xMin:0;const c=i?i+e.y:e.y||0;const d=r.useMinPixelWidth?Math.max(e.width||o.colw,o.pxw):e.width||o.colw;const m="height"in e?e.height:r.rowh;t.fillStyle=e.fill;t.fillRect(l,c,d,m)};a.renderCell=function(t){if(!t.fill)t.fill=t.$id in a.colorScaleByTermId?a.colorScaleByTermId[t.$id](t.key):n(t);const e=a.settings.matrix;r(this).attr("x",t.x||0).attr("y",t.y||0).attr("width",t.width||a.dimensions.colw).attr("height","height"in t?Math.max(0,t.height):e.rowh).attr("shape-rendering","crispEdges").attr("stroke-width",0).attr("fill",t.fill)};a.renderLabels=function(t,e,s,n){for(const o of["top","btm","left","right"]){const i=e[o];i.box.style("display",i.display||"").attr("transform",i.attr.boxTransform);const l=i.box.selectAll(".sjpp-matrix-label").data(i.data,i.key);l.exit().remove();l.each(c);l.enter().append("g").attr("class","sjpp-matrix-label").each(c);function c(e){const s=r(this);s.attr("transform",i.attr.labelGTransform);if(!s.select(":scope>text").size())s.append("text");const n=!i.isGroup&&e.grp?.type!=="hierCluster"&&e.tw?.q?.mode=="continuous";const o=i.label(e);const l=s.select(":scope>text").attr("fill","#000");l.attr("display",e.grp?.type==="hierCluster"&&t.clusterRowh<6?"none":i.attr.fontSize<6||o==="configure"?"none":"").attr("font-size",e.grp?.type==="hierCluster"?t.clusterRowh:i.attr.fontSize).attr("text-anchor",i.attr.labelAnchor).attr("transform",i.attr.labelTransform).attr("cursor","pointer").attr(i.attr.textpos.coord,i.attr.textpos.factor*(n?30:0));if(!Array.isArray(o)){l.text(o);l.attr("y",e.grp?.type!=="hierCluster"&&e.tw?.q?.mode=="continuous"?10:e.grp?.type==="hierCluster"?.3*t.clusterRowh:0)}else{l.text("");const t=l.selectAll("tspan").data(o);t.enter().append("tspan").attr("class",d).attr("dx",m).attr("font-size",p).text(f)}l.on("mouseover",o==="configure"?()=>l.attr("opacity",.5):null).on("mouseout",o==="configure"?()=>l.attr("opacity",0):null);const c=s.select(".sjpp-matrix-cell-axis").size()&&true;if(n&&o){if(!c){s.append("g").attr("class","sjpp-matrix-cell-axis").attr("shape-rendering","crispEdges")}const r=s.select(".sjpp-matrix-cell-axis");r.selectAll("*").remove();[e.counts.maxval,e.counts.minval];if(t.transpose);a.dimensions;const n=!t.transpose?0:e.tw.settings.gap-1-e.labelOffset;const o=!t.transpose?e.tw.settings.gap-1-e.labelOffset:0;r.attr("shape-rendering","crispEdges").attr("transform",`translate(${n},${o})`).call(i.attr.axisFxn(e.scales.full.domain(e.scales.tickValues)).tickValues(e.scales.tickValues))}else if(c){s.select(".sjpp-matrix-cell-axis").remove()}}function d(t){return t.cls}function m(t){return t.dx}function p(t){return t.fontSize||i.attr.fontSize}function f(t){return t.text}}};a.colLabelGTransform=(t,e)=>{const s=a.settings.matrix;const r=a.dimensions;t.labelOffset=.8*r.colw;const n=t.grpIndex*s.colgspace+t.totalIndex*r.dx+t.labelOffset+t.totalHtAdjustments;const o=0;return`translate(${n+r.seriesXoffset},${o})`};a.colGrpLabelGTransform=(t,e)=>{const s=a.settings.matrix;const r=a.dimensions;const n=(t.processedLst||t.grp.lst).length;const o=t.grpIndex*s.colgspace+t.prevGrpTotalIndex*r.dx+n*r.dx/2+s.grpLabelFontSize/2+t.totalHtAdjustments;return`translate(${o+r.seriesXoffset},0)`};a.rowLabelGTransform=(t,e)=>{const s=a.settings.matrix;const r=a.dimensions;const n=0;t.labelOffset=.7*(t.grp.type=="hierCluster"?s.clusterRowh:s.rowh);const o=t.grpIndex*s.rowgspace+t.totalIndex*r.dy+t.labelOffset+t.totalHtAdjustments;return`translate(${n},${o})`};a.rowGrpLabelGTransform=(t,e)=>{const s=a.settings.matrix;const r=a.dimensions;const n=(t.processedLst||t.grp.lst).length;const o=t.grpIndex*s.rowgspace+t.prevGrpTotalIndex*r.dy+n*r.dy/2+s.grpLabelFontSize/2+t.totalHtAdjustments;return`translate(0,${o})`};a.rowAxisGTransform=(t,e)=>{const s=a.settings.matrix;const r=a.dimensions;const n=0;const o=t.grpIndex*s.rowgspace+t.totalIndex*r.dy+.7*s.rowh+t.totalHtAdjustments;return`translate(${n},${o})`};a.renderDivideByLabel=async(r,n,o)=>{a.dom.mainG.selectAll(".sjpp-matrix-divide-by-label").remove();if(!a.config.divideBy)return;const i=a.config.divideBy?.term.name||"";const l=i.length<=r.rowlabelmaxchars?i:i.slice(0,r.rowlabelmaxchars)+"…";const c=!r.transpose?[n.left,n.right]:[n.top,n.bottom];const d=c.find((t=>!t.isGroup))?.box;const m=(r.collabelpos=="top"?o.mainh+r.collabelmaxchars:-r.collabelmaxchars)+8;const p=r.rowlabelpos=="left"?"end":"start";const f=r.controlLabels;const g=d.append("g").attr("class","sjpp-matrix-divide-by-label").attr("transform",`translate(0, ${m})`);g.append("text").attr("text-anchor",p).attr("font-style","italic").attr("y",-20).text(`${f.Samples} grouped by`);const h=d.datum({tw:a.config.divideBy}).append("g").attr("class","sjpp-matrix-divide-by-label").attr("transform",`translate(0, ${m})`);const x=h.append("text").attr("text-anchor",p).attr("font-weight",600).text(l).on("click",((t,e)=>{w.showMenu(t,x.node())}));h.append("title").text(`${f.Samples} are grouped by this gene or variable. Click to edit.`);const u=[];const y=t(a.config.divideBy.term)?"ranges":"values";if(a.config.legendValueFilter.lst?.find((t=>t.legendGrpName==a.config.divideBy.term.id||t.legendGrpName==a.config.divideBy.term.name))?.tvs[y]?.length){u.push({label:`Show filtered ${f.samples}`,callback:a.showDeletedSampleGroups})}const w=await e({menuOptions:"{edit,replace,remove}",customMenuOptions:u,vocabApi:a.app.vocabApi,vocab:a.state.vocab,holder:h,debug:a.opts.debug,usecase:{target:"matrix"},getBodyParams:()=>{const t=a.termOrder.filter((t=>t.tw.term.type==="geneVariant")).map((t=>t.tw.term.chr?`${t.tw.term.chr}:${t.tw.term.start}-${t.tw.term.stop}`:t.tw.term.gene||t.tw.term.name));return{currentGeneNames:t}},callback:async e=>{if(a.dom.loadingDiv&&a.dom.svg){a.dom.loadingDiv.selectAll("*").remove();a.dom.loadingDiv.html("").style("display","").style("position","relative").style("left","45%");a.dom.loadingDiv.html("Processing data ...");a.dom.svg.style("opacity",.1).style("pointer-events","none")}if(e&&!e.q)throw"data.q{} missing from pill callback";if(e?.term&&t(e.term)){e.q={...e.q,mode:"discrete"}}if(e)await s(e,a.app.vocabApi);await w.main(e?e:{term:null,q:null});d.datum({tw:e});a.app.dispatch({type:"plot_edit",id:a.id,config:{divideBy:e,legendValueFilter:a.mayRemoveTvsEntry(a.config.divideBy)}})}});const v={term:a.config.divideBy.term,q:a.config.divideBy.q};if(a.config.divideBy.$id)v.$id=a.config.divideBy.$id;w.main(v)};a.adjustSvgDimensions=async function(t){const e=a.settings.matrix;const s=a.settings.hierCluster||{};const r=s.yDendrogramHeight||0;const n=s.xDendrogramHeight||0;const i=a.dimensions;const l=a.dom.svg.attr("width")?e.duration:0;await o(t==e.transpose?l:e.duration);const c=a.layout;const d=c.top.box.node().getBBox();const m=c.btm.box.node().getBBox();const p=c.left.box.node().getBBox();const f=c.right.box.node().getBBox();const g=a.dom.legendG.node().getBBox();a.dom.seriesesG.node().getBBox();i.extraWidth=p.width+f.width+e.margin.left+e.margin.right+e.rowlabelgap*2;i.extraHeight=d.height+m.height+e.margin.top+e.margin.bottom+e.collabelgap*2;i.svgw=i.mainw+i.extraWidth+n;i.svgh=i.mainh+i.extraHeight+g.height+20+e.scrollHeight+r;a.dom.svg.attr("width",i.svgw).attr("height",i.svgh);let h=a.type=="hierCluster"?0:p.width;if(s.xDendrogramHeight){a.dom.termLabelG.selectAll(".sjpp-matrix-label").each((function(t){if(t.grp.type!=="hierCluster")return;const e=this.getBBox();if(e.width>h){h=e.width;t.label.length}}))}const x=-c.left.offset+n+h;const u=!s.xDendrogramHeight?0:Math.max(p.width-(s.xDendrogramHeight+h),0);const y=(c.top.display=="none"?0:d.height)-c.top.offset+r;a.dom.mainG.attr("transform",`translate(${x+u},${y})`);a.dom.clipRect.attr("y",-y).attr("height",i.mainh+500+y);const w=i.xOffset+(e.transpose?20:0);const v=i.yOffset+i.mainh+e.collabelgap+(c.btm.display=="none"?0:m.height)+20;a.dom.legendG.attr("transform",`translate(${w},${v})`);if(s.xDendrogramHeight){const t=h+u-c.left.offset+i.xOffset-i.dx/2;a.dom.hcClipRect.attr("x",t+n+i.dx/2).attr("y",0).attr("width",i.mainw+3).attr("height",i.mainh+s.yDendrogramHeight+500);a.topDendroX=t+i.seriesXoffset;a.dom.topDendrogram.attr("transform",`translate(${a.topDendroX}, 0)`);const r=c.top.display=="none"?0:d.height+e.collabelgap;a.dom.leftDendrogram.attr("transform",`translate(${t-h-10}, ${r})`)}}}function n(t){if(t.fill)return t.fill;const e=t.class||Array.isArray(t.values)&&t.values[0].class;return e?mclass[e].color:"#555"}function o(t){return new Promise((e=>setTimeout(e,t)))}export{a as setRenderers};
|
|
1
|
+
import{i as t,h as e,f as s}from"./termsetting-7467350f.js";import{d as r}from"./app-3d14cbe4.js";import"./tslib.es6-c3c2d88f.js";import"path";function a(a){a.render=function(){const t=a.settings.matrix;const e=a.layout;const s=a.dimensions;const r=a.dom.svg.attr("width")?t.duration:0;a.dom.clipRect.attr("x",s.xOffset-1).attr("y",0).attr("width",s.mainw+3).attr("height",s.mainh+500);a.renderSerieses(t,e,s,r);a.renderLabels(t,e,s,r);a.renderDivideByLabel(t,e,s,r);a.dom.colBeam.attr("width",s.dx).attr("height",s.mainh).style("stroke",t.beamStroke);a.dom.rowBeam.attr("width",s.zoomedMainW).attr("height",t.rowh).style("stroke",t.beamStroke)};a.renderSerieses=function(t,e,s,r){if(a.prevUseCanvas!=t.useCanvas){a.dom.seriesesG.selectAll("g").remove()}if(t.useCanvas){const e=a.dom.seriesesG.selectAll("g");const n=a.dom.seriesesG.append("g").datum(this.serieses);a.renderCanvas(this.serieses,n,s,t,e,r)}else{a.dom.seriesesG.attr("transform",`translate(${s.xOffset+s.seriesXoffset},${s.yOffset})`);const t=a.dom.seriesesG.selectAll(".sjpp-mass-series-g").data(this.serieses,(t=>t.tw.$id));t.exit().remove();t.each(a.renderSeries);t.enter().append("g").attr("class","sjpp-mass-series-g").style("opacity",.001).each(a.renderSeries);a.mouseout()}a.prevUseCanvas=t.useCanvas};a.renderSeries=async function(t){const e=a.settings.matrix;a.dimensions;const s=r(this);s.attr("transform")?e.duration:0;s.attr("transform",`translate(${t.x},${t.y})`).style("opacity",1);const n=t.cells[t.cells.length-1];t.y+n?.y+e.rowh;const o=s.selectAll("rect").data(t.cells,(t=>t.sample+";;"+t.tw.$id+";;"+t.valueIndex));o.exit().remove();o.each(a.renderCell);o.enter().append("rect").each(a.renderCell)};a.renderCanvas=async function(t,e,s,r,n,o){const i=window.devicePixelRatio<=1?1:window.devicePixelRatio;e.selectAll("*").remove();const l=s.imgW;const c=a.dimensions.mainh;const d=window.OffscreenCanvas?new OffscreenCanvas(l*i,c*i):a.dom.holder.append("canvas").attr("width",i*l).attr("height",i*c).style("opacity",0).node();const m=d.getContext("2d");m.imageSmoothingEnabled=false;m.imageSmoothingQuality="high";m.scale(i,i);for(const e of t){for(const t of e.cells){a.renderCellWithCanvas(m,t,e,r,s,e.y)}}if(window.OffscreenCanvas){const t=new FileReader;t.addEventListener("load",(()=>{n?.remove();a.dom.seriesesG.attr("transform",`translate(${s.xOffset+s.seriesXoffset},${s.yOffset})`);e.selectAll("image").remove();e.append("image").attr("xlink:href",t.result).attr("x",s.xMin).attr("width",l).attr("height",c)}),false);const r=await d.convertToBlob({quality:1});t.readAsDataURL(r)}else{n?.remove();a.dom.seriesesG.attr("transform",`translate(${s.xOffset+s.seriesXoffset},${s.yOffset})`);const t=d.toDataURL();e.append("image").attr("width",l).attr("height",c).attr("xlink:href",t);if(!window.OffscreenCanvas)d.remove()}a.mouseout()};a.renderCellWithCanvas=function(t,e,s,r,o,i){if(!e.fill)e.fill=e.$id in a.colorScaleByTermId?a.colorScaleByTermId[e.$id](e.key):n(e);const l=e.x?e.x-o.xMin:0;const c=i?i+e.y:e.y||0;const d=r.useMinPixelWidth?Math.max(e.width||o.colw,o.pxw):e.width||o.colw;const m="height"in e?e.height:r.rowh;t.fillStyle=e.fill;t.fillRect(l,c,d,m)};a.renderCell=function(t){if(!t.fill)t.fill=t.$id in a.colorScaleByTermId?a.colorScaleByTermId[t.$id](t.key):n(t);const e=a.settings.matrix;r(this).attr("x",t.x||0).attr("y",t.y||0).attr("width",t.width||a.dimensions.colw).attr("height","height"in t?Math.max(0,t.height):e.rowh).attr("shape-rendering","crispEdges").attr("stroke-width",0).attr("fill",t.fill)};a.renderLabels=function(t,e,s,n){for(const o of["top","btm","left","right"]){const i=e[o];i.box.style("display",i.display||"").attr("transform",i.attr.boxTransform);const l=i.box.selectAll(".sjpp-matrix-label").data(i.data,i.key);l.exit().remove();l.each(c);l.enter().append("g").attr("class","sjpp-matrix-label").each(c);function c(e){const s=r(this);s.attr("transform",i.attr.labelGTransform);if(!s.select(":scope>text").size())s.append("text");const n=!i.isGroup&&e.grp?.type!=="hierCluster"&&e.tw?.q?.mode=="continuous";const o=i.label(e);const l=s.select(":scope>text").attr("fill","#000");l.attr("display",e.grp?.type==="hierCluster"&&t.clusterRowh<6?"none":i.attr.fontSize<6||o==="configure"?"none":"").attr("font-size",e.grp?.type==="hierCluster"?t.clusterRowh:i.attr.fontSize).attr("text-anchor",i.attr.labelAnchor).attr("transform",i.attr.labelTransform).attr("cursor","pointer").attr(i.attr.textpos.coord,i.attr.textpos.factor*(n?30:0));if(!Array.isArray(o)){l.text(o);l.attr("y",e.grp?.type!=="hierCluster"&&e.tw?.q?.mode=="continuous"?10:e.grp?.type==="hierCluster"?.3*t.clusterRowh:0)}else{l.text("");const t=l.selectAll("tspan").data(o);t.enter().append("tspan").attr("class",d).attr("dx",m).attr("font-size",p).text(f)}l.on("mouseover",o==="configure"?()=>l.attr("opacity",.5):null).on("mouseout",o==="configure"?()=>l.attr("opacity",0):null);const c=s.select(".sjpp-matrix-cell-axis").size()&&true;if(n&&o){if(!c){s.append("g").attr("class","sjpp-matrix-cell-axis").attr("shape-rendering","crispEdges")}const r=s.select(".sjpp-matrix-cell-axis");r.selectAll("*").remove();[e.counts.maxval,e.counts.minval];if(t.transpose);a.dimensions;const n=!t.transpose?0:e.tw.settings.gap-1-e.labelOffset;const o=!t.transpose?e.tw.settings.gap-1-e.labelOffset:0;r.attr("shape-rendering","crispEdges").attr("transform",`translate(${n},${o})`).call(i.attr.axisFxn(e.scales.full.domain(e.scales.tickValues)).tickValues(e.scales.tickValues))}else if(c){s.select(".sjpp-matrix-cell-axis").remove()}}function d(t){return t.cls}function m(t){return t.dx}function p(t){return t.fontSize||i.attr.fontSize}function f(t){return t.text}}};a.colLabelGTransform=(t,e)=>{const s=a.settings.matrix;const r=a.dimensions;t.labelOffset=.8*r.colw;const n=t.grpIndex*s.colgspace+t.totalIndex*r.dx+t.labelOffset+t.totalHtAdjustments;const o=0;return`translate(${n+r.seriesXoffset},${o})`};a.colGrpLabelGTransform=(t,e)=>{const s=a.settings.matrix;const r=a.dimensions;const n=(t.processedLst||t.grp.lst).length;const o=t.grpIndex*s.colgspace+t.prevGrpTotalIndex*r.dx+n*r.dx/2+s.grpLabelFontSize/2+t.totalHtAdjustments;return`translate(${o+r.seriesXoffset},0)`};a.rowLabelGTransform=(t,e)=>{const s=a.settings.matrix;const r=a.dimensions;const n=0;t.labelOffset=.7*(t.grp.type=="hierCluster"?s.clusterRowh:s.rowh);const o=t.grpIndex*s.rowgspace+t.totalIndex*r.dy+t.labelOffset+t.totalHtAdjustments;return`translate(${n},${o})`};a.rowGrpLabelGTransform=(t,e)=>{const s=a.settings.matrix;const r=a.dimensions;const n=(t.processedLst||t.grp.lst).length;const o=t.grpIndex*s.rowgspace+t.prevGrpTotalIndex*r.dy+n*r.dy/2+s.grpLabelFontSize/2+t.totalHtAdjustments;return`translate(0,${o})`};a.rowAxisGTransform=(t,e)=>{const s=a.settings.matrix;const r=a.dimensions;const n=0;const o=t.grpIndex*s.rowgspace+t.totalIndex*r.dy+.7*s.rowh+t.totalHtAdjustments;return`translate(${n},${o})`};a.renderDivideByLabel=async(r,n,o)=>{a.dom.mainG.selectAll(".sjpp-matrix-divide-by-label").remove();if(!a.config.divideBy)return;const i=a.config.divideBy?.term.name||"";const l=i.length<=r.rowlabelmaxchars?i:i.slice(0,r.rowlabelmaxchars)+"…";const c=!r.transpose?[n.left,n.right]:[n.top,n.bottom];const d=c.find((t=>!t.isGroup))?.box;const m=(r.collabelpos=="top"?o.mainh+r.collabelmaxchars:-r.collabelmaxchars)+8;const p=r.rowlabelpos=="left"?"end":"start";const f=r.controlLabels;const g=d.append("g").attr("class","sjpp-matrix-divide-by-label").attr("transform",`translate(0, ${m})`);g.append("text").attr("text-anchor",p).attr("font-style","italic").attr("y",-20).text(`${f.Samples} grouped by`);const h=d.datum({tw:a.config.divideBy}).append("g").attr("class","sjpp-matrix-divide-by-label").attr("transform",`translate(0, ${m})`);const x=h.append("text").attr("text-anchor",p).attr("font-weight",600).text(l).on("click",((t,e)=>{w.showMenu(t,x.node())}));h.append("title").text(`${f.Samples} are grouped by this gene or variable. Click to edit.`);const u=[];const y=t(a.config.divideBy.term)?"ranges":"values";if(a.config.legendValueFilter.lst?.find((t=>t.legendGrpName==a.config.divideBy.term.id||t.legendGrpName==a.config.divideBy.term.name))?.tvs[y]?.length){u.push({label:`Show filtered ${f.samples}`,callback:a.showDeletedSampleGroups})}const w=await e({menuOptions:"{edit,replace,remove}",customMenuOptions:u,vocabApi:a.app.vocabApi,vocab:a.state.vocab,holder:h,debug:a.opts.debug,usecase:{target:"matrix"},getBodyParams:()=>{const t=a.termOrder.filter((t=>t.tw.term.type==="geneVariant")).map((t=>t.tw.term.chr?`${t.tw.term.chr}:${t.tw.term.start}-${t.tw.term.stop}`:t.tw.term.gene||t.tw.term.name));return{currentGeneNames:t}},callback:async e=>{if(a.dom.loadingDiv&&a.dom.svg){a.dom.loadingDiv.selectAll("*").remove();a.dom.loadingDiv.html("").style("display","").style("position","relative").style("left","45%");a.dom.loadingDiv.html("Processing data ...");a.dom.svg.style("opacity",.1).style("pointer-events","none")}if(e&&!e.q)throw"data.q{} missing from pill callback";if(e?.term&&t(e.term)){e.q={...e.q,mode:"discrete"}}if(e)await s(e,a.app.vocabApi);await w.main(e?e:{term:null,q:null});d.datum({tw:e});a.app.dispatch({type:"plot_edit",id:a.id,config:{divideBy:e,legendValueFilter:a.mayRemoveTvsEntry(a.config.divideBy)}})}});const v={term:a.config.divideBy.term,q:a.config.divideBy.q};if(a.config.divideBy.$id)v.$id=a.config.divideBy.$id;w.main(v)};a.adjustSvgDimensions=async function(t){const e=a.settings.matrix;const s=a.settings.hierCluster||{};const r=s.yDendrogramHeight||0;const n=s.xDendrogramHeight||0;const i=a.dimensions;const l=a.dom.svg.attr("width")?e.duration:0;await o(t==e.transpose?l:e.duration);const c=a.layout;const d=c.top.box.node().getBBox();const m=c.btm.box.node().getBBox();const p=c.left.box.node().getBBox();const f=c.right.box.node().getBBox();const g=a.dom.legendG.node().getBBox();a.dom.seriesesG.node().getBBox();i.extraWidth=p.width+f.width+e.margin.left+e.margin.right+e.rowlabelgap*2;i.extraHeight=d.height+m.height+e.margin.top+e.margin.bottom+e.collabelgap*2;i.svgw=i.mainw+i.extraWidth+n;i.svgh=i.mainh+i.extraHeight+g.height+20+e.scrollHeight+r;a.dom.svg.attr("width",i.svgw).attr("height",i.svgh);let h=a.type=="hierCluster"?0:p.width;if(s.xDendrogramHeight){a.dom.termLabelG.selectAll(".sjpp-matrix-label").each((function(t){if(t.grp.type!=="hierCluster")return;const e=this.getBBox();if(e.width>h){h=e.width;t.label.length}}))}const x=-c.left.offset+n+h;const u=!s.xDendrogramHeight?0:Math.max(p.width-(s.xDendrogramHeight+h),0);const y=(c.top.display=="none"?0:d.height)-c.top.offset+r;a.dom.mainG.attr("transform",`translate(${x+u},${y})`);a.dom.clipRect.attr("y",-y).attr("height",i.mainh+500+y);const w=i.xOffset+(e.transpose?20:0);const v=i.yOffset+i.mainh+e.collabelgap+(c.btm.display=="none"?0:m.height)+20;a.dom.legendG.attr("transform",`translate(${w},${v})`);if(s.xDendrogramHeight){const t=h+u-c.left.offset+i.xOffset-i.dx/2;a.dom.hcClipRect.attr("x",t+n+i.dx/2).attr("y",0).attr("width",i.mainw+3).attr("height",i.mainh+s.yDendrogramHeight+500);a.topDendroX=t+i.seriesXoffset;a.dom.topDendrogram.attr("transform",`translate(${a.topDendroX}, 0)`);const r=c.top.display=="none"?0:d.height+e.collabelgap;a.dom.leftDendrogram.attr("transform",`translate(${t-h-10}, ${r})`)}}}function n(t){if(t.fill)return t.fill;const e=t.class||Array.isArray(t.values)&&t.values[0].class;return e?mclass[e].color:"#555"}function o(t){return new Promise((e=>setTimeout(e,t)))}export{a as setRenderers};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getEmptyCell as e,setCellProps as t,maySetEmptyCell as s}from"./matrix.cells-
|
|
1
|
+
import{getEmptyCell as e,setCellProps as t,maySetEmptyCell as s}from"./matrix.cells-4dd055e7.js";import"./termsetting-7467350f.js";function i(i){const n=this.settings.matrix;const o=[];const{colw:l,dx:d,dy:a,xMin:c,xMax:p}=this.dimensions;const u=this.config.divideBy||{};const g="id"in u?u.id:u.name;const f={};this.colorScaleByTermId={};for(const i of this.termOrder){const r=i.tw.$id;const u="id"in i.tw.term?i.tw.term.id:i.tw.term.name;const m=u===g;const h=[];const v=i.grp.type=="hierCluster"?n.clusterRowh:a;const y=i.grp.type=="hierCluster"?0:i.totalHtAdjustments;const w=n.transpose?0:i.totalIndex*v+i.visibleGrpIndex*n.rowgspace+y;const x=(i.tw.settings?.gap||0)+w;const C={t:i,tw:i.tw,cells:[],y:w,hoverY0:x,hoverY1:x+(i.tw.settings?.barh||v)};for(const o of this.unfilteredSampleOrder){const{totalIndex:g,grpIndex:v,row:y}=o;C.x=!n.transpose?0:i.totalIndex*d+i.visibleGrpIndex*n.colgspace;const x=y[r];const $={s:o,sample:y.sample,tw:i.tw,term:i.tw.term,termid:u,$id:r,totalIndex:g,grpIndex:v,row:y,t:i,seriesY:w};if(!x){if(!o.grp.isExcluded&&(n.useCanvas||o.grp)){const t=e($,n,this.dimensions);C.cells.push(t)}continue}const I=x.key;const G=x.filteredValues||x.values||[x.value];const E=n.cellEncoding=="oncoprint"?1:G.length;const b=!n.transpose?n.rowh/E:l;const O=!n.transpose?l:l/G.length;const S=[];if(!x||!x.renderedValues?.length){if(!o.grp.isExcluded&&(n.useCanvas||o.grp)){const t=e($,n,this.dimensions);C.cells.push(t)}continue}for(const[e,s]of G.entries()){const l=Object.assign({key:I,siblingCells:S},$);l.valueIndex=e;let u;if(typeof i.tw.setCellProps=="function"){u=i.tw.setCellProps(l,x,s,n,i,this,O,b,d,a,e)}else{const r=i.grp.type=="hierCluster"?t["hierCluster"]:i.tw.term.type=="geneVariant"&&(i.tw?.q?.type=="predefined-groupset"||i.tw?.q?.type=="custom-groupset")?t["categorical"]:t[i.tw.term.type];u=r(l,i.tw,x,s,n,i,this,O,b,d,a,e)}if(!n.useCanvas&&(l.x+l.width<c||l.x-l.width>p))continue;if(u){for(const e of[f,o.grp.legendGroups]){if(!e)continue;if(!e[u.group]){e[u.group]={ref:u.ref,values:{},order:u.order,$id:r,origin:u.entry.origin};if(u.entry.dt)e[u.group].dt=[u.entry.dt]}const t=e[u.group];if(t.dt&&!t.dt.includes(u.entry.dt))t.dt.push(u.entry.dt);const s=u.entry.origin?u.entry.origin+u.value:u.value;if(!t.values[s]){t.values[s]=JSON.parse(JSON.stringify(u.entry));if(u.entry.scale)t.values[s].scale=u.entry.scale}if(!t.values[s].samples)t.values[s].samples=new Set;t.values[s].samples.add(y.sample);if(m){t.values[u.value].isExcluded=o.grp.isExcluded}}}if(!o.grp.isExcluded){if(x.renderedValues.includes(s))C.cells.push(l);S.push(l)}}if(n.showGrid=="rect"&&!o.grp.isExcluded){const t=i.grp.type=="hierCluster"?e($,n,this.dimensions):s[i.tw.term.type]?.(S,$,n,this.dimensions);if(t)h.push(t)}}if(h.length)C.cells.unshift(...h);if(C.cells.length)o.push(C)}r(f,this);this.legendData=this.getLegendData(f,i.refs,this);for(const e of this.sampleGroups){e.legendData=this.getLegendData(e.legendGroups,i.refs,this)}return o}function r(e,t){for(const s of t.config.legendValueFilter.lst){if(s.tvs.term.type=="categorical"&&!e[s.tvs.term.$id]){e[s.tvs.term.$id]={ref:{},values:{},$id:s.tvs.term.$id}}else if(s.tvs.term.type=="geneVariant"&&!e[s.legendGrpName]){e[s.legendGrpName]={ref:{},values:{},dt:[s.tvs.values[0].dt],origin:s.tvs.values[0].origin}}else if((s.tvs.term.type=="integer"||s.tvs.term.type=="float")&&!e[s.tvs.term.$id]){e[s.tvs.term.$id]={ref:{},values:{},$id:s.tvs.term.$id}}}}var n=Object.freeze({__proto__:null,getSerieses:i});export{n as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e}from"./termsetting-492eefa7.js";import{at as t,ak as r,ap as s,bE as i,bD as n}from"./app-6fb77603.js";import"./tslib.es6-c3c2d88f.js";import"path";function o(t,r,s,i={}){const n=r;a(n);if(t.config.chartType=="hierCluster"&&t.config.settings.hierCluster.clusterSamples){return t.hcSampleSorter}if(n.sortSamplesBy=="asListed"){return(e,r)=>t.asListedSampleOrder.indexOf(e.sample)-t.asListedSampleOrder.indexOf(r.sample)}if(n.sortSamplesBy=="name"){return l}const o=n.sortOptions[n.sortSamplesBy];if(!o)throw`unsupported s.sortSamplesBy='${n.sortSamplesBy}'`;t.selectedTermsToSortAgainst=t.termOrder.filter((e=>e.tw.sortSamples));const p=t.selectedTermsToSortAgainst.map((e=>e.tw)).sort(((e,t)=>e.sortSamples.priority-t.sortSamples.priority));const m=[];const b=o.sortPriority;if(b){for(const e of p){const t=structuredClone(e);if(t.sortSamples?.by){m.push(Object.assign({},t));continue}for(const e of b){if(i.skipSorter?.(e,t))continue;if(!e.types.includes(t.term.type))continue;for(const r of e.tiebreakers){const e=Object.assign(structuredClone(t.sortSamples||{}),r);const s=Object.assign(structuredClone(t),{sortSamples:e});m.push(s)}}}}if(b){for(const e of b){for(const r of t.termOrder){if(p.find((e=>e.$id===r.tw.$id)))continue;if(i.skipSorter?.(e,r.tw))continue;if(!e.types.includes(r.tw.term.type))continue;for(const t of e.tiebreakers){m.push(Object.assign({},r.tw,{sortSamples:t}))}}}}else{const r=t.app.vocabApi.vocab?.dslabel=="PNET"?[]:t.termOrder.filter((t=>!t.tw.sortSamples&&e(t.tw.term.type)&&!p.find((e=>e.$id===t.tw.$id)))).map((e=>Object.assign({sortSamples:{by:"values"}},e.tw)));const s=t.app.vocabApi.vocab?.dslabel=="PNET"?[]:t.termOrder.filter((t=>!t.tw.sortSamples&&!e(t.tw.term.type)&&!p.find((e=>e.$id===t.tw.$id)))).map((e=>Object.assign({sortSamples:{by:"hits"}},e.tw)));m.push(...s,...r)}if(i.tiebreaker)m.push(i.tiebreaker);m.push(...n.sortSamplesTieBreakers.map((e=>e)));const h=[];t.maxSampleSet=new Set;for(const e of m){if(typeof e==="function")h.push(e);else if(e.$id=="sample")h.push(l);else if(e.sortSamples.by=="hits")h.push(u(e,t,s));else if(e.term.type!="geneVariant")h.push(d(e,t,s));else if(e.sortSamples.by=="values")h.push(d(e,t,s));else if(e.sortSamples.by=="dt")h.push(f(e));else if(e.sortSamples.by=="class")h.push(c(e,t));else throw`unsupported sortSamplesBy entry by='${e.sortSamples.by}'`}if(!h.find((e=>e.$id==="sample"))){h.push(l)}return(e,t)=>{for(const r of h){const s=r(e,t);if(s!==0)return s}}}function a(e){if(!e.sortOptions)e.sortOptions="custom";if(["selectedTerms","class","dt","hits"].includes(e.sortSamplesBy))e.sortSamplesBy="custom"}function l(e,t){if(e._ref_.label&&t._ref_.label){return e._ref_.label<t._ref_.label?-1:e._ref_.label>t._ref_.label?1:0}if(!e.sample&&!t.sample&&e.row.sample){return e.row.sample<t.row.sample?-1:e.row.sample>t.row.sample?1:0}return e.sample<t.sample?-1:e.sample>t.sample?1:0}function u(e,t,r,s){const{$id:i,sortSamples:n}=e;const o={};for(const e of r){if(!o[e.sample])o[e.sample]=0;if(i in e){o[e.sample]+=e[i].countedValues?.length||0}}return(e,t)=>o[e.sample]==o[t.sample]?0:o[e.sample]>o[t.sample]?-1:1}function d(e,t,r,s){const{$id:i,sortSamples:n}=e;const o=t.termOrder.find((e=>e.tw.$id===i));if(o.grp.type=="hierCluster"){return(e,t)=>{if(i in e&&i in t){return e[i]?.values[0].value-t[i]?.values[0].value}if(i in e)return-1;if(i in t)return 1;return 0}}if(o.tw.q?.mode=="continuous"){return(e,t)=>{if(i in e&&i in t){return e[i]?.value-t[i]?.value}if(i in e)return-1;if(i in t)return 1;return 0}}const a=[];if(o?.term?.values){for(const e of term.values){a.push(e.key)}a.sort(((e,t)=>term.values[e].order<term.values[e].order?-1:1))}else if(o?.ref?.bins){a.push(...o.ref.bins.map((e=>e.name)))}else{for(const e of r){if(!(i in e))continue;const t=e[i].override?.key||e[i].key;if(a.indexOf(t)==-1)a.push(t)}}return(e,t)=>{if(!e[i]&&!t[i])return 0;if(!e[i])return t[i].override?-1:1;if(!t[i])return e[i].override?1:-1;if(e[i].override&&t[i].override){const r="order"in e[i].override?e[i].override.order:a.indexOf(e[i].override.key);const s="order"in t[i].override?t[i].override.order:a.indexOf(t[i].override.key);return r-s}if(!e[i].override&&!t[i].override){return a.indexOf(e[i].key)-a.indexOf(t[i].key)}if(!e[i].override)return-1;if(!t[i].override)return 1;return 0}}function f(e,t,r,s){const{$id:i,sortSamples:n,term:o}=e;const a=n.order;const l=a.length+1;const u=new Map;function d(e){if(!(i in e)){u.set(e.sample,l);return}if(n.filter&&!p(e[i].values,n.filter.values)){u.set(e.sample,l);return}const t=e[i].values.map((e=>a.indexOf(e.dt))).filter((e=>e!==-1));u.set(e.sample,t.length?Math.min(...t):l)}return(e,t)=>{if(!u.has(e.sample))d(e);if(!u.has(t.sample))d(t);return u.get(e.sample)-u.get(t.sample)}}function c(e,t,r,s){const{$id:i,sortSamples:n}=e;if(n.disabled)return()=>0;const o=t.config.settings.matrix;const a=o.showMatrixMutation!="none"&&!o.allMatrixMutationHidden;const l=o.showMatrixCNV!="none"&&!o.allMatrixCNVHidden;const u=n.order.filter(a&&l?e=>!o.hiddenVariants.includes(e):!a&&!l?()=>false:a?e=>o.mutationClasses.includes(e)&&!o.hiddenVariants.includes(e):l?e=>e.startsWith("CNV_")&&!o.hiddenVariants.includes(e):e=>!e.startsWith("CNV_"));if(!u.length&&n.ignoreEmptyFilteredOrder)return()=>0;const d="z";const f=new Map;function c(e){if(!(i in e)){f.set(e.sample,d);return}const t=e[i].renderedValues||e[i].filteredValues||e[i].values;if(n.filter&&!p(t,n.filter.values)){f.set(e.sample,d);return}const r=t.map((e=>e.class));if(!u.find((e=>r.includes(e)))){f.set(e.sample,d);return}else if(!n.isOrdered){f.set(e.sample,"1")}else{const t=u.map((e=>r.includes(e)?"1":"x"));f.set(e.sample,t)}}return(e,t)=>{if(!f.has(e.sample))c(e);if(!f.has(t.sample))c(t);const r=f.get(e.sample);const s=f.get(t.sample);return r<s?-1:r>s?1:0}}function p(e,t){for(const r of e){for(const e of t){if((!e.dt||r.dt===e.dt)&&(!e.mclassLst||e.mclassLst.includes(r.class))&&(!e.class||e.class===r.class)&&(!e.origin||r.origin===e.origin)){return true}}}}function m(e,t,r){if(r?.type=="hierCluster")return e.hcTermSorter;if(t.sortTermsBy=="asListed"){return(e,t)=>e.index-t.index}if(t.sortTermsBy!="sampleCount"){throw`unsupported s.sortTermsBy='${t.sortTermsBy}'`}return(t,r)=>{if(e.app.vocabApi.vocab?.dslabel==="GDC"){if(t.tw?.term?.id&&!r.tw?.term?.id)return-1;if(!t.tw?.term?.id&&r.tw?.term?.id)return 1}if(r.counts.samples!==t.counts.samples)return r.counts.samples-t.counts.samples;if(r.counts.hits!==t.counts.hits)return r.counts.hits-t.counts.hits;return t.index-r.index}}function b(e,o={},a){const l=a||e?.matrix?.settings||{};const u=Object.assign({sample:"sample"},o,l.controlLabels||{});const d={};if(l.sortPriority){const e=1;Object.values(d).forEach((t=>{if(t.order>=e)t.order+=1}));d.custom={label:l.sortPriority.label||"Custom sort",value:"custom",order:e,sortPriority:l.sortPriority}}d.a=l.sortOptions?.a?v(l.sortOptions.a,u):{value:"a",order:1,sortPriority:[{label:`For each gene mutation, sort ${u.samples} by matching data`,types:["geneVariant"],tiebreakers:[{skip:!l.mutationClasses.includes("Fuserna"),label:`${u.Samples} with Fusion RNASeq > without`,filter:{values:[{dt:t}]},by:"class",isOrdered:false,order:["Fuserna"]},{label:`${u.Samples} with truncating mutations > without`,filter:{values:[{dt:r}]},by:"class",isOrdered:false,order:[...l.truncatingMutations],notUsed:[]},{label:`${u.Samples} with CNV data > without`,mayToggle:true,filter:{values:[{dt:s}]},by:"class",isOrdered:true,disabled:true,order:[i,n]},{disabled:false,mayToggle:true,label:`${u.Samples} with protein-changing mutations > without`,filter:{values:[{dt:r}]},by:"class",isOrdered:false,order:l.proteinChangingMutations.filter((e=>!l.truncatingMutations.includes(e))),notUsed:l.truncatingMutations}]},{label:`For each dictionary variable, sort ${u.samples} by matching data`,types:["categorical","integer","float","survival"],tiebreakers:[{label:"Values",by:"values"}]}]};d.name={label:`By ${u.sample} name, ID, or label`,value:"name",order:Object.values(d).length};return d}function h(e){const t=e.settings.matrix;if(t.sortSampleGrpsBy=="hits")return(e,t)=>{if(e.lst.length&&!t.lst.length)return-1;if(!e.lst.length&&t.lst.length)return 1;return t.totalCountedValues-e.totalCountedValues};if(t.sortSampleGrpsBy=="sampleCount")return(e,t)=>{if(e.lst.length&&!t.lst.length)return-1;if(!e.lst.length&&t.lst.length)return 1;if(e.lst.length==t.lst.length){return y(e,t)}return t.lst.length-e.lst.length};if(!e.config.divideBy?.$id)return y;const r=e.data.refs.byTermId[e.config.divideBy.$id];if(r&&!r.keyOrder)r.keyOrder=r.bins?r.bins.map((e=>e.name)):[];const s=e.data.refs.byTermId[e.config.divideBy.$id]?.keyOrder;if(!s)return y;return(e,t)=>{e.order=s.indexOf(e.id);if(e.order==-1)delete e.order;t.order=s.indexOf(t.id);if(t.order==-1)delete t.order;if("order"in e&&"order"in t)return e.order-t.order;if("order"in e)return-1;if("order"in t)return 1;if(e.tw?.term?.values?.[e.id]?.order&&t.tw?.term?.values?.[t.id]?.order){return e.tw.term.values[e.id].order-t.tw.term.values[t.id].order}return y(e,t)}}function y(e,t){return e.name<t.name?-1:1}function g(e){const t=e.settings.matrix;const r=t.sortOptions[t.sortSamplesBy].sortPriority?t.sortOptions[t.sortSamplesBy]:t.sortOptions.a;const s=[];r.sortPriority.forEach((e=>{if(e.types.includes("geneVariant")){e.tiebreakers.forEach((e=>{if(e.by=="class"&&e.order){s.push(...e.order.filter((e=>e!=="WT"&&e!=="Blank")))}}))}}));const i=(e,t)=>{const r=s.indexOf(e.class);const i=s.indexOf(t.class);return r==-1&&i==-1?0:s.indexOf(e.class)==-1?1:s.indexOf(t.class)==-1?-1:s.indexOf(e.class)-s.indexOf(t.class)};return i}function v(e,o){const a=o;let l;for(const t of e.sortPriority){if(t.types.includes("categorical")){if(!t.label)t.label=`For each dictionary variable, sort ${a.samples} by matching data`;continue}if(!t.types?.includes("geneVariant"))continue;if(!l){l=t;if(!t.label)t.label=`For each gene mutation, sort ${a.samples} by matching data`}else{l.tiebreakers.push(...t.tiebreakers);t.toBeDeleted=true}}for(const e of l.tiebreakers){if(e.filter?.values?.find((e=>e.dt==t))){const t={label:`${a.Samples} with Fusion RNASeq > without`,isOrdered:true,disabled:false,mayToggle:true};Object.assign(e,t,e)}else if(e.filter?.values?.find((e=>e.dt==r))){const t=e.order.includes(i)||e.order.includes(n)?`${a.Samples} with SSM + CNV > SSM only`:`${a.Samples} with mutations`;const r={label:t,isOrdered:true,disabled:false,mayToggle:true};Object.assign(e,r,e)}else if(e.order.length==2&&e.order.includes(i)&&e.order.includes(n)){const t={label:`${a.Samples} with CNV only > without`,filter:{values:[{dt:s}]},by:"class",isOrdered:true,disabled:false,mayToggle:true};Object.assign(e,t,e)}}e.sortPriority=e.sortPriority.filter((e=>!e.toBeDeleted));return e}export{g as getMclassSorter,h as getSampleGroupSorter,o as getSampleSorter,b as getSortOptions,m as getTermSorter,v as reshapeSortPriority};
|
|
1
|
+
import{b as e}from"./termsetting-7467350f.js";import{at as t,ak as r,ap as s,bE as i,bD as n}from"./app-3d14cbe4.js";import"./tslib.es6-c3c2d88f.js";import"path";function o(t,r,s,i={}){const n=r;a(n);if(t.config.chartType=="hierCluster"&&t.config.settings.hierCluster.clusterSamples){return t.hcSampleSorter}if(n.sortSamplesBy=="asListed"){return(e,r)=>t.asListedSampleOrder.indexOf(e.sample)-t.asListedSampleOrder.indexOf(r.sample)}if(n.sortSamplesBy=="name"){return l}const o=n.sortOptions[n.sortSamplesBy];if(!o)throw`unsupported s.sortSamplesBy='${n.sortSamplesBy}'`;t.selectedTermsToSortAgainst=t.termOrder.filter((e=>e.tw.sortSamples));const p=t.selectedTermsToSortAgainst.map((e=>e.tw)).sort(((e,t)=>e.sortSamples.priority-t.sortSamples.priority));const m=[];const b=o.sortPriority;if(b){for(const e of p){const t=structuredClone(e);if(t.sortSamples?.by){m.push(Object.assign({},t));continue}for(const e of b){if(i.skipSorter?.(e,t))continue;if(!e.types.includes(t.term.type))continue;for(const r of e.tiebreakers){const e=Object.assign(structuredClone(t.sortSamples||{}),r);const s=Object.assign(structuredClone(t),{sortSamples:e});m.push(s)}}}}if(b){for(const e of b){for(const r of t.termOrder){if(p.find((e=>e.$id===r.tw.$id)))continue;if(i.skipSorter?.(e,r.tw))continue;if(!e.types.includes(r.tw.term.type))continue;for(const t of e.tiebreakers){m.push(Object.assign({},r.tw,{sortSamples:t}))}}}}else{const r=t.app.vocabApi.vocab?.dslabel=="PNET"?[]:t.termOrder.filter((t=>!t.tw.sortSamples&&e(t.tw.term.type)&&!p.find((e=>e.$id===t.tw.$id)))).map((e=>Object.assign({sortSamples:{by:"values"}},e.tw)));const s=t.app.vocabApi.vocab?.dslabel=="PNET"?[]:t.termOrder.filter((t=>!t.tw.sortSamples&&!e(t.tw.term.type)&&!p.find((e=>e.$id===t.tw.$id)))).map((e=>Object.assign({sortSamples:{by:"hits"}},e.tw)));m.push(...s,...r)}if(i.tiebreaker)m.push(i.tiebreaker);m.push(...n.sortSamplesTieBreakers.map((e=>e)));const h=[];t.maxSampleSet=new Set;for(const e of m){if(typeof e==="function")h.push(e);else if(e.$id=="sample")h.push(l);else if(e.sortSamples.by=="hits")h.push(u(e,t,s));else if(e.term.type!="geneVariant")h.push(d(e,t,s));else if(e.sortSamples.by=="values")h.push(d(e,t,s));else if(e.sortSamples.by=="dt")h.push(f(e));else if(e.sortSamples.by=="class")h.push(c(e,t));else throw`unsupported sortSamplesBy entry by='${e.sortSamples.by}'`}if(!h.find((e=>e.$id==="sample"))){h.push(l)}return(e,t)=>{for(const r of h){const s=r(e,t);if(s!==0)return s}}}function a(e){if(!e.sortOptions)e.sortOptions="custom";if(["selectedTerms","class","dt","hits"].includes(e.sortSamplesBy))e.sortSamplesBy="custom"}function l(e,t){if(e._ref_.label&&t._ref_.label){return e._ref_.label<t._ref_.label?-1:e._ref_.label>t._ref_.label?1:0}if(!e.sample&&!t.sample&&e.row.sample){return e.row.sample<t.row.sample?-1:e.row.sample>t.row.sample?1:0}return e.sample<t.sample?-1:e.sample>t.sample?1:0}function u(e,t,r,s){const{$id:i,sortSamples:n}=e;const o={};for(const e of r){if(!o[e.sample])o[e.sample]=0;if(i in e){o[e.sample]+=e[i].countedValues?.length||0}}return(e,t)=>o[e.sample]==o[t.sample]?0:o[e.sample]>o[t.sample]?-1:1}function d(e,t,r,s){const{$id:i,sortSamples:n}=e;const o=t.termOrder.find((e=>e.tw.$id===i));if(o.grp.type=="hierCluster"){return(e,t)=>{if(i in e&&i in t){return e[i]?.values[0].value-t[i]?.values[0].value}if(i in e)return-1;if(i in t)return 1;return 0}}if(o.tw.q?.mode=="continuous"){return(e,t)=>{if(i in e&&i in t){return e[i]?.value-t[i]?.value}if(i in e)return-1;if(i in t)return 1;return 0}}const a=[];if(o?.term?.values){for(const e of term.values){a.push(e.key)}a.sort(((e,t)=>term.values[e].order<term.values[e].order?-1:1))}else if(o?.ref?.bins){a.push(...o.ref.bins.map((e=>e.name)))}else{for(const e of r){if(!(i in e))continue;const t=e[i].override?.key||e[i].key;if(a.indexOf(t)==-1)a.push(t)}}return(e,t)=>{if(!e[i]&&!t[i])return 0;if(!e[i])return t[i].override?-1:1;if(!t[i])return e[i].override?1:-1;if(e[i].override&&t[i].override){const r="order"in e[i].override?e[i].override.order:a.indexOf(e[i].override.key);const s="order"in t[i].override?t[i].override.order:a.indexOf(t[i].override.key);return r-s}if(!e[i].override&&!t[i].override){return a.indexOf(e[i].key)-a.indexOf(t[i].key)}if(!e[i].override)return-1;if(!t[i].override)return 1;return 0}}function f(e,t,r,s){const{$id:i,sortSamples:n,term:o}=e;const a=n.order;const l=a.length+1;const u=new Map;function d(e){if(!(i in e)){u.set(e.sample,l);return}if(n.filter&&!p(e[i].values,n.filter.values)){u.set(e.sample,l);return}const t=e[i].values.map((e=>a.indexOf(e.dt))).filter((e=>e!==-1));u.set(e.sample,t.length?Math.min(...t):l)}return(e,t)=>{if(!u.has(e.sample))d(e);if(!u.has(t.sample))d(t);return u.get(e.sample)-u.get(t.sample)}}function c(e,t,r,s){const{$id:i,sortSamples:n}=e;if(n.disabled)return()=>0;const o=t.config.settings.matrix;const a=o.showMatrixMutation!="none"&&!o.allMatrixMutationHidden;const l=o.showMatrixCNV!="none"&&!o.allMatrixCNVHidden;const u=n.order.filter(a&&l?e=>!o.hiddenVariants.includes(e):!a&&!l?()=>false:a?e=>o.mutationClasses.includes(e)&&!o.hiddenVariants.includes(e):l?e=>e.startsWith("CNV_")&&!o.hiddenVariants.includes(e):e=>!e.startsWith("CNV_"));if(!u.length&&n.ignoreEmptyFilteredOrder)return()=>0;const d="z";const f=new Map;function c(e){if(!(i in e)){f.set(e.sample,d);return}const t=e[i].renderedValues||e[i].filteredValues||e[i].values;if(n.filter&&!p(t,n.filter.values)){f.set(e.sample,d);return}const r=t.map((e=>e.class));if(!u.find((e=>r.includes(e)))){f.set(e.sample,d);return}else if(!n.isOrdered){f.set(e.sample,"1")}else{const t=u.map((e=>r.includes(e)?"1":"x"));f.set(e.sample,t)}}return(e,t)=>{if(!f.has(e.sample))c(e);if(!f.has(t.sample))c(t);const r=f.get(e.sample);const s=f.get(t.sample);return r<s?-1:r>s?1:0}}function p(e,t){for(const r of e){for(const e of t){if((!e.dt||r.dt===e.dt)&&(!e.mclassLst||e.mclassLst.includes(r.class))&&(!e.class||e.class===r.class)&&(!e.origin||r.origin===e.origin)){return true}}}}function m(e,t,r){if(r?.type=="hierCluster")return e.hcTermSorter;if(t.sortTermsBy=="asListed"){return(e,t)=>e.index-t.index}if(t.sortTermsBy!="sampleCount"){throw`unsupported s.sortTermsBy='${t.sortTermsBy}'`}return(t,r)=>{if(e.app.vocabApi.vocab?.dslabel==="GDC"){if(t.tw?.term?.id&&!r.tw?.term?.id)return-1;if(!t.tw?.term?.id&&r.tw?.term?.id)return 1}if(r.counts.samples!==t.counts.samples)return r.counts.samples-t.counts.samples;if(r.counts.hits!==t.counts.hits)return r.counts.hits-t.counts.hits;return t.index-r.index}}function b(e,o={},a){const l=a||e?.matrix?.settings||{};const u=Object.assign({sample:"sample"},o,l.controlLabels||{});const d={};if(l.sortPriority){const e=1;Object.values(d).forEach((t=>{if(t.order>=e)t.order+=1}));d.custom={label:l.sortPriority.label||"Custom sort",value:"custom",order:e,sortPriority:l.sortPriority}}d.a=l.sortOptions?.a?v(l.sortOptions.a,u):{value:"a",order:1,sortPriority:[{label:`For each gene mutation, sort ${u.samples} by matching data`,types:["geneVariant"],tiebreakers:[{skip:!l.mutationClasses.includes("Fuserna"),label:`${u.Samples} with Fusion RNASeq > without`,filter:{values:[{dt:t}]},by:"class",isOrdered:false,order:["Fuserna"]},{label:`${u.Samples} with truncating mutations > without`,filter:{values:[{dt:r}]},by:"class",isOrdered:false,order:[...l.truncatingMutations],notUsed:[]},{label:`${u.Samples} with CNV data > without`,mayToggle:true,filter:{values:[{dt:s}]},by:"class",isOrdered:true,disabled:true,order:[i,n]},{disabled:false,mayToggle:true,label:`${u.Samples} with protein-changing mutations > without`,filter:{values:[{dt:r}]},by:"class",isOrdered:false,order:l.proteinChangingMutations.filter((e=>!l.truncatingMutations.includes(e))),notUsed:l.truncatingMutations}]},{label:`For each dictionary variable, sort ${u.samples} by matching data`,types:["categorical","integer","float","survival"],tiebreakers:[{label:"Values",by:"values"}]}]};d.name={label:`By ${u.sample} name, ID, or label`,value:"name",order:Object.values(d).length};return d}function h(e){const t=e.settings.matrix;if(t.sortSampleGrpsBy=="hits")return(e,t)=>{if(e.lst.length&&!t.lst.length)return-1;if(!e.lst.length&&t.lst.length)return 1;return t.totalCountedValues-e.totalCountedValues};if(t.sortSampleGrpsBy=="sampleCount")return(e,t)=>{if(e.lst.length&&!t.lst.length)return-1;if(!e.lst.length&&t.lst.length)return 1;if(e.lst.length==t.lst.length){return y(e,t)}return t.lst.length-e.lst.length};if(!e.config.divideBy?.$id)return y;const r=e.data.refs.byTermId[e.config.divideBy.$id];if(r&&!r.keyOrder)r.keyOrder=r.bins?r.bins.map((e=>e.name)):[];const s=e.data.refs.byTermId[e.config.divideBy.$id]?.keyOrder;if(!s)return y;return(e,t)=>{e.order=s.indexOf(e.id);if(e.order==-1)delete e.order;t.order=s.indexOf(t.id);if(t.order==-1)delete t.order;if("order"in e&&"order"in t)return e.order-t.order;if("order"in e)return-1;if("order"in t)return 1;if(e.tw?.term?.values?.[e.id]?.order&&t.tw?.term?.values?.[t.id]?.order){return e.tw.term.values[e.id].order-t.tw.term.values[t.id].order}return y(e,t)}}function y(e,t){return e.name<t.name?-1:1}function g(e){const t=e.settings.matrix;const r=t.sortOptions[t.sortSamplesBy].sortPriority?t.sortOptions[t.sortSamplesBy]:t.sortOptions.a;const s=[];r.sortPriority.forEach((e=>{if(e.types.includes("geneVariant")){e.tiebreakers.forEach((e=>{if(e.by=="class"&&e.order){s.push(...e.order.filter((e=>e!=="WT"&&e!=="Blank")))}}))}}));const i=(e,t)=>{const r=s.indexOf(e.class);const i=s.indexOf(t.class);return r==-1&&i==-1?0:s.indexOf(e.class)==-1?1:s.indexOf(t.class)==-1?-1:s.indexOf(e.class)-s.indexOf(t.class)};return i}function v(e,o){const a=o;let l;for(const t of e.sortPriority){if(t.types.includes("categorical")){if(!t.label)t.label=`For each dictionary variable, sort ${a.samples} by matching data`;continue}if(!t.types?.includes("geneVariant"))continue;if(!l){l=t;if(!t.label)t.label=`For each gene mutation, sort ${a.samples} by matching data`}else{l.tiebreakers.push(...t.tiebreakers);t.toBeDeleted=true}}for(const e of l.tiebreakers){if(e.filter?.values?.find((e=>e.dt==t))){const t={label:`${a.Samples} with Fusion RNASeq > without`,isOrdered:true,disabled:false,mayToggle:true};Object.assign(e,t,e)}else if(e.filter?.values?.find((e=>e.dt==r))){const t=e.order.includes(i)||e.order.includes(n)?`${a.Samples} with SSM + CNV > SSM only`:`${a.Samples} with mutations`;const r={label:t,isOrdered:true,disabled:false,mayToggle:true};Object.assign(e,r,e)}else if(e.order.length==2&&e.order.includes(i)&&e.order.includes(n)){const t={label:`${a.Samples} with CNV only > without`,filter:{values:[{dt:s}]},by:"class",isOrdered:true,disabled:false,mayToggle:true};Object.assign(e,t,e)}}e.sortPriority=e.sortPriority.filter((e=>!e.toBeDeleted));return e}export{g as getMclassSorter,h as getSampleGroupSorter,o as getSampleSorter,b as getSortOptions,m as getTermSorter,v as reshapeSortPriority};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as t,P as e,d as a,z as i}from"./app-6fb77603.js";const n=`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split("");function r(r){const{controls:s,holder:l}=r;const o=s.parent;const d=structuredClone(o.config.settings.matrix);const p=d.controlLabels;const c=new t({padding:"",parent_menu:o.app.tip?.d.node()});let y=[],g,u={};const h={dom:{tip:c},opts:r,highlightColor:"none",label:`Sort ${p.Samples}`,title:`Set how to sort ${p.samples}`,type:"custom",expanded:r.expanded||false,expandedSection:r.expandedSection||"",init(t={},s={}){c.clear().hide();if(o.config.settings.matrix!=d)e(d,o.config.settings.matrix);if(d!==t)e(d,t);h.settings=d;h.activeOption=structuredClone(d.sortOptions[d.sortSamplesBy]);g=[{label:`For each selected row, sort ${p.samples} by matching data`,notDraggable:true,tiebreakers:[],handler:U},...h.activeOption.sortPriority,{label:`Sort ${p.samples} by name, alphabetically`,notDraggable:true,tiebreakers:[]}];Object.assign(r,s);r.holder.selectAll("*").remove();const l=r.holder.append("div").style("text-align","right");l.append("button").html("Apply").on("click",j);l.append("button").html("Reset").on("click",((t,e)=>h.init()));const u=r.holder.append("table");const $=u.append("thead");$.append("th").html("Priority").style("text-align","left").style("max-width","0px");$.append("th").html("Description");$.append("th").html("Action");let I=0,M=0;for(const t of g){const e=t.tiebreakers?.[0]?.order||t.handler;const r=u.append("thead").datum(t).property("draggable",!t.notDraggable).attr("droppable",true).on("dragstart",f).on("dragover",m).on("dragleave",x).on("drop",v);y.push(a(r));const s=r.append("tr").style("background-color","#eee").on("mouseover",V);s.append("th").style("padding","5px").style("vertical-align","top").style("font-weight",400).html(n[M++]).on("click",e?b:null);const l=s.append("th").style("padding","5px").style("vertical-align","top").style("text-align","left").style("cursor",e?"pointer":"").on("click",e?b:null);l.append("span").style("margin-right","12px").style("font-weight",400).html(t.label);s.append("th").style("padding","5px").style("vertical-align","top").style("text-align","center").style("font-weight",400).style("cursor",e?"pointer":"").append("span").html(e?"Details":" ").on("click",e?b:null);const o=u.append("tbody").datum(t).style("display",h.expandedSection=="all"||h.expandedSection==t.label?"":"none");for(const e of t.tiebreakers){if(e.skip)continue;if(!t.types?.includes("geneVariant")){continue}const a=o.append("tr").on("mouseover",V).datum(e).attr("draggable",!e.disabled&&t.types?.length!==0).attr("droppable",!e.disabled&&t.types?.length!==0).on("dragstart",k).on("dragover",O).on("dragleave",D).on("drop",A);if(!e.disabled)I++;const n=a.append("td").attr("title",e.disabled?`This tiebreaker is currently not being used to sort ${p.cases}. Check the box to use.`:`The number indicates the order in which this tiebreaker is used. Unched the box to skip.`).datum(e);n.style("padding","5px").style("vertical-align","top").style("text-align","center");n.append("span").html(!e.disabled?I:"");const r=a.append("td").style("opacity",e.disabled?.5:1).style("padding","5px").style("vertical-align","top").style("max-width","500px");r.append("span").html(e.label||"");if(!e.disabled){const t=r.append("label");t.append("span").html("<br>(use data list order ");if(!e.isOrdered)e.isOrdered=false;t.append("input").datum(e).attr("type","checkbox").property("checked",e.isOrdered).style("vertical-align","bottom").on("change",S);t.append("span").html(")");const a=e.order;r.append("div").attr("class","sjpp-matrix-sorter-ui-value").selectAll("div").data(a.map(((t,a)=>({lstName:"order",key:t,cls:i[t],tb:e,dragstart:P,dragover:w,dragleave:T,drop:_,filterByClass:d.filterByClass,index:a})))).enter().append("div").style("display",e.isOrdered?"block":"inline-block").each(C);if(e.notUsed?.length){const t=r.append("div");t.append("div").attr("data-testid","sjpp-matrix-sorter-ui-hidden-add").style("display","inline-block").style("padding","5x").style("vertical-align","top").style("padding","3px 5px").style("cursor","pointer").html(`+Add`).on("click",N)}}const s=a.append("td").style("text-align","center").style("vertical-align","top");if(e.mayToggle){s.append("button").datum(e).html(e.disabled?"Enable":"Disable").on("click",B)}}const c=o.append("tr").attr("draggable",true).on("mouseover",V);c.append("td").html(" ");const g=c.append("td").style("text-align","left").html(t.details&&!t.order?.length?t.details:" ");if(t.handler)t.handler(g,c,o);c.append("td").html(" ")}},toggleSection:b,trackDraggedSection:f,highlightSection:m,unhighlightSection:x,adjustSortPriority:v,trackDraggedTieBreaker:k,highlightTieBreaker:O,unhighlightTieBreaker:D,adjustTieBreakers:A,trackDraggedValue:P,highlightValue:w,unhighlightValue:T,adjustValueOrder:_,apply:j};function b(t,e={label:"all"}){h.expandedSection=h.expandedSection===e.label?"":e.label;h.expanded=!!h.expandedSection;h.init()}function f(t,e){u.type="sortPriority";u.data=e;u.index=h.activeOption.sortPriority.indexOf(e)}function m(t,e){if(u.type!="sortPriority"||e==u.data)return;t.preventDefault();const i=h.activeOption.sortPriority.indexOf(e);const n=i<u.index?"border-top":i>u.index?"border-bottom":"";if(!n)return;a(this).selectAll("th").style(n,"2px solid blue")}function x(t,e){if(u.type!="sortPriority")return;t.preventDefault();a(this).selectAll("th").style("border","none")}function v(t,e){if(e==u.data)return;const a=h.activeOption.sortPriority.indexOf(e);const i=o.config.settings.matrix;h.activeOption.sortPriority.splice(u.index,1);h.activeOption.sortPriority.splice(a,0,u.data);h.init({sortOptions:{[i.sortSamplesBy]:h.activeOption}})}function k(t,e){u.type="tiebreaker";u.data=e;u.sectionData=t.target.closest("tbody").__data__;u.priorityIndex=h.activeOption.sortPriority.indexOf(u.sectionData);u.index=u.sectionData.tiebreakers.indexOf(e)}function O(t,e){if(u.type!="tiebreaker"||e==u.data)return;t.preventDefault();const i=u.sectionData.tiebreakers.indexOf(e);const n=i<u.index?"border-top":i>u.index?"border-bottom":"";if(!n)return;a(this).selectAll("td:nth-child(2)").style(n,"2px solid blue")}function D(t,e){if(u.type!="tiebreaker")return;t.preventDefault();a(this).selectAll("td:nth-child(2)").style("border","none")}function S(t,e){t.stopPropagation();e.isOrdered=!e.isOrdered;h.init({sortOptions:{[d.sortSamplesBy]:h.activeOption}})}function B(t,e){t.stopPropagation();e.disabled=!e.disabled;h.init({sortOptions:{[d.sortSamplesBy]:h.activeOption}})}function A(t,e){if(u.type!="tiebreaker"||e==u.data)return;t.preventDefault();const a=u.sectionData.tiebreakers.indexOf(e);const i=o.config.settings.matrix;u.sectionData.tiebreakers.splice(u.index,1);u.sectionData.tiebreakers.splice(a,0,u.data);h.init({sortOptions:{[i.sortSamplesBy]:h.activeOption}})}function C(t){const e=[];if(t.tb.notUsed?.includes(t.key))e.push(`- Click on this label to include in used data values.`);if(t.filterByClass[t.key])e.unshift("- Click on the corresponding entry in the matrix legend or Mutation/CNV menus to unhide");if(e.length)e.unshift(`To use this data value for sorting ${p.samples}:`);t.tb.notUsed?.includes(t.key);const i=t.filterByClass[t.key]=="value"?.5:1;const n=a(this).attr("aria-label",e.length?e.join("\n"):`Click to not use this data value to sort ${p.samples}`).attr("draggable",t.tb.isOrdered?true:false).attr("droppable",t.tb.isOrdered?true:false).style("width","fit-content").style("margin-right","10px").style("overflow","hidden").style("white-space","nowrap").style("opacity",i).style("cursor","pointer").on("dragstart",t.dragstart).on("dragover",t.dragover).on("dragleave",t.dragleave).on("drop",t.drop).on("mouseenter",(()=>r.style("opacity",1))).on("mouseleave",(()=>r.style("opacity",0))).on("click",(()=>{if(e.length){const a="sjpp-matrix-sorter-value-note";n.selectAll(`.${a}`).remove();const i=n.append("div").attr("class",a).style("max-width","200px").style("padding","5px");i.html(e.join("<br>"));if(t.filterByClass[t.key])return}const a=t.lstName=="order"?"notUsed":"order";if(!t.tb[a])t.tb[a]=[];const i=t.tb[a];t.tb[t.lstName].splice(t.index,1);if(t.lstName=="order")i.unshift(t.key);else i.push(t.key);h.init({sortOptions:{[d.sortSamplesBy]:h.activeOption}})}));n.append("div").style("display","inline-block").style("cursor","pointer").style("width","12px").style("height","12px").style("margin-right","3px").style("background-color",t.cls.color);n.append("span").style("cursor","pointer").style("text-decoration",t.filterByClass[t.key]=="case"?"line-through":"").html(t.cls.label+(t.filterByClass[t.key]?" (<i>not used since this value is hidden</i>)":""));const r=n.append("div").style("display","inline-block").style("width","12px").style("cursor","pointer").style("opacity",0).style("color",t.lstName=="order"?"red":"green").html(t.lstName=="order"?"✗":"✓")}function P(t,e){t.stopPropagation?.();u.type="value";u.data=e;u.sectionData=t.target.closest("tbody").__data__;u.priorityIndex=h.activeOption.sortPriority.indexOf(u.sectionData);u.tiebreaker=t.target.closest("tr").__data__;u.tbIndex=u.sectionData.tiebreakers.indexOf(u.priorityIndex);u.order=u.tiebreaker.order}function w(t,e){t.stopPropagation?.();if(u.type!="value"||e==u.data)return;if(e.tb!=u.data.tb)return;t.preventDefault();u.order.indexOf(e);a(this).style("border","2px solid blue")}function T(t,e){t.stopPropagation?.();if(u.type!="value")return;t.preventDefault();a(this).style("border","none")}function _(t,e){t.stopPropagation?.();if(u.type!="value"||e==u.data)return;t.preventDefault();const a=h.settings;u.data.tb[u.data.lstName].splice(u.data.index,1);e.tb[e.lstName].splice(e.index,0,u.data.key);const i=a.hiddenVariants.indexOf(u.data.key);const n=structuredClone(a.hiddenVariants);const r=structuredClone(a.filterByClass);if(i!=-1){n.splice(i,1);r[u.data.key]=false}h.init({hiddenVariants:n,filterByClass:r,sortOptions:{[a.sortSamplesBy]:h.activeOption}})}function N(t,e){t?.stopPropagation();const a=c.clear().d.append("div").attr("data-testid","sjpp-matrix-sorter-ui-hidden-vals").style("margin-top","3px").style("vertical-align","top").style("padding-left","12px");a.selectAll("div").data(e.notUsed.map(((t,a)=>({lstName:"notUsed",key:t,cls:i[t],tb:e,dragstart:P,dragover:w,dragleave:T,drop:_,filterByClass:d.filterByClass,index:a})))).enter().append("div").style("display","block").each(C);c.showunder(t.target)}function j(){o.app.tip?.hide();o.app.dispatch({type:"plot_edit",id:o.id,config:{settings:{matrix:{sortOptions:{[d.sortSamplesBy]:h.activeOption}}}}})}function V(){}function U(t,e){if(!o.selectedTermsToSortAgainst?.length){t.html(`Click on a matrix row label and the left triangle to add an entry here`);return}const i=o.selectedTermsToSortAgainst.map((t=>({t:t,label:t.tw.term.name+(t.tw.term.type=="geneVariant"?" alterations":" values")})));const n=a(e.node().parentNode);n.selectAll("tr").remove();n.selectAll("tr").data(i).enter().append("tr").selectAll("td").data(((t,e)=>[{label:e+1,textAlign:"center",cursor:"",t:t.t},{label:t.label,textAlign:"left",cursor:""},{label:"Delete",textAlign:"center",cursor:"pointer",click:o.unsortSamplesAgainstTerm,data:t}])).enter().append("td").style("text-align",(t=>t.textAlign)).style("cursor",(t=>t.cursor)).html((t=>t.label)).on("click",((t,e)=>e.click?.(t,e)))}h.init();h.api={main:h.init,destroy:()=>{r.holder.selectAll("*").remove()}};if(r.debug)h.api.Inner=h;return h.api}export{r as getSorterUi};
|
|
1
|
+
import{M as t,P as e,d as a,z as i}from"./app-3d14cbe4.js";const n=`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split("");function r(r){const{controls:s,holder:l}=r;const o=s.parent;const d=structuredClone(o.config.settings.matrix);const p=d.controlLabels;const c=new t({padding:"",parent_menu:o.app.tip?.d.node()});let y=[],g,u={};const h={dom:{tip:c},opts:r,highlightColor:"none",label:`Sort ${p.Samples}`,title:`Set how to sort ${p.samples}`,type:"custom",expanded:r.expanded||false,expandedSection:r.expandedSection||"",init(t={},s={}){c.clear().hide();if(o.config.settings.matrix!=d)e(d,o.config.settings.matrix);if(d!==t)e(d,t);h.settings=d;h.activeOption=structuredClone(d.sortOptions[d.sortSamplesBy]);g=[{label:`For each selected row, sort ${p.samples} by matching data`,notDraggable:true,tiebreakers:[],handler:U},...h.activeOption.sortPriority,{label:`Sort ${p.samples} by name, alphabetically`,notDraggable:true,tiebreakers:[]}];Object.assign(r,s);r.holder.selectAll("*").remove();const l=r.holder.append("div").style("text-align","right");l.append("button").html("Apply").on("click",j);l.append("button").html("Reset").on("click",((t,e)=>h.init()));const u=r.holder.append("table");const $=u.append("thead");$.append("th").html("Priority").style("text-align","left").style("max-width","0px");$.append("th").html("Description");$.append("th").html("Action");let I=0,M=0;for(const t of g){const e=t.tiebreakers?.[0]?.order||t.handler;const r=u.append("thead").datum(t).property("draggable",!t.notDraggable).attr("droppable",true).on("dragstart",f).on("dragover",m).on("dragleave",x).on("drop",v);y.push(a(r));const s=r.append("tr").style("background-color","#eee").on("mouseover",V);s.append("th").style("padding","5px").style("vertical-align","top").style("font-weight",400).html(n[M++]).on("click",e?b:null);const l=s.append("th").style("padding","5px").style("vertical-align","top").style("text-align","left").style("cursor",e?"pointer":"").on("click",e?b:null);l.append("span").style("margin-right","12px").style("font-weight",400).html(t.label);s.append("th").style("padding","5px").style("vertical-align","top").style("text-align","center").style("font-weight",400).style("cursor",e?"pointer":"").append("span").html(e?"Details":" ").on("click",e?b:null);const o=u.append("tbody").datum(t).style("display",h.expandedSection=="all"||h.expandedSection==t.label?"":"none");for(const e of t.tiebreakers){if(e.skip)continue;if(!t.types?.includes("geneVariant")){continue}const a=o.append("tr").on("mouseover",V).datum(e).attr("draggable",!e.disabled&&t.types?.length!==0).attr("droppable",!e.disabled&&t.types?.length!==0).on("dragstart",k).on("dragover",O).on("dragleave",D).on("drop",A);if(!e.disabled)I++;const n=a.append("td").attr("title",e.disabled?`This tiebreaker is currently not being used to sort ${p.cases}. Check the box to use.`:`The number indicates the order in which this tiebreaker is used. Unched the box to skip.`).datum(e);n.style("padding","5px").style("vertical-align","top").style("text-align","center");n.append("span").html(!e.disabled?I:"");const r=a.append("td").style("opacity",e.disabled?.5:1).style("padding","5px").style("vertical-align","top").style("max-width","500px");r.append("span").html(e.label||"");if(!e.disabled){const t=r.append("label");t.append("span").html("<br>(use data list order ");if(!e.isOrdered)e.isOrdered=false;t.append("input").datum(e).attr("type","checkbox").property("checked",e.isOrdered).style("vertical-align","bottom").on("change",S);t.append("span").html(")");const a=e.order;r.append("div").attr("class","sjpp-matrix-sorter-ui-value").selectAll("div").data(a.map(((t,a)=>({lstName:"order",key:t,cls:i[t],tb:e,dragstart:P,dragover:w,dragleave:T,drop:_,filterByClass:d.filterByClass,index:a})))).enter().append("div").style("display",e.isOrdered?"block":"inline-block").each(C);if(e.notUsed?.length){const t=r.append("div");t.append("div").attr("data-testid","sjpp-matrix-sorter-ui-hidden-add").style("display","inline-block").style("padding","5x").style("vertical-align","top").style("padding","3px 5px").style("cursor","pointer").html(`+Add`).on("click",N)}}const s=a.append("td").style("text-align","center").style("vertical-align","top");if(e.mayToggle){s.append("button").datum(e).html(e.disabled?"Enable":"Disable").on("click",B)}}const c=o.append("tr").attr("draggable",true).on("mouseover",V);c.append("td").html(" ");const g=c.append("td").style("text-align","left").html(t.details&&!t.order?.length?t.details:" ");if(t.handler)t.handler(g,c,o);c.append("td").html(" ")}},toggleSection:b,trackDraggedSection:f,highlightSection:m,unhighlightSection:x,adjustSortPriority:v,trackDraggedTieBreaker:k,highlightTieBreaker:O,unhighlightTieBreaker:D,adjustTieBreakers:A,trackDraggedValue:P,highlightValue:w,unhighlightValue:T,adjustValueOrder:_,apply:j};function b(t,e={label:"all"}){h.expandedSection=h.expandedSection===e.label?"":e.label;h.expanded=!!h.expandedSection;h.init()}function f(t,e){u.type="sortPriority";u.data=e;u.index=h.activeOption.sortPriority.indexOf(e)}function m(t,e){if(u.type!="sortPriority"||e==u.data)return;t.preventDefault();const i=h.activeOption.sortPriority.indexOf(e);const n=i<u.index?"border-top":i>u.index?"border-bottom":"";if(!n)return;a(this).selectAll("th").style(n,"2px solid blue")}function x(t,e){if(u.type!="sortPriority")return;t.preventDefault();a(this).selectAll("th").style("border","none")}function v(t,e){if(e==u.data)return;const a=h.activeOption.sortPriority.indexOf(e);const i=o.config.settings.matrix;h.activeOption.sortPriority.splice(u.index,1);h.activeOption.sortPriority.splice(a,0,u.data);h.init({sortOptions:{[i.sortSamplesBy]:h.activeOption}})}function k(t,e){u.type="tiebreaker";u.data=e;u.sectionData=t.target.closest("tbody").__data__;u.priorityIndex=h.activeOption.sortPriority.indexOf(u.sectionData);u.index=u.sectionData.tiebreakers.indexOf(e)}function O(t,e){if(u.type!="tiebreaker"||e==u.data)return;t.preventDefault();const i=u.sectionData.tiebreakers.indexOf(e);const n=i<u.index?"border-top":i>u.index?"border-bottom":"";if(!n)return;a(this).selectAll("td:nth-child(2)").style(n,"2px solid blue")}function D(t,e){if(u.type!="tiebreaker")return;t.preventDefault();a(this).selectAll("td:nth-child(2)").style("border","none")}function S(t,e){t.stopPropagation();e.isOrdered=!e.isOrdered;h.init({sortOptions:{[d.sortSamplesBy]:h.activeOption}})}function B(t,e){t.stopPropagation();e.disabled=!e.disabled;h.init({sortOptions:{[d.sortSamplesBy]:h.activeOption}})}function A(t,e){if(u.type!="tiebreaker"||e==u.data)return;t.preventDefault();const a=u.sectionData.tiebreakers.indexOf(e);const i=o.config.settings.matrix;u.sectionData.tiebreakers.splice(u.index,1);u.sectionData.tiebreakers.splice(a,0,u.data);h.init({sortOptions:{[i.sortSamplesBy]:h.activeOption}})}function C(t){const e=[];if(t.tb.notUsed?.includes(t.key))e.push(`- Click on this label to include in used data values.`);if(t.filterByClass[t.key])e.unshift("- Click on the corresponding entry in the matrix legend or Mutation/CNV menus to unhide");if(e.length)e.unshift(`To use this data value for sorting ${p.samples}:`);t.tb.notUsed?.includes(t.key);const i=t.filterByClass[t.key]=="value"?.5:1;const n=a(this).attr("aria-label",e.length?e.join("\n"):`Click to not use this data value to sort ${p.samples}`).attr("draggable",t.tb.isOrdered?true:false).attr("droppable",t.tb.isOrdered?true:false).style("width","fit-content").style("margin-right","10px").style("overflow","hidden").style("white-space","nowrap").style("opacity",i).style("cursor","pointer").on("dragstart",t.dragstart).on("dragover",t.dragover).on("dragleave",t.dragleave).on("drop",t.drop).on("mouseenter",(()=>r.style("opacity",1))).on("mouseleave",(()=>r.style("opacity",0))).on("click",(()=>{if(e.length){const a="sjpp-matrix-sorter-value-note";n.selectAll(`.${a}`).remove();const i=n.append("div").attr("class",a).style("max-width","200px").style("padding","5px");i.html(e.join("<br>"));if(t.filterByClass[t.key])return}const a=t.lstName=="order"?"notUsed":"order";if(!t.tb[a])t.tb[a]=[];const i=t.tb[a];t.tb[t.lstName].splice(t.index,1);if(t.lstName=="order")i.unshift(t.key);else i.push(t.key);h.init({sortOptions:{[d.sortSamplesBy]:h.activeOption}})}));n.append("div").style("display","inline-block").style("cursor","pointer").style("width","12px").style("height","12px").style("margin-right","3px").style("background-color",t.cls.color);n.append("span").style("cursor","pointer").style("text-decoration",t.filterByClass[t.key]=="case"?"line-through":"").html(t.cls.label+(t.filterByClass[t.key]?" (<i>not used since this value is hidden</i>)":""));const r=n.append("div").style("display","inline-block").style("width","12px").style("cursor","pointer").style("opacity",0).style("color",t.lstName=="order"?"red":"green").html(t.lstName=="order"?"✗":"✓")}function P(t,e){t.stopPropagation?.();u.type="value";u.data=e;u.sectionData=t.target.closest("tbody").__data__;u.priorityIndex=h.activeOption.sortPriority.indexOf(u.sectionData);u.tiebreaker=t.target.closest("tr").__data__;u.tbIndex=u.sectionData.tiebreakers.indexOf(u.priorityIndex);u.order=u.tiebreaker.order}function w(t,e){t.stopPropagation?.();if(u.type!="value"||e==u.data)return;if(e.tb!=u.data.tb)return;t.preventDefault();u.order.indexOf(e);a(this).style("border","2px solid blue")}function T(t,e){t.stopPropagation?.();if(u.type!="value")return;t.preventDefault();a(this).style("border","none")}function _(t,e){t.stopPropagation?.();if(u.type!="value"||e==u.data)return;t.preventDefault();const a=h.settings;u.data.tb[u.data.lstName].splice(u.data.index,1);e.tb[e.lstName].splice(e.index,0,u.data.key);const i=a.hiddenVariants.indexOf(u.data.key);const n=structuredClone(a.hiddenVariants);const r=structuredClone(a.filterByClass);if(i!=-1){n.splice(i,1);r[u.data.key]=false}h.init({hiddenVariants:n,filterByClass:r,sortOptions:{[a.sortSamplesBy]:h.activeOption}})}function N(t,e){t?.stopPropagation();const a=c.clear().d.append("div").attr("data-testid","sjpp-matrix-sorter-ui-hidden-vals").style("margin-top","3px").style("vertical-align","top").style("padding-left","12px");a.selectAll("div").data(e.notUsed.map(((t,a)=>({lstName:"notUsed",key:t,cls:i[t],tb:e,dragstart:P,dragover:w,dragleave:T,drop:_,filterByClass:d.filterByClass,index:a})))).enter().append("div").style("display","block").each(C);c.showunder(t.target)}function j(){o.app.tip?.hide();o.app.dispatch({type:"plot_edit",id:o.id,config:{settings:{matrix:{sortOptions:{[d.sortSamplesBy]:h.activeOption}}}}})}function V(){}function U(t,e){if(!o.selectedTermsToSortAgainst?.length){t.html(`Click on a matrix row label and the left triangle to add an entry here`);return}const i=o.selectedTermsToSortAgainst.map((t=>({t:t,label:t.tw.term.name+(t.tw.term.type=="geneVariant"?" alterations":" values")})));const n=a(e.node().parentNode);n.selectAll("tr").remove();n.selectAll("tr").data(i).enter().append("tr").selectAll("td").data(((t,e)=>[{label:e+1,textAlign:"center",cursor:"",t:t.t},{label:t.label,textAlign:"left",cursor:""},{label:"Delete",textAlign:"center",cursor:"pointer",click:o.unsortSamplesAgainstTerm,data:t}])).enter().append("td").style("text-align",(t=>t.textAlign)).style("cursor",(t=>t.cursor)).html((t=>t.label)).on("click",((t,e)=>e.click?.(t,e)))}h.init();h.api={main:h.init,destroy:()=>{r.holder.selectAll("*").remove()}};if(r.debug)h.api.Inner=h;return h.api}export{r as getSorterUi};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as t,bn as e,bo as a,Z as n,j as l,U as o,I as r,ag as s,a9 as i,d as c,ah as d,f as p}from"./app-6fb77603.js";import{b as f}from"./block.lazyload-d2951c91.js";import{d as u}from"./lasso-1a02a545.js";import{b as g,a as m}from"./axis-747c801e.js";import"./drag-2e9c80bb.js";import"./nodrag-b2737073.js";import"./pointer-c7475677.js";const h="#ffa200";const v=new t;function x(t,e,a,n){if(!t.dataname){t.dataname="Differential expression"}if(t.input){const l=t.input;delete t.input;const o=y({genome:t.genome,filename:t.dataname,holder:a,tracks:t.tracks,hostURL:t.hostURL,jwt:n},l.trim().split("\n"));if(o){e("Error with diferential gene expressionn data: "+o)}return}let l;if(t.url){l=new Request(t.hostURL+"/urltextfile",{method:"POST",body:JSON.stringify({url:t.url,jwt:n})});delete t.url}else if(t.file){l=new Request(t.hostURL+"/textfile",{method:"POST",body:JSON.stringify({file:t.file,jwt:n})});delete t.file}else{e("neither .input nor .url given for MA-Volcano plot");return}const o=a.append("div").style("margin","20px").style("color","#aaa").style("font-size","1.5em").text("Loading differential gene expression data ...");fetch(l).then((t=>t.json())).then((e=>{if(e.error)throw{message:e.error};if(!e.text)throw{message:"no data loaded"};const l=y({genome:t.genome,filename:t.dataname,holder:a,tracks:t.tracks,hostURL:t.hostURL,jwt:n},e.text.trim().split("\n"));if(l)throw{message:"Error with differential gene expression data: "+l}})).catch((t=>{e(t.message);if(t.stack)console.log(t.stack)})).then((()=>{o.remove()}))}function b(t,n,l,o,r){let s,i,c,d,p,f;if(o!==undefined)[i,c,d,p,f]=e(o,t);else{[s,i,c,d,p,f]=a(100,100,t);s.header.text("Differential gene expression viewer");s.body.style("margin","10px")}i.append("div").style("margin-top","30px").style("color","#858585").html(`\n\t\t<p>Interactive MA and Volcano plot for exploring differentially expressed genes.</p>\n\t\t<a href=https://docs.google.com/document/d/1gEhywyMzMQRM10NFvsObw1yDSWxVY7pxYjsQ2-nd6x4/edit?usp=sharing target=_blank>File format</a>\n\t\t`);function u(t,e){p.style("color",e?"red":"black").text(t)}const g=()=>{d.selectAll("*").remove();const e=d.append("input").attr("type","file").on("change",(e=>{const a=e.target.files[0];if(!a){g();return}if(!a.size){u("Invalid file "+a.name);g();return}const i=new FileReader;i.onload=e=>{const i=c.options[c.selectedIndex].innerHTML;const d=y({genome:t[i],filename:a.name,hostURL:n,jwt:l,holder:o,sandbox_header:r},e.target.result.trim().split("\n"));if(d){u(d,1);g();return}if(s)s.pane.remove()};i.onerror=function(){u("Error reading file "+a.name,1);g();return};i.readAsText(a,"utf8")}));setTimeout((()=>e.node().focus()),1100)};g()}function y(t,e){if(t.tracks){for(const e of t.tracks){e.iscustom=true}}const[a,o]=k(e[0].trim());if(a){return a}t.hastvalue=o.includes("tvalue");const r=[];let s=0;let i=0;let c=0;for(let a=1;a<e.length;a++){const n=e[a];if(n=="")continue;if(n[0]=="#")continue;const l=n.trim().split("\t");const d={};for(let t=0;t<o.length;t++){d[o[t]]=l[t]}if(!d.gene){return"(line "+(a+1)+") missing gene"}d.gene=d.gene.replace(/"/g,"");if(!d.logfoldchange){return"(line "+(a+1)+") missing log fold change"}{const t=Number.parseFloat(d.logfoldchange);if(Number.isNaN(t)){c++;continue}d.logfoldchange=t}if(!d.averagevalue){return"(line "+(a+1)+") missing average value"}{const t=Number.parseFloat(d.averagevalue);if(Number.isNaN(t)){return"(line "+(a+1)+") invalid value for average value: "+d.averagevalue}d.averagevalue=t}if(!d.pvalue){s++;continue}else{const t=Number.parseFloat(d.pvalue);if(Number.isNaN(t)){s++;continue}d.pvalue=t}if(d.pvalueadj){const t=Number.parseFloat(d.pvalueadj);if(Number.isNaN(t)){i++;continue}d.pvalueadj=t}if(t.hastvalue){if(!d.tvalue){return"(line "+(a+1)+") missing T value"}{const t=Number.parseFloat(d.tvalue);if(Number.isNaN(t)){return"(line "+(a+1)+") invalid value for T value: "+d.tvalue}d.tvalue=t}}r.push(d)}if(r.length==0){return"No valid data"}if(t.holder==undefined){const e=n({x:100,y:100});e.header.text(t.filename);t.holder=e.body}else{t.holder.selectAll("*").remove();if(t.sandbox_header!==undefined)t.holder.append("div").html('<span style="opacity:.5;font-size:.7em">FILE: </span> '+t.filename)}t.data=r;if(c+s+i>0){const e=t.holder.append("div").style("width","800px");if(c){l(e,c+" lines dropped for invalid log fold change value")}if(s){l(e,s+" lines dropped for invalid P value")}if(i){l(e,i+" lines dropped for invalid adjusted P value")}}_(t);return null}function k(t){const e=t.toLowerCase().split("\t");const a=t.split("\t");if(a.length<=1){return["invalid file header"]}const n=(...t)=>{for(const a of t){const t=e.indexOf(a);if(t!=-1)return t}return-1};let l=n("gene");if(l==-1)return["gene missing from header"];a[l]="gene";l=n("logfc","log.foldchange");if(l==-1)return["log.foldchange missing from header"];a[l]="logfoldchange";l=n("aveexpr","average.value");if(l==-1)return["average.value missing from header"];a[l]="averagevalue";l=n("t","t.value");if(l!=-1){a[l]="tvalue"}l=n("p.value");if(l==-1)return["p.value missing from header"];a[l]="pvalue";l=n("p.value.adjusted","adj.p.val","adjustedp-value(fdr)");if(l!=-1){a[l]="pvalueadj"}return[null,a]}function _(t){if(t.hastvalue){let e=Math.abs(t.data[0].tvalue);let a=0;for(const n of t.data){const t=Math.abs(n.tvalue);e=Math.min(e,t);a=Math.max(a,t)}t.tvaluemin=e;t.tvaluemax=a}const e=t.holder.append("div").style("display","inline-block").style("vertical-align","top").style("margin","20px");const a=w(e,t);const n=t.holder.append("div").style("display","inline-block").style("vertical-align","top").style("margin","20px");const l=M(n,t);const r=t.holder.append("div").style("margin","20px");const s=r.append("textarea").style("display","inline-block").attr("rows",5).attr("cols",10).style("resize","both").attr("placeholder","Enter genes, separate by space or newline");const i=r.append("div").style("display","inline-block").style("margin-left","10px").style("vertical-align","top");i.append("button").style("display","block").text("Show gene labels").on("click",(e=>{const a=s.property("value").trim();if(a=="")return;const n=new Set;for(const t of a.split(/[\s\n\t]+/)){n.add(t.toUpperCase())}if(n.size==0)return;for(const e of t.data){if(!e.ma_label&&n.has(e.gene.toUpperCase())){A(e,t)}}}));i.append("button").style("display","block").text("Remove all labels").on("click",(e=>{for(const e of t.data){if(e.ma_label){A(e,t)}}}));i.append("div").style("margin-top","10px").style("color","#858585").style("font-size",".8em").html('<span style="font-size:1.3em">TIP:</span> click circles to toggle highlight on genes;<br>drag to move a gene label around.');const c=r.append("div").style("display","inline-block").style("margin-left","30px").style("vertical-align","top");c.append("button").text("Get MA plot").style("display","block").on("click",(t=>{o(a.node(),"MAplot")}));c.append("button").text("Get volcano plot").style("display","block").on("click",(t=>{o(l.node(),"Volcano")}))}function w(t,e){const a=[];let n=0,l=0;for(const t of e.data){n=Math.min(n,t.logfoldchange);l=Math.max(l,t.logfoldchange);a.push(t.averagevalue)}a.sort(((t,e)=>t-e));const o=a[0];const i=a[a.length-1];let c,d,p,f,u,v,x,b=50,y=50,k;const _=t.append("svg");const w=_.append("g");const M=_.append("g");const A=_.append("text").text("Average expression value").attr("fill","black").attr("text-anchor","middle");const E=_.append("text").text("log2(fold change)").attr("fill","black").attr("text-anchor","middle");e.ma_dotarea=_.append("g");const P=e.ma_dotarea.append("rect").attr("stroke","#ededed").attr("fill","none").attr("shape-rendering","crispEdges");const U=r().domain([o,i]);const z=r().domain([n,l]);let F;if(e.hastvalue){F=r().domain([e.tvaluemin,e.tvaluemax])}const S=e.ma_dotarea.selectAll().data(e.data).enter().append("g").each((function(t){t.ma_g=this}));const T=S.append("circle").attr("stroke","black").attr("stroke-opacity",.2).attr("stroke-width",1).attr("fill",h).attr("fill-opacity",0).each((function(t){t.ma_circle=this})).on("mouseover",N).on("mouseout",R).on("click",((t,a)=>{L(a,e,t.clientX,t.clientY)}));const I=e.ma_dotarea.append("line").attr("stroke","#ccc").attr("shape-rendering","crispEdges");const O=_.append("g");const Y=O.append("line").attr("stroke",h).attr("shape-rendering","crispEdges");const X=O.append("line").attr("stroke",h).attr("shape-rendering","crispEdges");const C=O.append("line").attr("stroke",h).attr("shape-rendering","crispEdges");const V=O.append("rect").attr("fill","white").attr("stroke",h).attr("shape-rendering","crispEdges");const D=O.append("line").attr("stroke",h).attr("shape-rendering","crispEdges");const q=a[Math.ceil(a.length*.05)];const J=a[Math.ceil(a.length*.95)];const G=a[Math.ceil(a.length*.25)];const Q=a[Math.ceil(a.length*.75)];const H=a[Math.ceil(a.length/2)];function W(t,a){p=t;f=a;c=Math.max(50,p/8);d=Math.max(50,f/8);k=Math.max(p,f)/80;const n=k*3;U.range([0,p]);z.range([f,0]);if(F)F.range([k,n]);T.each((t=>{t.ma_radius=F?F(Math.abs(t.tvalue)):k}));x=k*3;u=Math.max(n,p/50);v=Math.max(n,f/50);w.attr("transform","translate("+c+","+b+")");M.attr("transform","translate("+(c+u)+","+(b+f+v+x+v)+")");A.attr("x",c+u+p/2).attr("y",b+f+v+x+v+d-5);E.attr("transform","translate(15,"+(b+f/2)+") rotate(-90)");e.ma_dotarea.attr("transform","translate("+(c+u)+","+b+")");P.attr("width",p).attr("height",f);S.attr("transform",(t=>"translate("+U(t.averagevalue)+","+z(t.logfoldchange)+")"));T.attr("r",(t=>t.ma_radius));I.attr("x2",p).attr("y1",z(0)).attr("y2",z(0));O.attr("transform","translate("+(c+u)+","+(b+f+v)+")");const l=U(q),o=U(G),r=U(H),i=U(Q),h=U(J);X.attr("x1",l).attr("x2",l).attr("y2",x);C.attr("x1",h).attr("x2",h).attr("y2",x);D.attr("x1",r).attr("x2",r).attr("y2",x);V.attr("x",o).attr("width",i-o).attr("height",x);Y.attr("x1",l).attr("x2",h).attr("y1",x/2).attr("y2",x/2);_.attr("width",c+u+p+y).attr("height",b+f+v+x+v+d);s({axis:w.call(g().scale(z)),color:"black",showline:true});s({axis:M.call(m().scale(U)),color:"black",showline:true})}W(400,400);j(S.selectAll("circle"),_,"vo_circle");return _}function M(t,e){let a=0,n=0,l=0,o=0;for(const t of e.data){a=Math.min(a,t.logfoldchange);n=Math.max(n,t.logfoldchange);if(t.pvalue==0){continue}else{const e=-Math.log(t.pvalue,10);l=Math.min(l,e);o=Math.max(o,e)}}let i,c,d,p,f,u,v=50,x=50,b;const y=t.append("svg");const k=y.append("g");const _=y.append("g");const w=y.append("text").text("log2(fold change)").attr("fill","black").attr("text-anchor","middle");const M=y.append("text").text("-log(P value)").attr("fill","black").attr("text-anchor","middle");e.vo_dotarea=y.append("g");const A=e.vo_dotarea.append("rect").attr("stroke","#ededed").attr("fill","none").attr("shape-rendering","crispEdges");const E=r().domain([a,n]);const P=r().domain([l,o]);let U;if(e.hastvalue)U=r().domain([e.tvaluemin,e.tvaluemax]);const z=e.vo_dotarea.selectAll().data(e.data).enter().append("g").each((function(t){t.vo_g=this}));const F=z.append("circle").attr("stroke","black").attr("stroke-opacity",.2).attr("stroke-width",1).attr("fill",h).attr("fill-opacity",0).each((function(t){t.vo_circle=this})).on("mouseover",N).on("mouseout",R).on("click",((t,a)=>{L(a,e,t.clientX,t.clientY)}));const S=e.vo_dotarea.append("line").attr("stroke","#ccc").attr("shape-rendering","crispEdges");function T(t,a){d=t;p=a;i=Math.max(50,d/8);c=Math.max(50,p/8);b=Math.max(d,p)/80;const n=b*3;if(U)U.range([b,n]);F.each((t=>{t.vo_radius=U?U(Math.abs(t.tvalue)):b}));f=Math.max(n,d/50);u=Math.max(n,p/50);k.attr("transform","translate("+i+","+v+")");_.attr("transform","translate("+(i+f)+","+(v+p+u)+")");w.attr("x",i+f+d/2).attr("y",v+p+u+c-5);M.attr("transform","translate(15,"+(v+p/2)+") rotate(-90)");e.vo_dotarea.attr("transform","translate("+(i+f)+","+v+")");A.attr("width",d).attr("height",p);E.range([0,d]);P.range([p,0]);z.attr("transform",(t=>"translate("+E(t.logfoldchange)+","+P(t.pvalue==0?o:-Math.log(t.pvalue,10))+")"));F.attr("r",(t=>t.vo_radius));S.attr("x1",E(0)).attr("x2",E(0)).attr("y2",p);y.attr("width",i+f+d+x).attr("height",v+p+u+c);s({axis:k.call(g().scale(P)),color:"black",showline:true});s({axis:_.call(m().scale(E)),color:"black",showline:true})}T(400,400);if(e.data[0].pvalueadj!=undefined){const a=t.append("div").style("margin","20px");a.append("span").text("Select P value for Volcano plot:");const n=a.append("select").style("margin-left","5px").on("change",(t=>{l=0;o=0;const a=n.node().selectedIndex==0;for(const t of e.data){const e=a?t.pvalue:t.pvalueadj;if(e==0)continue;const n=-Math.log(e,10);l=Math.min(l,n);o=Math.max(o,n)}P.domain([l,o]);s({axis:k.call(g().scale(P)),color:"black",showline:true});z.attr("transform",(t=>{const e=a?t.pvalue:t.pvalueadj;return"translate("+E(t.logfoldchange)+","+P(e==0?o:-Math.log(e,10))+")"}));M.text(a?"-log(P value)":"-log(adjusted P value)")}));n.append("option").text("Unadjusted P value");n.append("option").text("Adjusted P value")}j(z.selectAll("circle"),y,"ma_circle");return y}function j(t,e,a){const n=u().items(t).targetArea(e);function l(){e.selectAll(".possible").style("fill-opacity",0).classed("not_possible",true).classed("selected",false).each((t=>{c(t[a]).attr("fill-opacity",0)}))}function o(){n.possibleItems().style("fill-opacity",.9).classed("not_possible",false).classed("possible",true).each((t=>{c(t[a]).attr("fill-opacity",.9)}))}function r(){}n.on("start",l).on("draw",o).on("end",r);e.call(n)}function N(t,e){v.clear().show(t.clientX,t.clientY);const a=[{k:"gene",v:e.gene},{k:"average value",v:e.averagevalue},{k:"log fold change",v:e.logfoldchange},{k:"P value",v:e.pvalue}];if(e.pvalueadj!=undefined){a.push({k:"adjusted P value",v:e.pvalueadj})}if(e.tvalue!=undefined){a.push({k:"T value",v:e.tvalue})}for(const t in e){if(t=="gene"||t=="averagevalue"||t=="logfoldchange"||t=="pvalue"||t=="pvalueadj"||t=="tvalue"){continue}const n=e[t];if(typeof n!="string"){continue}a.push({k:t,v:n})}i(v.d,a);if(!e.ma_label){c(e.ma_circle).attr("fill-opacity",.9);c(e.vo_circle).attr("fill-opacity",.9)}}function R(t,e){v.hide();if(!e.ma_label){c(e.ma_circle).attr("fill-opacity",0);c(e.vo_circle).attr("fill-opacity",0)}}function A(t,e){if(t.ma_label){t.ma_label.remove();t.ma_labelbg.remove();t.ma_label=null;t.vo_label.remove();t.vo_labelbg.remove();t.vo_label=null;c(t.ma_circle).attr("fill-opacity",0);c(t.vo_circle).attr("fill-opacity",0);return}e.ma_dotarea.node().appendChild(t.ma_g);t.ma_labelbg=c(t.ma_g).append("text").text(t.gene).attr("x",t.ma_radius+5).attr("y",0).attr("dominant-baseline","central").attr("font-size",14).attr("font-family",d).attr("fill","none").attr("stroke","white").attr("stroke-width",3);t.ma_label=c(t.ma_g).append("text").text(t.gene).attr("x",t.ma_radius+5).attr("y",0).attr("dominant-baseline","central").attr("font-size",14).attr("fill","black").attr("font-family",d).on("mousedown",((t,e)=>{E(e.ma_label,e.ma_labelbg,t)}));e.vo_dotarea.node().appendChild(t.vo_g);t.vo_labelbg=c(t.vo_g).append("text").text(t.gene).attr("x",t.vo_radius+5).attr("y",0).attr("dominant-baseline","central").attr("font-size",14).attr("font-family",d).attr("fill","none").attr("stroke","white").attr("stroke-width",3);t.vo_label=c(t.vo_g).append("text").text(t.gene).attr("x",t.vo_radius+5).attr("y",0).attr("dominant-baseline","central").attr("font-size",14).attr("fill","black").attr("font-family",d).on("mousedown",((t,e)=>{E(e.vo_label,e.vo_labelbg,t)}));c(t.ma_circle).attr("fill-opacity",.8);c(t.vo_circle).attr("fill-opacity",.8)}function E(t,e,a){event.preventDefault();const n=Number.parseFloat(t.attr("x"));const l=Number.parseFloat(t.attr("y"));const o=a.clientX;const r=a.clientY;const s=c(document.body);s.on("mousemove",(a=>{t.attr("x",n+a.clientX-o).attr("y",l+a.clientY-r);e.attr("x",n+a.clientX-o).attr("y",l+a.clientY-r)})).on("mouseup",(t=>{s.on("mousemove",null).on("mouseup",null)}))}function L(t,e,a,l){if(e.tracks){if(!t.ma_label){const o=n({x:a+20,y:l-50});o.header.text(t.gene);P(e,t.gene,o.body)}}A(t,e)}function P(t,e,a){fetch(new Request(t.hostURL+"/genelookup",{method:"POST",body:JSON.stringify({deep:1,input:e,genome:t.genome.name,jwt:t.jwt})})).then((t=>t.json())).then((n=>{if(n.error)throw{message:n.error};if(!n.gmlst||n.gmlst.length==0)throw{message:"No genes can be found for "+e};const l=new Map;for(const t of n.gmlst){if(!l.has(t.chr)){l.set(t.chr,{chr:t.chr,start:t.start,stop:t.stop})}l.get(t.chr).start=Math.min(t.start,l.get(t.chr).start);l.get(t.chr).stop=Math.max(t.stop,l.get(t.chr).stop)}const o=[...l][0][1];const r=[...t.tracks];p(t.genome,r);f({holder:a,hostURL:t.hostURL,jwt:t.jwt,genome:t.genome,chr:o.chr,start:o.start,stop:o.stop,tklst:r,nobox:true})})).catch((t=>{l(a,t.message);if(t.stack)console.log(t.stack)}))}export{x as mavbparseinput,b as mavbui};
|
|
1
|
+
import{M as t,bn as e,bo as a,Z as n,j as l,U as o,I as r,ag as s,a9 as i,d as c,ah as d,f as p}from"./app-3d14cbe4.js";import{b as f}from"./block.lazyload-4c4e81ff.js";import{d as u}from"./lasso-845446b8.js";import{b as g,a as m}from"./axis-747c801e.js";import"./drag-e11d6644.js";import"./nodrag-f6c0801c.js";import"./pointer-c7475677.js";const h="#ffa200";const v=new t;function x(t,e,a,n){if(!t.dataname){t.dataname="Differential expression"}if(t.input){const l=t.input;delete t.input;const o=y({genome:t.genome,filename:t.dataname,holder:a,tracks:t.tracks,hostURL:t.hostURL,jwt:n},l.trim().split("\n"));if(o){e("Error with diferential gene expressionn data: "+o)}return}let l;if(t.url){l=new Request(t.hostURL+"/urltextfile",{method:"POST",body:JSON.stringify({url:t.url,jwt:n})});delete t.url}else if(t.file){l=new Request(t.hostURL+"/textfile",{method:"POST",body:JSON.stringify({file:t.file,jwt:n})});delete t.file}else{e("neither .input nor .url given for MA-Volcano plot");return}const o=a.append("div").style("margin","20px").style("color","#aaa").style("font-size","1.5em").text("Loading differential gene expression data ...");fetch(l).then((t=>t.json())).then((e=>{if(e.error)throw{message:e.error};if(!e.text)throw{message:"no data loaded"};const l=y({genome:t.genome,filename:t.dataname,holder:a,tracks:t.tracks,hostURL:t.hostURL,jwt:n},e.text.trim().split("\n"));if(l)throw{message:"Error with differential gene expression data: "+l}})).catch((t=>{e(t.message);if(t.stack)console.log(t.stack)})).then((()=>{o.remove()}))}function b(t,n,l,o,r){let s,i,c,d,p,f;if(o!==undefined)[i,c,d,p,f]=e(o,t);else{[s,i,c,d,p,f]=a(100,100,t);s.header.text("Differential gene expression viewer");s.body.style("margin","10px")}i.append("div").style("margin-top","30px").style("color","#858585").html(`\n\t\t<p>Interactive MA and Volcano plot for exploring differentially expressed genes.</p>\n\t\t<a href=https://docs.google.com/document/d/1gEhywyMzMQRM10NFvsObw1yDSWxVY7pxYjsQ2-nd6x4/edit?usp=sharing target=_blank>File format</a>\n\t\t`);function u(t,e){p.style("color",e?"red":"black").text(t)}const g=()=>{d.selectAll("*").remove();const e=d.append("input").attr("type","file").on("change",(e=>{const a=e.target.files[0];if(!a){g();return}if(!a.size){u("Invalid file "+a.name);g();return}const i=new FileReader;i.onload=e=>{const i=c.options[c.selectedIndex].innerHTML;const d=y({genome:t[i],filename:a.name,hostURL:n,jwt:l,holder:o,sandbox_header:r},e.target.result.trim().split("\n"));if(d){u(d,1);g();return}if(s)s.pane.remove()};i.onerror=function(){u("Error reading file "+a.name,1);g();return};i.readAsText(a,"utf8")}));setTimeout((()=>e.node().focus()),1100)};g()}function y(t,e){if(t.tracks){for(const e of t.tracks){e.iscustom=true}}const[a,o]=k(e[0].trim());if(a){return a}t.hastvalue=o.includes("tvalue");const r=[];let s=0;let i=0;let c=0;for(let a=1;a<e.length;a++){const n=e[a];if(n=="")continue;if(n[0]=="#")continue;const l=n.trim().split("\t");const d={};for(let t=0;t<o.length;t++){d[o[t]]=l[t]}if(!d.gene){return"(line "+(a+1)+") missing gene"}d.gene=d.gene.replace(/"/g,"");if(!d.logfoldchange){return"(line "+(a+1)+") missing log fold change"}{const t=Number.parseFloat(d.logfoldchange);if(Number.isNaN(t)){c++;continue}d.logfoldchange=t}if(!d.averagevalue){return"(line "+(a+1)+") missing average value"}{const t=Number.parseFloat(d.averagevalue);if(Number.isNaN(t)){return"(line "+(a+1)+") invalid value for average value: "+d.averagevalue}d.averagevalue=t}if(!d.pvalue){s++;continue}else{const t=Number.parseFloat(d.pvalue);if(Number.isNaN(t)){s++;continue}d.pvalue=t}if(d.pvalueadj){const t=Number.parseFloat(d.pvalueadj);if(Number.isNaN(t)){i++;continue}d.pvalueadj=t}if(t.hastvalue){if(!d.tvalue){return"(line "+(a+1)+") missing T value"}{const t=Number.parseFloat(d.tvalue);if(Number.isNaN(t)){return"(line "+(a+1)+") invalid value for T value: "+d.tvalue}d.tvalue=t}}r.push(d)}if(r.length==0){return"No valid data"}if(t.holder==undefined){const e=n({x:100,y:100});e.header.text(t.filename);t.holder=e.body}else{t.holder.selectAll("*").remove();if(t.sandbox_header!==undefined)t.holder.append("div").html('<span style="opacity:.5;font-size:.7em">FILE: </span> '+t.filename)}t.data=r;if(c+s+i>0){const e=t.holder.append("div").style("width","800px");if(c){l(e,c+" lines dropped for invalid log fold change value")}if(s){l(e,s+" lines dropped for invalid P value")}if(i){l(e,i+" lines dropped for invalid adjusted P value")}}_(t);return null}function k(t){const e=t.toLowerCase().split("\t");const a=t.split("\t");if(a.length<=1){return["invalid file header"]}const n=(...t)=>{for(const a of t){const t=e.indexOf(a);if(t!=-1)return t}return-1};let l=n("gene");if(l==-1)return["gene missing from header"];a[l]="gene";l=n("logfc","log.foldchange");if(l==-1)return["log.foldchange missing from header"];a[l]="logfoldchange";l=n("aveexpr","average.value");if(l==-1)return["average.value missing from header"];a[l]="averagevalue";l=n("t","t.value");if(l!=-1){a[l]="tvalue"}l=n("p.value");if(l==-1)return["p.value missing from header"];a[l]="pvalue";l=n("p.value.adjusted","adj.p.val","adjustedp-value(fdr)");if(l!=-1){a[l]="pvalueadj"}return[null,a]}function _(t){if(t.hastvalue){let e=Math.abs(t.data[0].tvalue);let a=0;for(const n of t.data){const t=Math.abs(n.tvalue);e=Math.min(e,t);a=Math.max(a,t)}t.tvaluemin=e;t.tvaluemax=a}const e=t.holder.append("div").style("display","inline-block").style("vertical-align","top").style("margin","20px");const a=w(e,t);const n=t.holder.append("div").style("display","inline-block").style("vertical-align","top").style("margin","20px");const l=M(n,t);const r=t.holder.append("div").style("margin","20px");const s=r.append("textarea").style("display","inline-block").attr("rows",5).attr("cols",10).style("resize","both").attr("placeholder","Enter genes, separate by space or newline");const i=r.append("div").style("display","inline-block").style("margin-left","10px").style("vertical-align","top");i.append("button").style("display","block").text("Show gene labels").on("click",(e=>{const a=s.property("value").trim();if(a=="")return;const n=new Set;for(const t of a.split(/[\s\n\t]+/)){n.add(t.toUpperCase())}if(n.size==0)return;for(const e of t.data){if(!e.ma_label&&n.has(e.gene.toUpperCase())){A(e,t)}}}));i.append("button").style("display","block").text("Remove all labels").on("click",(e=>{for(const e of t.data){if(e.ma_label){A(e,t)}}}));i.append("div").style("margin-top","10px").style("color","#858585").style("font-size",".8em").html('<span style="font-size:1.3em">TIP:</span> click circles to toggle highlight on genes;<br>drag to move a gene label around.');const c=r.append("div").style("display","inline-block").style("margin-left","30px").style("vertical-align","top");c.append("button").text("Get MA plot").style("display","block").on("click",(t=>{o(a.node(),"MAplot")}));c.append("button").text("Get volcano plot").style("display","block").on("click",(t=>{o(l.node(),"Volcano")}))}function w(t,e){const a=[];let n=0,l=0;for(const t of e.data){n=Math.min(n,t.logfoldchange);l=Math.max(l,t.logfoldchange);a.push(t.averagevalue)}a.sort(((t,e)=>t-e));const o=a[0];const i=a[a.length-1];let c,d,p,f,u,v,x,b=50,y=50,k;const _=t.append("svg");const w=_.append("g");const M=_.append("g");const A=_.append("text").text("Average expression value").attr("fill","black").attr("text-anchor","middle");const E=_.append("text").text("log2(fold change)").attr("fill","black").attr("text-anchor","middle");e.ma_dotarea=_.append("g");const P=e.ma_dotarea.append("rect").attr("stroke","#ededed").attr("fill","none").attr("shape-rendering","crispEdges");const U=r().domain([o,i]);const z=r().domain([n,l]);let F;if(e.hastvalue){F=r().domain([e.tvaluemin,e.tvaluemax])}const S=e.ma_dotarea.selectAll().data(e.data).enter().append("g").each((function(t){t.ma_g=this}));const T=S.append("circle").attr("stroke","black").attr("stroke-opacity",.2).attr("stroke-width",1).attr("fill",h).attr("fill-opacity",0).each((function(t){t.ma_circle=this})).on("mouseover",N).on("mouseout",R).on("click",((t,a)=>{L(a,e,t.clientX,t.clientY)}));const I=e.ma_dotarea.append("line").attr("stroke","#ccc").attr("shape-rendering","crispEdges");const O=_.append("g");const Y=O.append("line").attr("stroke",h).attr("shape-rendering","crispEdges");const X=O.append("line").attr("stroke",h).attr("shape-rendering","crispEdges");const C=O.append("line").attr("stroke",h).attr("shape-rendering","crispEdges");const V=O.append("rect").attr("fill","white").attr("stroke",h).attr("shape-rendering","crispEdges");const D=O.append("line").attr("stroke",h).attr("shape-rendering","crispEdges");const q=a[Math.ceil(a.length*.05)];const J=a[Math.ceil(a.length*.95)];const G=a[Math.ceil(a.length*.25)];const Q=a[Math.ceil(a.length*.75)];const H=a[Math.ceil(a.length/2)];function W(t,a){p=t;f=a;c=Math.max(50,p/8);d=Math.max(50,f/8);k=Math.max(p,f)/80;const n=k*3;U.range([0,p]);z.range([f,0]);if(F)F.range([k,n]);T.each((t=>{t.ma_radius=F?F(Math.abs(t.tvalue)):k}));x=k*3;u=Math.max(n,p/50);v=Math.max(n,f/50);w.attr("transform","translate("+c+","+b+")");M.attr("transform","translate("+(c+u)+","+(b+f+v+x+v)+")");A.attr("x",c+u+p/2).attr("y",b+f+v+x+v+d-5);E.attr("transform","translate(15,"+(b+f/2)+") rotate(-90)");e.ma_dotarea.attr("transform","translate("+(c+u)+","+b+")");P.attr("width",p).attr("height",f);S.attr("transform",(t=>"translate("+U(t.averagevalue)+","+z(t.logfoldchange)+")"));T.attr("r",(t=>t.ma_radius));I.attr("x2",p).attr("y1",z(0)).attr("y2",z(0));O.attr("transform","translate("+(c+u)+","+(b+f+v)+")");const l=U(q),o=U(G),r=U(H),i=U(Q),h=U(J);X.attr("x1",l).attr("x2",l).attr("y2",x);C.attr("x1",h).attr("x2",h).attr("y2",x);D.attr("x1",r).attr("x2",r).attr("y2",x);V.attr("x",o).attr("width",i-o).attr("height",x);Y.attr("x1",l).attr("x2",h).attr("y1",x/2).attr("y2",x/2);_.attr("width",c+u+p+y).attr("height",b+f+v+x+v+d);s({axis:w.call(g().scale(z)),color:"black",showline:true});s({axis:M.call(m().scale(U)),color:"black",showline:true})}W(400,400);j(S.selectAll("circle"),_,"vo_circle");return _}function M(t,e){let a=0,n=0,l=0,o=0;for(const t of e.data){a=Math.min(a,t.logfoldchange);n=Math.max(n,t.logfoldchange);if(t.pvalue==0){continue}else{const e=-Math.log(t.pvalue,10);l=Math.min(l,e);o=Math.max(o,e)}}let i,c,d,p,f,u,v=50,x=50,b;const y=t.append("svg");const k=y.append("g");const _=y.append("g");const w=y.append("text").text("log2(fold change)").attr("fill","black").attr("text-anchor","middle");const M=y.append("text").text("-log(P value)").attr("fill","black").attr("text-anchor","middle");e.vo_dotarea=y.append("g");const A=e.vo_dotarea.append("rect").attr("stroke","#ededed").attr("fill","none").attr("shape-rendering","crispEdges");const E=r().domain([a,n]);const P=r().domain([l,o]);let U;if(e.hastvalue)U=r().domain([e.tvaluemin,e.tvaluemax]);const z=e.vo_dotarea.selectAll().data(e.data).enter().append("g").each((function(t){t.vo_g=this}));const F=z.append("circle").attr("stroke","black").attr("stroke-opacity",.2).attr("stroke-width",1).attr("fill",h).attr("fill-opacity",0).each((function(t){t.vo_circle=this})).on("mouseover",N).on("mouseout",R).on("click",((t,a)=>{L(a,e,t.clientX,t.clientY)}));const S=e.vo_dotarea.append("line").attr("stroke","#ccc").attr("shape-rendering","crispEdges");function T(t,a){d=t;p=a;i=Math.max(50,d/8);c=Math.max(50,p/8);b=Math.max(d,p)/80;const n=b*3;if(U)U.range([b,n]);F.each((t=>{t.vo_radius=U?U(Math.abs(t.tvalue)):b}));f=Math.max(n,d/50);u=Math.max(n,p/50);k.attr("transform","translate("+i+","+v+")");_.attr("transform","translate("+(i+f)+","+(v+p+u)+")");w.attr("x",i+f+d/2).attr("y",v+p+u+c-5);M.attr("transform","translate(15,"+(v+p/2)+") rotate(-90)");e.vo_dotarea.attr("transform","translate("+(i+f)+","+v+")");A.attr("width",d).attr("height",p);E.range([0,d]);P.range([p,0]);z.attr("transform",(t=>"translate("+E(t.logfoldchange)+","+P(t.pvalue==0?o:-Math.log(t.pvalue,10))+")"));F.attr("r",(t=>t.vo_radius));S.attr("x1",E(0)).attr("x2",E(0)).attr("y2",p);y.attr("width",i+f+d+x).attr("height",v+p+u+c);s({axis:k.call(g().scale(P)),color:"black",showline:true});s({axis:_.call(m().scale(E)),color:"black",showline:true})}T(400,400);if(e.data[0].pvalueadj!=undefined){const a=t.append("div").style("margin","20px");a.append("span").text("Select P value for Volcano plot:");const n=a.append("select").style("margin-left","5px").on("change",(t=>{l=0;o=0;const a=n.node().selectedIndex==0;for(const t of e.data){const e=a?t.pvalue:t.pvalueadj;if(e==0)continue;const n=-Math.log(e,10);l=Math.min(l,n);o=Math.max(o,n)}P.domain([l,o]);s({axis:k.call(g().scale(P)),color:"black",showline:true});z.attr("transform",(t=>{const e=a?t.pvalue:t.pvalueadj;return"translate("+E(t.logfoldchange)+","+P(e==0?o:-Math.log(e,10))+")"}));M.text(a?"-log(P value)":"-log(adjusted P value)")}));n.append("option").text("Unadjusted P value");n.append("option").text("Adjusted P value")}j(z.selectAll("circle"),y,"ma_circle");return y}function j(t,e,a){const n=u().items(t).targetArea(e);function l(){e.selectAll(".possible").style("fill-opacity",0).classed("not_possible",true).classed("selected",false).each((t=>{c(t[a]).attr("fill-opacity",0)}))}function o(){n.possibleItems().style("fill-opacity",.9).classed("not_possible",false).classed("possible",true).each((t=>{c(t[a]).attr("fill-opacity",.9)}))}function r(){}n.on("start",l).on("draw",o).on("end",r);e.call(n)}function N(t,e){v.clear().show(t.clientX,t.clientY);const a=[{k:"gene",v:e.gene},{k:"average value",v:e.averagevalue},{k:"log fold change",v:e.logfoldchange},{k:"P value",v:e.pvalue}];if(e.pvalueadj!=undefined){a.push({k:"adjusted P value",v:e.pvalueadj})}if(e.tvalue!=undefined){a.push({k:"T value",v:e.tvalue})}for(const t in e){if(t=="gene"||t=="averagevalue"||t=="logfoldchange"||t=="pvalue"||t=="pvalueadj"||t=="tvalue"){continue}const n=e[t];if(typeof n!="string"){continue}a.push({k:t,v:n})}i(v.d,a);if(!e.ma_label){c(e.ma_circle).attr("fill-opacity",.9);c(e.vo_circle).attr("fill-opacity",.9)}}function R(t,e){v.hide();if(!e.ma_label){c(e.ma_circle).attr("fill-opacity",0);c(e.vo_circle).attr("fill-opacity",0)}}function A(t,e){if(t.ma_label){t.ma_label.remove();t.ma_labelbg.remove();t.ma_label=null;t.vo_label.remove();t.vo_labelbg.remove();t.vo_label=null;c(t.ma_circle).attr("fill-opacity",0);c(t.vo_circle).attr("fill-opacity",0);return}e.ma_dotarea.node().appendChild(t.ma_g);t.ma_labelbg=c(t.ma_g).append("text").text(t.gene).attr("x",t.ma_radius+5).attr("y",0).attr("dominant-baseline","central").attr("font-size",14).attr("font-family",d).attr("fill","none").attr("stroke","white").attr("stroke-width",3);t.ma_label=c(t.ma_g).append("text").text(t.gene).attr("x",t.ma_radius+5).attr("y",0).attr("dominant-baseline","central").attr("font-size",14).attr("fill","black").attr("font-family",d).on("mousedown",((t,e)=>{E(e.ma_label,e.ma_labelbg,t)}));e.vo_dotarea.node().appendChild(t.vo_g);t.vo_labelbg=c(t.vo_g).append("text").text(t.gene).attr("x",t.vo_radius+5).attr("y",0).attr("dominant-baseline","central").attr("font-size",14).attr("font-family",d).attr("fill","none").attr("stroke","white").attr("stroke-width",3);t.vo_label=c(t.vo_g).append("text").text(t.gene).attr("x",t.vo_radius+5).attr("y",0).attr("dominant-baseline","central").attr("font-size",14).attr("fill","black").attr("font-family",d).on("mousedown",((t,e)=>{E(e.vo_label,e.vo_labelbg,t)}));c(t.ma_circle).attr("fill-opacity",.8);c(t.vo_circle).attr("fill-opacity",.8)}function E(t,e,a){event.preventDefault();const n=Number.parseFloat(t.attr("x"));const l=Number.parseFloat(t.attr("y"));const o=a.clientX;const r=a.clientY;const s=c(document.body);s.on("mousemove",(a=>{t.attr("x",n+a.clientX-o).attr("y",l+a.clientY-r);e.attr("x",n+a.clientX-o).attr("y",l+a.clientY-r)})).on("mouseup",(t=>{s.on("mousemove",null).on("mouseup",null)}))}function L(t,e,a,l){if(e.tracks){if(!t.ma_label){const o=n({x:a+20,y:l-50});o.header.text(t.gene);P(e,t.gene,o.body)}}A(t,e)}function P(t,e,a){fetch(new Request(t.hostURL+"/genelookup",{method:"POST",body:JSON.stringify({deep:1,input:e,genome:t.genome.name,jwt:t.jwt})})).then((t=>t.json())).then((n=>{if(n.error)throw{message:n.error};if(!n.gmlst||n.gmlst.length==0)throw{message:"No genes can be found for "+e};const l=new Map;for(const t of n.gmlst){if(!l.has(t.chr)){l.set(t.chr,{chr:t.chr,start:t.start,stop:t.stop})}l.get(t.chr).start=Math.min(t.start,l.get(t.chr).start);l.get(t.chr).stop=Math.max(t.stop,l.get(t.chr).stop)}const o=[...l][0][1];const r=[...t.tracks];p(t.genome,r);f({holder:a,hostURL:t.hostURL,jwt:t.jwt,genome:t.genome,chr:o.chr,start:o.start,stop:o.stop,tklst:r,nobox:true})})).catch((t=>{l(a,t.message);if(t.stack)console.log(t.stack)}))}export{x as mavbparseinput,b as mavbui};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as t,k as e,p as a,q as n,ah as r,a9 as o,ag as i,I as s,w as l}from"./app-6fb77603.js";import{c as p}from"./axis-747c801e.js";const f=80;const c=5;async function d(t){window.obj=t;t.errdiv=t.div.append("div");try{g(t);await h(t)}catch(e){t.errdiv.text(e.message||e);if(e.stack)console.log(e.stack)}}function g(a){a.motifrowheight=16;a.gaincolor="red";a.losscolor="blue";a.flankspan=15;if(!a.fimo_thresh)a.fimo_thresh=.001;if(!a.minabslogp)a.minabslogp=1;a.tip=new t;const n=a.div.append("table").style("border-spacing","3px").style("border-collapse","separate").style("margin","10px");{const t=n.append("tr");t.append("td").text("Flanking sequence (#nt)");const r=t.append("td");r.append("input").attr("type","number").style("margin","0px 10px").style("width","100px").property("value",a.flankspan).on("keyup",(t=>{if(!e(t))return;const n=Number.parseInt(t.target.value);if(n<10){window.alert("Enter integer above 10");return}if(n==a.flankspan)return;a.flankspan=n;h(a)}));r.append("span").style("font-size","0.7em").style("opacity",.5).text("Press ENTER to update")}{const t=n.append("tr");t.append("td").text("P-value cutoff");const r=t.append("td");r.append("input").attr("type","number").style("margin","0px 10px").style("width","100px").property("value",a.fimo_thresh).on("keyup",(t=>{if(!e(t))return;const n=Number.parseFloat(t.target.value);if(n<=0){window.alert("Enter a p value between 0 to 1");return}if(n==a.fimo_thresh)return;a.fimo_thresh=n;h(a)}));r.append("span").style("font-size","0.7em").style("opacity",.5).text("Press ENTER to update")}{const t=n.append("tr");t.append("td").text("Minimum log10 p-value difference");const r=t.append("td");r.append("input").attr("type","number").style("margin","0px 10px").style("width","100px").property("value",a.minabslogp).on("keyup",(t=>{if(!e(t))return;const n=Number.parseFloat(t.target.value);if(n<=0){window.alert("Enter a number above 0");return}if(n==a.minabslogp)return;a.minabslogp=n;h(a)}));r.append("span").style("font-size","0.7em").style("opacity",.5).text("Press ENTER to update")}a.wait=a.div.append("div");a.svg=a.div.append("svg");a.dynamic_g=a.svg.append("g");a.legend={};a.legend.logpvaluediv=a.div.append("div");m(a)}function m(t){if(!t.factor_profiles)return;if(!Array.isArray(t.factor_profiles))throw"factor_profiles is not array";for(const e of t.factor_profiles){if(!e.name)throw"name missing for a profile";if(!e.leftpad)e.leftpad=20;if(!e.width)e.width=300;e.headerg=t.svg.append("g");e.textlabel=e.headerg.append("text").text(e.name).attr("x",e.width/2).attr("text-anchor","middle").attr("y",-30);if(e.isgenevalue){e.color="green";e.axisg=e.headerg.append("g");continue}if(e.isgenevalueonesample){if(!e.samplename)throw"samplename missing for isgenevalueonesample";e.barcolor="#62945B";e.axisg=e.headerg.append("g");continue}throw"unknown profile type"}}function h(t){a(t.wait.text("Loading..."));t.dynamic_g.selectAll("*").remove();const e={genome:t.genome.name,m:t.m,fimo_thresh:t.fimo_thresh,flankspan:t.flankspan,minabslogp:t.minabslogp};return n("fimo",e).then((e=>{if(e.error)throw"Error: cannot do motif finding: "+e.error;if(t.callback_once){t.callback_once();delete t.callback_once}if(!e.items||e.items.length==0)throw"Found no motif change due to this mutation";t.wait.style("display","none");for(const t of e.items){if(t.attr){t.gene=t.attr["Transcription factor"]}else{t.gene=t.name}}return u(e,t)})).catch((e=>{t.wait.style("display","block").text(e.message||e);if(e.stack)console.log(e.stack)}))}async function u(t,e){x(t,e);if(e.factor_profiles){await v(t,e);let a=Number.parseInt(e.svg.attr("width"));for(const n of e.factor_profiles){n.headerg.attr("transform","translate("+(a+n.leftpad)+","+f+")");n.motifs=[];for(const e of t.items){const t=e.layer1_g.append("g").attr("transform","translate("+(a+n.leftpad)+",0)");n.motifs.push({motif:e,g:t,message:t.append("text").text("Loading...").attr("dominant-baseline","central").attr("fill","#ccc")})}a+=n.leftpad+n.width;e.svg.attr("width",a+5);await _(e,n);for(const e of t.items){e.bgbox.attr("width",a);e.coverbox.attr("width",a)}}}}function x(t,e){const a=14;const n=a*t.refseq.length;{const n=(e.m.pos-t.refstart+.5)*a;const r=e.dynamic_g.append("g").attr("transform","translate("+n+","+f+")");r.append("rect").attr("x",-a/2).attr("y",-10).attr("width",a).attr("height",10).attr("fill","#666");r.append("text").attr("y",-15).attr("text-anchor","middle").text(e.m.chr+":"+e.m.pos+" "+e.m.ref+">"+e.m.alt)}let o=f+c;const i=1;const s=e.dynamic_g.append("g").attr("transform","translate(0,"+o+")");for(const[o,l]of t.items.entries()){l.g=s.append("g").attr("transform","translate(0,"+(e.motifrowheight*(o+.5)+i*o)+")");l.layer1_g=l.g.append("g");l.layer2_g=l.g.append("g");l.bgbox=l.layer1_g.append("rect").attr("y",-e.motifrowheight/2).attr("width",n).attr("height",e.motifrowheight).attr("fill","white");const p=(l.start-t.refstart)*a;const f=(Math.min(l.stop,t.refstop)-l.start)*a;l.layer1_g.append("rect").attr("x",p).attr("y",-e.motifrowheight/2).attr("width",f).attr("height",e.motifrowheight).attr("fill",l.gain?e.gaincolor:e.losscolor).attr("fill-opacity",l.logpvaluediff/(l.gain?t.valuemax:t.valuemin));let c;if(l.strand=="+"){c="> "+l.name+" >"}else{c="< "+l.name+" <"}l.layer1_g.append("text").text(c).attr("x",p+f/2).attr("dominant-baseline","central").attr("text-anchor","middle").attr("stroke","white").attr("stroke-width",3).attr("font-size",e.motifrowheight-3).attr("font-family",r).style("white-space","pre");l.layer1_g.append("text").text(c).attr("x",p+f/2).attr("dominant-baseline","central").attr("text-anchor","middle").attr("font-size",e.motifrowheight-3).attr("font-family",r).style("white-space","pre");l.coverbox=l.layer2_g.append("rect").attr("y",-e.motifrowheight/2).attr("width",n).attr("height",e.motifrowheight).attr("fill","white").attr("fill-opacity",0).on("mouseover",(t=>{l.bgbox.attr("fill","#f9fabd");y(l,e,t)})).on("mouseout",(()=>{l.bgbox.attr("fill","white");e.tip.hide()}))}o+=(i+e.motifrowheight)*t.items.length+20;b(t,e);e.svg.attr("width",n).attr("height",o)}function y(t,e,a){e.tip.clear();if(t.attr){e.tip.d.append("div").text("MOTIF").style("font-weight","bold");const a=[{k:"P-values",v:w(t,e)},{k:"Strand",v:t.strand}];o(e.tip.d,a);e.tip.d.append("div").text("FACTOR").style("font-weight","bold");const n=[];for(const e in t.attr){n.push({k:e,v:t.attr[e]})}o(e.tip.d,n)}else{const a=[{k:"TF",v:t.name},{k:"P-values",v:w(t,e)},{k:"Strand",v:t.strand}];o(e.tip.d,a)}e.tip.show(a.clientX,a.clientY)}function w(t,e){return(t.pvalue_ref==undefined?'<span style="opacity:.5;padding:2px"><span style="font-size:.7em">REF</span> not found</span>':'<span style="background-color:'+e.losscolor+';padding:2px;color:white;"><span style="font-size:.7em">REF</span> '+t.pvalue_ref+"</span>")+"<br>"+(t.pvalue_alt==undefined?'<span style="opacity:.5;padding:2px"><span style="font-size:.7em">ALT</span> not found</span>':'<span style="background-color:'+e.gaincolor+';padding:2px;color:white;"><span style="font-size:.7em">ALT</span> '+t.pvalue_alt+"</span>")}function b(t,e){e.legend.logpvaluediv.selectAll("*").remove();const a=50,n=4,o=12,l=55,f=20;e.legend.logpvaluediv.append("span").text("Log10 p-value difference");const c=e.legend.logpvaluediv.append("svg").attr("width",(a+l)*2).attr("height",o+n+f);const d=c.append("g").attr("transform","translate("+a+","+(o+n)+")");i({axis:d.call(p().scale(s().domain([t.valuemin,0,t.valuemax]).range([0,l,l*2])).tickValues([t.valuemin,0,t.valuemax]).tickSize(n))});const g=Math.random().toString();const m=Math.random().toString();const h=c.append("defs");{const t=h.append("linearGradient").attr("id",m);t.append("stop").attr("offset","0%").attr("stop-color",e.losscolor);t.append("stop").attr("offset","100%").attr("stop-color","white")}{const t=h.append("linearGradient").attr("id",g);t.append("stop").attr("offset","0%").attr("stop-color","white");t.append("stop").attr("offset","100%").attr("stop-color",e.gaincolor)}c.append("rect").attr("x",a).attr("y",o+n).attr("width",l).attr("height",f).attr("fill","url(#"+m+")");c.append("rect").attr("x",a+l).attr("y",o+n).attr("width",l).attr("height",f).attr("fill","url(#"+g+")");c.append("text").attr("x",a-5).attr("y",o+n+f/2).attr("font-family",r).attr("font-size",o).attr("text-anchor","end").attr("dominant-baseline","central").attr("fill","black").text("Loss");c.append("text").attr("x",a+l*2+5).attr("y",o+n+f/2).attr("font-family",r).attr("font-size",o).attr("dominant-baseline","central").attr("fill","black").text("Gain")}async function v(t,e){e.gene2position={};const a=new Set;for(const e of t.items){a.add(e.gene)}for(const t of a){const a=await k(t,e);if(a){e.gene2position[t]=a}}}function k(t,e){return n("genelookup",{genome:e.genome.name,input:t,deep:1}).then((t=>{if(!t.gmlst)return null;const e=l(t.gmlst);return e[0]}))}function _(t,e){if(e.isgenevalue){return M(t,e)}if(e.isgenevalueonesample){return E(t,e)}throw"unknown profile type"}async function E(t,e){const r={genome:t.genome.name,genes:[],sample:e.samplename};if(e.mdslabel){r.dslabel=e.mdslabel;r.querykey=e.querykey;if(e.samplegroup_attrlst){r.getgroup=e.samplegroup_attrlst}}else{r.iscustom=1;r.file=e.file;r.url=e.url;r.indexURL=e.indexURL}for(const e in t.gene2position){const a=t.gene2position[e];r.genes.push({gene:e,chr:a.chr,start:a.start,stop:a.stop})}return n("mdsgenevalueonesample",r).then((a=>{if(a.error)throw a.error;for(const t of e.motifs){t.message.text("No data")}if(a.nodata)return;if(!a.result)throw"error";let n=0,r=0;for(const t in a.result){n=Math.min(n,a.result[t]);r=Math.max(r,a.result[t])}const o=s().domain([n,r]).range([0,e.width]);i({axis:e.axisg.call(p().scale(o).ticks(4)),showline:1});for(const n of e.motifs){const r=a.result[n.motif.gene];if(Number.isFinite(r)){n.message.text("");n.g.append("rect").attr("y",-t.motifrowheight/2).attr("width",Math.max(1,o(r))).attr("height",t.motifrowheight).attr("shape-rendering","crispEdges").attr("fill",e.barcolor)}}e.textlabel.attr("x",e.width/2).attr("text-anchor","middle").attr("y",-30)})).catch((e=>{if(e.stack)console.log(e.stack);a(t.wait.text(e.message||e))}))}async function M(t,e){e.gene2result=new Map;for(const a in t.gene2position){const n=await L(t,e,a);if(n){z(t,e,a,n);e.gene2result.set(a,n);F(t,e)}}N(t,e)}function z(t,e,a,n){if(n.nodata)return;for(const t of e.motifs){if(t.motif.gene!=a)continue;t.boxplot={out:[]};if(n.w1!=undefined){t.boxplot.hline=t.g.append("line").attr("stroke",e.color).attr("shape-rendering","crispEdges");t.boxplot.linew1=t.g.append("line").attr("stroke",e.color).attr("shape-rendering","crispEdges");t.boxplot.linew2=t.g.append("line").attr("stroke",e.color).attr("shape-rendering","crispEdges");t.boxplot.box=t.g.append("rect").attr("fill","white").attr("stroke",e.color).attr("shape-rendering","crispEdges");t.boxplot.linep50=t.g.append("line").attr("stroke",e.color).attr("shape-rendering","crispEdges")}if(n.out){for(const a of n.out){const n=t.g.append("circle").attr("stroke",e.color).attr("fill","white").attr("fill-opacity",0);t.boxplot.out.push({value:a.value,circle:n})}}}}function F(t,e){let a=0,n=0;for(const t of e.gene2result.values()){a=Math.min(a,t.min);n=Math.max(n,t.max)}const r=s().domain([a,n]).range([0,e.width]);const o=t.motifrowheight-2;for(const[t,a]of e.gene2result){for(const n of e.motifs){if(n.motif.gene!=t)continue;const e=n.boxplot;if(!e)continue;if(e.hline){const t=r(a.w1);const n=r(a.w2);const i=r(a.p25);const s=r(a.p50);const l=r(a.p75);e.hline.transition().attr("x1",t).attr("x2",n);e.linew1.transition().attr("x1",t).attr("x2",t).attr("y1",-o/2).attr("y2",o/2);e.linew2.transition().attr("x1",n).attr("x2",n).attr("y1",-o/2).attr("y2",o/2);e.box.transition().attr("x",i).attr("y",-o/2).attr("width",l-i).attr("height",o);e.linep50.transition().attr("x1",s).attr("x2",s).attr("y1",-o/2).attr("y2",o/2)}for(const t of e.out){t.circle.transition().attr("cx",r(t.value)).attr("r",o/3)}}}i({axis:e.axisg.transition().call(p().scale(r).ticks(4)),showline:1})}function L(t,e,a){const r=t.gene2position[a];const o={genome:t.genome.name,gene:a,chr:r.chr,start:r.start,stop:r.stop,getgroup2boxplot:1};if(e.mdslabel){o.dslabel=e.mdslabel;o.querykey=e.querykey;if(e.samplegroup_attrlst){o.getgroup=e.samplegroup_attrlst}}else{o.iscustom=1;o.file=e.file;o.url=e.url;o.indexURL=e.indexURL}return n("mdsgeneboxplot",o).then((t=>{if(t.error)throw"Error: "+t.error;if(t.nodata)throw"No data";for(const t of e.motifs){if(t.motif.gene==a){t.message.text("")}}return t})).catch((t=>{if(t.stack)console.log(t.stack);for(const n of e.motifs){if(n.motif.gene==a){n.message.text(t.message||t)}}}))}function N(t,e){let a=0;for(const t of e.gene2result.values()){a=Math.max(a,t.n)}e.textlabel.text(e.name+" (n="+a+")").attr("x",e.width/2).attr("text-anchor","middle").attr("y",-30)}export{d as init};
|
|
1
|
+
import{M as t,k as e,p as a,q as n,ah as r,a9 as o,ag as i,I as s,w as l}from"./app-3d14cbe4.js";import{c as p}from"./axis-747c801e.js";const f=80;const c=5;async function d(t){window.obj=t;t.errdiv=t.div.append("div");try{g(t);await h(t)}catch(e){t.errdiv.text(e.message||e);if(e.stack)console.log(e.stack)}}function g(a){a.motifrowheight=16;a.gaincolor="red";a.losscolor="blue";a.flankspan=15;if(!a.fimo_thresh)a.fimo_thresh=.001;if(!a.minabslogp)a.minabslogp=1;a.tip=new t;const n=a.div.append("table").style("border-spacing","3px").style("border-collapse","separate").style("margin","10px");{const t=n.append("tr");t.append("td").text("Flanking sequence (#nt)");const r=t.append("td");r.append("input").attr("type","number").style("margin","0px 10px").style("width","100px").property("value",a.flankspan).on("keyup",(t=>{if(!e(t))return;const n=Number.parseInt(t.target.value);if(n<10){window.alert("Enter integer above 10");return}if(n==a.flankspan)return;a.flankspan=n;h(a)}));r.append("span").style("font-size","0.7em").style("opacity",.5).text("Press ENTER to update")}{const t=n.append("tr");t.append("td").text("P-value cutoff");const r=t.append("td");r.append("input").attr("type","number").style("margin","0px 10px").style("width","100px").property("value",a.fimo_thresh).on("keyup",(t=>{if(!e(t))return;const n=Number.parseFloat(t.target.value);if(n<=0){window.alert("Enter a p value between 0 to 1");return}if(n==a.fimo_thresh)return;a.fimo_thresh=n;h(a)}));r.append("span").style("font-size","0.7em").style("opacity",.5).text("Press ENTER to update")}{const t=n.append("tr");t.append("td").text("Minimum log10 p-value difference");const r=t.append("td");r.append("input").attr("type","number").style("margin","0px 10px").style("width","100px").property("value",a.minabslogp).on("keyup",(t=>{if(!e(t))return;const n=Number.parseFloat(t.target.value);if(n<=0){window.alert("Enter a number above 0");return}if(n==a.minabslogp)return;a.minabslogp=n;h(a)}));r.append("span").style("font-size","0.7em").style("opacity",.5).text("Press ENTER to update")}a.wait=a.div.append("div");a.svg=a.div.append("svg");a.dynamic_g=a.svg.append("g");a.legend={};a.legend.logpvaluediv=a.div.append("div");m(a)}function m(t){if(!t.factor_profiles)return;if(!Array.isArray(t.factor_profiles))throw"factor_profiles is not array";for(const e of t.factor_profiles){if(!e.name)throw"name missing for a profile";if(!e.leftpad)e.leftpad=20;if(!e.width)e.width=300;e.headerg=t.svg.append("g");e.textlabel=e.headerg.append("text").text(e.name).attr("x",e.width/2).attr("text-anchor","middle").attr("y",-30);if(e.isgenevalue){e.color="green";e.axisg=e.headerg.append("g");continue}if(e.isgenevalueonesample){if(!e.samplename)throw"samplename missing for isgenevalueonesample";e.barcolor="#62945B";e.axisg=e.headerg.append("g");continue}throw"unknown profile type"}}function h(t){a(t.wait.text("Loading..."));t.dynamic_g.selectAll("*").remove();const e={genome:t.genome.name,m:t.m,fimo_thresh:t.fimo_thresh,flankspan:t.flankspan,minabslogp:t.minabslogp};return n("fimo",e).then((e=>{if(e.error)throw"Error: cannot do motif finding: "+e.error;if(t.callback_once){t.callback_once();delete t.callback_once}if(!e.items||e.items.length==0)throw"Found no motif change due to this mutation";t.wait.style("display","none");for(const t of e.items){if(t.attr){t.gene=t.attr["Transcription factor"]}else{t.gene=t.name}}return u(e,t)})).catch((e=>{t.wait.style("display","block").text(e.message||e);if(e.stack)console.log(e.stack)}))}async function u(t,e){x(t,e);if(e.factor_profiles){await v(t,e);let a=Number.parseInt(e.svg.attr("width"));for(const n of e.factor_profiles){n.headerg.attr("transform","translate("+(a+n.leftpad)+","+f+")");n.motifs=[];for(const e of t.items){const t=e.layer1_g.append("g").attr("transform","translate("+(a+n.leftpad)+",0)");n.motifs.push({motif:e,g:t,message:t.append("text").text("Loading...").attr("dominant-baseline","central").attr("fill","#ccc")})}a+=n.leftpad+n.width;e.svg.attr("width",a+5);await _(e,n);for(const e of t.items){e.bgbox.attr("width",a);e.coverbox.attr("width",a)}}}}function x(t,e){const a=14;const n=a*t.refseq.length;{const n=(e.m.pos-t.refstart+.5)*a;const r=e.dynamic_g.append("g").attr("transform","translate("+n+","+f+")");r.append("rect").attr("x",-a/2).attr("y",-10).attr("width",a).attr("height",10).attr("fill","#666");r.append("text").attr("y",-15).attr("text-anchor","middle").text(e.m.chr+":"+e.m.pos+" "+e.m.ref+">"+e.m.alt)}let o=f+c;const i=1;const s=e.dynamic_g.append("g").attr("transform","translate(0,"+o+")");for(const[o,l]of t.items.entries()){l.g=s.append("g").attr("transform","translate(0,"+(e.motifrowheight*(o+.5)+i*o)+")");l.layer1_g=l.g.append("g");l.layer2_g=l.g.append("g");l.bgbox=l.layer1_g.append("rect").attr("y",-e.motifrowheight/2).attr("width",n).attr("height",e.motifrowheight).attr("fill","white");const p=(l.start-t.refstart)*a;const f=(Math.min(l.stop,t.refstop)-l.start)*a;l.layer1_g.append("rect").attr("x",p).attr("y",-e.motifrowheight/2).attr("width",f).attr("height",e.motifrowheight).attr("fill",l.gain?e.gaincolor:e.losscolor).attr("fill-opacity",l.logpvaluediff/(l.gain?t.valuemax:t.valuemin));let c;if(l.strand=="+"){c="> "+l.name+" >"}else{c="< "+l.name+" <"}l.layer1_g.append("text").text(c).attr("x",p+f/2).attr("dominant-baseline","central").attr("text-anchor","middle").attr("stroke","white").attr("stroke-width",3).attr("font-size",e.motifrowheight-3).attr("font-family",r).style("white-space","pre");l.layer1_g.append("text").text(c).attr("x",p+f/2).attr("dominant-baseline","central").attr("text-anchor","middle").attr("font-size",e.motifrowheight-3).attr("font-family",r).style("white-space","pre");l.coverbox=l.layer2_g.append("rect").attr("y",-e.motifrowheight/2).attr("width",n).attr("height",e.motifrowheight).attr("fill","white").attr("fill-opacity",0).on("mouseover",(t=>{l.bgbox.attr("fill","#f9fabd");y(l,e,t)})).on("mouseout",(()=>{l.bgbox.attr("fill","white");e.tip.hide()}))}o+=(i+e.motifrowheight)*t.items.length+20;b(t,e);e.svg.attr("width",n).attr("height",o)}function y(t,e,a){e.tip.clear();if(t.attr){e.tip.d.append("div").text("MOTIF").style("font-weight","bold");const a=[{k:"P-values",v:w(t,e)},{k:"Strand",v:t.strand}];o(e.tip.d,a);e.tip.d.append("div").text("FACTOR").style("font-weight","bold");const n=[];for(const e in t.attr){n.push({k:e,v:t.attr[e]})}o(e.tip.d,n)}else{const a=[{k:"TF",v:t.name},{k:"P-values",v:w(t,e)},{k:"Strand",v:t.strand}];o(e.tip.d,a)}e.tip.show(a.clientX,a.clientY)}function w(t,e){return(t.pvalue_ref==undefined?'<span style="opacity:.5;padding:2px"><span style="font-size:.7em">REF</span> not found</span>':'<span style="background-color:'+e.losscolor+';padding:2px;color:white;"><span style="font-size:.7em">REF</span> '+t.pvalue_ref+"</span>")+"<br>"+(t.pvalue_alt==undefined?'<span style="opacity:.5;padding:2px"><span style="font-size:.7em">ALT</span> not found</span>':'<span style="background-color:'+e.gaincolor+';padding:2px;color:white;"><span style="font-size:.7em">ALT</span> '+t.pvalue_alt+"</span>")}function b(t,e){e.legend.logpvaluediv.selectAll("*").remove();const a=50,n=4,o=12,l=55,f=20;e.legend.logpvaluediv.append("span").text("Log10 p-value difference");const c=e.legend.logpvaluediv.append("svg").attr("width",(a+l)*2).attr("height",o+n+f);const d=c.append("g").attr("transform","translate("+a+","+(o+n)+")");i({axis:d.call(p().scale(s().domain([t.valuemin,0,t.valuemax]).range([0,l,l*2])).tickValues([t.valuemin,0,t.valuemax]).tickSize(n))});const g=Math.random().toString();const m=Math.random().toString();const h=c.append("defs");{const t=h.append("linearGradient").attr("id",m);t.append("stop").attr("offset","0%").attr("stop-color",e.losscolor);t.append("stop").attr("offset","100%").attr("stop-color","white")}{const t=h.append("linearGradient").attr("id",g);t.append("stop").attr("offset","0%").attr("stop-color","white");t.append("stop").attr("offset","100%").attr("stop-color",e.gaincolor)}c.append("rect").attr("x",a).attr("y",o+n).attr("width",l).attr("height",f).attr("fill","url(#"+m+")");c.append("rect").attr("x",a+l).attr("y",o+n).attr("width",l).attr("height",f).attr("fill","url(#"+g+")");c.append("text").attr("x",a-5).attr("y",o+n+f/2).attr("font-family",r).attr("font-size",o).attr("text-anchor","end").attr("dominant-baseline","central").attr("fill","black").text("Loss");c.append("text").attr("x",a+l*2+5).attr("y",o+n+f/2).attr("font-family",r).attr("font-size",o).attr("dominant-baseline","central").attr("fill","black").text("Gain")}async function v(t,e){e.gene2position={};const a=new Set;for(const e of t.items){a.add(e.gene)}for(const t of a){const a=await k(t,e);if(a){e.gene2position[t]=a}}}function k(t,e){return n("genelookup",{genome:e.genome.name,input:t,deep:1}).then((t=>{if(!t.gmlst)return null;const e=l(t.gmlst);return e[0]}))}function _(t,e){if(e.isgenevalue){return M(t,e)}if(e.isgenevalueonesample){return E(t,e)}throw"unknown profile type"}async function E(t,e){const r={genome:t.genome.name,genes:[],sample:e.samplename};if(e.mdslabel){r.dslabel=e.mdslabel;r.querykey=e.querykey;if(e.samplegroup_attrlst){r.getgroup=e.samplegroup_attrlst}}else{r.iscustom=1;r.file=e.file;r.url=e.url;r.indexURL=e.indexURL}for(const e in t.gene2position){const a=t.gene2position[e];r.genes.push({gene:e,chr:a.chr,start:a.start,stop:a.stop})}return n("mdsgenevalueonesample",r).then((a=>{if(a.error)throw a.error;for(const t of e.motifs){t.message.text("No data")}if(a.nodata)return;if(!a.result)throw"error";let n=0,r=0;for(const t in a.result){n=Math.min(n,a.result[t]);r=Math.max(r,a.result[t])}const o=s().domain([n,r]).range([0,e.width]);i({axis:e.axisg.call(p().scale(o).ticks(4)),showline:1});for(const n of e.motifs){const r=a.result[n.motif.gene];if(Number.isFinite(r)){n.message.text("");n.g.append("rect").attr("y",-t.motifrowheight/2).attr("width",Math.max(1,o(r))).attr("height",t.motifrowheight).attr("shape-rendering","crispEdges").attr("fill",e.barcolor)}}e.textlabel.attr("x",e.width/2).attr("text-anchor","middle").attr("y",-30)})).catch((e=>{if(e.stack)console.log(e.stack);a(t.wait.text(e.message||e))}))}async function M(t,e){e.gene2result=new Map;for(const a in t.gene2position){const n=await L(t,e,a);if(n){z(t,e,a,n);e.gene2result.set(a,n);F(t,e)}}N(t,e)}function z(t,e,a,n){if(n.nodata)return;for(const t of e.motifs){if(t.motif.gene!=a)continue;t.boxplot={out:[]};if(n.w1!=undefined){t.boxplot.hline=t.g.append("line").attr("stroke",e.color).attr("shape-rendering","crispEdges");t.boxplot.linew1=t.g.append("line").attr("stroke",e.color).attr("shape-rendering","crispEdges");t.boxplot.linew2=t.g.append("line").attr("stroke",e.color).attr("shape-rendering","crispEdges");t.boxplot.box=t.g.append("rect").attr("fill","white").attr("stroke",e.color).attr("shape-rendering","crispEdges");t.boxplot.linep50=t.g.append("line").attr("stroke",e.color).attr("shape-rendering","crispEdges")}if(n.out){for(const a of n.out){const n=t.g.append("circle").attr("stroke",e.color).attr("fill","white").attr("fill-opacity",0);t.boxplot.out.push({value:a.value,circle:n})}}}}function F(t,e){let a=0,n=0;for(const t of e.gene2result.values()){a=Math.min(a,t.min);n=Math.max(n,t.max)}const r=s().domain([a,n]).range([0,e.width]);const o=t.motifrowheight-2;for(const[t,a]of e.gene2result){for(const n of e.motifs){if(n.motif.gene!=t)continue;const e=n.boxplot;if(!e)continue;if(e.hline){const t=r(a.w1);const n=r(a.w2);const i=r(a.p25);const s=r(a.p50);const l=r(a.p75);e.hline.transition().attr("x1",t).attr("x2",n);e.linew1.transition().attr("x1",t).attr("x2",t).attr("y1",-o/2).attr("y2",o/2);e.linew2.transition().attr("x1",n).attr("x2",n).attr("y1",-o/2).attr("y2",o/2);e.box.transition().attr("x",i).attr("y",-o/2).attr("width",l-i).attr("height",o);e.linep50.transition().attr("x1",s).attr("x2",s).attr("y1",-o/2).attr("y2",o/2)}for(const t of e.out){t.circle.transition().attr("cx",r(t.value)).attr("r",o/3)}}}i({axis:e.axisg.transition().call(p().scale(r).ticks(4)),showline:1})}function L(t,e,a){const r=t.gene2position[a];const o={genome:t.genome.name,gene:a,chr:r.chr,start:r.start,stop:r.stop,getgroup2boxplot:1};if(e.mdslabel){o.dslabel=e.mdslabel;o.querykey=e.querykey;if(e.samplegroup_attrlst){o.getgroup=e.samplegroup_attrlst}}else{o.iscustom=1;o.file=e.file;o.url=e.url;o.indexURL=e.indexURL}return n("mdsgeneboxplot",o).then((t=>{if(t.error)throw"Error: "+t.error;if(t.nodata)throw"No data";for(const t of e.motifs){if(t.motif.gene==a){t.message.text("")}}return t})).catch((t=>{if(t.stack)console.log(t.stack);for(const n of e.motifs){if(n.motif.gene==a){n.message.text(t.message||t)}}}))}function N(t,e){let a=0;for(const t of e.gene2result.values()){a=Math.max(a,t.n)}e.textlabel.text(e.name+" (n="+a+")").attr("x",e.width/2).attr("text-anchor","middle").attr("y",-30)}export{d as init};
|