@sjcrh/proteinpaint-client 2.63.0 → 2.63.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -7
- package/dist/{2dmaf-70c0b6bb.js → 2dmaf-0cabb4a4.js} +1 -1
- package/dist/{ColorScale-b44d51ef.js → ColorScale-9800a609.js} +1 -1
- package/dist/{DEanalysis-b86d0874.js → DEanalysis-567989ff.js} +1 -1
- package/dist/{Disco-16cd51c0.js → Disco-5d1404ce.js} +1 -1
- package/dist/{Disco.UI-a38a12e6.js → Disco.UI-54228bb6.js} +1 -1
- package/dist/{DragControls-0c173a20.js → DragControls-a05737c2.js} +1 -1
- package/dist/{DziViewer-5c2d68e7.js → DziViewer-3f466d90.js} +2 -2
- package/dist/{FilterRxComp-0e75dd8d.js → FilterRxComp-fc769f34.js} +1 -1
- package/dist/{FilterStateless-ad3df967.js → FilterStateless-8f30f856.js} +1 -1
- package/dist/{HicApp-bcf8330c.js → HicApp-aac413df.js} +1 -1
- package/dist/{OrbitControls-c33cf781.js → OrbitControls-8b7f91ca.js} +1 -1
- package/dist/app-59194db0.js +1 -0
- package/dist/{app-f91922b4.js → app-71453429.js} +1 -1
- package/dist/{app-bfce9bf5.js → app-fb676934.js} +1 -1
- package/dist/app.js +1 -1
- package/dist/{bam-95f36008.js → bam-e7f6baea.js} +1 -1
- package/dist/{barchart-e2af00a8.js → barchart-ef4874c8.js} +1 -1
- package/dist/{barchart.events-272fd122.js → barchart.events-e24facf7.js} +1 -1
- package/dist/{bars.renderer-f0e5af5a.js → bars.renderer-c46d3f44.js} +1 -1
- package/dist/{block-ec76524e.js → block-4f585abe.js} +1 -1
- package/dist/block.lazyload-6f83d057.js +1 -0
- package/dist/{block.legend-f8cad7e4.js → block.legend-cec87c6f.js} +1 -1
- package/dist/{block.mds-20655637.js → block.mds-f5a11c42.js} +1 -1
- package/dist/{block.mds.cnv-5feb86a0.js → block.mds.cnv-25423c1e.js} +1 -1
- package/dist/{block.mds.expressionrank-c7043f35.js → block.mds.expressionrank-fc1996d5.js} +1 -1
- package/dist/{block.mds.expressionstat-4bf457f3.js → block.mds.expressionstat-45b6bf47.js} +1 -1
- package/dist/{block.mds.geneboxplot-132e5fe6.js → block.mds.geneboxplot-037df46d.js} +1 -1
- package/dist/{block.mds.junction-1f9810df.js → block.mds.junction-00161de6.js} +1 -1
- package/dist/{block.mds.svcnv-094c416f.js → block.mds.svcnv-0c257af4.js} +1 -1
- package/dist/{block.mds.svcnv.share-bb976e02.js → block.mds.svcnv.share-c0b9dfad.js} +1 -1
- package/dist/{block.mds2-7045e32c.js → block.mds2-9009f8d8.js} +1 -1
- package/dist/{block.svg-d8d76ba7.js → block.svg-86bbfcb0.js} +1 -1
- package/dist/{block.tk.aicheck-317d04bd.js → block.tk.aicheck-a5697794.js} +1 -1
- package/dist/{block.tk.ase-d1577ec1.js → block.tk.ase-ad1be47c.js} +1 -1
- package/dist/{block.tk.bam-3cdc13a0.js → block.tk.bam-14339d16.js} +1 -1
- package/dist/{block.tk.bedgraphdot-5304e06c.js → block.tk.bedgraphdot-efe19e56.js} +1 -1
- package/dist/{block.tk.bigwig.ui-0c96dce5.js → block.tk.bigwig.ui-a92f286b.js} +1 -1
- package/dist/{block.tk.hicstraw-39d89269.js → block.tk.hicstraw-57fbbe61.js} +1 -1
- package/dist/{block.tk.junction-b45b3a95.js → block.tk.junction-64c39cd5.js} +1 -1
- package/dist/{block.tk.junction.textmatrixui-6ec019e1.js → block.tk.junction.textmatrixui-09e5e02f.js} +1 -1
- package/dist/{block.tk.ld-5c54e58b.js → block.tk.ld-f681d099.js} +1 -1
- package/dist/{block.tk.menu-30a2c3a5.js → block.tk.menu-2563364c.js} +1 -1
- package/dist/{block.tk.pgv-7ff2dfaf.js → block.tk.pgv-9dfc00c0.js} +1 -1
- package/dist/{boxplot-7de25274.js → boxplot-a2e1ace0.js} +1 -1
- package/dist/brainImaging-21701238.js +1 -0
- package/dist/{brush-db0ed33a.js → brush-bb4566a3.js} +1 -1
- package/dist/{categorical-bc309399.js → categorical-a00f4ffc.js} +1 -1
- package/dist/{condition-f0eb2343.js → condition-2034db37.js} +1 -1
- package/dist/{controls-8d4972c8.js → controls-0467d2ec.js} +1 -1
- package/dist/{controls.btns-bad9e4cf.js → controls.btns-ad7b28a2.js} +1 -1
- package/dist/{controls.config-e0f394cb.js → controls.config-6cf816fb.js} +1 -1
- package/dist/{controls.divide-d8ac5a9b.js → controls.divide-3c0d52d7.js} +1 -1
- package/dist/{controls.overlay-3ac8773d.js → controls.overlay-3a55c2ec.js} +1 -1
- package/dist/{controls.term1-008f4be4.js → controls.term1-59f4cd60.js} +1 -1
- package/dist/cuminc-8d21132b.js +1 -0
- package/dist/{customdata.inputui-58cd9b32.js → customdata.inputui-40ba6d7f.js} +1 -1
- package/dist/{dataDownload-91da6dd6.js → dataDownload-bfa92dad.js} +1 -1
- package/dist/{databrowser.ui-c50862e4.js → databrowser.ui-4799f04d.js} +1 -1
- package/dist/{density-7c3f91eb.js → density-4c2b53f6.js} +1 -1
- package/dist/{dictionary-48a38837.js → dictionary-89e860ee.js} +1 -1
- package/dist/{drag-c354e2c6.js → drag-88d451b4.js} +1 -1
- package/dist/{e2pca-3bba91fa.js → e2pca-8a3f2566.js} +1 -1
- package/dist/{ep-144d8973.js → ep-5399c5cc.js} +1 -1
- package/dist/{fusion.parse-ae1253f4.js → fusion.parse-fc25e5bd.js} +1 -1
- package/dist/{geneExpClustering-96d09008.js → geneExpClustering-a916ebda.js} +1 -1
- package/dist/{geneExpression-d6494fd3.js → geneExpression-501e95c0.js} +1 -1
- package/dist/{geneExpression-9ca2da4f.js → geneExpression-9047481a.js} +1 -1
- package/dist/{geneExpression-be9b5da2.js → geneExpression-da4b50f0.js} +1 -1
- package/dist/{geneORA-85850143.js → geneORA-ffb2497e.js} +1 -1
- package/dist/{geneVariant-3df05e0c.js → geneVariant-7ab521d6.js} +1 -1
- package/dist/{geneVariant-3d674865.js → geneVariant-d79431a2.js} +1 -1
- package/dist/{genefusion.ui-3e2a3a73.js → genefusion.ui-3ce190c7.js} +1 -1
- package/dist/{geneset-3b761b2c.js → geneset-3522bcda.js} +1 -1
- package/dist/{genomeBrowser-2105a98f.js → genomeBrowser-9b72eb22.js} +1 -1
- package/dist/{genomeBrowser.controls-f9b9bf42.js → genomeBrowser.controls-bef8bf99.js} +1 -1
- package/dist/{groupsetting-4901d033.js → groupsetting-574ad150.js} +1 -1
- package/dist/{hierCluster-a7ff7f5a.js → hierCluster-3b14b2b3.js} +1 -1
- package/dist/{hierCluster.config-3d124abf.js → hierCluster.config-f8686a30.js} +1 -1
- package/dist/{hierCluster.interactivity-3463cc0b.js → hierCluster.interactivity-3b5f1e81.js} +1 -1
- package/dist/{hierCluster.renderers-668d0075.js → hierCluster.renderers-9f9a7cad.js} +1 -1
- package/dist/{html.legend-3e428f9e.js → html.legend-ef8066dd.js} +1 -1
- package/dist/{imagePlot-6d89200c.js → imagePlot-095b9a92.js} +1 -1
- package/dist/{lasso-393c1570.js → lasso-ef63631b.js} +1 -1
- package/dist/{launch.adhoc-9c59874e.js → launch.adhoc-1b356f97.js} +1 -1
- package/dist/{legacyDataset-26ead9cc.js → legacyDataset-056e9d4c.js} +1 -1
- package/dist/{log-4d74231e.js → log-ca1e2a74.js} +1 -1
- package/dist/{lollipop-59f65024.js → lollipop-6ad9ec3c.js} +1 -1
- package/dist/{maf-72e5b7da.js → maf-dfada1c8.js} +1 -1
- package/dist/{maftimeline-ed8aaae8.js → maftimeline-1b715a01.js} +1 -1
- package/dist/{matrix-3d09a31f.js → matrix-3fae58f8.js} +1 -1
- package/dist/matrix.cells-3620eb3a.js +1 -0
- package/dist/{matrix.cluster-acdfc6a7.js → matrix.cluster-15b8a865.js} +1 -1
- package/dist/{matrix.config-cd01ebbd.js → matrix.config-8247bea5.js} +1 -1
- package/dist/{matrix.controls-86eb8d5c.js → matrix.controls-dea65894.js} +1 -1
- package/dist/{matrix.data-e2d7ac16.js → matrix.data-121a1a8c.js} +1 -1
- package/dist/{matrix.dom-e5f91cc0.js → matrix.dom-83c5fa39.js} +1 -1
- package/dist/{matrix.groups-f1969b5c.js → matrix.groups-2e1202ef.js} +1 -1
- package/dist/{matrix.interactivity-92bc8332.js → matrix.interactivity-2b076155.js} +1 -1
- package/dist/{matrix.layout-29a8f334.js → matrix.layout-8dc54c05.js} +1 -1
- package/dist/{matrix.legend-8c28039e.js → matrix.legend-e0078739.js} +1 -1
- package/dist/matrix.renderers-0c8eddc9.js +1 -0
- package/dist/{matrix.serieses-e079f04a.js → matrix.serieses-2898da6b.js} +1 -1
- package/dist/{matrix.sort-e1f83454.js → matrix.sort-249d4a35.js} +1 -1
- package/dist/{matrix.sorterUi-2025f39d.js → matrix.sorterUi-d26208c8.js} +1 -1
- package/dist/{mavb-37fffd68.js → mavb-9a6fa2e9.js} +1 -1
- package/dist/{mds.fimo-68f0eaf5.js → mds.fimo-ce97371c.js} +1 -1
- package/dist/{mds.samplescatterplot-362f3591.js → mds.samplescatterplot-a54b9e93.js} +1 -1
- package/dist/{mds.survivalplot-f5bda05a.js → mds.survivalplot-c5093f73.js} +1 -1
- package/dist/{mdsjsonform-7f0b6cc7.js → mdsjsonform-09b4e1cb.js} +1 -1
- package/dist/metaboliteIntensity-eeb5ad12.js +1 -0
- package/dist/niceNumLabels-ddb76164.js +1 -0
- package/dist/{nodrag-777a34a5.js → nodrag-bed2488c.js} +1 -1
- package/dist/{numeric-2eb8c25b.js → numeric-d5536b1c.js} +1 -1
- package/dist/numeric.binary-d67da945.js +1 -0
- package/dist/numeric.continuous-9a0c88bc.js +1 -0
- package/dist/numeric.discrete-921f7097.js +1 -0
- package/dist/numeric.spline-649308d5.js +1 -0
- package/dist/{numeric.toggle-5316211b.js → numeric.toggle-52789fd2.js} +1 -1
- package/dist/{oncomatrix-cd9fa01b.js → oncomatrix-6950c48c.js} +1 -1
- package/dist/{parseData-1bfa9946.js → parseData-480d1ff3.js} +1 -1
- package/dist/{plot.2dvaf-1ed153c1.js → plot.2dvaf-1ecc4bbc.js} +1 -1
- package/dist/plot.app-c841507a.js +1 -0
- package/dist/{plot.barplot-61742e94.js → plot.barplot-24140b0f.js} +1 -1
- package/dist/{plot.boxplot-fe966ac3.js → plot.boxplot-87fe8ab2.js} +1 -1
- package/dist/{plot.brainImaging-d2c23bb7.js → plot.brainImaging-325ebded.js} +1 -1
- package/dist/{plot.disco-70d493f4.js → plot.disco-621d1b8e.js} +1 -1
- package/dist/{plot.dzi-14e6fdc4.js → plot.dzi-3a7e478e.js} +1 -1
- package/dist/{plot.ssgq-9d364d41.js → plot.ssgq-1949c207.js} +1 -1
- package/dist/{plot.vaf2cov-4d28015b.js → plot.vaf2cov-d03c6409.js} +1 -1
- package/dist/{profileBarchart-c104f8e2.js → profileBarchart-11755d7c.js} +1 -1
- package/dist/{profileHome-a555583d.js → profileHome-9c5e266b.js} +1 -1
- package/dist/{profilePlot-5ce5b6a0.js → profilePlot-8ee3034a.js} +1 -1
- package/dist/{profilePolar-610213d4.js → profilePolar-9fe70c32.js} +1 -1
- package/dist/{profileRadar-fddb18f7.js → profileRadar-0e744181.js} +1 -1
- package/dist/{profileRadarFacility-2c2db1dd.js → profileRadarFacility-102544c5.js} +1 -1
- package/dist/{recover-a08c8d01.js → recover-b1ec4fed.js} +1 -1
- package/dist/{regression.inputs-5718cf72.js → regression.inputs-ad548745.js} +1 -1
- package/dist/{regression.inputs.values.table-d587c1cf.js → regression.inputs.values.table-1618447a.js} +1 -1
- package/dist/{regression.results-748024be.js → regression.results-25008028.js} +1 -1
- package/dist/{renderPvalueTable-c435aefd.js → renderPvalueTable-46056189.js} +1 -1
- package/dist/sampleScatter-47dd82cb.js +1 -0
- package/dist/{sampleScatter.interactivity-e9c30652.js → sampleScatter.interactivity-cfa3451d.js} +1 -1
- package/dist/{sampleScatter.rendererThree-3e6c032e.js → sampleScatter.rendererThree-c5321d24.js} +2 -2
- package/dist/{sampleView-d6a91293.js → sampleView-30b97c7d.js} +1 -1
- package/dist/{samplelst-821ec148.js → samplelst-2bdc1b9d.js} +1 -1
- package/dist/{samplematrix-7aa0a780.js → samplematrix-4f0ec523.js} +1 -1
- package/dist/{scatter-2e2c76f4.js → scatter-8a337eeb.js} +1 -1
- package/dist/{selectGenomeWithTklst-51cd21a4.js → selectGenomeWithTklst-895106fb.js} +1 -1
- package/dist/{singleCellPlot-c7347a27.js → singleCellPlot-360eaec6.js} +1 -1
- package/dist/{singlecell-a668bb17.js → singlecell-29c1cbb1.js} +1 -1
- package/dist/{singlecell-7c851ef8.js → singlecell-75f8af89.js} +1 -1
- package/dist/{snplocus-fe6f4ba1.js → snplocus-0cafa73c.js} +1 -1
- package/dist/{snplst-751cea95.js → snplst-2284d5ce.js} +1 -1
- package/dist/{spliceevent.a53ss.diagram-b157f95d.js → spliceevent.a53ss.diagram-44ccabf9.js} +1 -1
- package/dist/{spliceevent.exonskip.diagram-071a3467.js → spliceevent.exonskip.diagram-c8d1bdf0.js} +1 -1
- package/dist/spliceevent.exonskip.getdefault-9fe16119.js +1 -0
- package/dist/{spliceevent.noeventdiagram-1c731f35.js → spliceevent.noeventdiagram-5e244090.js} +1 -1
- package/dist/{spliceevent.phrase-7a3bfb00.js → spliceevent.phrase-186eb050.js} +1 -1
- package/dist/{stattable-a7713026.js → stattable-886f7dad.js} +1 -1
- package/dist/{style.gdc-40ec2784.js → style.gdc-4ac9b96b.js} +1 -1
- package/dist/{summary-592d8f81.js → summary-ee2045a5.js} +1 -1
- package/dist/{sunburst-452df940.js → sunburst-bbff8818.js} +1 -1
- package/dist/survival-04e279f8.js +1 -0
- package/dist/{survival-450b6df4.js → survival-d7bd3c6b.js} +1 -1
- package/dist/{svg.download-56529955.js → svg.download-54c99186.js} +1 -1
- package/dist/{svg.legend-c82b153f.js → svg.legend-28652faa.js} +1 -1
- package/dist/{svgraph-3c5cd8d2.js → svgraph-a12d89da.js} +1 -1
- package/dist/{svmr-3dd531ef.js → svmr-248055c8.js} +1 -1
- package/dist/{table-d6c411fd.js → table-1dae543a.js} +1 -1
- package/dist/{table-bf604c50.js → table-b4a61573.js} +1 -1
- package/dist/{termInfo-96285f4a.js → termInfo-4c759483.js} +1 -1
- package/dist/{termsetting-9a7511e6.js → termsetting-636d2271.js} +1 -1
- package/dist/{tk-6a8e5bb0.js → tk-741d4674.js} +1 -1
- package/dist/{tp.ui-221efed6.js → tp.ui-23151bb1.js} +1 -1
- package/dist/{tvs.density-9fdae0cc.js → tvs.density-9fe0c7fd.js} +1 -1
- package/dist/{tvs.geneVariant-149e25b7.js → tvs.geneVariant-1b179327.js} +1 -1
- package/dist/tvs.numeric-b4cfc975.js +1 -0
- package/dist/{tvs.samplelst-a38e9c2b.js → tvs.samplelst-681358bc.js} +1 -1
- package/dist/{uiUtils-a6de7f14.js → uiUtils-74700a01.js} +1 -1
- package/dist/{variantBrowser-05375469.js → variantBrowser-910b4bcd.js} +1 -1
- package/dist/{vcf-58904308.js → vcf-16ba1e06.js} +1 -1
- package/dist/{violin-c1b78717.js → violin-a41b2e2b.js} +1 -1
- package/dist/{violin.interactivity-534d6993.js → violin.interactivity-bcf0ccc2.js} +1 -1
- package/dist/{violin.renderer-16540fb8.js → violin.renderer-149310eb.js} +1 -1
- package/dist/{violinRenderer-688abcb2.js → violinRenderer-71c9f3ab.js} +1 -1
- package/dist/{viridis-d3cf2713.js → viridis-81de7bcd.js} +1 -1
- package/dist/{y-2d48b9e4.js → y-76c7da8c.js} +1 -1
- package/dist/{zoom-2d4ede33.js → zoom-a40839cf.js} +1 -1
- package/package.json +7 -7
- package/dist/app-de19f41c.js +0 -1
- package/dist/block.lazyload-ebd949e4.js +0 -1
- package/dist/brainImaging-007edaa3.js +0 -1
- package/dist/cuminc-72257faf.js +0 -1
- package/dist/matrix.cells-a5157233.js +0 -1
- package/dist/matrix.renderers-3b8dfd04.js +0 -1
- package/dist/metaboliteIntensity-512257f3.js +0 -1
- package/dist/niceNumLabels-8fdc6507.js +0 -1
- package/dist/numeric.binary-0a3b17d2.js +0 -1
- package/dist/numeric.continuous-f77038de.js +0 -1
- package/dist/numeric.discrete-b977e88f.js +0 -1
- package/dist/numeric.spline-d64b1abe.js +0 -1
- package/dist/plot.app-91a1d78d.js +0 -1
- package/dist/sampleScatter-031f47de.js +0 -1
- package/dist/spliceevent.exonskip.getdefault-93feb627.js +0 -1
- package/dist/survival-6a4c4f12.js +0 -1
- package/dist/tvs.numeric-f9ce58bc.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as e,J as l,af as t,aJ as s,K as a,aN as n}from"./app-71453429.js";import{T as r}from"./FilterRxComp-fc769f34.js";import"./table-1dae543a.js";function o(e,l,t,s,a,r,o,i,c,g,d,u){const f=t.key;const p=l.term.values||{};e.label="label"in t?t.label:p[f]?.label?p[f].label:f;e.fill=t.color||p[t.key]?.color;e.order=r.ref.bins?r.ref.bins.findIndex((e=>e.name==f)):0;if(l.q?.mode=="continuous"){if(!l.settings)l.settings={};if(!l.settings.barh)l.settings.barh=a.barh;if(!("gap"in l.settings))l.settings.gap=4;const t=l.term.values?.[e.key];if(t?.uncomputable){e.x=e.totalIndex*g+e.grpIndex*a.colgspace;e.y=c*u;e.height=l.settings.barh;e.fill="transparent";l.legend?.group||l.$id;return}e.fill="#555";if(a.transpose){e.height=r.scale(e.key);e.x=l.settings.gap}else{const l=e.term.valueConversion;const t=l?e.key*l.scaleFactor:e.key;e.height=e.key>=0?r.scales.pos(t):r.scales.neg(t);e.x=e.totalIndex*g+e.grpIndex*a.colgspace;e.y=e.key>=0?r.counts.posMaxHt+r.tw.settings.gap-e.height:r.counts.posMaxHt+r.tw.settings.gap;e.convertedValueLabel=l?n(e.key,l.fromUnit,l.toUnit,l.scaleFactor):""}}else{e.x=e.totalIndex*g+e.grpIndex*a.colgspace;e.y=c*u;const t=l.legend?.group||l.$id;return{ref:r.ref,group:t,value:f,entry:{key:f,label:e.label,fill:e.fill}}}}function i(e,l,t,s,a,r,o,i,c,g,d,u){const f=l.q?.mode=="continuous"?t.value:t.key;e.key=f;e.label=l.q?.mode=="continuous"?l.term.unit?`${f}(${l.term.unit})`:f:"Exit code: "+f;e.fill=f==1?"#ff7f0e":"#1f77b4";e.order=0;if(l.q?.mode=="continuous"){if(!l.settings)l.settings={};if(!l.settings.barh)l.settings.barh=a.barh;if(!("gap"in l.settings))l.settings.gap=4;e.fill="#555";if(a.transpose){e.height=r.scale(e.key);e.x=l.settings.gap}else{const l=e.term.valueConversion;const t=l?e.key*l.scaleFactor:e.key;e.height=e.key>=0?r.scales.pos(t):r.scales.neg(t);e.x=e.totalIndex*g+e.grpIndex*a.colgspace;e.y=e.key>=0?r.counts.posMaxHt+r.tw.settings.gap-e.height:r.counts.posMaxHt+r.tw.settings.gap;e.convertedValueLabel=l?n(e.key,l.fromUnit,l.toUnit,l.scaleFactor):""}}else{e.x=e.totalIndex*g+e.grpIndex*a.colgspace;e.y=c*u;const t=l.legend?.group||l.$id;return{ref:r.ref,group:t,value:f,entry:{key:f,label:e.label,fill:e.fill}}}}function c(e,l,t,s,a,n,r,o,i,c,g,d){const u=l.term.values||{};const f=t.key;e.label="label"in t?t.label:u[f]?.label?u[f].label:f;e.fill=t.color||u[f]?.color;e.x=e.totalIndex*c+e.grpIndex*a.colgspace;e.y=i*d;const p=l.legend?.group||l.$id;return{ref:n.ref,group:p,value:t.key,entry:{key:f,label:e.label,fill:e.fill}}}function g(n,r,o,i,c,g,d,u,f,p,x,h){const b=o.renderedValues||o.filteredValues||o.values||[o.value];const y=r.q?.values&&r.q?.values[i.class]?.color;if(r.q?.groupsetting?.inuse){n.label=i;n.fill=["Mutated","Protein-changing","Truncating"].includes(i)?"#FF0000":["Wildtype","Rest"].includes(o.key)?"#0000FF":o.key=="Not tested"?"#00FF00":"#000000";n.value={value:i,dt:r.q.dt,origin:r.q.origin};n.x=n.totalIndex*p+n.grpIndex*c.colgspace;n.y=f*h;const e=r.legend?.group||r.q.origin?`${r.q.origin[0].toUpperCase()+r.q.origin.slice(1)} ${d.dt2label[r.q.dt]}`:d.dt2label[r.q.dt];return{ref:g.ref,group:e,value:o.key,order:-2,entry:{key:o.key,label:n.label,fill:n.fill,dt:r.q.dt,origin:r.q.origin}}}else{n.label=i.label||d.mclass[i.class].label;n.fill=d.getValueColor?.(i.value)||y||i.color||d.mclass[i.class]?.color;n.class=i.class;n.value=i;const o=d.dimensions.colw;if(c.cellEncoding==""){n.height=c.rowh/b.length;n.width=o;n.x=n.totalIndex*p+n.grpIndex*c.colgspace;n.y=f*h}else if(i.dt==e||i.dt==l){if(c.cellEncoding=="single"){n.height=c.rowh;n.width=o;n.x=n.totalIndex*p+n.grpIndex*c.colgspace;n.y=0}else{const e=3;n.height=c.rowh/e;n.width=o;n.x=n.totalIndex*p+n.grpIndex*c.colgspace;n.y=f*.33333}}else if(i.dt==t||i.dt==s){n.height=c.rowh;n.width=o;n.x=n.totalIndex*p+n.grpIndex*c.colgspace;n.y=0}else{throw`cannot set cell props for dt='${i.dt}'`}if(i.class=="Blank"||i.class=="WT"){n.label=`${d.dt2label[i.dt]} ${n.label}`}const u=d.state.termdbConfig.assayAvailability?.byDt;const x=i.class=="CNV_loss"?-2:i.class.startsWith("CNV_")?-1:0;if(i.dt==t){if(g.scales&&i.class.startsWith("CNV_")){g.scales.max;const{maxLoss:e,maxGain:l,minLoss:t,minGain:s}=g.scales;i.scaledValue=i.value<0?i.value/t:i.value/l;n.fill=i.value<0?g.scales.loss(i.scaledValue):g.scales.gain(i.scaledValue);return{ref:g.ref,group:"CNV",value:i.class,order:-1,entry:{key:i.class,label:n.label,scale:i.class=="CNV_loss"?g.scales.loss:g.scales.gain,domain:i.class=="CNV_loss"?[0,-t]:[0,l],minLabel:0,maxLabel:i.class=="CNV_loss"?t:l,order:x,dt:i.dt,origin:i.origin}}}else{const e="CNV";return{ref:g.ref,group:e,value:i.class,order:-1,entry:{key:i.class,label:n.label,fill:n.fill,order:x,dt:i.dt,origin:i.origin}}}}else if(i.dt==l&&u?.[l]){const e="Fusion RNA";return{ref:g.ref,group:e,value:i.class,order:-1,entry:{key:i.class,label:n.label,fill:n.fill,order:x,dt:i.dt,origin:i.origin}}}else if(i.dt==a&&u?.[a]){const e="Structural Variation";return{ref:g.ref,group:e,value:i.class,order:-1,entry:{key:i.class,label:n.label,fill:n.fill,order:x,dt:i.dt,origin:i.origin}}}else if(i.dt==s){return{ref:g.ref,group:d.config.settings.hierCluster?.termGroupName||"Gene Expression",value:i.class,order:-1,entry:{key:i.class,label:"",scale:d.geneExpValues.scale,domain:[0,.5,1],minLabel:d.geneExpValues.min,maxLabel:d.geneExpValues.max,order:x,dt:i.dt,origin:i.origin}}}else{const e=d.settings.matrix.controlLabels;const l=r.legend?.group||(i.origin?`${i.origin[0].toUpperCase()+i.origin.slice(1)} ${e.Mutations}`:e.Mutations);return{ref:g.ref,group:l,value:i.class,order:-2,entry:{key:i.class,label:n.label,fill:n.fill,order:x,dt:i.dt,origin:i.origin}}}}}function d(e,l,t,s,a,n,r,o,i,c,g,d){const u=t.renderedValues||t.filteredValues||t.values||[t.value];e.label=s.value;e.fill=r.getValueColor?.(s.value);e.value=s;const f=r.dimensions.colw;e.height=a.rowh/u.length;e.width=f;e.x=e.totalIndex*c+e.grpIndex*a.colgspace;e.y=i*d;const p=r.config.settings.hierCluster?.termGroupName?r.config.settings.hierCluster?.termGroupName:l.term.type=="geneExpression"?"Expression":l.term.type=="metaboliteIntensity"?"Intensity":"Heatmap color scale";return{ref:n.ref,group:p,order:-1,entry:{label:"",scale:r.hierClusterValues.scale,domain:[0,.5,1],minLabel:r.hierClusterValues.min,maxLabel:r.hierClusterValues.max,order:0,dt:s.dt}}}function u(e,l,t){const s=Object.assign({},e);s.fill=l.cellbg;s.height=l.rowh;s.width=t.colw;s.x=s.totalIndex*t.dx+s.grpIndex*l.colgspace;s.y=0;return s}const f={categorical:c,integer:o,float:o,survival:i,geneVariant:g,hierCluster:d,[r.GENE_EXPRESSION]:o,[r.METABOLITE_INTENSITY]:o};const p={geneVariant:x,integer:h,float:h,categorical:b,survival:h,[r.GENE_EXPRESSION]:h,[r.METABOLITE_INTENSITY]:h};function x(e,l,s,a){if(e.find((e=>e.value.dt==t)))return;const n=Object.assign({},l);n.fill=s.cellbg;n.height=s.rowh;n.width=a.colw;n.x=n.totalIndex*a.dx+n.grpIndex*s.colgspace;n.y=0;return n}function h(e,l,t,s){const a=l.tw.q;if(a.mode!="continuous"){if(e.length)return;b(e,l,t,s)}else{if(a?.mode!="continuous")return;const e=l.tw.settings;const n=e?e.barh+2*e.gap:t.rowh;if(l.height>=n)return;const r=Object.assign({},l);r.fill=t.cellbg;r.height=n||t.rowh;r.width=s.colw;r.x=r.totalIndex*s.dx+r.grpIndex*t.colgspace;r.y=0;return r}}function b(e,l,t,s){if(e.length)return;const a=Object.assign({},l);a.fill=t.cellbg;a.height=t.rowh;a.width=s.colw;a.x=a.totalIndex*s.dx+a.grpIndex*t.colgspace;a.y=0;return a}export{u as getEmptyCell,p as maySetEmptyCell,f as setCellProps,g as setGeneVariantCellProps,d as setHierClusterCellProps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{q as t}from"./app-
|
|
1
|
+
import{q as t}from"./app-71453429.js";class s{constructor(t){this.parent=t.parent;t.svg;this.patternId=`sjpp-matrix-grid-pattern-${this.parent.id}`;this.patternIdSuffix=0;this.dom={holder:t.holder,clusterbg:t.holder.insert("g","g").attr("class","sjpp-matrix-clusterbg").on("mouseover",this.mouseout),outlines:t.holder.append("g").attr("class","sjpp-matrix-clusteroutlines")};e(this)}main(t){this.currData=t;this.settings=t.settings;this.xGrps=t.xGrps;this.xGrpKey=!this.settings.transpose?"samplegrp":"termgrp";this.yGrps=t.yGrps;this.yGrpKey=!this.settings.transpose?"termgrp":"samplegrp";this.clusters=this.processData();this.render(this.clusters)}processData(){const t=this.settings;const s=this.currData.dimensions;const e=[];this.totalWidth=t.zoomLevel==1?-4:0;for(const r of this.xGrps){const n=s.dx;const o=r.prevGrpTotalIndex*n+t.colgspace*r.grpIndex+r.totalHtAdjustments;const a=n*(r.processedLst||r.grp.lst).length+r.grpTotals.htAdjustment-t.colspace;this.totalWidth+=a+2*Math.max(1,t.colspace);for(const n of this.yGrps){const i=n.prevGrpTotalIndex*s.dy+n.grpIndex*t.rowgspace+n.totalHtAdjustments;const c=s.dy*(n.processedLst||n.grp.lst).length+n.grpTotals.htAdjustment-t.rowspace;const p=1;const l=1;e.push({xg:r,yg:n,x:o-p,y:i-l,width:a+2*p,height:c+2*l})}}return e}}function e(s){s.render=function(t){const r=s.settings;const a=s.currData.dimensions;const i=s.dom.outlines.attr("transform")?r.duration:0;s.translateElems(0,r,a,i);if(r.prevShowGrid!=r.showGrid){s.dom.outlines.selectAll("*").remove()}if(r.showGrid!="pattern"){e(t)}else{const e=s.dom.outlines.selectAll("g").data(t,(t=>t.xg.grp.name+";;"+t.yg.grp.name));e.exit().remove();e.each(o);e.enter().append("g").each(n)}r.prevShowGrid=r.showGrid;s.parent.delayedMouseoutHandler()};s.translateElems=function(t,e,r,n=0){const o=!n?s.dom.outlines:s.dom.outlines.transition().duration(n);o.attr("transform",`translate(${r.xOffset+r.seriesXoffset+t},${r.yOffset})`)};function e(t,e,n){const o=s.dom.outlines.selectAll("rect").data(t,(t=>t.xg.grp.name+";;"+t.yg.grp.name));o.exit().remove();o.each(r);o.enter().append("rect").each(r)}function r(e){const r=s.settings;t(this).transition().duration("x"in this?r.duration:0).attr("x",e.x).attr("y",e.y).attr("width",e.width).attr("height",e.height).attr("shape-rendering","crispEdges").attr("fill",!r.showGrid?r.cellbg:r.gridStroke).attr("stroke",r.outlineStroke).attr("stroke-width",1)}function n(e){const r=t(this);const n=r.append("pattern").attr("id",`${s.patternId}-${s.patternIdSuffix++}`).attr("patternUnits","userSpaceOnUse").attr("patternUnits","userSpaceOnUse");n.append("line");n.append("line");r.append("rect");r.append("rect");o.call(this,e)}function o(e){const r=s.settings;const n=s.parent.dimensions;const o=t(this);const c=a(o,r,n);const p=o.node().querySelectorAll("rect");i.call(p[0],e,Object.assign({},r,{fill:r.cellbg}));const l=r.showGrid?`url(#${c})`:"none";i.call(p[1],e,Object.assign({},r,{fill:l,stroke:r.gridStroke}))}function a(s,e,r,n){const o=s.select("pattern").attr("x",0).attr("y",0).attr("width",r.colw+e.colspace).attr("height",e.rowh+e.rowspace);const a=.5*e.rowspace;const i=e.rowh+a;const[c,p]=o.node().querySelectorAll("line");t(c).attr("x1",0).attr("y1",i).attr("x2",r.colw+e.colspace).attr("y2",i).attr("stroke",e.gridStroke).attr("stroke-width",e.rowspace);const l=.5*e.colspace;const d=r.colw+l;t(p).attr("x1",d).attr("y1",0).attr("x2",d).attr("y2",e.rowh).attr("stroke",e.gridStroke).attr("stroke-width",e.colspace);return o.attr("id")}function i(s,e){const r=t(this);r.transition().duration(r.attr("x")?e.duration:0).attr("x",s.x).attr("y",s.y).attr("width",s.width).attr("height",s.height).attr("shape-rendering","crispEdges").attr("fill",e.fill||"none").attr("stroke",e.stroke||"none")}}export{s as MatrixCluster};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bY as e,bZ as t,b_ as s,b$ as a,c0 as i,aS as l,E as o,af as r}from"./app-
|
|
1
|
+
import{bY as e,bZ as t,b_ as s,b$ as a,c0 as i,aS as l,E as o,af as r}from"./app-71453429.js";import{getSortOptions as n}from"./matrix.sort-249d4a35.js";import{f as m}from"./termsetting-636d2271.js";import{d as p}from"./FilterRxComp-fc769f34.js";import"path";import"./table-1dae543a.js";async function c(o={},r){const c={Samples:"Samples",samples:"samples",Sample:"Sample",sample:"sample",Terms:"Variables",terms:"variables",Term:"Variable",term:"Variable",Mutations:"Mutations"};const d={termgroups:[],samplegroups:[],divideBy:null,legendValueFilter:{isAtomic:true,type:"tvslst",in:true,join:"and",lst:[]},legendGrpFilter:{isAtomic:true,type:"tvslst",in:true,join:"and",lst:[]},settings:{matrix:{svgCanvasSwitch:1e3,useMinPixelWidth:true,cellEncoding:"",margin:{top:10,right:5,bottom:20,left:50},maxGenes:o.settings?.maxGenes||50,maxSample:o.settings?.maxSample||1e3,sampleNameFilter:"",sortSamplesBy:"a",sortPriority:undefined,sortByMutation:"consequence",sortByCNV:true,sortSampleGrpsBy:"name",sortSamplesTieBreakers:[{$id:"sample",sortSamples:{}}],sortTermsBy:"sampleCount",samplecount4gene:o.chartType=="hierCluster"?"":"abs",geneVariantCountSamplesSkipMclass:[],cellbg:"#ececec",showGrid:"",addMutationCNVButtons:false,truncatingMutations:e,proteinChangingMutations:t,synonymousMutations:s,mutationClasses:a,CNVClasses:i,gridStroke:"#fff",outlineStroke:"#ccc",beamStroke:"#f00",colw:0,colwMin:.1/window.devicePixelRatio,colwMax:16,colspace:1,colgspace:8,colglabelpos:true,collabelpos:"bottom",collabelvisible:true,collabelgap:5,collabelpad:1,collabelmaxchars:32,rowh:18,rowspace:1,rowgspace:8,rowlabelpos:"left",rowlabelgap:5,rowlabelvisible:true,rowlabelpad:1,rowlabelmaxchars:32,legendGrpLabelMaxChars:26,grpLabelFontSize:12,minLabelFontSize:6,maxLabelFontSize:14,transpose:false,sampleLabelOffset:120,sampleGrpLabelOffset:120,sampleGrpLabelMaxChars:32,termLabelOffset:80,termGrpLabelOffset:80,termGrpLabelMaxChars:32,duration:0,zoomLevel:1,zoomCenterPct:0,zoomIndex:0,zoomGrpIndex:0,zoomMin:.5,zoomIncrement:.1,zoomStep:1,imgWMax:6e4/window.devicePixelRatio,scrollHeight:12,controlLabels:c,cnvUnit:"log2ratio",ignoreCnvValues:false,barh:32,showHints:[]}}};const f=d.settings;const u=Math.max(f.matrix.rowh+f.matrix.rowspace-3*f.matrix.rowlabelpad,12);f.legend={ontop:false,lineh:25,padx:5,padleft:0,padright:20,padbtm:30,fontsize:u,iconh:u-2,iconw:u-2,hangleft:1,linesep:false};const g=r.vocabApi.termdbConfig.matrix||{};l(d.settings.matrix,g.settings);if(g.legendGrpFilter)d.legendGrpFilter=g.legendGrpFilter;if(g.legendValueFilter)d.legendValueFilter=g.legendValueFilter;if(o.name){const e=await r.vocabApi.getMatrixByName(o.name);if(!e)throw"error from getMatrixByName()";if(e.error)throw e.error;l(d,e)}const h=o?.settings?.matrix;if(h){if((h.sortSamplesBy=="custom"||h.sortSamplesBy=="asListed")&&h.sortOptions?.custom.label=="against alteration type"){h.sortSamplesBy="a"}if(h.sortOptions){delete h.sortOptions.custom;delete h.sortOptions.asListed}}l(d,o);const b=d.settings.matrix;b.sortOptions=n(r.vocabApi.termdbConfig,c,b);b.duration=0;b.colw=0;if(b.sortSamplesBy!="asListed"&&!b.sortOptions?.[b.sortSamplesBy])b.sortSamplesBy="a";else if(["selectedTerms","class","dt","hits"].includes(b.sortSamplesBy))b.sortSamplesBy="a";if(b.samplecount4gene===true||b.samplecount4gene===1)b.samplecount4gene="abs";if(window.location.hostname=="localhost"){if(window.location.hash=="#canvas")b.svgCanvasSwitch=0}const y=[];for(const e of d.termgroups){e.lst=JSON.parse(JSON.stringify(e.lst));for(const t of e.lst){if(!t.term?.type||p(t.term.type)){if(!t.id){if(!t.term.id)throw`missing tw.id and tw.term.id`;t.id=t.term.id}delete t.term}y.push(m(t,r.vocabApi))}}if(d.divideBy)y.push(m(d.divideBy,r.vocabApi));await Promise.all(y);return d}function d(e){const t=e.settings.matrix;const s=[...t.mutationClasses,...t.CNVClasses];t.filterByClass={isAtomic:true};for(const a of e.legendGrpFilter.lst){if(!a.dt)continue;s.filter((e=>a.dt.includes(o[e].dt))).forEach((e=>{t.filterByClass[e]="value"}))}for(const s of e.legendValueFilter.lst){if(!s.legendGrpName||!s.tvs?.term?.type.startsWith("gene"))continue;if(s.tvs.values?.[0].mclasslst)s.tvs.values[0].mclasslst.forEach((e=>{t.filterByClass[e]=s.legendFilterType?.endsWith("_hard")?"case":"value"}));else if(s.tvs.values)s.tvs.values.forEach((e=>{t.filterByClass[key]="value"}));else throw`unhandled tvs from legendValueFilter`}t.hiddenVariants=Object.keys(t.filterByClass).filter((e=>e!=="isAtomic"));const a=new Set(t.hiddenVariants.filter((e=>o[e]?.dt===r)));t.hiddenCNVs=[...a];t.showMatrixCNV=!a.size?"all":a.size==t.CNVClasses.length?"none":"bySelection";t.allMatrixCNVHidden=a.size==t.CNVClasses.length;const i=new Set(t.hiddenVariants.filter((e=>t.mutationClasses.find((t=>t===e)))));t.hiddenMutations=[...i];const l=new Set(t.proteinChangingMutations);const n=new Set(t.truncatingMutations);t.showMatrixMutation=!i.size?"all":i.size==t.mutationClasses.length?"none":i.size===t.mutationClasses.length-l.size&&[...i].every((e=>!l.has(e)))?"onlyPC":i.size===t.mutationClasses.length-n.size&&[...i].every((e=>!n.has(e)))?"onlyTruncating":"bySelection";t.allMatrixMutationHidden=i.size==t.mutationClasses.length;const m=t.sortOptions.a?.sortPriority.find((e=>e.types.length==1&&e.types[0]=="geneVariant"))?.tiebreakers||[];t.sortByMutation=m.find((e=>e.filter?.values[0]?.dt===1)).isOrdered?"consequence":"presence";t.sortByCNV=m.find((e=>e.filter?.values[0]?.dt===4)).disabled!==true}export{c as getPlotConfig,d as setComputedConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initByInput as t}from"./controls.config-e0f394cb.js";import{q as e,M as a,aU as n,L as s,O as i,E as o,af as l,aJ as r,J as p,K as c,aV as d}from"./app-f91922b4.js";import{getSorterUi as h}from"./matrix.sorterUi-2025f39d.js";import{f as m,g as u}from"./termsetting-9a7511e6.js";import{m as g}from"./radiobutton-09bff425.js";import{m as y}from"./checkbox-0e5c659f.js";import{k as b}from"./recover-a08c8d01.js";import"./controls.overlay-3ac8773d.js";import"./FilterRxComp-0e75dd8d.js";import"./table-d6c411fd.js";import"path";import"./controls.term1-008f4be4.js";import"./controls.divide-d8ac5a9b.js";import"./FilterStateless-ad3df967.js";import"./app-bfce9bf5.js";import"./termInfo-96285f4a.js";function x(t){if(!t.holder)throw`zoom requires an opts.holder`;if(typeof t.callback!="function")throw`zoom requires an opts.callback function`;const e={min:1,max:100,value:25,step:10,increment:1,numberInputWidth:"35px",showJumpBtns:false};const a=Object.assign({},e,t.settings||{});t.holder.attr("title",t.title||null).style("vertical-align","top").style("text-align","center").on("mouseenter",(()=>{o.style("display","inline-block").style("overflow","visible")})).on("mouseleave",(()=>{o.style("display","none").style("overflow","hidden")}));const n=t.holder.append("label");n.append("span").text("Zoom");const s=n.append("input").attr("title","enter a desired zoom level").attr("type","number").attr("min",a.min).attr("max",a.max).attr("step",a.increment).style("min-width",a.numberInputWidth).style("width",t.width||"fit-content").style("margin","3px 5px").property("value",a.value).on("change",(e=>{const a=Number(e.target.value);c.update({value:a});t.callback(a)}));n.append("span").text("unit"in t?t.unit:"%");const i=t.holder.node().getBoundingClientRect();t.holder.style("max-height",i.height+"px").style("max-width",i.width+"px");t.holder.append("br");const o=t.holder.append("div").style("display","none");const l=!t.showJumpBtns?null:t.holder.append("button").attr("title","Zoom in").style("width","25px").html("-").on("click",(()=>{const e=Math.max(a.step*Math.ceil((a.value-a.step)/a.step),a.min);c.update({value:e});t.callback(e)}));const r=o.append("input").attr("title","slide to desired zoom level").attr("type","range").attr("min",a.min).attr("max",a.max).attr("step",a.increment).style("margin","2px 5px").style("padding",0).style("vertical-align","middle").property("value",a.value).html("-").on("input",(t=>{s.property("value",t.target.value)})).on("change",(e=>{const a=Number(e.target.value);c.update({value:a});t.callback(a)}));const p=!t.showJumpBtns?null:t.holder.append("button").attr("title","Zoom out").style("width","25px").html("+").on("click",(()=>{const e=Math.min(a.step*Math.floor((a.value+a.step)/a.step),a.max);c.update({value:e});t.callback(e)}));o.append("span").style("text-decoration","underline").style("cursor","pointer").style("title","use the default zoom value").text("Reset").on("click",t.reset);const c={update(e={}){const n=t.holder.node().getBoundingClientRect();if(!n.height||!n.width){t.holder.style("max-height","").style("max-width","");const e=t.holder.node().getBoundingClientRect();t.holder.style("max-height",e.height+"px").style("max-width",e.width+"px")}Object.assign(a,e);r.property("value",a.value).attr("min",a.min).attr("max",a.max).attr("step",a.increment);s.property("value",a.value).attr("min",a.min).attr("max",a.max).attr("step",a.increment);l?.property("disabled",a.value<=a.min);p?.property("disabled",a.value>=a.max)}};if(t.debug)c.Inner={settings:a,number:s,slider:r,minusBtn:l,plusBtn:p};return c}function f(t){if(!t.holder)throw`missing svgScroll.opts.holder argument`;const a={height:12,zoomLevel:1,opacity:.3};const n=Object.assign({},a,t);function s(t){g.x=t.clientX;e("body").on("mousemove.sjppSvgScroll",i).on("mouseup.sjppSvgScroll",o)}function i(t){if(!("x"in g))return;const e=t.clientX-g.x;if(g.sliderX+g.sliderWidth+e>n.visibleWidth-1){return}if(g.sliderX+e<0){return}m.attr("x",g.sliderX+e);n.callback(g.dxFactor*e,"move")}function o(t){if(!("x"in g))return;const a=t.clientX-g.x;n.callback(g.dxFactor*Math.min(g.maxDx,Math.max(a,g.minDx)),"up");delete g.x;e("body").on("mousemove.sjppSvgScroll",null).on("mouseup.sjppSvgScroll",null)}function l(t){g.x=t.clientX;const e=t.clientX<u.getBoundingClientRect().x?-1:1;o({clientX:Math.floor(g.x+e*g.arrowDx)})}n.holder.attr("display","none").attr("opacity",n.opacity).on("mouseover",(()=>n.holder.attr("opacity",1))).on("mouseout",(()=>n.holder.attr("opacity",n.opacity)));const r=n.holder.append("rect").style("height",n.height).style("stroke","none").style("fill","#fff").on("click",l);const p=n.holder.append("line").style("stroke","#ccc").style("stroke-width",1).on("click",l);const c=n.holder.append("path").attr("y",-n.height).attr("d",`M0,${n.height/2}L${n.height},0L${n.height},${n.height}Z`).style("stroke","#ccc").style("stroke-width",1).style("fill","#ccc").on("click",(t=>{g.x=t.clientX;o({clientX:Math.round(g.x-g.arrowDx)})}));const d=n.holder.append("path").attr("y",-n.height).style("stroke","#ccc").style("stroke-width",1).style("fill","#ccc").attr("d",`M0,0L${n.height},${n.height/2}L0,${n.height}Z`).on("click",(t=>{g.x=t.clientX;o({clientX:Math.round(g.x+g.arrowDx)})}));const h=n.height-4;const m=n.holder.append("rect").attr("y",2).attr("height",h).attr("stroke","#aaa").attr("stroke-width",1).attr("fill","#ccc").attr("rx",h/2).on("mousedown",s).on("mousemove",i).on("mouseup",o);const u=m.node();const g={};const y={update(t){const e={v:n.visibleWidth,t:n.totalWidth,z:n.zoomCenter};Object.assign(n,t);const a=n.totalWidth;const s=n.visibleWidth;if(a<=s){n.holder.attr("display","none");return}n.holder.attr("transform",`translate(${n.x},${n.y})`).attr("display","");r.attr("width",s);p.attr("x1",0).attr("x2",s).attr("y1",n.height/2).attr("y2",n.height/2);c.attr("transform",`translate(0,0)`);d.attr("transform",`translate(${s-n.height},0)`);if(s!=e.v||a!=e.t){g.sliderWidth=s*s/a;g.dxFactor=(a-s)/(s-g.sliderWidth)}const i=s*(n.zoomCenter/a);g.sliderX=Math.max(0,Math.min(i-g.sliderWidth/2,s-g.sliderWidth-1));m.attr("width",g.sliderWidth).attr("x",g.sliderX);g.maxDx=n.visibleWidth-g.sliderX-g.sliderWidth;g.minDx=-g.sliderX;g.arrowDx=Math.round(.1*n.visibleWidth);delete g.x}};return y}const v=new a({padding:""});class w{constructor(t,e){this.type="matrixControls";this.opts=t;this.parent=t.parent;this.overrides={};this.opts.holder.style("margin","10px 10px 20px 10px").style("white-space","nowrap");const a=this.parent.getState(e);const n=a.config.settings.matrix;if(this.parent.setClusteringBtn)this.parent.setClusteringBtn(this.opts.holder,((t,e)=>this.callback(t,e)));this.setSamplesBtn(n);this.setGenesBtn(n);if(n.addMutationCNVButtons&&this.parent.chartType!=="hierCluster"){this.setMutationBtn();this.setCNVBtn()}this.setVariablesBtn(n);this.setDimensionsBtn(n);this.setLegendBtn(n);this.setDownloadBtn(n);this.setZoomInput();this.setDragToggle({holder:this.opts.holder.append("div").style("display","inline-block"),target:this.parent.dom.seriesesG});this.setSvgScroll(a);this.keyboardNavHandler=async t=>{if(t.target.tagName=="BUTTON")this.keyEventTarget=t.target;if(t.key=="Escape"){this.parent.app.tip.hide()}else if(t.key=="Enter"||t.key=="ArrowDown"){const e=t.target.tagName=="BUTTON"?this.parent.app.tip.d.node().querySelectorAll("input, select"):t.target.querySelectorAll("input, select");for(const t of e){if(t.checkVisibility?.()||!t.checkVisibility&&t.getBoundingClientRect().height){t.focus();return false}}}else if(t.key=="Tab"&&t.shiftKey||t.key=="Backspace"||t.key=="ArrowUp"){this.keyEventTarget.focus();return false}};this.btns=this.opts.holder.selectAll(":scope>button").filter((t=>t&&t.label)).on(`keyup.matrix-${this.parent.id}`,this.keyboardNavHandler)}setSamplesBtn(t){const e=t.controlLabels;const a=this;const n=this.parent;const s=[{label:`Maximum # ${e.Samples}`,title:`Limit the number of displayed ${e.samples}`,type:"number",chartType:"matrix",settingsKey:"maxSample",getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"}},{label:`Sort ${e.Sample} Groups`,title:`Set how to sort ${e.sample} groups`,type:"radio",chartType:"matrix",settingsKey:"sortSampleGrpsBy",options:[{label:"Predefined or Group Name",value:"name",title:`Sort by group name`},{label:`${e.Sample} Count`,value:"sampleCount",title:`Sort by the number of samples in the group`},{label:`Hits`,value:"hits",title:`Sort by the total number of variants for every ${e.sample} in the group`}],getDisplayStyle(t){return t.divideBy&&!t.hierCluster?"table-row":"none"}},{label:`${e.Sample} Group Label Character Limit`,title:`Truncate the ${e.sample} group label if it exceeds this maximum number of characters`,type:"number",chartType:"matrix",settingsKey:"sampleGrpLabelMaxChars",getDisplayStyle(t){return t.divideBy&&!t.hierCluster?"table-row":"none"}},{label:`${e.Sample} Label Character Limit`,title:`Truncate the ${e.sample} label if it exceeds this maximum number of characters`,type:"number",chartType:"matrix",settingsKey:"collabelmaxchars"},{label:`Group ${e.Samples} By`,title:`Select a variable with discrete values to group ${e.samples}`,type:"term",chartType:"matrix",configKey:"divideBy",vocabApi:this.opts.app.vocabApi,state:{vocab:this.opts.vocab},getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"},processInput:t=>{if(t)m(t,this.opts.app.vocabApi);return t},processConfig:t=>{if(this.parent.config.divideBy)t.legendValueFilter=this.parent.mayRemoveTvsEntry(this.parent.config.divideBy)},getBodyParams:()=>{const t=this.parent.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}}}];s.push({label:`Sort ${e.Sample} Priority`,title:`Set how to sort ${e.samples}`,type:"custom",init(t){const e=n.config.settings.matrix;if(!a.activeTab)a.activeTab="basic";t.dom.inputTd.style("padding","5px");const s=t.dom.inputTd.append("div").style("margin-bottom","5px");const i=s.append("div").style("display","inline-block").style("padding-right","5px").style("border-right","2px solid black").style("text-decoration",a.activeTab=="basic"?"underline":"").style("cursor","pointer").html("Basic").on("click",(()=>{a.activeTab="basic";i.style("text-decoration","underline");o.style("text-decoration","");l.style("display","");m.style("display","none")}));const o=s.append("div").style("display","inline-block").style("margin-left","5px").style("text-decoration",a.activeTab=="advanced"?"underline":"").style("cursor","pointer").html("Advanced").on("click",(()=>{a.activeTab="advanced";i.style("text-decoration","");o.style("text-decoration","underline");l.style("display","none");m.style("display","")}));const l=t.dom.inputTd.append("div").style("display",a.activeTab=="basic"?"":"none");const r=l.append("div");r.append("span").html("SSM");const{inputs:p}=g({holder:r.append("span"),options:[{label:"by consequence",value:"consequence",checked:e.sortByMutation==="consequence"},{label:"by presence",value:"presence",checked:e.sortByMutation==="presence"}],styles:{display:"inline-block"},callback:t=>{const e=n.config.settings.matrix.sortOptions;const a=e.a;const s=a.sortPriority[0].tiebreakers[1];s.disabled=!t;s.isOrdered=t==="consequence";n.app.dispatch({type:"plot_edit",id:n.id,config:{settings:{matrix:{sortByMutation:t,sortOptions:e}}}})}});p.style("margin","2px 0 0 2px").style("vertical-align","top");const c=l.append("div").style("display",e.showMatrixCNV!="none"&&!e.allMatrixCNVHidden?"block":"none");c.append("span").html("CNV");const d=y({holder:c.append("span"),divstyle:{display:"inline-block"},checked:e.sortByCNV,labeltext:"sort by CNV",callback:()=>{const t=d.property("checked");const e=n.config.settings.matrix.sortOptions;const a=e.a;const s=a.sortPriority[0].tiebreakers[2];s.disabled=!t;s.isOrdered=t;n.app.dispatch({type:"plot_edit",id:n.id,config:{settings:{matrix:{sortByCNV:t,sortOptions:e}}}})}});const m=t.dom.inputTd.append("div").style("display",a.activeTab=="advanced"?"":"none");t.dom.row.on("mouseover",(function(){this.style.backgroundColor="#fff";this.style.textShadow="none"}));if(!a.sorterUi){a.sorterUi=h({controls:this,holder:m,tip:this.parent.app.tip})}else{a.sorterUi.main(this.parent.config.settings.matrix,{holder:m})}return{main:t=>{const e=t.settings.matrix;p.property("checked",(t=>t.value==e.sortByMutation));d.property("checked",e.sortByCNV);c.style("display",e.showMatrixCNV!="none"&&!e.allMatrixCNVHidden?"block":"none")}}}});this.opts.holder.append("button").datum({label:e.Samples||`Samples`,getCount:()=>"sampleCount"in this.overrides?this.overrides.sampleCount:this.parent.sampleOrder?.length||0,rows:s,customInputs:this.updateSamplesControls}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setGenesBtn(t){const e=t.controlLabels;const a=[{label:` Stacked <span style="font-size:.7em;color:#858585;">Show stacked rectangles in the same matrix cell to render variants for the same ${e.sample} and gene</span>`,value:"",title:`Show stacked rectangles in the same matrix cell to render variants for the same ${e.sample} and gene`},{label:` OncoPrint <span style="font-size:.7em;color:#858585;">Show overlapping rectangles in the same matrix cell to render variants for the same ${e.sample} and gene</span>`,value:"oncoprint",title:`Show overlapping rectangles in the same matrix cell to render variants for the same ${e.sample} and gene`}];if(t.addMutationCNVButtons&&this.parent.chartType!=="hierCluster")a.unshift({label:` Single <span style="font-size:.7em;color:#858585;">Show a single rectangle in a matrix cell to render the most severe variant (truncating > indels > missense > synonymous) for the same ${e.sample} and gene</span>`,value:"single",title:`Show a single rectangle in a matrix cell to render the most severe variant (truncating > indels > missense > synonymous) for the same ${e.sample} and gene`});this.opts.holder.append("button").datum({label:"Genes",getCount:()=>this.parent.termOrder?.filter((t=>t.tw.term.type=="geneVariant")).length||0,customInputs:this.appendGeneInputs,rows:[{label:`Display ${e.Sample} Counts for Gene`,title:`Include the ${e.sample} count in the gene label`,type:"radio",chartType:"matrix",settingsKey:"samplecount4gene",options:[{label:"Absolute",value:"abs"},{label:`Percent`,value:"pct"},{label:`None`,value:""}]},{label:`Row Group Label Character Limit`,title:`Truncate the row group label if it exceeds this maximum number of characters`,type:"number",chartType:"matrix",settingsKey:"termGrpLabelMaxChars"},{label:`Row Label Character Limit`,title:`Truncate the row label if it exceeds this maximum number of characters`,type:"number",chartType:"matrix",settingsKey:"rowlabelmaxchars"},{label:"Genomic Alterations Rendering",title:`Set how to indicate a ${e.sample}'s applicable variant types in the same matrix cell`,type:"radio",chartType:"matrix",settingsKey:"cellEncoding",options:a,styles:{padding:"5px 0px",margin:0},labelDisplay:"block",callback:this.parent.geneStyleControlCallback},{label:"Sort Genes",title:"Set how to order the genes as rows",type:"radio",chartType:"matrix",settingsKey:"sortTermsBy",options:[{label:"By Input Data Order",value:"asListed"},{label:`By ${e.sample} Count`,value:"sampleCount"}],styles:{padding:0,"padding-right":"10px",margin:0}}]}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setVariablesBtn(t){t.controlLabels;this.opts.holder.append("button").datum({label:t.controlLabels.Terms||`Variables`,rows:[{label:`Row Group Label Max Length`,title:`Truncate the row group label if it exceeds this maximum number of characters`,type:"number",chartType:"matrix",settingsKey:"termGrpLabelMaxChars"},{label:`Row Label Max Length`,title:`Truncate the row label if it exceeds this maximum number of characters`,type:"number",chartType:"matrix",settingsKey:"rowlabelmaxchars"}],customInputs:this.appendDictInputs}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setDimensionsBtn(t){const e=t.controlLabels;this.opts.holder.append("button").datum({label:"Cell Layout",tables:[{rows:[{label:"Grid",title:"Show grid lines, which creates borders around each matrix cells. "+" Note that grid lines are hidden when the auto-computed width <= 2, or when either the column and row spacing is set to 0.",type:"checkbox",boxLabel:"show",processInput:t=>t===true?"rect":t==="rect",chartType:"matrix",settingsKey:"showGrid",colspan:2,align:"center"},{label:"Outline Color",title:"Set a border color for the whole matrix",type:"color",chartType:"matrix",settingsKey:"outlineStroke",colspan:2,align:"center"},{label:"Beam Color",title:"Set a color for the beam highlighter",type:"color",chartType:"matrix",settingsKey:"beamStroke",colspan:2,align:"center"},{label:"Grid Line Color",title:"Set the grid color, equivalent to applying the same border color for each matrix cell",type:"color",chartType:"matrix",settingsKey:"gridStroke",colspan:2,align:"center"},{label:"Background Color",title:`Set the background color when there are no alterations or annotation data for a ${e.sample}`,type:"color",chartType:"matrix",settingsKey:"cellbg",colspan:2,align:"center"},{label:`Use Canvas If # ${e.sample} Exceeds`,title:`Switch from SVG to canvas rendering when the number of ${e.samples} exceeds this number`,type:"number",chartType:"matrix",settingsKey:"svgCanvasSwitch",colspan:2,align:"center",width:60,min:0,max:1e4,step:1},{label:"Canvas Min. Pixel Width",title:"Set a minimum pixel width for a matrix cell when using canvas, may affect the perceived sharpness of the canvas image",type:"checkbox",boxLabel:"apply",chartType:"matrix",settingsKey:"useMinPixelWidth",colspan:2,align:"center",getDisplayStyle:()=>this.parent.settings.matrix.useCanvas?"":"none"}]},{header:["Cells","Columns","Rows"],rows:[{label:"Row Height",title:"Set the height of a matrix row",type:"number",width:50,align:"center",chartType:"matrix",inputs:[{label:"N/A"},{settingsKey:"rowh",min:8,max:30,step:1}],getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"}},{label:"Min Col. Width",title:"Set the minimum width of the auto-computed matrix column width",type:"number",width:50,align:"center",chartType:"matrix",inputs:[{settingsKey:"colwMin",min:.1,max:16,step:.2},{label:"N/A"}]},{label:"Max Col. Width",title:"Set the maximum width of the auto-computed matrix column width",type:"number",width:50,align:"center",chartType:"matrix",inputs:[{settingsKey:"colwMax",min:1,max:24,step:.2},{label:"N/A"}]},{label:"Spacing",title:"Set the column spacing. Note that this will be set to 0 when the auto-computed width < 2.",type:"number",width:50,align:"center",chartType:"matrix",inputs:[{settingsKey:"colspace",min:0,max:20,step:1},{settingsKey:"rowspace",min:0,max:20,step:1}],getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"}},{label:"Group spacing",title:"Set the spacing between column and row groups.",type:"number",width:50,align:"center",chartType:"matrix",inputs:[this.parent.chartType=="hierCluster"?{label:"N/A"}:{settingsKey:"colgspace",min:0,max:20,step:1},{settingsKey:"rowgspace",min:0,max:20,step:1}]}]},{header:["Labels","Columns","Rows"],rows:[{label:"Offset",title:"Set the gap between the label text and matrix edge",type:"number",width:50,align:"center",chartType:"matrix",inputs:[{settingsKey:"collabelgap",min:0,max:20,step:1},{settingsKey:"rowlabelgap",min:0,max:20,step:1}]},{label:"Spacing",title:"Set the gap between labels",type:"number",width:50,align:"center",chartType:"matrix",inputs:[{settingsKey:"collabelpad",min:0,max:20,step:1},{settingsKey:"rowlabelpad",min:0,max:20,step:1}]},{label:"Min font size",title:"Set the minimum auto-computed font size for labels. Note that labels will be hidden if the auto-computed values falls below this minimum.",type:"number",width:50,align:"center",colspan:2,chartType:"matrix",settingsKey:"minLabelFontSize",min:0,max:24,step:.1},{label:"Max font size",title:"Set the maximum auto-computed font size for labels",type:"number",width:50,align:"center",colspan:2,chartType:"matrix",settingsKey:"maxLabelFontSize",min:0,max:24,step:.1},{label:"Group label<br/>position",title:"Set which side of the matrix to display group labels",type:"radio",width:50,chartType:"matrix",labelDisplay:"block",getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"},inputs:[{settingsKey:"collabelpos",options:[{label:"Top",value:"bottom",title:`Display ${e.sample} group labels at the bottom`},{label:"Bottom",value:"top",title:`Display ${e.sample} group labels on top`}]},{settingsKey:"rowlabelpos",options:[{label:"Left",value:"right",title:`Display gene or variable group labels on the left side`},{label:"Right",value:"left",title:`Display gene or variable group labels on the right side`}]}]}]}]}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setLegendBtn(t){this.opts.holder.append("button").style("margin","2px 0").datum({label:"Legend Layout",rows:[{label:"Font Size",title:"Set the font size for the legend text",type:"number",chartType:"legend",settingsKey:"fontsize"},{label:"Line Height",title:"Set the line height for a legend group",type:"number",chartType:"legend",settingsKey:"lineh"},{label:"Icon Height",title:"Set the icon height for a legend item",type:"number",chartType:"legend",settingsKey:"iconh"},{label:"Icon Width",title:"Set the icon width for a legend item",type:"number",chartType:"legend",settingsKey:"iconw"},{label:"Item Left Pad",title:"Set a left margin for each legend item",type:"number",chartType:"legend",settingsKey:"padx"},{label:"Left Margin",title:"Set a left margin for the whole legend",type:"number",chartType:"legend",settingsKey:"padleft"},{label:"Left Indent",title:`Set a left margin for the first legend item in each group, and should be set to the length of the longest group label.`+` The left indent will align the legend group label text to the right.`,type:"number",chartType:"legend",settingsKey:"hangleft"},{label:"Item Layout",title:"Option to separate each legend item into a new line, instead of a horizontal layout in the same line.",type:"checkbox",chartType:"legend",settingsKey:"linesep",boxLabel:"Line separated"}]}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setMutationBtn(){this.opts.holder.append("button").style("margin","2px 0").datum({label:"Mutation",updateBtn:t=>{const e=this.parent.config.settings.matrix;t.style("text-decoration",e.allMatrixMutationHidden?"line-through":"").style("text-decoration-thickness",e.allMatrixMutationHidden?"2px":"")},rows:[{title:`Show mutation options`,type:"radio",chartType:"matrix",settingsKey:"showMatrixMutation",options:[{label:"Show all mutations",value:"all"},{label:`Show only truncating mutations`,value:"onlyTruncating"},{label:`Show only protein-changing mutations`,value:"onlyPC"},{label:`Do not show mutations`,value:"none"},{label:`Show selected mutation`,value:"bySelection"}],labelDisplay:"block",getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"},callback:this.parent.mutationControlCallback}],customInputs:this.generateMutationItems}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setCNVBtn(){this.opts.holder.append("button").style("margin","2px 0").datum({label:"CNV",updateBtn:t=>{const e=this.parent.config.settings.matrix;const a=e.allMatrixCNVHidden;t.style("text-decoration",a?"line-through":"").style("text-decoration-thickness",a?"2px":"")},rows:[{title:`Show CNV options`,type:"radio",chartType:"matrix",settingsKey:"showMatrixCNV",options:[{label:"Show all CNV",value:"all"},{label:`Do not show CNV`,value:"none"},{label:`Show selected CNV`,value:"bySelection"}],labelDisplay:"block",getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"},callback:this.parent.CNVControlCallback}],customInputs:this.generateCNVItems}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setDownloadBtn(t){this.opts.holder.append("button").style("margin","2px 0").text("Download").on("focus",(()=>this.parent.app.tip.hide())).on("click.sjpp-matrix-download",(t=>{const e=this.parent;if(!e.dom.downloadMenu)e.dom.downloadMenu=new a({padding:""});const d=e.dom.downloadMenu.clear();const h=d.d.append("div");h.append("div").attr("class","sja_menuoption sja_sharp_border").text(`SVG image`).on("click.sjpp-matrix-download",(()=>{n(this.opts.getSvg(),"matrix",{apply_dom_styles:true});e.dom.downloadMenu.destroy()}));h.append("div").attr("class","sja_menuoption sja_sharp_border").text(`TSV data`).on("click.sjpp-matrix-download",(()=>{const t=e.data.lst;const a=e.termOrder.map((t=>t.tw));const n=e.state.termdbConfig.assayAvailability;const d=e.settings.matrix.controlLabels;if(e.config.divideBy?.id&&!a.find((t=>t.id==e.config.divideBy.id))){a.push(e.config.divideBy)}const h=[];for(const e of t){for(const t of a){if(t.$id in e){h.push(e);break}}}const m=[d.Sample];for(const t of a)m.push(t.term.name);const u=[m];for(const t of h){const e=[t._ref_.label];for(const d of a){if(!t[d.$id]){e.push("")}else{if(d.term.type=="geneVariant"){const a=[];for(const e of t[d.$id].renderedValues){const t=n?.byDt?.[parseInt(e.dt)];if(e.dt==s){a.push((e.origin?`${e.origin} `:"")+(t?`${i[e.dt]}:`:"")+`${o[e.class]?.label}`+(e.mname?`,${e.mname}`:""))}else if(e.dt==l){const n=e.value?`${t?"":"CNV:"}${e.value}`:e.class=="CNV_amp"?"CNV gain":e.class=="CNV_loss"?"CNV loss":o[e.class]?.label;a.push((e.origin?`${e.origin} `:"")+(t?`${i[e.dt]}:`:"")+n)}else if(e.dt==r){a.push(e.origin?`${e.origin}:${e.value}`:e.value)}else if(e.dt==p||e.dt==c){a.push((e.origin?`${e.origin} `:"")+(t?`${i[e.dt]}:`:"")+`${o[e.class]?.label}`+(e.gene&&e.mname?`(${e.gene}::${e.mname})`:""))}else{a.push(`DO NOT SUPPORT dt='${e.dt}'`)}}e.push(a.join("|"))}else{e.push(t[d.$id]?.renderedValues?.[0]||t[d.$id]?.value||"")}}}u.push(e)}const g=u.map((t=>t.join("\t"))).join("\n");const y=document.createElement("a");document.body.appendChild(y);y.addEventListener("click",(function(){const t=(new Date).toISOString().split("T")[0];y.download=e.config.settings?.hierCluster?.termGroupName?.startsWith("Gene Expression")?`GeneExpression.${t}.tsv`:e.chartType=="hierCluster"?`HierCluster.${t}.tsv`:`${e.app.vocabApi.termdbConfig.matrix?.appName||"Matrix"}.${t}.tsv`;y.href=URL.createObjectURL(new Blob([g],{type:"text/tab-separated-values"}));document.body.removeChild(y)}),false);y.click();e.dom.downloadMenu.destroy()}));d.showunder(t.target)}))}main(t={}){this.overrides=t;this.parent.app.tip.hide();this.btns.text((t=>(t.getCount?`${t.getCount()} `:"")+t.label)).each((function(t){if(t.updateBtn)t.updateBtn(e(this))}));const a=this.parent.config.settings.matrix;const n=this.parent.dimensions;if(this.zoomApi)this.zoomApi.update({value:a.zoomLevel.toFixed(1),min:a.colwMin/a.colw,max:a.colwMax/a.colw,increment:a.zoomIncrement,step:a.zoomStep||1});if(this.svgScrollApi&&n){this.svgScrollApi.update({x:n.xOffset,y:n.yOffset-a.scrollHeight,totalWidth:n.zoomedMainW,visibleWidth:n.mainw,zoomCenter:a.zoomCenterPct*n.mainw-n.seriesXoffset})}if(this.dragToggleApi){this.dragToggleApi.update(a.mouseMode?{mouseMode:a.mouseMode}:{})}}getSettings(){return{mouseMode:this.dragToggleApi.getSettings().mouseMode}}async callback(e,a){const n=this.opts.app;const s=this.opts.parent;const i=a.tables||[a];e.target.focus();n.tip.clear();const o=n.tip.d.append("table").attr("class","sjpp-controls-table");for(const e of i){if(e.header){o.append("tr").selectAll("th").data(e.header).enter().append("th").html((t=>t))}for(const a of e.rows){const e=o.append("tr");if(a.title)e.attr("title",a.title);const i=await t[a.type](Object.assign({},{holder:e,dispatch:n.dispatch,id:s.id,debug:this.opts.debug,parent:s},a));i.main(s.config)}if(e.customInputs)e.customInputs(this,n,s,o);o.selectAll("select, input, button").attr("tabindex",0).on("keydown",self.keyboardNavHandler)}n.tip.showunder(e.target)}prependInfo(t,e,a){const n=t.append("tr");n.append("td").text(e).attr("class","sja-termdb-config-row-label");n.append("td").text(a)}async appendGeneInputs(e,a,n,s){v.clear();if(!n.selectedGroup)n.selectedGroup=0;if(n.opts.customInputs?.genes){for(const a of n.opts.customInputs?.genes){a.chartType="matrix";const i=s.append("tr");if(a.title)i.attr("title",a.title);const o=await t[a.type](Object.assign({},{holder:i,id:n.id,debug:e.opts.debug,parent:n},a));o.main(n.config)}}e.addGenesetInput(event,a,n,s.append("tr"))}addGenesetInput(t,e,a,n){const s=this.btns.filter((t=>t.label=="Genes"))?.node();const i=e.tip;const o=a.config.termgroups;let l;const r=t=>{t.selectAll("*").remove();const a=l.lst.map((t=>({gene:t.name})));b({holder:t,genome:e.opts.genome,geneList:a,mode:l.mode,minNumGenes:l.mode=="expression"?3:1,vocabApi:this.opts.app.vocabApi,callback:async({geneList:t,groupName:a})=>{if(!l)throw`missing selectedGroup`;i.hide();const n=l.status=="new"?{name:a,lst:[]}:o[l.index];if(l.status=="new")o.push(n);const s=n.lst.filter((t=>t.term.type!="geneVariant"));const r=await Promise.all(t.map((async t=>{const e={gene:t.symbol||t.gene,name:t.symbol||t.gene,type:"geneVariant"};let a=n.lst.find((e=>e.term.name==t.symbol||e.term.name==t.gene));if(!a){a={term:e,q:{}};a.$id=await u(this.opts.app.vocabApi.getTwMinCopy(a))}else if(!a.$id){a.$id=await u(this.opts.app.vocabApi.getTwMinCopy({term:e}))}return a})));n.lst=[...s,...r];if(!n.lst.length)o.splice(l.index,1);e.dispatch({type:"plot_edit",id:this.parent.id,config:{termgroups:o}})},backBtn:{target:"Genes Menu",callback:()=>{s.click()}}})};n.append("td").attr("class","sja-termdb-config-row-label").html("Gene Set");const p=n.append("td");p.append("button").html("Edit Group").on("click",(()=>{i.clear();this.setMenuBackBtn(i.d.append("div").style("padding","5px"),(()=>s.click()));const{groups:t,groupSelect:e}=this.setTermGroupSelector(i.d.append("div"),o);const a=i.d.append("div");e.on("change",(()=>{l=t[e.property("value")];r(a)}));const n=e.property("value");l=t[n];r(a)}));const c=p.append("button").html("Create Group").on("click",(()=>{i.clear();this.setMenuBackBtn(i.d.append("div"),(()=>s.click()));const t=i.d.append("div").style("padding","5px");const e=t.append("label");e.append("span").text("Create ");const a=e.append("input").style("margin","2px 5px").style("width","210px").attr("placeholder","Group Name").on("input",(()=>{c.property("disabled",!a.property("value"))}));const n=a.property("value");l={index:o.length,name:n,label:n,lst:[],status:"new"};r(i.d.append("div"))}))}setMenuBackBtn(t,e){t.attr("tabindex",0).style("padding","5px").style("text-decoration","underline").style("cursor","pointer").style("margin-bottom","12px").html(`« Back to Genes`).on("click",e).on("keyup",(t=>{if(t.key=="Enter")t.target.click()}))}setTermGroupSelector(t,e){t.style("padding","5px");const a=e.find((t=>t.lst.find((t=>t.term.type.startsWith("gene")))));const n=e.map(((t,e)=>({index:e,name:t.name,type:t.type,lst:t.lst.filter((t=>t.term.type.startsWith("gene"))).map((t=>({name:t.term.name}))),mode:this.parent.chartType=="hierCluster"&&(t.type=="hierCluster"||t.name==this.parent.config.settings.hierCluster?.termGroupName)?"expression":"",selected:this.parent.chartType=="hierCluster"&&(t.type=="hierCluster"||t.name&&t.name==this.parent.config.settings.hierCluster?.termGroupName)||t===a})));const s=t.append("label");s.append("span").text("Edit ");const i=s.append("select").style("margin","2px 5px").style("width","218px");for(const[t,e]of n.entries()){if(e.name)e.label=e.name;else{const a=e.lst.filter((t=>t.term?.type=="geneVariant")).length;e.label=a>0?`${a} gene${a<2?"":"s"}`:`Unlabeled group #${t}`}}i.selectAll("option").data(n).enter().append("option").property("selected",(t=>t.selected)).attr("value",((t,e)=>e)).html((t=>t.label));return{groups:n,groupSelect:i}}appendDictInputs(t,e,a,n){v.clear();if(!a.selectedGroup)a.selectedGroup=t.chartType=="hierCluster"?1:0;e.tip.d.append("hr");t.addDictMenu(e,a,e.tip.d.append("div"))}generateCNVItems(t,e,a,n){n.attr("class",null);const i=a.config.settings.matrix;const o=a.legendData.find((t=>t.dt?.includes(s)));if(i.showMatrixCNV!=="none"&&(i.allMatrixMutationHidden||!o||o.crossedOut||!o.items.find((t=>!t.greyedOut&&!t.crossedOut)))){n.select("input[type='radio'][value='none']").property("disabled",true);n.select("input[type='radio'][value='none'] + span").style("opacity","0.5").on("mouseup",null)}if(i.addMutationCNVButtons&&a.chartType!=="hierCluster"&&i.showMatrixCNV=="bySelection")a.CNVControlCallback("bySelection")}generateMutationItems(t,e,a,n){n.attr("class",null);const s=a.config.settings.matrix;const i=a.legendData.find((t=>t.dt?.includes(l)));if(s.showMatrixMutation!=="none"&&(s.allMatrixCNVHidden||!i||i.crossedOut||!i.items.find((t=>!t.greyedOut&&!t.crossedOut)))){n.select("input[type='radio'][value='none']").property("disabled",true);n.select("input[type='radio'][value='none'] + span").style("opacity","0.5").on("mouseup",null)}if(s.addMutationCNVButtons&&a.chartType!=="hierCluster"&&s.showMatrixMutation=="bySelection")a.mutationControlCallback("bySelection")}updateSamplesControls(t,e,a,n){if(a.chartType=="hierCluster"&&a.config.settings.hierCluster.clusterSamples){const t=a.config.settings.matrix.controlLabels;const e=n.select(`tr[title='Set how to sort ${t.samples}']`);e.style("display","none")}}async addDictMenu(t,e,a,n=undefined){const s=await import("./app-bfce9bf5.js");s.appInit({holder:n||t.tip.d,vocabApi:this.parent.app.vocabApi,focus:"off",state:{vocab:this.parent.state.vocab,activeCohort:this.parent.activeCohort,nav:{header_mode:"search_only"},tree:{usecase:{target:"matrix",detail:"termgroups"}}},tree:{submit_lst:e=>{this.submit_lst(e);t.tip.hide()}},search:{focus:"off"}})}async submit_lst(t){const e=await Promise.all(t.map((async t=>{const e=structuredClone(t);const a="id"in e?{id:e.id,term:e}:{term:e};await m(a,this.opts.app.vocabApi);return a})));this.parent.settings.matrix;const a=structuredClone(this.parent.config.termgroups);const n=a.findIndex((t=>t.name=="Variables"));if(n!==-1){const t=a[n];t.lst.push(...e);this.parent.app.dispatch({type:"plot_nestedEdits",id:this.parent.id,edits:[{nestedKeys:["termgroups",n,"lst"],value:t.lst}]})}else{const t={name:"Variables",lst:e};a.push(t);this.parent.app.dispatch({type:"plot_edit",id:this.parent.id,config:{termgroups:a}})}}setZoomInput(){const t=this.opts.holder.append("div").style("display","inline-block").style("margin-left","50px");const e=this.parent.config.settings.matrix;this.zoomApi=x({holder:t,title:"Zoom factor relative to the ideal column width, as computed for the number of columns versus available screen width",unit:"",width:"80px",settings:{value:1,min:.1,max:10,increment:e.zoomIncrement,step:e.zoomStep||5},callback:t=>{const e=this.parent;e.dimensions;e.settings.matrix;const a=e.getVisibleCenterCell(0);e.app.dispatch({type:"plot_edit",id:e.id,config:{settings:{matrix:{zoomLevel:t,zoomCenterPct:.5,zoomIndex:a.totalIndex,zoomGrpIndex:a.grpIndex}}}})},reset:()=>{this.parent.settings.matrix;this.parent.dimensions;this.parent.app.dispatch({type:"plot_edit",id:this.parent.id,config:{settings:{matrix:{zoomLevel:1,zoomCenterPct:0}}}})}})}setDragToggle(t={}){const e={mouseMode:"select",activeBgColor:"rgb(255, 255, 255)"};t.target.style("cursor","default");const a={opts:Object.assign({},e,t),dom:{selectBtn:t.holder.append("button").attr("title","Click the matrix to select data").style("display","inline-block").style("width","25px").style("height","24.5px").style("background-color",e.activeBgColor).on("click",(()=>s("select"))),grabBtn:t.holder.append("button").attr("title","Click the matrix to drag and move").style("display","inline-block").style("width","25px").style("height","24.5px").on("click",(()=>s("pan")))}};d.arrowPointer(a.dom.selectBtn,{width:14,height:14,transform:"translate(50,50)"});d.grab(a.dom.grabBtn,{width:14,height:14,transform:"translate(30,50)"});const n=this;function s(e){a.opts.mouseMode=e;n.parent.settings.matrix.mouseMode=e;t.target.style("cursor",e=="select"?"default":"grab");a.dom.selectBtn.style("background-color",e=="select"?a.opts.activeBgColor:"");a.dom.grabBtn.style("background-color",e=="pan"?a.opts.activeBgColor:"")}this.dragToggleApi={update(t={}){Object.assign(a.opts,t);s(a.opts.mouseMode)},getSettings(){return{mouseMode:a.opts.mouseMode}}}}setSvgScroll(t){this.svgScrollApi=f({holder:this.parent.dom.scroll,height:t.config.settings.matrix.scrollHeight,callback:(t,e)=>{const a=this.parent;const n=a.settings.matrix;const s=a.dimensions;if(e=="move"){a.dom.seriesesG.attr("transform",`translate(${s.xOffset+s.seriesXoffset-t},${s.yOffset})`);a.clusterRenderer.translateElems(-t,n,s);a.layout.top.attr.adjustBoxTransform(-t);a.layout.btm.attr.adjustBoxTransform(-t);if(a.dom.topDendrogram){a.dom.topDendrogram.attr("transform",`translate(${a.topDendroX-t},0)`)}}else if(e=="up"){const e=a.getVisibleCenterCell(-t);a.app.dispatch({type:"plot_edit",id:a.id,config:{settings:{matrix:{zoomCenterPct:.5,zoomIndex:e.totalIndex,zoomGrpIndex:e.grpIndex}}}})}}})}}export{w as MatrixControls};
|
|
1
|
+
import{initByInput as t}from"./controls.config-6cf816fb.js";import{q as e,M as a,aU as n,L as s,O as i,E as o,af as l,aJ as r,J as p,K as c,aV as d}from"./app-71453429.js";import{getSorterUi as h}from"./matrix.sorterUi-d26208c8.js";import{f as m,g as u}from"./termsetting-636d2271.js";import{m as g}from"./radiobutton-09bff425.js";import{m as y}from"./checkbox-0e5c659f.js";import{k as b}from"./recover-b1ec4fed.js";import"./controls.overlay-3a55c2ec.js";import"./FilterRxComp-fc769f34.js";import"./table-1dae543a.js";import"path";import"./controls.term1-59f4cd60.js";import"./controls.divide-3c0d52d7.js";import"./FilterStateless-8f30f856.js";import"./app-fb676934.js";import"./termInfo-4c759483.js";function x(t){if(!t.holder)throw`zoom requires an opts.holder`;if(typeof t.callback!="function")throw`zoom requires an opts.callback function`;const e={min:1,max:100,value:25,step:10,increment:1,numberInputWidth:"35px",showJumpBtns:false};const a=Object.assign({},e,t.settings||{});t.holder.attr("title",t.title||null).style("vertical-align","top").style("text-align","center").on("mouseenter",(()=>{o.style("display","inline-block").style("overflow","visible")})).on("mouseleave",(()=>{o.style("display","none").style("overflow","hidden")}));const n=t.holder.append("label");n.append("span").text("Zoom");const s=n.append("input").attr("title","enter a desired zoom level").attr("type","number").attr("min",a.min).attr("max",a.max).attr("step",a.increment).style("min-width",a.numberInputWidth).style("width",t.width||"fit-content").style("margin","3px 5px").property("value",a.value).on("change",(e=>{const a=Number(e.target.value);c.update({value:a});t.callback(a)}));n.append("span").text("unit"in t?t.unit:"%");const i=t.holder.node().getBoundingClientRect();t.holder.style("max-height",i.height+"px").style("max-width",i.width+"px");t.holder.append("br");const o=t.holder.append("div").style("display","none");const l=!t.showJumpBtns?null:t.holder.append("button").attr("title","Zoom in").style("width","25px").html("-").on("click",(()=>{const e=Math.max(a.step*Math.ceil((a.value-a.step)/a.step),a.min);c.update({value:e});t.callback(e)}));const r=o.append("input").attr("title","slide to desired zoom level").attr("type","range").attr("min",a.min).attr("max",a.max).attr("step",a.increment).style("margin","2px 5px").style("padding",0).style("vertical-align","middle").property("value",a.value).html("-").on("input",(t=>{s.property("value",t.target.value)})).on("change",(e=>{const a=Number(e.target.value);c.update({value:a});t.callback(a)}));const p=!t.showJumpBtns?null:t.holder.append("button").attr("title","Zoom out").style("width","25px").html("+").on("click",(()=>{const e=Math.min(a.step*Math.floor((a.value+a.step)/a.step),a.max);c.update({value:e});t.callback(e)}));o.append("span").style("text-decoration","underline").style("cursor","pointer").style("title","use the default zoom value").text("Reset").on("click",t.reset);const c={update(e={}){const n=t.holder.node().getBoundingClientRect();if(!n.height||!n.width){t.holder.style("max-height","").style("max-width","");const e=t.holder.node().getBoundingClientRect();t.holder.style("max-height",e.height+"px").style("max-width",e.width+"px")}Object.assign(a,e);r.property("value",a.value).attr("min",a.min).attr("max",a.max).attr("step",a.increment);s.property("value",a.value).attr("min",a.min).attr("max",a.max).attr("step",a.increment);l?.property("disabled",a.value<=a.min);p?.property("disabled",a.value>=a.max)}};if(t.debug)c.Inner={settings:a,number:s,slider:r,minusBtn:l,plusBtn:p};return c}function f(t){if(!t.holder)throw`missing svgScroll.opts.holder argument`;const a={height:12,zoomLevel:1,opacity:.3};const n=Object.assign({},a,t);function s(t){g.x=t.clientX;e("body").on("mousemove.sjppSvgScroll",i).on("mouseup.sjppSvgScroll",o)}function i(t){if(!("x"in g))return;const e=t.clientX-g.x;if(g.sliderX+g.sliderWidth+e>n.visibleWidth-1){return}if(g.sliderX+e<0){return}m.attr("x",g.sliderX+e);n.callback(g.dxFactor*e,"move")}function o(t){if(!("x"in g))return;const a=t.clientX-g.x;n.callback(g.dxFactor*Math.min(g.maxDx,Math.max(a,g.minDx)),"up");delete g.x;e("body").on("mousemove.sjppSvgScroll",null).on("mouseup.sjppSvgScroll",null)}function l(t){g.x=t.clientX;const e=t.clientX<u.getBoundingClientRect().x?-1:1;o({clientX:Math.floor(g.x+e*g.arrowDx)})}n.holder.attr("display","none").attr("opacity",n.opacity).on("mouseover",(()=>n.holder.attr("opacity",1))).on("mouseout",(()=>n.holder.attr("opacity",n.opacity)));const r=n.holder.append("rect").style("height",n.height).style("stroke","none").style("fill","#fff").on("click",l);const p=n.holder.append("line").style("stroke","#ccc").style("stroke-width",1).on("click",l);const c=n.holder.append("path").attr("y",-n.height).attr("d",`M0,${n.height/2}L${n.height},0L${n.height},${n.height}Z`).style("stroke","#ccc").style("stroke-width",1).style("fill","#ccc").on("click",(t=>{g.x=t.clientX;o({clientX:Math.round(g.x-g.arrowDx)})}));const d=n.holder.append("path").attr("y",-n.height).style("stroke","#ccc").style("stroke-width",1).style("fill","#ccc").attr("d",`M0,0L${n.height},${n.height/2}L0,${n.height}Z`).on("click",(t=>{g.x=t.clientX;o({clientX:Math.round(g.x+g.arrowDx)})}));const h=n.height-4;const m=n.holder.append("rect").attr("y",2).attr("height",h).attr("stroke","#aaa").attr("stroke-width",1).attr("fill","#ccc").attr("rx",h/2).on("mousedown",s).on("mousemove",i).on("mouseup",o);const u=m.node();const g={};const y={update(t){const e={v:n.visibleWidth,t:n.totalWidth,z:n.zoomCenter};Object.assign(n,t);const a=n.totalWidth;const s=n.visibleWidth;if(a<=s){n.holder.attr("display","none");return}n.holder.attr("transform",`translate(${n.x},${n.y})`).attr("display","");r.attr("width",s);p.attr("x1",0).attr("x2",s).attr("y1",n.height/2).attr("y2",n.height/2);c.attr("transform",`translate(0,0)`);d.attr("transform",`translate(${s-n.height},0)`);if(s!=e.v||a!=e.t){g.sliderWidth=s*s/a;g.dxFactor=(a-s)/(s-g.sliderWidth)}const i=s*(n.zoomCenter/a);g.sliderX=Math.max(0,Math.min(i-g.sliderWidth/2,s-g.sliderWidth-1));m.attr("width",g.sliderWidth).attr("x",g.sliderX);g.maxDx=n.visibleWidth-g.sliderX-g.sliderWidth;g.minDx=-g.sliderX;g.arrowDx=Math.round(.1*n.visibleWidth);delete g.x}};return y}const v=new a({padding:""});class w{constructor(t,e){this.type="matrixControls";this.opts=t;this.parent=t.parent;this.overrides={};this.opts.holder.style("margin","10px 10px 20px 10px").style("white-space","nowrap");const a=this.parent.getState(e);const n=a.config.settings.matrix;if(this.parent.setClusteringBtn)this.parent.setClusteringBtn(this.opts.holder,((t,e)=>this.callback(t,e)));this.setSamplesBtn(n);this.setGenesBtn(n);if(n.addMutationCNVButtons&&this.parent.chartType!=="hierCluster"){this.setMutationBtn();this.setCNVBtn()}this.setVariablesBtn(n);this.setDimensionsBtn(n);this.setLegendBtn(n);this.setDownloadBtn(n);this.setZoomInput();this.setDragToggle({holder:this.opts.holder.append("div").style("display","inline-block"),target:this.parent.dom.seriesesG});this.setSvgScroll(a);this.keyboardNavHandler=async t=>{if(t.target.tagName=="BUTTON")this.keyEventTarget=t.target;if(t.key=="Escape"){this.parent.app.tip.hide()}else if(t.key=="Enter"||t.key=="ArrowDown"){const e=t.target.tagName=="BUTTON"?this.parent.app.tip.d.node().querySelectorAll("input, select"):t.target.querySelectorAll("input, select");for(const t of e){if(t.checkVisibility?.()||!t.checkVisibility&&t.getBoundingClientRect().height){t.focus();return false}}}else if(t.key=="Tab"&&t.shiftKey||t.key=="Backspace"||t.key=="ArrowUp"){this.keyEventTarget.focus();return false}};this.btns=this.opts.holder.selectAll(":scope>button").filter((t=>t&&t.label)).on(`keyup.matrix-${this.parent.id}`,this.keyboardNavHandler)}setSamplesBtn(t){const e=t.controlLabels;const a=this;const n=this.parent;const s=[{label:`Maximum # ${e.Samples}`,title:`Limit the number of displayed ${e.samples}`,type:"number",chartType:"matrix",settingsKey:"maxSample",getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"}},{label:`Sort ${e.Sample} Groups`,title:`Set how to sort ${e.sample} groups`,type:"radio",chartType:"matrix",settingsKey:"sortSampleGrpsBy",options:[{label:"Predefined or Group Name",value:"name",title:`Sort by group name`},{label:`${e.Sample} Count`,value:"sampleCount",title:`Sort by the number of samples in the group`},{label:`Hits`,value:"hits",title:`Sort by the total number of variants for every ${e.sample} in the group`}],getDisplayStyle(t){return t.divideBy&&!t.hierCluster?"table-row":"none"}},{label:`${e.Sample} Group Label Character Limit`,title:`Truncate the ${e.sample} group label if it exceeds this maximum number of characters`,type:"number",chartType:"matrix",settingsKey:"sampleGrpLabelMaxChars",getDisplayStyle(t){return t.divideBy&&!t.hierCluster?"table-row":"none"}},{label:`${e.Sample} Label Character Limit`,title:`Truncate the ${e.sample} label if it exceeds this maximum number of characters`,type:"number",chartType:"matrix",settingsKey:"collabelmaxchars"},{label:`Group ${e.Samples} By`,title:`Select a variable with discrete values to group ${e.samples}`,type:"term",chartType:"matrix",configKey:"divideBy",vocabApi:this.opts.app.vocabApi,state:{vocab:this.opts.vocab},getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"},processInput:t=>{if(t)m(t,this.opts.app.vocabApi);return t},processConfig:t=>{if(this.parent.config.divideBy)t.legendValueFilter=this.parent.mayRemoveTvsEntry(this.parent.config.divideBy)},getBodyParams:()=>{const t=this.parent.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}}}];s.push({label:`Sort ${e.Sample} Priority`,title:`Set how to sort ${e.samples}`,type:"custom",init(t){const e=n.config.settings.matrix;if(!a.activeTab)a.activeTab="basic";t.dom.inputTd.style("padding","5px");const s=t.dom.inputTd.append("div").style("margin-bottom","5px");const i=s.append("div").style("display","inline-block").style("padding-right","5px").style("border-right","2px solid black").style("text-decoration",a.activeTab=="basic"?"underline":"").style("cursor","pointer").html("Basic").on("click",(()=>{a.activeTab="basic";i.style("text-decoration","underline");o.style("text-decoration","");l.style("display","");m.style("display","none")}));const o=s.append("div").style("display","inline-block").style("margin-left","5px").style("text-decoration",a.activeTab=="advanced"?"underline":"").style("cursor","pointer").html("Advanced").on("click",(()=>{a.activeTab="advanced";i.style("text-decoration","");o.style("text-decoration","underline");l.style("display","none");m.style("display","")}));const l=t.dom.inputTd.append("div").style("display",a.activeTab=="basic"?"":"none");const r=l.append("div");r.append("span").html("SSM");const{inputs:p}=g({holder:r.append("span"),options:[{label:"by consequence",value:"consequence",checked:e.sortByMutation==="consequence"},{label:"by presence",value:"presence",checked:e.sortByMutation==="presence"}],styles:{display:"inline-block"},callback:t=>{const e=n.config.settings.matrix.sortOptions;const a=e.a;const s=a.sortPriority[0].tiebreakers[1];s.disabled=!t;s.isOrdered=t==="consequence";n.app.dispatch({type:"plot_edit",id:n.id,config:{settings:{matrix:{sortByMutation:t,sortOptions:e}}}})}});p.style("margin","2px 0 0 2px").style("vertical-align","top");const c=l.append("div").style("display",e.showMatrixCNV!="none"&&!e.allMatrixCNVHidden?"block":"none");c.append("span").html("CNV");const d=y({holder:c.append("span"),divstyle:{display:"inline-block"},checked:e.sortByCNV,labeltext:"sort by CNV",callback:()=>{const t=d.property("checked");const e=n.config.settings.matrix.sortOptions;const a=e.a;const s=a.sortPriority[0].tiebreakers[2];s.disabled=!t;s.isOrdered=t;n.app.dispatch({type:"plot_edit",id:n.id,config:{settings:{matrix:{sortByCNV:t,sortOptions:e}}}})}});const m=t.dom.inputTd.append("div").style("display",a.activeTab=="advanced"?"":"none");t.dom.row.on("mouseover",(function(){this.style.backgroundColor="#fff";this.style.textShadow="none"}));if(!a.sorterUi){a.sorterUi=h({controls:this,holder:m,tip:this.parent.app.tip})}else{a.sorterUi.main(this.parent.config.settings.matrix,{holder:m})}return{main:t=>{const e=t.settings.matrix;p.property("checked",(t=>t.value==e.sortByMutation));d.property("checked",e.sortByCNV);c.style("display",e.showMatrixCNV!="none"&&!e.allMatrixCNVHidden?"block":"none")}}}});this.opts.holder.append("button").datum({label:e.Samples||`Samples`,getCount:()=>"sampleCount"in this.overrides?this.overrides.sampleCount:this.parent.sampleOrder?.length||0,rows:s,customInputs:this.updateSamplesControls}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setGenesBtn(t){const e=t.controlLabels;const a=[{label:` Stacked <span style="font-size:.7em;color:#858585;">Show stacked rectangles in the same matrix cell to render variants for the same ${e.sample} and gene</span>`,value:"",title:`Show stacked rectangles in the same matrix cell to render variants for the same ${e.sample} and gene`},{label:` OncoPrint <span style="font-size:.7em;color:#858585;">Show overlapping rectangles in the same matrix cell to render variants for the same ${e.sample} and gene</span>`,value:"oncoprint",title:`Show overlapping rectangles in the same matrix cell to render variants for the same ${e.sample} and gene`}];if(t.addMutationCNVButtons&&this.parent.chartType!=="hierCluster")a.unshift({label:` Single <span style="font-size:.7em;color:#858585;">Show a single rectangle in a matrix cell to render the most severe variant (truncating > indels > missense > synonymous) for the same ${e.sample} and gene</span>`,value:"single",title:`Show a single rectangle in a matrix cell to render the most severe variant (truncating > indels > missense > synonymous) for the same ${e.sample} and gene`});this.opts.holder.append("button").datum({label:"Genes",getCount:()=>this.parent.termOrder?.filter((t=>t.tw.term.type=="geneVariant")).length||0,customInputs:this.appendGeneInputs,rows:[{label:`Display ${e.Sample} Counts for Gene`,title:`Include the ${e.sample} count in the gene label`,type:"radio",chartType:"matrix",settingsKey:"samplecount4gene",options:[{label:"Absolute",value:"abs"},{label:`Percent`,value:"pct"},{label:`None`,value:""}]},{label:`Row Group Label Character Limit`,title:`Truncate the row group label if it exceeds this maximum number of characters`,type:"number",chartType:"matrix",settingsKey:"termGrpLabelMaxChars"},{label:`Row Label Character Limit`,title:`Truncate the row label if it exceeds this maximum number of characters`,type:"number",chartType:"matrix",settingsKey:"rowlabelmaxchars"},{label:"Genomic Alterations Rendering",title:`Set how to indicate a ${e.sample}'s applicable variant types in the same matrix cell`,type:"radio",chartType:"matrix",settingsKey:"cellEncoding",options:a,styles:{padding:"5px 0px",margin:0},labelDisplay:"block",callback:this.parent.geneStyleControlCallback},{label:"Sort Genes",title:"Set how to order the genes as rows",type:"radio",chartType:"matrix",settingsKey:"sortTermsBy",options:[{label:"By Input Data Order",value:"asListed"},{label:`By ${e.sample} Count`,value:"sampleCount"}],styles:{padding:0,"padding-right":"10px",margin:0}}]}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setVariablesBtn(t){t.controlLabels;this.opts.holder.append("button").datum({label:t.controlLabels.Terms||`Variables`,rows:[{label:`Row Group Label Max Length`,title:`Truncate the row group label if it exceeds this maximum number of characters`,type:"number",chartType:"matrix",settingsKey:"termGrpLabelMaxChars"},{label:`Row Label Max Length`,title:`Truncate the row label if it exceeds this maximum number of characters`,type:"number",chartType:"matrix",settingsKey:"rowlabelmaxchars"}],customInputs:this.appendDictInputs}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setDimensionsBtn(t){const e=t.controlLabels;this.opts.holder.append("button").datum({label:"Cell Layout",tables:[{rows:[{label:"Grid",title:"Show grid lines, which creates borders around each matrix cells. "+" Note that grid lines are hidden when the auto-computed width <= 2, or when either the column and row spacing is set to 0.",type:"checkbox",boxLabel:"show",processInput:t=>t===true?"rect":t==="rect",chartType:"matrix",settingsKey:"showGrid",colspan:2,align:"center"},{label:"Outline Color",title:"Set a border color for the whole matrix",type:"color",chartType:"matrix",settingsKey:"outlineStroke",colspan:2,align:"center"},{label:"Beam Color",title:"Set a color for the beam highlighter",type:"color",chartType:"matrix",settingsKey:"beamStroke",colspan:2,align:"center"},{label:"Grid Line Color",title:"Set the grid color, equivalent to applying the same border color for each matrix cell",type:"color",chartType:"matrix",settingsKey:"gridStroke",colspan:2,align:"center"},{label:"Background Color",title:`Set the background color when there are no alterations or annotation data for a ${e.sample}`,type:"color",chartType:"matrix",settingsKey:"cellbg",colspan:2,align:"center"},{label:`Use Canvas If # ${e.sample} Exceeds`,title:`Switch from SVG to canvas rendering when the number of ${e.samples} exceeds this number`,type:"number",chartType:"matrix",settingsKey:"svgCanvasSwitch",colspan:2,align:"center",width:60,min:0,max:1e4,step:1},{label:"Canvas Min. Pixel Width",title:"Set a minimum pixel width for a matrix cell when using canvas, may affect the perceived sharpness of the canvas image",type:"checkbox",boxLabel:"apply",chartType:"matrix",settingsKey:"useMinPixelWidth",colspan:2,align:"center",getDisplayStyle:()=>this.parent.settings.matrix.useCanvas?"":"none"}]},{header:["Cells","Columns","Rows"],rows:[{label:"Row Height",title:"Set the height of a matrix row",type:"number",width:50,align:"center",chartType:"matrix",inputs:[{label:"N/A"},{settingsKey:"rowh",min:8,max:30,step:1}],getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"}},{label:"Min Col. Width",title:"Set the minimum width of the auto-computed matrix column width",type:"number",width:50,align:"center",chartType:"matrix",inputs:[{settingsKey:"colwMin",min:.1,max:16,step:.2},{label:"N/A"}]},{label:"Max Col. Width",title:"Set the maximum width of the auto-computed matrix column width",type:"number",width:50,align:"center",chartType:"matrix",inputs:[{settingsKey:"colwMax",min:1,max:24,step:.2},{label:"N/A"}]},{label:"Spacing",title:"Set the column spacing. Note that this will be set to 0 when the auto-computed width < 2.",type:"number",width:50,align:"center",chartType:"matrix",inputs:[{settingsKey:"colspace",min:0,max:20,step:1},{settingsKey:"rowspace",min:0,max:20,step:1}],getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"}},{label:"Group spacing",title:"Set the spacing between column and row groups.",type:"number",width:50,align:"center",chartType:"matrix",inputs:[this.parent.chartType=="hierCluster"?{label:"N/A"}:{settingsKey:"colgspace",min:0,max:20,step:1},{settingsKey:"rowgspace",min:0,max:20,step:1}]}]},{header:["Labels","Columns","Rows"],rows:[{label:"Offset",title:"Set the gap between the label text and matrix edge",type:"number",width:50,align:"center",chartType:"matrix",inputs:[{settingsKey:"collabelgap",min:0,max:20,step:1},{settingsKey:"rowlabelgap",min:0,max:20,step:1}]},{label:"Spacing",title:"Set the gap between labels",type:"number",width:50,align:"center",chartType:"matrix",inputs:[{settingsKey:"collabelpad",min:0,max:20,step:1},{settingsKey:"rowlabelpad",min:0,max:20,step:1}]},{label:"Min font size",title:"Set the minimum auto-computed font size for labels. Note that labels will be hidden if the auto-computed values falls below this minimum.",type:"number",width:50,align:"center",colspan:2,chartType:"matrix",settingsKey:"minLabelFontSize",min:0,max:24,step:.1},{label:"Max font size",title:"Set the maximum auto-computed font size for labels",type:"number",width:50,align:"center",colspan:2,chartType:"matrix",settingsKey:"maxLabelFontSize",min:0,max:24,step:.1},{label:"Group label<br/>position",title:"Set which side of the matrix to display group labels",type:"radio",width:50,chartType:"matrix",labelDisplay:"block",getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"},inputs:[{settingsKey:"collabelpos",options:[{label:"Top",value:"bottom",title:`Display ${e.sample} group labels at the bottom`},{label:"Bottom",value:"top",title:`Display ${e.sample} group labels on top`}]},{settingsKey:"rowlabelpos",options:[{label:"Left",value:"right",title:`Display gene or variable group labels on the left side`},{label:"Right",value:"left",title:`Display gene or variable group labels on the right side`}]}]}]}]}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setLegendBtn(t){this.opts.holder.append("button").style("margin","2px 0").datum({label:"Legend Layout",rows:[{label:"Font Size",title:"Set the font size for the legend text",type:"number",chartType:"legend",settingsKey:"fontsize"},{label:"Line Height",title:"Set the line height for a legend group",type:"number",chartType:"legend",settingsKey:"lineh"},{label:"Icon Height",title:"Set the icon height for a legend item",type:"number",chartType:"legend",settingsKey:"iconh"},{label:"Icon Width",title:"Set the icon width for a legend item",type:"number",chartType:"legend",settingsKey:"iconw"},{label:"Item Left Pad",title:"Set a left margin for each legend item",type:"number",chartType:"legend",settingsKey:"padx"},{label:"Left Margin",title:"Set a left margin for the whole legend",type:"number",chartType:"legend",settingsKey:"padleft"},{label:"Left Indent",title:`Set a left margin for the first legend item in each group, and should be set to the length of the longest group label.`+` The left indent will align the legend group label text to the right.`,type:"number",chartType:"legend",settingsKey:"hangleft"},{label:"Item Layout",title:"Option to separate each legend item into a new line, instead of a horizontal layout in the same line.",type:"checkbox",chartType:"legend",settingsKey:"linesep",boxLabel:"Line separated"}]}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setMutationBtn(){this.opts.holder.append("button").style("margin","2px 0").datum({label:"Mutation",updateBtn:t=>{const e=this.parent.config.settings.matrix;t.style("text-decoration",e.allMatrixMutationHidden?"line-through":"").style("text-decoration-thickness",e.allMatrixMutationHidden?"2px":"")},rows:[{title:`Show mutation options`,type:"radio",chartType:"matrix",settingsKey:"showMatrixMutation",options:[{label:"Show all mutations",value:"all"},{label:`Show only truncating mutations`,value:"onlyTruncating"},{label:`Show only protein-changing mutations`,value:"onlyPC"},{label:`Do not show mutations`,value:"none"},{label:`Show selected mutation`,value:"bySelection"}],labelDisplay:"block",getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"},callback:this.parent.mutationControlCallback}],customInputs:this.generateMutationItems}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setCNVBtn(){this.opts.holder.append("button").style("margin","2px 0").datum({label:"CNV",updateBtn:t=>{const e=this.parent.config.settings.matrix;const a=e.allMatrixCNVHidden;t.style("text-decoration",a?"line-through":"").style("text-decoration-thickness",a?"2px":"")},rows:[{title:`Show CNV options`,type:"radio",chartType:"matrix",settingsKey:"showMatrixCNV",options:[{label:"Show all CNV",value:"all"},{label:`Do not show CNV`,value:"none"},{label:`Show selected CNV`,value:"bySelection"}],labelDisplay:"block",getDisplayStyle(t){return t.chartType=="hierCluster"?"none":"table-row"},callback:this.parent.CNVControlCallback}],customInputs:this.generateCNVItems}).html((t=>t.label)).style("margin","2px 0").on("click",((t,e)=>this.callback(t,e)))}setDownloadBtn(t){this.opts.holder.append("button").style("margin","2px 0").text("Download").on("focus",(()=>this.parent.app.tip.hide())).on("click.sjpp-matrix-download",(t=>{const e=this.parent;if(!e.dom.downloadMenu)e.dom.downloadMenu=new a({padding:""});const d=e.dom.downloadMenu.clear();const h=d.d.append("div");h.append("div").attr("class","sja_menuoption sja_sharp_border").text(`SVG image`).on("click.sjpp-matrix-download",(()=>{n(this.opts.getSvg(),"matrix",{apply_dom_styles:true});e.dom.downloadMenu.destroy()}));h.append("div").attr("class","sja_menuoption sja_sharp_border").text(`TSV data`).on("click.sjpp-matrix-download",(()=>{const t=e.data.lst;const a=e.termOrder.map((t=>t.tw));const n=e.state.termdbConfig.assayAvailability;const d=e.settings.matrix.controlLabels;if(e.config.divideBy?.id&&!a.find((t=>t.id==e.config.divideBy.id))){a.push(e.config.divideBy)}const h=[];for(const e of t){for(const t of a){if(t.$id in e){h.push(e);break}}}const m=[d.Sample];for(const t of a)m.push(t.term.name);const u=[m];for(const t of h){const e=[t._ref_.label];for(const d of a){if(!t[d.$id]){e.push("")}else{if(d.term.type=="geneVariant"){const a=[];for(const e of t[d.$id].renderedValues){const t=n?.byDt?.[parseInt(e.dt)];if(e.dt==s){a.push((e.origin?`${e.origin} `:"")+(t?`${i[e.dt]}:`:"")+`${o[e.class]?.label}`+(e.mname?`,${e.mname}`:""))}else if(e.dt==l){const n=e.value?`${t?"":"CNV:"}${e.value}`:e.class=="CNV_amp"?"CNV gain":e.class=="CNV_loss"?"CNV loss":o[e.class]?.label;a.push((e.origin?`${e.origin} `:"")+(t?`${i[e.dt]}:`:"")+n)}else if(e.dt==r){a.push(e.origin?`${e.origin}:${e.value}`:e.value)}else if(e.dt==p||e.dt==c){a.push((e.origin?`${e.origin} `:"")+(t?`${i[e.dt]}:`:"")+`${o[e.class]?.label}`+(e.gene&&e.mname?`(${e.gene}::${e.mname})`:""))}else{a.push(`DO NOT SUPPORT dt='${e.dt}'`)}}e.push(a.join("|"))}else{e.push(t[d.$id]?.renderedValues?.[0]||t[d.$id]?.value||"")}}}u.push(e)}const g=u.map((t=>t.join("\t"))).join("\n");const y=document.createElement("a");document.body.appendChild(y);y.addEventListener("click",(function(){const t=(new Date).toISOString().split("T")[0];y.download=e.config.settings?.hierCluster?.termGroupName?.startsWith("Gene Expression")?`GeneExpression.${t}.tsv`:e.chartType=="hierCluster"?`HierCluster.${t}.tsv`:`${e.app.vocabApi.termdbConfig.matrix?.appName||"Matrix"}.${t}.tsv`;y.href=URL.createObjectURL(new Blob([g],{type:"text/tab-separated-values"}));document.body.removeChild(y)}),false);y.click();e.dom.downloadMenu.destroy()}));d.showunder(t.target)}))}main(t={}){this.overrides=t;this.parent.app.tip.hide();this.btns.text((t=>(t.getCount?`${t.getCount()} `:"")+t.label)).each((function(t){if(t.updateBtn)t.updateBtn(e(this))}));const a=this.parent.config.settings.matrix;const n=this.parent.dimensions;if(this.zoomApi)this.zoomApi.update({value:a.zoomLevel.toFixed(1),min:a.colwMin/a.colw,max:a.colwMax/a.colw,increment:a.zoomIncrement,step:a.zoomStep||1});if(this.svgScrollApi&&n){this.svgScrollApi.update({x:n.xOffset,y:n.yOffset-a.scrollHeight,totalWidth:n.zoomedMainW,visibleWidth:n.mainw,zoomCenter:a.zoomCenterPct*n.mainw-n.seriesXoffset})}if(this.dragToggleApi){this.dragToggleApi.update(a.mouseMode?{mouseMode:a.mouseMode}:{})}}getSettings(){return{mouseMode:this.dragToggleApi.getSettings().mouseMode}}async callback(e,a){const n=this.opts.app;const s=this.opts.parent;const i=a.tables||[a];e.target.focus();n.tip.clear();const o=n.tip.d.append("table").attr("class","sjpp-controls-table");for(const e of i){if(e.header){o.append("tr").selectAll("th").data(e.header).enter().append("th").html((t=>t))}for(const a of e.rows){const e=o.append("tr");if(a.title)e.attr("title",a.title);const i=await t[a.type](Object.assign({},{holder:e,dispatch:n.dispatch,id:s.id,debug:this.opts.debug,parent:s},a));i.main(s.config)}if(e.customInputs)e.customInputs(this,n,s,o);o.selectAll("select, input, button").attr("tabindex",0).on("keydown",self.keyboardNavHandler)}n.tip.showunder(e.target)}prependInfo(t,e,a){const n=t.append("tr");n.append("td").text(e).attr("class","sja-termdb-config-row-label");n.append("td").text(a)}async appendGeneInputs(e,a,n,s){v.clear();if(!n.selectedGroup)n.selectedGroup=0;if(n.opts.customInputs?.genes){for(const a of n.opts.customInputs?.genes){a.chartType="matrix";const i=s.append("tr");if(a.title)i.attr("title",a.title);const o=await t[a.type](Object.assign({},{holder:i,id:n.id,debug:e.opts.debug,parent:n},a));o.main(n.config)}}e.addGenesetInput(event,a,n,s.append("tr"))}addGenesetInput(t,e,a,n){const s=this.btns.filter((t=>t.label=="Genes"))?.node();const i=e.tip;const o=a.config.termgroups;let l;const r=t=>{t.selectAll("*").remove();const a=l.lst.map((t=>({gene:t.name})));b({holder:t,genome:e.opts.genome,geneList:a,mode:l.mode,minNumGenes:l.mode=="expression"?3:1,vocabApi:this.opts.app.vocabApi,callback:async({geneList:t,groupName:a})=>{if(!l)throw`missing selectedGroup`;i.hide();const n=l.status=="new"?{name:a,lst:[]}:o[l.index];if(l.status=="new")o.push(n);const s=n.lst.filter((t=>t.term.type!="geneVariant"));const r=await Promise.all(t.map((async t=>{const e={gene:t.symbol||t.gene,name:t.symbol||t.gene,type:"geneVariant"};let a=n.lst.find((e=>e.term.name==t.symbol||e.term.name==t.gene));if(!a){a={term:e,q:{}};a.$id=await u(this.opts.app.vocabApi.getTwMinCopy(a))}else if(!a.$id){a.$id=await u(this.opts.app.vocabApi.getTwMinCopy({term:e}))}return a})));n.lst=[...s,...r];if(!n.lst.length)o.splice(l.index,1);e.dispatch({type:"plot_edit",id:this.parent.id,config:{termgroups:o}})},backBtn:{target:"Genes Menu",callback:()=>{s.click()}}})};n.append("td").attr("class","sja-termdb-config-row-label").html("Gene Set");const p=n.append("td");p.append("button").html("Edit Group").on("click",(()=>{i.clear();this.setMenuBackBtn(i.d.append("div").style("padding","5px"),(()=>s.click()));const{groups:t,groupSelect:e}=this.setTermGroupSelector(i.d.append("div"),o);const a=i.d.append("div");e.on("change",(()=>{l=t[e.property("value")];r(a)}));const n=e.property("value");l=t[n];r(a)}));const c=p.append("button").html("Create Group").on("click",(()=>{i.clear();this.setMenuBackBtn(i.d.append("div"),(()=>s.click()));const t=i.d.append("div").style("padding","5px");const e=t.append("label");e.append("span").text("Create ");const a=e.append("input").style("margin","2px 5px").style("width","210px").attr("placeholder","Group Name").on("input",(()=>{c.property("disabled",!a.property("value"))}));const n=a.property("value");l={index:o.length,name:n,label:n,lst:[],status:"new"};r(i.d.append("div"))}))}setMenuBackBtn(t,e){t.attr("tabindex",0).style("padding","5px").style("text-decoration","underline").style("cursor","pointer").style("margin-bottom","12px").html(`« Back to Genes`).on("click",e).on("keyup",(t=>{if(t.key=="Enter")t.target.click()}))}setTermGroupSelector(t,e){t.style("padding","5px");const a=e.find((t=>t.lst.find((t=>t.term.type.startsWith("gene")))));const n=e.map(((t,e)=>({index:e,name:t.name,type:t.type,lst:t.lst.filter((t=>t.term.type.startsWith("gene"))).map((t=>({name:t.term.name}))),mode:this.parent.chartType=="hierCluster"&&(t.type=="hierCluster"||t.name==this.parent.config.settings.hierCluster?.termGroupName)?"expression":"",selected:this.parent.chartType=="hierCluster"&&(t.type=="hierCluster"||t.name&&t.name==this.parent.config.settings.hierCluster?.termGroupName)||t===a})));const s=t.append("label");s.append("span").text("Edit ");const i=s.append("select").style("margin","2px 5px").style("width","218px");for(const[t,e]of n.entries()){if(e.name)e.label=e.name;else{const a=e.lst.filter((t=>t.term?.type=="geneVariant")).length;e.label=a>0?`${a} gene${a<2?"":"s"}`:`Unlabeled group #${t}`}}i.selectAll("option").data(n).enter().append("option").property("selected",(t=>t.selected)).attr("value",((t,e)=>e)).html((t=>t.label));return{groups:n,groupSelect:i}}appendDictInputs(t,e,a,n){v.clear();if(!a.selectedGroup)a.selectedGroup=t.chartType=="hierCluster"?1:0;e.tip.d.append("hr");t.addDictMenu(e,a,e.tip.d.append("div"))}generateCNVItems(t,e,a,n){n.attr("class",null);const i=a.config.settings.matrix;const o=a.legendData.find((t=>t.dt?.includes(s)));if(i.showMatrixCNV!=="none"&&(i.allMatrixMutationHidden||!o||o.crossedOut||!o.items.find((t=>!t.greyedOut&&!t.crossedOut)))){n.select("input[type='radio'][value='none']").property("disabled",true);n.select("input[type='radio'][value='none'] + span").style("opacity","0.5").on("mouseup",null)}if(i.addMutationCNVButtons&&a.chartType!=="hierCluster"&&i.showMatrixCNV=="bySelection")a.CNVControlCallback("bySelection")}generateMutationItems(t,e,a,n){n.attr("class",null);const s=a.config.settings.matrix;const i=a.legendData.find((t=>t.dt?.includes(l)));if(s.showMatrixMutation!=="none"&&(s.allMatrixCNVHidden||!i||i.crossedOut||!i.items.find((t=>!t.greyedOut&&!t.crossedOut)))){n.select("input[type='radio'][value='none']").property("disabled",true);n.select("input[type='radio'][value='none'] + span").style("opacity","0.5").on("mouseup",null)}if(s.addMutationCNVButtons&&a.chartType!=="hierCluster"&&s.showMatrixMutation=="bySelection")a.mutationControlCallback("bySelection")}updateSamplesControls(t,e,a,n){if(a.chartType=="hierCluster"&&a.config.settings.hierCluster.clusterSamples){const t=a.config.settings.matrix.controlLabels;const e=n.select(`tr[title='Set how to sort ${t.samples}']`);e.style("display","none")}}async addDictMenu(t,e,a,n=undefined){const s=await import("./app-fb676934.js");s.appInit({holder:n||t.tip.d,vocabApi:this.parent.app.vocabApi,focus:"off",state:{vocab:this.parent.state.vocab,activeCohort:this.parent.activeCohort,nav:{header_mode:"search_only"},tree:{usecase:{target:"matrix",detail:"termgroups"}}},tree:{submit_lst:e=>{this.submit_lst(e);t.tip.hide()}},search:{focus:"off"}})}async submit_lst(t){const e=await Promise.all(t.map((async t=>{const e=structuredClone(t);const a="id"in e?{id:e.id,term:e}:{term:e};await m(a,this.opts.app.vocabApi);return a})));this.parent.settings.matrix;const a=structuredClone(this.parent.config.termgroups);const n=a.findIndex((t=>t.name=="Variables"));if(n!==-1){const t=a[n];t.lst.push(...e);this.parent.app.dispatch({type:"plot_nestedEdits",id:this.parent.id,edits:[{nestedKeys:["termgroups",n,"lst"],value:t.lst}]})}else{const t={name:"Variables",lst:e};a.push(t);this.parent.app.dispatch({type:"plot_edit",id:this.parent.id,config:{termgroups:a}})}}setZoomInput(){const t=this.opts.holder.append("div").style("display","inline-block").style("margin-left","50px");const e=this.parent.config.settings.matrix;this.zoomApi=x({holder:t,title:"Zoom factor relative to the ideal column width, as computed for the number of columns versus available screen width",unit:"",width:"80px",settings:{value:1,min:.1,max:10,increment:e.zoomIncrement,step:e.zoomStep||5},callback:t=>{const e=this.parent;e.dimensions;e.settings.matrix;const a=e.getVisibleCenterCell(0);e.app.dispatch({type:"plot_edit",id:e.id,config:{settings:{matrix:{zoomLevel:t,zoomCenterPct:.5,zoomIndex:a.totalIndex,zoomGrpIndex:a.grpIndex}}}})},reset:()=>{this.parent.settings.matrix;this.parent.dimensions;this.parent.app.dispatch({type:"plot_edit",id:this.parent.id,config:{settings:{matrix:{zoomLevel:1,zoomCenterPct:0}}}})}})}setDragToggle(t={}){const e={mouseMode:"select",activeBgColor:"rgb(255, 255, 255)"};t.target.style("cursor","default");const a={opts:Object.assign({},e,t),dom:{selectBtn:t.holder.append("button").attr("title","Click the matrix to select data").style("display","inline-block").style("width","25px").style("height","24.5px").style("background-color",e.activeBgColor).on("click",(()=>s("select"))),grabBtn:t.holder.append("button").attr("title","Click the matrix to drag and move").style("display","inline-block").style("width","25px").style("height","24.5px").on("click",(()=>s("pan")))}};d.arrowPointer(a.dom.selectBtn,{width:14,height:14,transform:"translate(50,50)"});d.grab(a.dom.grabBtn,{width:14,height:14,transform:"translate(30,50)"});const n=this;function s(e){a.opts.mouseMode=e;n.parent.settings.matrix.mouseMode=e;t.target.style("cursor",e=="select"?"default":"grab");a.dom.selectBtn.style("background-color",e=="select"?a.opts.activeBgColor:"");a.dom.grabBtn.style("background-color",e=="pan"?a.opts.activeBgColor:"")}this.dragToggleApi={update(t={}){Object.assign(a.opts,t);s(a.opts.mouseMode)},getSettings(){return{mouseMode:a.opts.mouseMode}}}}setSvgScroll(t){this.svgScrollApi=f({holder:this.parent.dom.scroll,height:t.config.settings.matrix.scrollHeight,callback:(t,e)=>{const a=this.parent;const n=a.settings.matrix;const s=a.dimensions;if(e=="move"){a.dom.seriesesG.attr("transform",`translate(${s.xOffset+s.seriesXoffset-t},${s.yOffset})`);a.clusterRenderer.translateElems(-t,n,s);a.layout.top.attr.adjustBoxTransform(-t);a.layout.btm.attr.adjustBoxTransform(-t);if(a.dom.topDendrogram){a.dom.topDendrogram.attr("transform",`translate(${a.topDendroX-t},0)`)}}else if(e=="up"){const e=a.getVisibleCenterCell(-t);a.app.dispatch({type:"plot_edit",id:a.id,config:{settings:{matrix:{zoomCenterPct:.5,zoomIndex:e.totalIndex,zoomGrpIndex:e.grpIndex}}}})}}})}}export{w as MatrixControls};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{q as t}from"./FilterRxComp-
|
|
1
|
+
import{q as t}from"./FilterRxComp-fc769f34.js";function e(t=""){const e=t||this.state.tokenVerificationMessage;if(!e&&this.state.hasVerifiedToken){this.dom.errdiv.style("display","none").html();this.dom.controls.style("display",this.opts.controls?"inline-block":"");this.dom.svg.style("display","");return false}else{this.dom.errdiv.style("display","").html(e||"Requires login");this.dom.controls.style("display","none");this.dom.svg.style("display","none");return true}}function s(t){const e=[];const s=this.chartType=="hierCluster"?t.config.termgroups.filter((t=>t.type!="hierCluster")):t.config.termgroups;for(const t of s){e.push(...i(t.lst))}if(t.config.divideBy)e.push(r(structuredClone(t.config.divideBy)));const o={terms:e,filter:t.filter,filter0:t.filter0,maxGenes:t.config.settings.matrix.maxGenes};if(this.chartType=="hierCluster"){o.isHierCluster=1}return o}function i(t){const e=structuredClone(t);e.forEach(r);e.sort(o);return e}function r(t){if(!t?.term)return;delete t.term.category2samplecount;delete t.term.values;return t}function o(t,e){const s=t?.$id||t.term?.id||t?.term?.name;const i=e?.$id||e.term?.id||e?.term?.name;return s<i?-1:1}async function l(t){const e=this.currRequestOpts?.matrix||this.getMatrixRequestOpts(this.state);this.numTerms=e.terms.length;const s=new AbortController;e.signal=s.signal;e.loadingDiv=this.chartType!="hierCluster"&&this.dom.loadingDiv;const[i,r]=await this.api.detectStale((()=>this.app.vocabApi.getAnnotatedSampleData(e,t)),{abortCtrl:s});if(r)throw`stale sequenceId`;this.data=i;this.origData=structuredClone(this.data);this.sampleIdMap={};for(const t of this.data.lst){this.sampleIdMap[t.sample]=t._ref_.label}}function n(){const e=this;if(!e.config.legendValueFilter.lst.length&&!e.config.legendGrpFilter.lst.length)return;for(const t of e.config.legendGrpFilter.lst){if(t.dt){const s=new Set;for(const i of e.origData.lst){for(const e of Object.values(i)){if(e.values){const i=[];for(const r of e.values){if(!(t.dt.includes(r.dt)&&(!t.origin||r.origin==t.origin))){i.push(r)}else{s.add(r.class)}}e.values=i}}}t.filteredOutCats=[...s];for(const s of Object.values(e.origData.samples)){for(const e of Object.values(s)){if(e.values)e.values=e.values.filter((e=>!(t.dt.includes(e.dt)&&(!t.origin||e.origin==t.origin))))}}}}const s=Object.values(e.data.refs.byTermId).filter((t=>t.term?.type=="geneVariant")).map((t=>t.$id));const i={samples:{},lst:[],refs:e.data.refs};const r=structuredClone(e.config.legendValueFilter);r.lst=r.lst.filter((t=>!t.tvs.legendFilterType||t.tvs.legendFilterType!=="geneVariant_soft"));for(const o of e.origData.lst){const l=t(o,r,s);if(l||e.chartType=="hierCluster"){i.samples[o.sample]=o;i.lst.push(o)}}for(const t of e.config.legendValueFilter.lst){if(t.tvs.legendFilterType!=="geneVariant_soft")continue;const e=t.tvs.values[0];const s=new Set;for(const t of i.lst){for(const i of Object.values(t)){if(i.values){const t=[];for(const r of i.values){if(!(r.dt==e.dt&&(!e.origin||r.origin==e.origin)&&e.mclasslst.includes(r.class))){t.push(r)}else{s.add(r.class)}}i.values=t}}}t.filteredOutCats=[...s];for(const t of Object.values(i.samples)){for(const s of Object.values(t)){if(s.values)s.values=s.values.filter((t=>!(t.dt==e.dt&&(!e.origin||t.origin==e.origin)&&e.mclasslst.includes(t.class))))}}}if(e.chartType!=="hierCluster"&&s.length&&e.app.vocabApi.vocab?.dslabel=="GDC")a(i);e.data=i}function a(t){for(const e of t.lst){let s=true;for(const[i,r]of Object.entries(e)){if(!r.values)continue;const e=t.refs.byTermId[i].term.type;if(e!="geneVariant")continue;if(r.values.length)s=false}if(s){t.lst=t.lst.filter((t=>t.sample!==e.sample));delete t.samples[parseInt(e.sample)]}}return t}var c=Object.freeze({__proto__:null,mayRequireToken:e,getMatrixRequestOpts:s,setData:l,applyLegendValueFilter:n});export{c as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as e,q as s}from"./app-
|
|
1
|
+
import{M as e,q as s}from"./app-71453429.js";function t(t){const o=t.controls?t.holder:t.holder.append("div");o.style("position","relative");const i=this.opts.controls||o.append("div");const p=o.append("div").style("position","relative").style("top",this.opts.controls?0:"50px").style("left","50px");const n=o.append("div").attr("class","sja_errorbar").style("display","none");const a=o.append("svg").style("margin","20px 10px").style("overflow","visible").on("mousemove.label",this.svgMousemove).on("mouseup.label",this.svgMouseup);this.seriesClipId=`sjpp_clip_${this.id}`;const l=a.append("g").on("mouseover",this.showCellInfo).on("mousemove",this.showCellInfo).on("mouseout",this.mouseout);const r=l.append("g").attr("clip-path",`url(#${this.seriesClipId})`);const d=l.append("g");const u=l.append("g");const h=new e({padding:"5px"});this.dom={header:t.header,holder:o,contentNode:t.holder.node().closest(".sjpp-output-sandbox-content")||t.holder.node().parentNode,errdiv:n,controls:i,loadingDiv:p,svg:a,clipRect:a.append("defs").append("clipPath").attr("id",this.seriesClipId).attr("clipPathUnits","userSpaceOnUse").append("rect").attr("display","block"),mainG:l,cluster:r.append("g").attr("class","sjpp-matrix-cluster-g").on("mousedown",this.seriesesGMousedown).on("mousemove",this.seriesesGMousemove),seriesesG:r.append("g").attr("class","sjpp-matrix-serieses-g").attr("data-testid","sjpp_matrix_mainG_serieses").on("mousedown",this.seriesesGMousedown),highlightBeamG:r.append("g").attr("class","sjpp-matrix-highlight-beam"),sampleLabelsPG:d,sampleGrpLabelG:d.append("g").attr("class","sjpp-matrix-series-group-label-g").on("click",this.showSampleGroupMenu).on("mousedown.sjppMatrixLabelText",this.enableTextHighlight).on("mouseup.sjppMatrixLabelText",this.disableTextHighlight),sampleLabelG:d.append("g").attr("class","sjpp-matrix-series-label-g").on("click",(e=>this.mouseclick(e))),termLabelsPG:u,termGrpLabelG:u.append("g").attr("class","sjpp-matrix-term-group-label-g").on("mouseover",this.termGrpLabelMouseover).on("mouseout",this.termGrpLabelMouseout).on("mousedown",this.termGrpLabelMousedown).on("mousemove",this.termGrpLabelMousemove).on("mouseup",this.termGrpLabelMouseup).on("mousedown.sjppMatrixLabelText",this.enableTextHighlight).on("mouseup.sjppMatrixLabelText",this.disableTextHighlight),termLabelG:u.append("g").attr("class","sjpp-matrix-term-label-g").on("mouseover",this.termLabelMouseover).on("mouseout",this.termLabelMouseout).on("mousedown",this.termLabelMousedown).on("mousemove",this.termLabelMousemove).on("mouseup",this.termLabelMouseup).on("mousedown.sjppMatrixLabelText",this.enableTextHighlight).on("mouseup.sjppMatrixLabelText",this.disableTextHighlight),scroll:l.append("g"),legendG:l.append("g").attr("class","sjpp-matrix-legend-g").on("mouseover",this.legendLabelMouseover).on("mouseout",this.legendLabelMouseout).on("mouseup",this.legendLabelMouseup),tip:h,menutop:h.d.append("div"),menubody:h.d.append("div"),clickMenu:new e({padding:"0px"}),brushMenu:new e({padding:"0px"}),dendroClickMenu:new e({padding:"0px"}),legendMenu:new e({padding:"0px"}),matrixCellHoverOver:new e({padding:"0px"})};this.dom.colBeam=this.dom.highlightBeamG.append("rect").style("display","none").style("stroke-width","0.5px").style("fill","transparent").style("pointer-events","none");this.dom.rowBeam=this.dom.highlightBeamG.append("rect").style("display","none").style("stroke-width","0.5px").style("fill","transparent").style("pointer-events","none");this.dom.tip.onHide=()=>{this.lastActiveLabel=this.activeLabel;delete this.activeLabel};s("body").on(`mousedown.matrixZoom-${this.id}`,this.resetInteractions);window.onscroll=this.delayedMouseoutHandler;const m=this.dom.holder.node().closest(".sjpp-output-sandbox-content");if(m)m.onscroll=this.delayedMouseoutHandler}export{t as setMatrixDom};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./filter-b3d3964e.js";import{getTermSorter as t,getMclassSorter as s,getSampleSorter as n,getSampleGroupSorter as i}from"./matrix.sort-
|
|
1
|
+
import{s as e}from"./filter-b3d3964e.js";import{getTermSorter as t,getMclassSorter as s,getSampleSorter as n,getSampleGroupSorter as i}from"./matrix.sort-249d4a35.js";import{af as l,L as r,J as o,aJ as a}from"./app-71453429.js";function u(e){const n=this.settings.matrix;this.termSorter=t(this,n);this.termGroups=JSON.parse(JSON.stringify(this.config.termgroups));const i=[];let l=0,r=0;this.mclassSorter=s(this);for(const[s,o]of this.termGroups.entries()){const a=[];for(const[t,s]of o.lst.entries()){const i={samples:0,hits:0};const l=new Set;for(const t of e.lst){if(l.has(t.sample))continue;l.add(t.sample);const e=t[s.$id];if(e){const{filteredValues:l,countedValues:r,renderedValues:a}=this.classifyValues(e,s,o,n,t);e.filteredValues=l;e.countedValues=r;e.renderedValues=a;if(e.countedValues?.length){const t=s.term.values?.[e.value];if(t?.uncountable)continue;i.samples+=1;i.hits+=e.countedValues.length;if(s.q?.mode=="continuous"){const t=e.value;if(!("minval"in i)||i.minval>t)i.minval=t;if(!("maxval"in i)||i.maxval<t)i.maxval=t}}}}if(o.type!="hierCluster"||i.samples)a.push({tw:s,counts:i,index:t})}const u=o.sortTermsBy||o.type=="hierCluster"?t(this,n,o):this.termSorter;const c=a.filter((e=>{if("minNumSamples"in e.tw)return e.tw.minNumSamples<=e.counts.samples;if(!o.settings)return true;return!("minNumSamples"in o.settings)||e.counts.samples>=o.settings.minNumSamples})).sort(u);if(!c.length)continue;for(const[t,n]of c.entries()){const{tw:a,counts:u}=n;const d=e.refs.byTermId[n.tw.$id]||{};i.push({grp:o,grpIndex:s,visibleGrpIndex:r,tw:a,index:t,lstIndex:n.index,processedLst:c,prevGrpTotalIndex:l,totalIndex:l+t,ref:d,allCounts:u})}l+=c.length;r+=1}return i}function c(e){const t=this.settings.matrix;const s={id:this.config.divideBy?.$id,name:this.config.divideBy?"Not annotated":"",lst:[]};const l=new Map;const r=this.config.divideBy?.term||{};const o=this.config.divideBy?.$id||"-";const a=this.config.divideBy?.exclude||[];const u=r.values||{};const c=e.refs.byTermId[o]||{};for(const n of e.lst){if(o in n){const e=n[o].key;const s=e in u&&u[e].label?u[e].label:e;if(!l.has(e)){const n={name:`${s}`,id:e,lst:[],tw:this.config.divideBy,legendGroups:{},isExcluded:a.includes(e)};if(c.bins&&t.sortSampleGrpsBy=="name")n.order=c.bins.findIndex((t=>t.name==e));else delete n.order;l.set(e,n)}l.get(e).lst.push(n)}else{s.lst.push(n)}}const d=[...l.values()];const f=l.size;if(f>100&&d.filter((e=>e.lst.length<3)).length>.8*f){const e=t.controlLabels;throw`Did not group ${e.samples} by "${r.name}": too many ${e.sample} groups (${f}), with the majority of groups having <= 2 ${e.samples} per group.`}if(s.lst.length&&!l.size){l.set(undefined,s);d.push(...l.values())}this.asListedSampleOrder=[];for(const e of d){this.asListedSampleOrder.push(...e.lst.map((e=>e.sample)))}const p=this.termOrder.filter((e=>e.tw.sortSamples&&e.tw.term.type!="geneVariant"));const m=n(this,t,e.lst,{skipSorter:(e,t)=>!e.types?.includes("geneVariant")&&p.find((e=>e.tw.$id===t.$id))});const h=e.lst.sort(m);const g=h.slice(0,t.maxSample);const v=e=>g.includes(e);const x=(e,t)=>e+(typeof t=="object"&&t.countedValues?.length?1:0);const y=(e,t)=>e+(Object.values(t).reduce(x,0)?1:0);const S=n(this,t,e.lst);for(const e of d){e.lst=e.lst.filter(v);e.totalCountedValues=e.lst.reduce(y,0);e.lst.sort(S)}const V=i(this);return d.sort(V)}function d(e){this.settings.matrix;this.visibleSampleGrps=new Set;const t=[];let s=0,n=0;for(const[e,i]of this.sampleGroups.entries()){if(!i.lst.length)continue;if(i.isExcluded)n++;let l=i.lst;for(const[r,o]of l.entries()){t.push({grp:i,grpIndex:e-n,row:o,index:r,prevGrpTotalIndex:s,totalIndex:s+r,totalHtAdjustments:0,grpTotals:{htAdjustment:0},processedLst:l})}if(!i.isExcluded)s+=l.length;this.visibleSampleGrps.add(i)}this.unfilteredSampleOrder=t;return t.filter((e=>!e.grp.isExcluded))}function f(t,s,n,i,u){const c="value"in t?[t.value]:t.values;if(!c)return{filteredValues:null,countedValues:null,renderedValues:null};const d=[s.valueFilter||n.valueFilter].filter((e=>e&&true));if(d.length&&d[0].type!=="tvs"&&d[0].type!=="tvslst")throw`unknown matrix value filter type='${d.type}'`;let f=!d.length?c:c.filter((t=>e(t,d[0],s.term,u)));const p=[];if(s.term.type!="geneVariant"||s.q?.groupsetting?.inuse)p.push(...f);else{f.sort(this.mclassSorter);if(i.cellEncoding=="")p.push(...f);else{const e=[];for(const t of[l,r,o,a]){const s=t==a?f.find((e=>e.dt===t)):f.find((e=>e.dt===t&&e.class!=="WT"&&e.class!=="Blank"));if(s)p.push(s);const n=f.filter((e=>e.dt===t));e.push(...n)}f=e}}return{filteredValues:f,countedValues:f.filter((e=>{if(s.term.type=="geneVariant"){if(!s.q?.groupsetting?.inuse){if(e.class=="WT"||e.class=="Blank"||i.geneVariantCountSamplesSkipMclass.includes(e.class))return false}else{const t=s.term.groupsetting.lst[s.q.groupsetting.predefined_groupset_idx];const n=t.groups[0];if(e!=n.name)return false}}return true})),renderedValues:p}}function p(e,t){return e.class===t.class?0:e.class==="Blank"?1:t.class=="Blank"?-1:e.class<t.class?-1:1}var m=Object.freeze({__proto__:null,getTermOrder:u,getSampleGroups:c,getSampleOrder:d,classifyValues:f,stackSiblingCellsByClass:p});export{m};
|