@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
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a0 as t,o as e,bP as n,M as a,_ as o,l as r,aU as s,q as l,a as i}from"./app-
|
|
1
|
+
import{a0 as t,o as e,bP as n,M as a,_ as o,l as r,aU as s,q as l,a as i}from"./app-71453429.js";import{d as p}from"./tp.ui-23151bb1.js";import{p as c}from"./viridis-81de7bcd.js";import{c as d,b as u}from"./axis-6cb4f314.js";import"./block.lazyload-6f83d057.js";const m="#ccc";function f(n,a){const o=t({x:100,y:100});o.header.text("PCA - expression plot");const r=o.body.append("div").style("margin","20px");const s=o.body.append("div").style("margin","20px");const l=r.append("input").attr("size",30).attr("placeholder","PCA/SNE matrix file path").style("margin","10px").property("value","xiang/sep20/set1");const i=r.append("input").attr("size",30).attr("placeholder","numerical db file path").style("margin","10px").property("value","xiang/sep20/set1.db");r.append("button").text("Submit").on("click",(()=>{s.selectAll("*").remove();const t=l.property("value");if(t==""){s.text("No PCA file");return}const o=i.property("value");if(o==""){s.text("No db file");return}p(n+"/textfile").post(JSON.stringify({file:t,jwt:a}),(t=>{if(t.error){s.text("Error getting file: "+t.error);return}const[r,l]=h({holder:s,text:t.text});if(r){e(s,r);return}b({holder:s.append("div"),numdata2plot:l,hostURL:n,jwt:a,obj:{dbfile:o}})}))}));r.append("button").text("Clear").on("click",(()=>{l.property("value","");i.property("value","")}));r.append("span").style("padding-left","10px").html("<a href=https://docs.google.com/document/d/1Midt0rYs1iIJveUMjeng9si3q31YelcNe_PI3Njce9E/edit?usp=sharing target=_blank>Help</a>")}function h(t){const e=[];const p=t.text.split(/\r?\n/);for(let n=0;n<p.length;n++){const a=p[n];if(!a)continue;const o=a.split("\t");const r=o[0];const s=Number.parseFloat(o[1]);const l=Number.parseFloat(o[2]);if(Number.isNaN(s)){return["invalid x value at line "+(n+1)]}if(Number.isNaN(l)){return["invalid y value at line "+(n+1)]}const i={sample:r,x:s,y:l};if(t.mdanno){if(t.mdanno.annotation[r]){i.attr=[];for(const e in t.mdanno.annotation[r]){if(t.mdanno.mdh[e]){const n=t.mdanno.annotation[r][e];if(t.mdanno.mdh[e].values[n]){i.attr.push({k:t.mdanno.mdh[e].label,v:t.mdanno.mdh[e].values[n].label})}else{i.attr.push({k:t.mdanno.mdh[e].label,v:n})}}else{i.attr.push({k:e,v:"unknown term key"})}}}}e.push(i)}if(e.length==0){return["no samples"]}let f;if(t.obj&&t.obj.colorscale&&t.obj.colorscale.from&&t.obj.colorscale.to){f=n(t.obj.colorscale.from,t.obj.colorscale.to)}else{f=c}let h=e[0].x,b=e[0].x,x=e[0].y,g=e[0].y;for(const t of e){h=Math.min(h,t.x);b=Math.max(b,t.x);x=Math.min(x,t.y);g=Math.max(g,t.y)}const v=t.holder.append("div").style("display","inline-block");const y=new a({padding:"5px"});const j=v.append("svg");let k=30,w=50,N=100,M=30,A=20,z=500,C=500;const S=j.append("g");const E=j.append("g");const P=j.append("g");const Y=P.selectAll().data(e).enter().append("g");const U=Y.append("circle").attr("fill","#aaa").attr("stroke","none").on("mouseover",((t,e)=>{t.target.setAttribute("stroke","white");y.clear();y.show(t.clientX,t.clientY);const n=[{k:"name",v:e.sample}];if(e.value!=undefined){n.push({k:"value",v:e.value})}if(e.attr){for(const t of e.attr){n.push(t)}}o(y.d,n)})).on("mouseout",((t,e)=>{t.target.setAttribute("stroke","none");y.hide()}));if(t.obj){t.obj.circles=U}const _=r().domain([h,b]);const q=r().domain([x,g]);function J(){const t=3;w=z/20+20;j.attr("width",N+A+z+M).attr("height",k+C+A+w);S.attr("transform","translate("+(N+A)+","+(k+C+A)+")");E.attr("transform","translate("+N+","+k+")");P.attr("transform","translate("+(N+A)+","+k+")");_.range([0,z]);q.range([C,0]);i({axis:S.call(d().scale(_)),color:"black",fontsize:z/40,showline:true});i({axis:E.call(u().scale(q)),color:"black",fontsize:C/40,showline:true});Y.attr("transform",(t=>"translate("+_(t.x)+","+q(t.y)+")"));U.attr("r",t)}J();const L=v.append("div").style("position","relative");{const e=t.toprow||L;e.append("button").style("margin-right","20px").text("SVG").on("click",(()=>s(j.node(),"plot")))}const X=L.append("div").style("margin","10px 10px 10px 30px");if(t.obj){t.obj.legendholder=X}L.append("div").style("position","absolute").style("right","0px").style("top","0px").attr("class","sja_clbtext").text("drag to resize").on("mousedown",(t=>{t.preventDefault();const e=l(document.body);const n=t.clientX;const a=t.clientY;const o=z;const r=C;e.on("mousemove",(t=>{z=o+t.clientX-n;C=r+t.clientY-a;J()}));e.on("mouseup",(t=>{e.on("mousemove",null).on("mouseup",null)}))}));let F=false;const I=(t,e)=>{const n=new Map;let a=t[0].value,o=t[0].value;for(const e of t){n.set(e.sample,e.value);a=Math.max(a,e.value);o=Math.min(o,e.value)}let r,s;if(F){r=t.reduce(((t,e)=>t+e.value),0)/t.length;s=Math.sqrt(t.reduce(((t,e)=>t+Math.pow(e.value-r,2)),0)/t.length);console.log(r,s);o=a=0;t.forEach((t=>{const e=(t.value-r)/s;o=Math.min(o,e);a=Math.max(a,e)}))}U.attr("fill",(t=>{if(n.has(t.sample)){let e=n.get(t.sample);t.value=e;if(F){e=(e-r)/s;t.value=e}const l=(e-o)/(a-o);return f(l)}t.value=undefined;return m}));Y.each((function(t){if(t.value!=undefined){this.parentNode.appendChild(this)}}));X.selectAll("*").remove();X.append("span").html(e+" ");X.append("span").html("min: "+o+" ");const l=[];for(let t=0;t<=1;t+=.1){l.push(f(t))}X.append("div").style("display","inline-block").style("width","150px").style("height","20px").style("background","linear-gradient(to right,"+l.join(",")+")").style("border","solid 1px "+m);X.append("span").html(" max: "+a);const i=X.append("div").style("margin-top","10px");const p=Math.random().toString();i.append("input").attr("type","checkbox").style("margin-right","10px").property("checked",F).attr("id",p).on("change",(()=>{F=!F;I(t,e)}));i.append("label").attr("for",p).text("apply Z-score")};return[null,I]}function b(t){const e=t.holder.append("input").attr("placeholder","search gene").attr("padding-right","20px");const n=t.holder.append("span");e.on("keyup",(a=>{n.text("");if(a.code!="Enter")return;const o=e.property("value");if(!o)return;e.property("value","");p(t.hostURL+"/dbdata").post(JSON.stringify({db:t.obj.dbfile,tablename:"data",keyname:"gene",key:o.toLowerCase(),jwt:t.jwt}),(e=>{if(e.error){n.text("error getting data: "+e.error);return}if(!e.rows){n.text(".rows missing");return}if(e.rows.length==0){n.text("no match for "+o);return}t.obj.expressiondata=e.rows;t.obj.searchedgene=o;t.numdata2plot(e.rows,o);if(t.callback){t.callback()}}))}))}export{b as e2pca_genesearchui,f as e2pca_inputui,h as e2pca_plot};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as t}from"./legacy-d3-polyfill-bdb2d792.js";import{p as e,A as a,z as s,x as i,l as o,q as r,_ as n,am as h,a0 as l,M as d,bX as p,bT as c,a as f,g,h as m,aU as x,N as u}from"./app-f91922b4.js";import{d as b}from"./arc-3d6751aa.js";import{p as y}from"./partition-db811f6b.js";import{p as v}from"./pointer-c7475677.js";import{l as w}from"./log-4d74231e.js";import{d as k}from"./axis-6cb4f314.js";import"./constant-426a1483.js";import"./math-2fb199c6.js";function _(t,n,h){if(!t.p.cohort){return}t.grab.min=Math.min(n,h);t.grab.max=Math.max(n,h);let l=t.data.filter((e=>e.value>=t.grab.min&&e.value<=t.grab.max));if(l.length==0){if(t.grab.sun){t.grab.sun.g.remove()}return}if(t.p.cohort.annotation){const e=[];for(const a of l){const s={};for(const t in a){if(t!="circle"){s[t]=a[t]}}const i=t.p.cohort.annotation[a[t.p.sampletype]];if(i){for(const t in i){s[t]=i[t]}}e.push(s)}l=e}const d=t.grab;if(d.sun){d.sun.g.remove()}else{d.sun={x:0,y:0}}const p=d.sun;p.g=d.holder.append("g").attr("transform","translate("+p.x+","+p.y+")").on("mouseover",(()=>{t.dottip.hide()}));let c=0;for(const e of l){if(e[t.p.cohort.levels[0].k]!=undefined){c++}}if(c==0){p.g.append("text").text("0/"+l.length).attr("font-size",40).attr("font-family",e).attr("stroke","white").attr("stroke-width",3).attr("text-anchor","middle");p.g.append("text").text("0/"+l.length).attr("font-size",40).attr("font-family",e).attr("fill",t.p.hlcolor).attr("text-anchor","middle").attr("fill-opacity",.8).on("click",(()=>{M(p,d,t)}));return}if(t.samplecart){d.selectedsamples=l.map((t=>t.sample_name?t.sample_name:t.sample));t.samplecart.setBtns({samplelst:d.selectedsamples,basket:"Gene Expression",id:t.genename+(!t.grab||!l.length?"":" FPKM:"+t.grab.min+"-"+t.grab.max),container:t.samplecartWrapper,reselectable:true})}const f=Math.min(t.width,t.height)*.3;const g=p.g.append("g");let m;let x;const u=b().startAngle((t=>t.x0)).endAngle((t=>t.x1)).innerRadius((t=>{if(!t.parent){x=Math.sqrt(t.y1)-f/15;return x}return Math.sqrt(t.y0)})).outerRadius((t=>{t.outradius=Math.sqrt(t.y1);if(t.parent&&!t.parent.parent){m=t.outradius}return t.outradius}));const v=a(l,t.p.cohort.levels);const w=s()(v);w.sum((t=>t.value));w.sort(((t,e)=>e.value-t.value));y().size([Math.PI*2,f*f])(w);p.ring=p.g.selectAll().data(w.descendants()).enter().append("path").attr("d",u).attr("stroke","white").attr("fill-opacity",1).attr("fill-rule","evenodd").attr("fill",(e=>{if(!e.parent)return"white";let a;if(e.children){a=e.id}else{if(!e.parent.parent){a=e.id}else{a=e.parent.id}}e._color=t.p.cohort.suncolor(a);return e._color})).on("mouseover",((t,e)=>{if(!e.parent)return;D.text(e.data.name);C.text(e.data.name);L.text(e.value);U.text(e.data.full||"");t.target.setAttribute("fill",i(e._color).darker(.5).toString())})).on("mouseout",((e,a)=>{D.text(d.min+" - "+d.max).attr("font-size",X);C.text(d.min+" - "+d.max).attr("font-size",X);L.text(c==l.length?l.length:c+"/"+l.length);U.text(t.p.datatype);e.target.setAttribute("fill",a._color)})).on("click",((e,a)=>{if(!t.samplecart){return}const s=[];for(const t of a.data.lst){s.push(t.sample_name?t.sample_name:t.sample)}t.samplecart.setBtns({samplelst:s,basket:"Gene Expression",note:a.data.name+" samples with "+t.genename+" "+t.p.datatype+" between "+t.grab.min+" and "+t.grab.max,id:t.genename+(!t.grab||!a.data.lst.length||!a.data.lst[0]?"":" FPKM:"+t.grab.min+"-"+t.grab.max)+" "+a.data.lst[0].ancestor_dx,container:t.samplecartWrapper,reselectable:true})}));g.append("circle").attr("r",m).attr("fill","white").attr("fill-opacity",.7);const k=[],_=[],z=[],F=[];for(const t of w.leaves()){const e=(t.x0+t.x1)/2;if(e<=Math.PI/2)k.push(t);else if(e<=Math.PI)_.push(t);else if(e<=Math.PI*1.5)z.push(t);else F.push(t)}k.sort(((t,e)=>e.x0-t.x0));_.sort(((t,e)=>t.x0-e.x0));z.sort(((t,e)=>e.x0-t.x0));F.sort(((t,e)=>t.x0-e.x0));const j=[...k,..._,...z,...F];const B=[];const P=[];const A=Math.max(13,t.dotsize*.7);p.g.selectAll().data(j).enter().append("text").text((t=>(t.parent.data.name?t.parent.data.name=="root"?"":t.parent.data.name+", ":"")+t.data.name)).attr("font-size",A).attr("font-family",e).attr("stroke","white").attr("stroke-width",3).attr("fill","none").each((function(t){const e=this.getBBox().height;const a=(t.x0+t.x1)/2;let s=f+5;let i=-s*Math.cos(a);if(a<=Math.PI){let t=true;for(const o of P){if(i>=o[0]&&i<=o[1]){t=false;if(a<=Math.PI/2){i=o[0]-2;s=-i/Math.cos(a);o[0]=i-e}else{i=2+o[1];s=-i/Math.cos(a);o[1]=i+e}break}}if(t){if(a<=Math.PI/2){P.push([i-e,i])}else{P.push([i,i+e])}}}else{let t=true;for(const o of B){if(i>=o[0]&&i<=o[1]){t=false;if(a<=Math.PI*1.5){i=2+o[1];s=-i/Math.cos(a);o[1]=i+e}else{i=o[0]-2;s=-i/Math.cos(a);o[0]=i-e}break}}if(t){if(a<=Math.PI*1.5){B.push([i,i+e])}else{B.push([i-e,i])}}}t.labely=i;t.labelx=s*Math.sin(a)})).attr("x",(t=>t.labelx)).attr("y",(t=>t.labely)).attr("text-anchor",(t=>(t.x0+t.x1)/2<=Math.PI?"start":"end")).attr("dominant-baseline",(t=>{var e=(t.x0+t.x1)/2;if(e<=Math.PI/2||e>=Math.PI*1.5)return"";return"hanging"}));p.g.selectAll().data(j).enter().append("text").text((t=>(t.parent.parent?t.parent.data.name+", ":"")+t.data.name)).attr("font-size",A).attr("font-family",e).attr("fill","#858585").attr("x",(t=>t.labelx)).attr("y",(t=>t.labely)).attr("text-anchor",(t=>(t.x0+t.x1)/2<=Math.PI?"start":"end")).attr("dominant-baseline",(t=>{var e=(t.x0+t.x1)/2;if(e<=Math.PI/2||e>=Math.PI*1.5)return"";return"hanging"}));p.g.selectAll().data(j).enter().append("line").attr("x1",(t=>t.outradius*Math.sin((t.x0+t.x1)/2))).attr("y1",(t=>-t.outradius*Math.cos((t.x0+t.x1)/2))).attr("x2",(t=>t.labelx)).attr("y2",(t=>t.labely)).attr("stroke","#858585");const I=Math.max(18,x*.6);const R=Math.max(14,x*.2);let N=-3;let X;p.g.append("text").text(t.p.sampletype.toUpperCase()).attr("font-size",R).attr("font-family",e).attr("y",-I).attr("fill",t.p.hlcolor).attr("text-anchor","middle");const L=p.g.append("text").text(c==l.length?l.length:c+"/"+l.length).attr("font-size",I).attr("font-family",e).attr("y",N).attr("fill",t.p.hlcolor).attr("text-anchor","middle").attr("fill-opacity",.8);N=5;const U=p.g.append("text").text(t.p.datatype).attr("font-size",R).attr("font-family",e).attr("y",N).attr("dominant-baseline","hanging").attr("text-anchor","middle").attr("fill","#b5b5b5");const Y=d.min+" - "+d.max;const S=o().domain([5,15]).range([x,x*2]);const C=p.g.append("text").text(Y).attr("font-size",1).each((function(){var t=this.getBBox();X=Math.min(S(Y.length)/t.width,x*.4/t.height)})).attr("font-size",X).attr("font-family",e).attr("y",N+R).attr("dominant-baseline","hanging").attr("text-anchor","middle").attr("stroke","white").attr("stroke-width",3).attr("fill","none");const D=p.g.append("text").text(Y).attr("font-size",X).attr("font-family",e).attr("y",N+R).attr("dominant-baseline","hanging").attr("text-anchor","middle").attr("fill","#858585");p.g.append("circle").attr("r",x+f/15).attr("fill","white").attr("fill-opacity",0).on("click",(()=>{if(p.busy)return;M(p,d,t)})).on("mousedown",(t=>{const e=p.x,a=p.y,s=t.clientX,i=t.clientY,o=r(document.body);o.on("mousemove",(t=>{t.preventDefault();p.busy=true;p.x=e+t.clientX-s;p.y=a+t.clientY-i;p.g.attr("transform","translate("+p.x+","+p.y+")")})).on("mouseup",(()=>{o.on("mousemove",null).on("mouseup",null);setTimeout((()=>p.busy=false),10)}))}))}function M(t,e,a){if(t.ring){t.ring.transition().attr("fill-opacity",0)}t.g.transition().attr("transform","scale(.5,.5)").on("end",(()=>{t.g.remove();e.shade.attr("transform","translate(0,1000)")}));e.shadebox.transition().duration(500).attr("stroke-opacity",0).attr("fill-opacity",0);e.shadehandle1.transition().duration(500).attr("fill-opacity",0);e.shadehandle2.transition().duration(500).attr("fill-opacity",0);delete e.x;if(a.selectsample_button){a.selectsample_button.style("display","none").text("")}}function z(t,a,s,i,o){for(const e of t.boxplots){if(e.id==i)return}o.style("border-color",t.boxcolor);for(const e of t.boxplots){e.highlight=false;e.label.attr("fill",t.boxcolor);e.label2.attr("fill",t.boxcolor)}let r=[[0,t.height]];for(const e of t.boxplots){const t=e.yoff;const a=e.height;for(const e of r){if(Math.max(t,e[0])<Math.min(t+a,e[1])){if(t+a<e[1]){r.push([t+a+1,e[1]])}e[1]=t-1}}}const h=t.sf_boxlabelfontsize(Math.log(a.length));const l=t.sf_boxheight(a.length);let d=0;for(const t of r){if(t[1]-t[0]>Math.max(l,h)){d=t[0]+3;break}}const p=t.boxbag.append("g").attr("transform","translate(0,"+d+")");const c={labeltext:s,lst:a,holder:p,yoff:d,highlight:false,id:i,handle:o,height:Math.max(l,h),lookuphash:{}};for(const e of a){c.lookuphash[e[t.p.sampletype]]=1}t.boxplots.push(c);const f=a[Math.floor((a.length-1)*.91)].value,g=a[Math.floor((a.length-1)*.75)].value,m=a[Math.floor((a.length-1)*.5)].value,x=a[Math.floor((a.length-1)*.25)].value,u=a[Math.floor((a.length-1)*.09)].value;c.percentile={9:f==0?1e-4:f,25:g==0?1e-4:g,50:m==0?1e-4:m,75:x==0?1e-4:x,91:u==0?1e-4:u};c.hline=p.append("line").attr("y1",l/2).attr("y2",l/2).attr("stroke",t.boxcolor).attr("stroke-dasharray","5,3").attr("shape-rendering","crispEdges");c.hline.transition().duration(t.dur).attr("x1",Math.max(0,t.x_scale(f))).attr("x2",Math.max(0,t.x_scale(u)));c.label=p.append("text").attr("y",l/2).attr("font-size",h).attr("font-family",e).attr("text-anchor","end").attr("dominant-baseline","middle").attr("fill",c.highlight?t.p.hlcolor:t.boxcolor).style("cursor","default").text(s).on("mousedown",(e=>B(t,c,e))).on("click",(()=>j(t,c))).each((function(){c.labelwidth=this.getBBox().width})).attr("x",t.width+t.width2+c.labelwidth);c.label.transition().duration(t.dur).attr("x",t.width+t.width2-t.width2_-3);c.label2=p.append("text").attr("x",t.width+t.width2+c.labelwidth).attr("y",l/2).attr("font-size",h).attr("font-family",e).attr("dominant-baseline","middle").attr("fill",c.highlight?t.p.hlcolor:t.boxcolor).style("cursor","default").text(a.length).on("mousedown",(()=>B(t,c))).on("click",(()=>j(t,c)));c.label2.transition().duration(t.dur).attr("x",t.width+t.width2-t.width2_+3);c.connline=p.append("line").attr("y1",l/2).attr("y2",l/2).attr("stroke",t.boxcolor).attr("stroke-dasharray","1,3").attr("shape-rendering","crispEdges");c.connline.transition().duration(t.dur).attr("x1",Math.max(0,t.x_scale(c.percentile[91]))).attr("x2",Math.max(0,t.width+t.width2-c.labelwidth-t.width2_-3));c.box=p.append("rect").attr("height",l).attr("shape-rendering","crispEdges").attr("fill","white").attr("stroke",t.boxcolor).on("click",(()=>F(t,c))).on("mousedown",(t=>{const e=t.target;e.setAttribute("fill","#FFeeee");e.setAttribute("stroke","#D10000")})).on("mouseover",(e=>{t.dottip.show(e.clientX,e.clientY).clear();const a=[{k:"Group",v:c.labeltext||"All samples"},{k:"1st quartile",v:c.percentile[25]},{k:"Median",v:c.percentile[50]},{k:"3rd quartile",v:c.percentile[75]}];n(t.dottip.d.append("div"),a)})).on("mouseout",(()=>{t.dottip.hide()}));c.box.transition().duration(t.dur).attr("x",Math.max(0,t.x_scale(c.percentile[25]))).attr("width",Math.max(0,t.x_scale(c.percentile[75]))-Math.max(0,t.x_scale(c.percentile[25])));c.vlines=p.selectAll().data([c.percentile[9],c.percentile[25],c.percentile[50],c.percentile[75],c.percentile[91]]).enter().append("line").attr("x1",0).attr("x2",0).attr("y1",0).attr("y2",l).attr("stroke",t.boxcolor).attr("shape-rendering","crispEdges");c.vlines.transition().duration(t.dur).attr("x1",(e=>Math.max(0,t.x_scale(e)))).attr("x2",(e=>Math.max(0,t.x_scale(e))));if(s!=""){j(t,c)}}function F(t,e){let a=null;if(typeof e=="object"){a=e}else{for(const s of t.boxplots){if(s.id==e)a=s}}if(!a){console.log("cannot remove boxplot");return}a.handle.style("border-color","transparent");if(a.label.attr("fill")==t.p.hlcolor){j(t,a)}a.holder.transition().attr("transform","translate("+(t.width+20)+","+a.yoff+")").each((()=>a.holder.remove()));for(let e=0;e<t.boxplots.length;e++){if(t.boxplots[e].id==a.id){t.boxplots.splice(e,1);return}}}function j(t,e){if(t.busy)return;for(const a of t.boxplots){if(a.id!=e.id)a.highlight=false}e.highlight=!e.highlight;t.epdot.transition().duration(1e3).attr("r",(a=>{if(a[t.p.sampletype]in e.lookuphash)return e.highlight?t.dotsize*.7:t.dotsize/2;return e.highlight?t.dotsize*.2:t.dotsize/2})).attr("stroke",(a=>{if(a[t.p.sampletype]in e.lookuphash)return e.highlight?t.p.hlcolor:"black";return"black"})).attr("stroke-opacity",(a=>{if(a[t.p.sampletype]in e.lookuphash)return e.highlight?.4:.2;return e.highlight?.1:.2}));for(const e of t.boxplots){e.label.attr("fill",e.highlight?t.p.hlcolor:t.boxcolor);e.label2.attr("fill",e.highlight?t.p.hlcolor:t.boxcolor)}}function B(t,e,a){a.preventDefault();const s=a.clientY,i=e.yoff;const o=r(document.body);o.on("mousemove",(a=>{t.busy=true;e.yoff=i+a.clientY-s;e.holder.attr("transform","translate(0,"+e.yoff+")")})).on("mouseup",(()=>{o.on("mousemove",null).on("mouseup",null);setTimeout((()=>t.busy=false),100)}))}const P=300,A=500,I=400,R=700;const N=.6;const X=.2;class L{constructor(i){this.p=i.expp;if(this.p.cohort){if(!this.p.cohort.suncolor){this.p.cohort.suncolor=h(t)}}this.boxcolor="#006600";this.boxplots=[];this.const_all="All "+this.p.sampletype+"s";this.uselog=false;this.dotmoved=false;this.genename=i.genename;this.presize=i.presize;this.dsname=i.dsname;this.genome=i.genome;this.hostURL=i.block?i.block.hostURL:i.hostURL;this.samplecart=i.samplecart;if(i.block){const t=i.block.holder.node().getBoundingClientRect();this.presize={x:t.left+i.block.leftheadw+i.block.width+20,y:t.top,width:Math.min(A,Math.max(P,document.body.scrollWidth-t.left-t.width-100)),height:Math.min(R,Math.max(I,document.body.clientHeight-270))}}this.source=i.source;this.data=i.data;this.data.sort(((t,e)=>e.value-t.value));this.minvalue=0;this.maxvalue=0;if(this.data.length>0){this.minvalue=this.maxvalue=this.data[0].value}this.sampletype2value={};for(const t of this.data){const e=t.value;this.minvalue=Math.min(this.minvalue,e);this.maxvalue=Math.max(this.maxvalue,e);this.sampletype2value[t[this.p.sampletype]]=e}if(this.p.scaleminvalue!=undefined){this.minvalue=this.p.scaleminvalue}this.pane=l({x:this.presize.x,y:this.presize.y});this.pane.pane.classed("sja_ep_pane",true);this.dottip=new d({padding:"10px"});if(i.block){const t=r(this.pane.header.node().previousSibling);t.on("click",(()=>{this.epaintfold(i.block)}))}this.pane.body.style("padding","10px");const c=t=>{this.pane.body.append("p").text(t)};if(this.data.length==0){this.pane.header.text(this.p.name);c("No expression data for "+this.genename);return}this.pane.header.text(this.genename+" "+this.p.name+(this.dsname?" from "+this.dsname:""));S(this);this.treediv=this.pane.body.append("div").style("display","none").style("margin","20px 0px 30px 0px").style("padding","10px").style("background-color","#FFFFE8");this.treediv.append("div").style("font-size",".7em").style("color","#858585").style("text-align","center").text("Click on a row to show/hide boxplot");this.svg=this.pane.body.append("svg");if(this.samplecart){this.samplecartWrapper=this.pane.body.append("div");this.samplecart.setBtns({samplelst:this.grab&&this.grab.selectedsamples?this.grab.selectedsamples:[],basket:"Gene Expression",id:this.genename+(!this.grab?"":" FPKM:"+this.grab.min+"-"+this.grab.max),container:this.samplecartWrapper,reselectable:true,replaceable:false})}this.pane.body.append("div").style("text-align","right").append("span").text("drag to resize").attr("font-size",".8em").attr("font-family",e).attr("class","sja_clbtext").on("mousedown",(t=>{t.preventDefault();const e=t.clientX;const a=t.clientY;const s=this.width;const i=this.height;const o=r(document.body);o.on("mousemove",(t=>{this.render(s+t.clientX-e,i+t.clientY-a)}));o.on("mouseup",(()=>{o.on("mousemove",null).on("mouseup",null)}))}));this.sf_boxheight=o().domain([0,this.data.length]);this.sf_boxlabelfontsize=o();this.boxplots=[];if(this.svgg){this.svgg.remove()}this.svgg=this.svg.append("g");this.axisg=this.svgg.append("g");this.grabbar=this.svgg.append("rect").attr("x",0).attr("y",0).attr("fill","white").attr("fill-opacity",0).on("mousedown",(t=>{if(!this.p.cohort){console.log("no .p.cohort");return}this.busy=true;const e=v(t,this.grabbar.node())[0];const a=Number.parseFloat(this.x_scale.invert(e).toFixed(1));this.grab.x=e;this.grab.width=1;this.grab.shade.attr("transform","translate("+e+","+this.grab.y+")");this.grab.shadebox.attr("width",2).attr("height",this.grab.height).attr("stroke-opacity",.7).attr("fill-opacity",.1);this.grab.shadehandle1.attr("fill-opacity",.5);this.grab.shadehandle2.attr("x",2).attr("fill-opacity",.5);_(this,a,Number.parseFloat(this.x_scale.invert(e+1).toFixed(1)));const s=r(document.body);s.on("mousemove",(t=>{t.preventDefault();let s=v(t,this.grabbar.node())[0];s=Math.max(-this.dotsize,s);s=Math.min(this.width+this.dotsize,s);this.grab.width=Math.max(1,Math.abs(s-e));this.grab.shadebox.attr("width",this.grab.width);this.grab.shadehandle2.attr("x",this.grab.width);if(s<e){this.grab.x=s;this.grab.shade.attr("transform","translate("+this.grab.x+","+this.grab.y+")")}_(this,a,Number.parseFloat(this.x_scale.invert(s).toFixed(1)))}));s.on("mouseup",(()=>{this.busy=false;s.on("mousemove",null).on("mouseup",null)}))}));this.verticalline=this.svgg.append("line").attr("stroke",this.boxcolor).attr("stroke-opacity",.1).attr("shape-rendering","crispEdges");this.dur=2e3;this.boxbag=this.svgg.append("g");this.graph=this.svgg.append("g");this.sung=this.svgg.append("g");this.grab={shade:this.sung.append("g"),holder:this.sung.append("g")};this.grab.shadebox=this.grab.shade.append("rect").attr("stroke",this.p.hlcolor).attr("stroke-width",1).attr("fill",this.p.hlcolor).style("cursor","move").on("mousedown",(t=>{if(!this.p.cohort){return}this.busy=true;let e=t.clientX;const a=r(document.body);a.on("mousemove",(t=>{t.preventDefault();const a=t.clientX;this.grab.x+=a-e;e=a;this.grab.shade.attr("transform","translate("+this.grab.x+","+this.grab.y+")");_(this,Number.parseFloat(this.x_scale.invert(this.grab.x).toFixed(1)),Number.parseFloat(this.x_scale.invert(this.grab.x+this.grab.width).toFixed(1)))})).on("mouseup",(()=>{this.busy=false;a.on("mousemove",null).on("mouseup",null)}))}));this.grab.shadehandle1=this.grab.shade.append("rect").attr("x",-5).attr("width",5).attr("height",40).attr("fill",this.p.hlcolor).attr("fill-opacity",0).style("cursor","ew-resize").on("mousedown",(t=>{this.busy=true;let e=t.clientX;const a=r(document.body);a.on("mousemove",(t=>{t.preventDefault();const a=t.clientX;this.grab.width+=e-a;if(this.grab.width<=0){this.grab.width-=e-a;return}this.grab.x+=a-e;e=a;this.grab.shade.attr("transform","translate("+this.grab.x+","+this.grab.y+")");this.grab.shadebox.attr("width",this.grab.width);this.grab.shadehandle2.attr("x",this.grab.width);_(this,Number.parseFloat(this.x_scale.invert(this.grab.x).toFixed(1)),Number.parseFloat(this.x_scale.invert(this.grab.x+this.grab.width).toFixed(1)))})).on("mouseup",(()=>{this.busy=false;a.on("mousemove",null).on("mouseup",null)}))}));this.grab.shadehandle2=this.grab.shade.append("rect").attr("x",0).attr("width",5).attr("height",40).attr("fill",this.p.hlcolor).attr("fill-opacity",0).style("cursor","ew-resize").on("mousedown",(t=>{let e=t.clientX;const a=r(document.body);a.on("mousemove",(t=>{t.preventDefault();const a=t.clientX;this.grab.width+=a-e;if(this.grab.width<=0){this.grab.width-=a-e;return}e=a;this.grab.shadebox.attr("width",this.grab.width);this.grab.shadehandle2.attr("x",this.grab.width);_(this,Number.parseFloat(this.x_scale.invert(this.grab.x).toFixed(1)),Number.parseFloat(this.x_scale.invert(this.grab.x+this.grab.width).toFixed(1)))})).on("mouseup",(()=>{this.busy=false;a.on("mousemove",null).on("mouseup",null)}))}));this.epdotg=this.graph.selectAll().data(this.data).enter().append("g");this.epdot=this.epdotg.append("circle").attr("fill",this.p.hlcolor).attr("fill-opacity",0).attr("stroke","black").attr("stroke-width",2).attr("stroke-opacity",X).each((function(t){t.circle=this})).on("mouseover",((t,e)=>{if(this.busy)return;e.circle.setAttribute("transform","scale(1.5)");this.dottip.clear();const a=[{k:this.p.datatype,v:'<span style="font-size:150%">'+e.value+"</span>"}];if(this.p.attrlst){for(const t of this.p.attrlst){a.push({k:t.label||t.k,v:e[t.k]})}}const s=this.getsampleinfo(e,a);n(this.dottip.d,a).style("zoom",.7);this.dottip.show(t.clientX,t.clientY);if(s){this.dottip.d.append("div").text("Full details").attr("class","sja_menuoption").on("click",(()=>{Y(e,this.p.cohort,t.clientX-100,t.clientY-100)}))}})).on("mouseout",((t,e)=>{e.circle.setAttribute("transform","scale(1)")})).on("mousedown",((t,e)=>{t.preventDefault();const a=t.clientY;const s=r(document.body);const i=this.data[Math.floor(this.data.length/2)].value;if(e.value<i){const t=this.dotgraph_y;s.on("mousemove",(e=>{this.busy=true;this.dotmoved=true;this.dotgraph_y=t+e.clientY-a;this.graph.attr("transform","translate(0,"+this.dotgraph_y+")")}))}else{const t=this.heightmove;s.on("mousemove",(e=>{this.dotmoved=true;this.heightmove=t+a-e.clientY;const s=this.heightmove/this.data.length;this.epdotg.attr("transform",((t,e)=>{t._y=this.height-this.heightmove+e*s;return"translate("+Math.max(0,this.x_scale(t.value))+","+t._y+")"}))}))}s.on("mouseup",(()=>{setTimeout((()=>this.busy=false),50);s.on("mousemove",null).on("mouseup",null)}))}));this.render();const f=this.treediv.append("div").style("margin","10px").style("padding","2px").style("border","solid 1px transparent").html("All samples "+this.data.length).attr("class","sja_clb").on("click",(()=>{let t=true;for(const e of this.boxplots){if(e.id=="all")t=false}if(t){z(this,this.data,"","all",f)}else{F(this,"all")}}));if(this.p.cohort){if(this.p.cohort&&this.p.cohort.annotation&&this.p.cohort.key4annotation){for(const t of this.data){const e=t[this.p.cohort.key4annotation];if(e){const a=this.p.cohort.annotation[e];if(a){if(this.p.cohort.levels){for(const e of this.p.cohort.levels){t[e.k]=a[e.k];if(e.full){t[e.full]=a[e.full]}}}else{for(const e in a){t[e]=a[e]}}}}}}const t=this.treediv.append("div").style("margin","10px").style("height","400px").style("overflow-y","scroll").style("resize","vertical");const e=a(this.data,this.p.cohort.levels);const i=p(s()(e));i.sum((t=>t.value));i.eachBefore((e=>{if(!e.parent)return;const a=t.append("div").style("margin","2px").style("padding","2px").style("border","solid 1px transparent").attr("class","sja_clb");for(let t=1;t<e.depth;t++){a.append("span").style("color","#ccc").style("padding","0px 15px").text("|")}const s=e.data.data;a.append("span").html(s.name+" ");if(s.full){a.append("span").html(s.full+" ").style("font-size",".7em").style("color","#858585")}if(s.lst&&s.lst.length){a.append("span").text(s.lst.length);a.on("click",(()=>{let t=true;for(const e of this.boxplots){if(e.id==s.id)t=false}if(t){z(this,s.lst,s.name,s.id,a)}else{F(this,s.id)}}))}}))}else{this.treediv.append("div").style("margin","10px").text("Cannot stratify sample: no cohort information.")}z(this,this.data,"","all",f)}epaintfold(t){if(!this.handle){const e=this.genome.datasets[this.dsname];if(!e){alert("invalid dataset name: "+this.dsname);return}this.handle=t.ds2handle[this.dsname].handle.append("div").classed("sja_opaque8",true).style("background-color","#999").style("color","white").style("padding","2px 4px").style("margin-left","1px").text("e");this.handle.on("click",(()=>{this.pane.pane.style("display","block");c(this.handle,this.pane.pane);this.handle.style("display","none")}))}this.handle.style("display","inline-block");c(this.pane.pane,this.handle);this.pane.pane.style("display","none")}makescale_ep(){const t=this.axish-2;if(this.uselog){this.x_scale=w().domain([1,this.maxvalue]).range([0,this.width])}else{this.x_scale=o().domain([this.minvalue,this.maxvalue]).range([0,this.width])}const e=k().scale(this.x_scale).tickSizeInner(this.tickh);if(this.uselog){e.ticks(6,",.0f")}else{let a;this.axisg.append("text").text(Math.ceil(this.maxvalue)).attr("font-size",t-this.tickh).each((function(){a=this.getBBox().width})).remove();e.ticks(Math.floor(this.width/(a+20)))}if(this.axis){this.axis.remove()}this.axis=this.axisg.append("g").attr("transform","translate(0,"+t+")").call(e);f({axis:this.axis,fontsize:t-this.tickh,showline:true})}render(t,a){if(!t){t=this.presize.width;a=this.presize.height}this.width=t;this.width2=t*.05;this.dotsize=Math.max(13,t/30);this.height=a;this.sf_boxheight.range([10,this.height/8]);const s=Math.min(this.data.length*.7,300);this.sf_boxlabelfontsize.domain([0,Math.log(s),Math.log(this.data.length)]).range([8,this.sf_boxheight(s)/2,1+this.sf_boxheight(s)/2]);this.heightmove=this.height;this.rowheight_reset();this.svgg.attr("transform","translate("+this.dotsize+",0)");this.axish=Math.max(18,this.width*.04);this.tickh=this.axish*.3;this.makescale_ep();this.grabbar.attr("width",this.width);this.grabbar.attr("height",this.axish);const i=this.svgg.append("text").text(this.data.length).attr("font-family",e).attr("font-size",this.sf_boxlabelfontsize(Math.log(this.data.length)));this.width2_=i.node().getBBox().width+3;i.remove();const o=this.svgg.append("text").text("COUNT").attr("font-size",1).attr("font-family",e);const r=Math.max(8,(this.width2_-3)/o.node().getBBox().width);o.remove();this.axispad=5+r+this.dotsize/2;this.verticalline.attr("x1",this.width+this.width2-this.width2_).attr("y1",this.axish+5).attr("x2",this.width+this.width2-this.width2_).attr("y2",this.axish+this.height+this.axispad);this.dotgraph_y=this.axish+this.axispad;this.dotgraph_y_default=this.dotgraph_y;this.boxbag.attr("transform","translate(0,"+this.dotgraph_y+")");this.graph.attr("transform","translate(0,"+this.dotgraph_y+")");this.sung.attr("transform","translate(0,"+this.dotgraph_y+")");this.grab.y=-this.dotgraph_y-10;this.grab.height=this.height+this.dotgraph_y+30;this.grab.holder.attr("transform","translate("+this.width/2+","+this.height/2+")");this.grab.shadehandle1.attr("y",12+this.axish);this.grab.shadehandle2.attr("y",12+this.axish);this.epdotg.attr("transform",((t,e)=>{t._y=e*this.rowheight;return"translate(0,"+t._y+")"}));this.epdot.attr("r",this.dotsize/2);this.epdotg.attr("transform",(t=>"translate("+Math.max(0,this.x_scale(t.value))+","+t._y+")"));if(this.grab.x){let t=this.x_scale(this.grab.min),e=this.x_scale(this.grab.max);this.grab.x=t;this.grab.width=e-t;this.grab.shade.attr("transform","translate("+t+","+this.grab.y+")");this.grab.shadebox.attr("width",this.grab.width).attr("height",this.grab.height);this.grab.shadehandle2.attr("x",this.grab.width);_(this,this.grab.min,this.grab.max)}for(const t of this.boxplots){const e=this.sf_boxlabelfontsize(Math.log(t.lst.length));const a=this.sf_boxheight(t.lst.length);t.holder.attr("transform","translate(0,"+t.yoff+")");t.hline.attr("y1",a/2).attr("y2",a/2).attr("x1",Math.max(0,this.x_scale(t.percentile[9]))).attr("x2",Math.max(0,this.x_scale(t.percentile[91])));t.label.attr("x",this.width+this.width2-this.width2_-3).attr("y",a/2).attr("font-size",e);t.label2.attr("x",this.width+this.width2-this.width2_+3).attr("y",a/2).attr("font-size",e);t.connline.attr("y1",a/2).attr("y2",a/2).attr("x1",Math.max(0,this.x_scale(t.percentile[91]))).attr("x2",Math.max(0,this.width+this.width2-t.labelwidth-this.width2_-3));t.box.attr("height",a).attr("x",Math.max(0,this.x_scale(t.percentile[25]))).attr("width",Math.max(0,this.x_scale(t.percentile[75]))-Math.max(0,this.x_scale(t.percentile[25])));t.vlines.attr("x1",(t=>Math.max(0,this.x_scale(t)))).attr("x2",(t=>Math.max(0,this.x_scale(t)))).attr("y1",0).attr("y2",a)}this.svg.attr("width",this.width+this.width2+this.dotsize).attr("height",this.height+this.axish+this.axispad+this.dotsize/2)}getsampleinfo(t,e){if(this.p.cohort){if(this.p.cohort.annotation&&this.p.cohort.key4annotation){const a=t[this.p.cohort.key4annotation];if(a){e.push({k:this.p.cohort.key4annotation,v:a});const t=this.p.cohort.annotation[a];if(t){let a=0;for(const e in t)a++;if(this.p.cohort.levels){for(const a of this.p.cohort.levels){e.push({k:a.label||a.k,v:t[a.k]==undefined?"":t[a.k]})}return a>this.p.cohort.levels.length}let s=0;for(const i in t){e.push({k:i,v:t[i]});if(++s==a)return true}return false}}}else if(this.p.cohort.levels){for(const a of this.p.cohort.levels){const s=t[a.k];if(!s)continue;e.push({k:a.label||a.k,v:t[a.k]+(a.full?t[a.full]?' <span style="font-size:.8em;color:#858585">'+t[a.full]+"</span>":"":"")})}return false}}for(const a in t){if(a=="circle"||a=="_y")continue;if(typeof a=="string"){const s=t[a];if(s){e.push({k:a,v:s})}}}return false}rowheight_reset(){if(this.data){this.rowheight=this.height/this.data.length;return}this.rowheight=0}dot_appendtext(t,a){const s=[];t.append("text").text((t=>a.get(t[this.p.sampletype]))).attr("font-family",e).attr("font-size",this.dotsize).each((function(t){t.bb=this.getBBox()})).each((t=>{const e=this.x_scale(t.value);const a=e-this.dotsize>t.bb.width;let i=t._y-t.bb.height/2,o=i+t.bb.height;for(const e of s){if(e.onleft==a&&Math.max(e.y1,i)<Math.min(e.y2,o)){i=e.y2;o=i+t.bb.height}}delete t.bb;t.mafrect={y1:i,y2:o,onleft:a};s.push(t.mafrect)})).attr("class","sja_svgtext").attr("dominant-baseline","central").attr("fill",this.p.hlcolor).attr("text-anchor",(t=>t.mafrect.onleft?"end":"start")).attr("x",(t=>(t.mafrect.onleft?-1:1)*this.dotsize)).attr("y",(t=>t.mafrect.y1-t._y+this.dotsize/2)).on("click",((t,e)=>{r(e.circle).attr("stroke-width",1).attr("stroke-opacity",X).attr("stroke","black").attr("r",this.dotsize/2);e.showtext=false;r(t.target).remove()})).attr("font-size",1).transition().attr("font-size",this.dotsize)}may_hl(t,e){if(!this.data)return;const a=new Set;let s=true;for(const e of t){const t=e[this.p.sampletype];if(!t)continue;a.add(t);if(this.sampletype2value[t]){s=false}}if(s)return;this.epdot.filter((t=>a.has(t[this.p.sampletype]))).attr("r",e?this.dotsize*.8:this.dotsize/2).attr("stroke",e?this.p.hlcolor:"black").attr("stroke-opacity",e?N:X);const i=this.p.maf;if(!i)return;const o=new Map;for(const e of t){const t=e[this.p.sampletype];const a=this.p.maf.get(e);if(!a)continue;if(typeof a=="string"){o.set(t,a)}else{o.set(t,a.v2==0?"No "+this.p.maf.label+": site not covered":this.p.maf.label+": "+(a.f*100).toFixed(0)+"% ("+a.v1+"/"+a.v2+")")}}const r=this.epdotg.filter((t=>o.has(t[this.p.sampletype])&&!t.showtext));if(e){this.dot_appendtext(r,o)}else{r.select("text").remove()}}}function U(t,e){const a=t.genome.datasets[t.dsname];if(a.dbexpression){const s={db:a.dbexpression.dbfile,tablename:a.dbexpression.tablename,keyname:a.dbexpression.keyname,key:e};fetch(new Request(t.hostURL+"/dbdata",{method:"POST",body:JSON.stringify(s)})).then((t=>t.json())).then((s=>{if(s.error)throw{message:s.error};if(a.dbexpression.tidy){a.dbexpression.tidy(s.rows)}const i=t.pane.pane.node().getBoundingClientRect();new L({hostURL:t.hostURL,data:s.rows,expp:t.p,presize:{x:i.left+30,y:i.top+50,width:t.width,height:t.height},genome:t.genome,dsname:t.dsname,genename:e,samplecart:t.samplecart})})).catch((t=>{window.alert(t.message);if(t.stack)console.log(t.stack)}));return}fetch(new Request(t.hostURL+"/dsdata",{method:"POST",body:JSON.stringify({genome:t.genome.name,dsname:t.dsname,expressiononly:1,genename:e})})).then((t=>t.json())).then((a=>{if(a.error)throw{message:a.error};const s=t.pane.pane.node().getBoundingClientRect();new L({hostURL:t.hostURL,data:a.data[0].lst,expp:t.p,presize:{x:s.left+30,y:s.top+50,width:t.width,height:t.height},genome:t.genome,dsname:t.dsname,genename:e,samplecart:t.samplecart})})).catch((t=>{window.alert(t.message);if(t.stack)console.log(t.stack)}))}function Y(t,e,a,s){const i=l({x:a,y:s});const o=t[e.key4annotation];i.header.text(o);const r=[];const h=e.annotation[o];for(const t in h){r.push({k:t,v:h[t]})}n(i.body,r)}function S(t){const e=t.pane.body.append("div").style("margin-bottom","10px");e.append("button").text("Cohort").on("click",(()=>{if(t.treediv.style("display")=="none"){g(t.treediv)}else{m(t.treediv)}}));e.append("button").text("Log10").on("click",(()=>{const e=700;t.uselog=!t.uselog;t.makescale_ep();t.epdotg.transition().duration(e).attr("transform",((e,a)=>"translate("+(t.uselog&&e.value==0?0:Math.max(0,t.x_scale(e.value)))+","+e._y+")"));for(const a of t.boxplots){a.vlines.transition().duration(e).attr("x1",(e=>Math.max(0,t.x_scale(e)))).attr("x2",(e=>Math.max(0,t.x_scale(e))));a.box.transition().duration(e).attr("x",Math.max(0,t.x_scale(a.percentile[25]))).attr("width",Math.max(0,t.x_scale(a.percentile[75]))-Math.max(0,t.x_scale(a.percentile[25])));a.hline.transition().duration(e).attr("x1",Math.max(0,t.x_scale(a.percentile[9]))).attr("x2",Math.max(0,t.x_scale(a.percentile[91])));a.connline.transition().duration(e).attr("x1",Math.max(0,t.x_scale(a.percentile[91]))).attr("x2",t.width+t.width2-a.labelwidth-t.width2_-3)}if(t.grab.x){let a=t.x_scale(t.grab.min),s=t.x_scale(t.grab.max);t.grab.x=a;t.grab.width=s-a;t.grab.shade.transition().duration(e).attr("transform","translate("+a+","+t.grab.y+")");t.grab.shadebox.transition().duration(e).attr("width",t.grab.width);t.grab.shadehandle2.transition().duration(e).attr("x",t.grab.width)}}));e.append("button").text("SVG").on("click",(()=>{x(t.svg.node(),t.genename+"_expression")}));e.append("button").text("Data").on("click",(()=>{const e=[t.p.sampletype,t.p.datatype];const a=[];if(t.p.attrlst){for(const s of t.p.attrlst){e.push(s.k);a.push(s.k)}}if(t.p.cohort){for(const s of t.p.cohort.levels){e.push(s.k);a.push(s.k)}}const s=[];for(const e of t.data){const i=[e[t.p.sampletype],e.value];for(const t of a){i.push(e[t]||"")}s.push(i.join("\t"))}u(t.genename+" "+t.p.name+" data",[{text:e.join("\t")+"\n"+s.join("\n")}])}));e.append("input").attr("placeholder","Sample").style("width","60px").style("margin-left","5px").on("keyup",(e=>{const a=e.target.value;if(a==""){t.epdot.attr("r",t.dotsize/2).attr("stroke","black").attr("stroke-opacity",X);return}const s=a.toLowerCase();const i=new Set;for(const e in t.sampletype2value){if(e.toLowerCase().indexOf(s)!=-1){i.add(e)}}t.epdot.filter((e=>i.has(e[t.p.sampletype]))).attr("r",t.dotsize).attr("stroke",t.p.hlcolor).attr("stroke-opacity",N);t.epdot.filter((e=>!i.has(e[t.p.sampletype]))).attr("r",t.dotsize/2).attr("stroke","black").attr("stroke-opacity",X)}));e.append("input").attr("placeholder","Gene").style("width","60px").style("margin-left","5px").on("keyup",(e=>{const a=e.target.value;if(e.code=="Enter"){U(t,a);e.target.value="";return}}));if(t.p.gtexlink){e.append("span").html(" <a target=_blank href=https://www.gtexportal.org/home/gene/"+t.genename+">GTeX normal</a>")}}export{L as default};
|
|
1
|
+
import{s as t}from"./legacy-d3-polyfill-bdb2d792.js";import{p as e,A as a,z as s,x as i,l as o,q as r,_ as n,am as h,a0 as l,M as d,bX as p,bT as c,a as f,g,h as m,aU as x,N as u}from"./app-71453429.js";import{d as b}from"./arc-3d6751aa.js";import{p as y}from"./partition-db811f6b.js";import{p as v}from"./pointer-c7475677.js";import{l as w}from"./log-ca1e2a74.js";import{d as k}from"./axis-6cb4f314.js";import"./constant-426a1483.js";import"./math-2fb199c6.js";function _(t,n,h){if(!t.p.cohort){return}t.grab.min=Math.min(n,h);t.grab.max=Math.max(n,h);let l=t.data.filter((e=>e.value>=t.grab.min&&e.value<=t.grab.max));if(l.length==0){if(t.grab.sun){t.grab.sun.g.remove()}return}if(t.p.cohort.annotation){const e=[];for(const a of l){const s={};for(const t in a){if(t!="circle"){s[t]=a[t]}}const i=t.p.cohort.annotation[a[t.p.sampletype]];if(i){for(const t in i){s[t]=i[t]}}e.push(s)}l=e}const d=t.grab;if(d.sun){d.sun.g.remove()}else{d.sun={x:0,y:0}}const p=d.sun;p.g=d.holder.append("g").attr("transform","translate("+p.x+","+p.y+")").on("mouseover",(()=>{t.dottip.hide()}));let c=0;for(const e of l){if(e[t.p.cohort.levels[0].k]!=undefined){c++}}if(c==0){p.g.append("text").text("0/"+l.length).attr("font-size",40).attr("font-family",e).attr("stroke","white").attr("stroke-width",3).attr("text-anchor","middle");p.g.append("text").text("0/"+l.length).attr("font-size",40).attr("font-family",e).attr("fill",t.p.hlcolor).attr("text-anchor","middle").attr("fill-opacity",.8).on("click",(()=>{M(p,d,t)}));return}if(t.samplecart){d.selectedsamples=l.map((t=>t.sample_name?t.sample_name:t.sample));t.samplecart.setBtns({samplelst:d.selectedsamples,basket:"Gene Expression",id:t.genename+(!t.grab||!l.length?"":" FPKM:"+t.grab.min+"-"+t.grab.max),container:t.samplecartWrapper,reselectable:true})}const f=Math.min(t.width,t.height)*.3;const g=p.g.append("g");let m;let x;const u=b().startAngle((t=>t.x0)).endAngle((t=>t.x1)).innerRadius((t=>{if(!t.parent){x=Math.sqrt(t.y1)-f/15;return x}return Math.sqrt(t.y0)})).outerRadius((t=>{t.outradius=Math.sqrt(t.y1);if(t.parent&&!t.parent.parent){m=t.outradius}return t.outradius}));const v=a(l,t.p.cohort.levels);const w=s()(v);w.sum((t=>t.value));w.sort(((t,e)=>e.value-t.value));y().size([Math.PI*2,f*f])(w);p.ring=p.g.selectAll().data(w.descendants()).enter().append("path").attr("d",u).attr("stroke","white").attr("fill-opacity",1).attr("fill-rule","evenodd").attr("fill",(e=>{if(!e.parent)return"white";let a;if(e.children){a=e.id}else{if(!e.parent.parent){a=e.id}else{a=e.parent.id}}e._color=t.p.cohort.suncolor(a);return e._color})).on("mouseover",((t,e)=>{if(!e.parent)return;D.text(e.data.name);C.text(e.data.name);L.text(e.value);U.text(e.data.full||"");t.target.setAttribute("fill",i(e._color).darker(.5).toString())})).on("mouseout",((e,a)=>{D.text(d.min+" - "+d.max).attr("font-size",X);C.text(d.min+" - "+d.max).attr("font-size",X);L.text(c==l.length?l.length:c+"/"+l.length);U.text(t.p.datatype);e.target.setAttribute("fill",a._color)})).on("click",((e,a)=>{if(!t.samplecart){return}const s=[];for(const t of a.data.lst){s.push(t.sample_name?t.sample_name:t.sample)}t.samplecart.setBtns({samplelst:s,basket:"Gene Expression",note:a.data.name+" samples with "+t.genename+" "+t.p.datatype+" between "+t.grab.min+" and "+t.grab.max,id:t.genename+(!t.grab||!a.data.lst.length||!a.data.lst[0]?"":" FPKM:"+t.grab.min+"-"+t.grab.max)+" "+a.data.lst[0].ancestor_dx,container:t.samplecartWrapper,reselectable:true})}));g.append("circle").attr("r",m).attr("fill","white").attr("fill-opacity",.7);const k=[],_=[],z=[],F=[];for(const t of w.leaves()){const e=(t.x0+t.x1)/2;if(e<=Math.PI/2)k.push(t);else if(e<=Math.PI)_.push(t);else if(e<=Math.PI*1.5)z.push(t);else F.push(t)}k.sort(((t,e)=>e.x0-t.x0));_.sort(((t,e)=>t.x0-e.x0));z.sort(((t,e)=>e.x0-t.x0));F.sort(((t,e)=>t.x0-e.x0));const j=[...k,..._,...z,...F];const B=[];const P=[];const A=Math.max(13,t.dotsize*.7);p.g.selectAll().data(j).enter().append("text").text((t=>(t.parent.data.name?t.parent.data.name=="root"?"":t.parent.data.name+", ":"")+t.data.name)).attr("font-size",A).attr("font-family",e).attr("stroke","white").attr("stroke-width",3).attr("fill","none").each((function(t){const e=this.getBBox().height;const a=(t.x0+t.x1)/2;let s=f+5;let i=-s*Math.cos(a);if(a<=Math.PI){let t=true;for(const o of P){if(i>=o[0]&&i<=o[1]){t=false;if(a<=Math.PI/2){i=o[0]-2;s=-i/Math.cos(a);o[0]=i-e}else{i=2+o[1];s=-i/Math.cos(a);o[1]=i+e}break}}if(t){if(a<=Math.PI/2){P.push([i-e,i])}else{P.push([i,i+e])}}}else{let t=true;for(const o of B){if(i>=o[0]&&i<=o[1]){t=false;if(a<=Math.PI*1.5){i=2+o[1];s=-i/Math.cos(a);o[1]=i+e}else{i=o[0]-2;s=-i/Math.cos(a);o[0]=i-e}break}}if(t){if(a<=Math.PI*1.5){B.push([i,i+e])}else{B.push([i-e,i])}}}t.labely=i;t.labelx=s*Math.sin(a)})).attr("x",(t=>t.labelx)).attr("y",(t=>t.labely)).attr("text-anchor",(t=>(t.x0+t.x1)/2<=Math.PI?"start":"end")).attr("dominant-baseline",(t=>{var e=(t.x0+t.x1)/2;if(e<=Math.PI/2||e>=Math.PI*1.5)return"";return"hanging"}));p.g.selectAll().data(j).enter().append("text").text((t=>(t.parent.parent?t.parent.data.name+", ":"")+t.data.name)).attr("font-size",A).attr("font-family",e).attr("fill","#858585").attr("x",(t=>t.labelx)).attr("y",(t=>t.labely)).attr("text-anchor",(t=>(t.x0+t.x1)/2<=Math.PI?"start":"end")).attr("dominant-baseline",(t=>{var e=(t.x0+t.x1)/2;if(e<=Math.PI/2||e>=Math.PI*1.5)return"";return"hanging"}));p.g.selectAll().data(j).enter().append("line").attr("x1",(t=>t.outradius*Math.sin((t.x0+t.x1)/2))).attr("y1",(t=>-t.outradius*Math.cos((t.x0+t.x1)/2))).attr("x2",(t=>t.labelx)).attr("y2",(t=>t.labely)).attr("stroke","#858585");const I=Math.max(18,x*.6);const R=Math.max(14,x*.2);let N=-3;let X;p.g.append("text").text(t.p.sampletype.toUpperCase()).attr("font-size",R).attr("font-family",e).attr("y",-I).attr("fill",t.p.hlcolor).attr("text-anchor","middle");const L=p.g.append("text").text(c==l.length?l.length:c+"/"+l.length).attr("font-size",I).attr("font-family",e).attr("y",N).attr("fill",t.p.hlcolor).attr("text-anchor","middle").attr("fill-opacity",.8);N=5;const U=p.g.append("text").text(t.p.datatype).attr("font-size",R).attr("font-family",e).attr("y",N).attr("dominant-baseline","hanging").attr("text-anchor","middle").attr("fill","#b5b5b5");const Y=d.min+" - "+d.max;const S=o().domain([5,15]).range([x,x*2]);const C=p.g.append("text").text(Y).attr("font-size",1).each((function(){var t=this.getBBox();X=Math.min(S(Y.length)/t.width,x*.4/t.height)})).attr("font-size",X).attr("font-family",e).attr("y",N+R).attr("dominant-baseline","hanging").attr("text-anchor","middle").attr("stroke","white").attr("stroke-width",3).attr("fill","none");const D=p.g.append("text").text(Y).attr("font-size",X).attr("font-family",e).attr("y",N+R).attr("dominant-baseline","hanging").attr("text-anchor","middle").attr("fill","#858585");p.g.append("circle").attr("r",x+f/15).attr("fill","white").attr("fill-opacity",0).on("click",(()=>{if(p.busy)return;M(p,d,t)})).on("mousedown",(t=>{const e=p.x,a=p.y,s=t.clientX,i=t.clientY,o=r(document.body);o.on("mousemove",(t=>{t.preventDefault();p.busy=true;p.x=e+t.clientX-s;p.y=a+t.clientY-i;p.g.attr("transform","translate("+p.x+","+p.y+")")})).on("mouseup",(()=>{o.on("mousemove",null).on("mouseup",null);setTimeout((()=>p.busy=false),10)}))}))}function M(t,e,a){if(t.ring){t.ring.transition().attr("fill-opacity",0)}t.g.transition().attr("transform","scale(.5,.5)").on("end",(()=>{t.g.remove();e.shade.attr("transform","translate(0,1000)")}));e.shadebox.transition().duration(500).attr("stroke-opacity",0).attr("fill-opacity",0);e.shadehandle1.transition().duration(500).attr("fill-opacity",0);e.shadehandle2.transition().duration(500).attr("fill-opacity",0);delete e.x;if(a.selectsample_button){a.selectsample_button.style("display","none").text("")}}function z(t,a,s,i,o){for(const e of t.boxplots){if(e.id==i)return}o.style("border-color",t.boxcolor);for(const e of t.boxplots){e.highlight=false;e.label.attr("fill",t.boxcolor);e.label2.attr("fill",t.boxcolor)}let r=[[0,t.height]];for(const e of t.boxplots){const t=e.yoff;const a=e.height;for(const e of r){if(Math.max(t,e[0])<Math.min(t+a,e[1])){if(t+a<e[1]){r.push([t+a+1,e[1]])}e[1]=t-1}}}const h=t.sf_boxlabelfontsize(Math.log(a.length));const l=t.sf_boxheight(a.length);let d=0;for(const t of r){if(t[1]-t[0]>Math.max(l,h)){d=t[0]+3;break}}const p=t.boxbag.append("g").attr("transform","translate(0,"+d+")");const c={labeltext:s,lst:a,holder:p,yoff:d,highlight:false,id:i,handle:o,height:Math.max(l,h),lookuphash:{}};for(const e of a){c.lookuphash[e[t.p.sampletype]]=1}t.boxplots.push(c);const f=a[Math.floor((a.length-1)*.91)].value,g=a[Math.floor((a.length-1)*.75)].value,m=a[Math.floor((a.length-1)*.5)].value,x=a[Math.floor((a.length-1)*.25)].value,u=a[Math.floor((a.length-1)*.09)].value;c.percentile={9:f==0?1e-4:f,25:g==0?1e-4:g,50:m==0?1e-4:m,75:x==0?1e-4:x,91:u==0?1e-4:u};c.hline=p.append("line").attr("y1",l/2).attr("y2",l/2).attr("stroke",t.boxcolor).attr("stroke-dasharray","5,3").attr("shape-rendering","crispEdges");c.hline.transition().duration(t.dur).attr("x1",Math.max(0,t.x_scale(f))).attr("x2",Math.max(0,t.x_scale(u)));c.label=p.append("text").attr("y",l/2).attr("font-size",h).attr("font-family",e).attr("text-anchor","end").attr("dominant-baseline","middle").attr("fill",c.highlight?t.p.hlcolor:t.boxcolor).style("cursor","default").text(s).on("mousedown",(e=>B(t,c,e))).on("click",(()=>j(t,c))).each((function(){c.labelwidth=this.getBBox().width})).attr("x",t.width+t.width2+c.labelwidth);c.label.transition().duration(t.dur).attr("x",t.width+t.width2-t.width2_-3);c.label2=p.append("text").attr("x",t.width+t.width2+c.labelwidth).attr("y",l/2).attr("font-size",h).attr("font-family",e).attr("dominant-baseline","middle").attr("fill",c.highlight?t.p.hlcolor:t.boxcolor).style("cursor","default").text(a.length).on("mousedown",(()=>B(t,c))).on("click",(()=>j(t,c)));c.label2.transition().duration(t.dur).attr("x",t.width+t.width2-t.width2_+3);c.connline=p.append("line").attr("y1",l/2).attr("y2",l/2).attr("stroke",t.boxcolor).attr("stroke-dasharray","1,3").attr("shape-rendering","crispEdges");c.connline.transition().duration(t.dur).attr("x1",Math.max(0,t.x_scale(c.percentile[91]))).attr("x2",Math.max(0,t.width+t.width2-c.labelwidth-t.width2_-3));c.box=p.append("rect").attr("height",l).attr("shape-rendering","crispEdges").attr("fill","white").attr("stroke",t.boxcolor).on("click",(()=>F(t,c))).on("mousedown",(t=>{const e=t.target;e.setAttribute("fill","#FFeeee");e.setAttribute("stroke","#D10000")})).on("mouseover",(e=>{t.dottip.show(e.clientX,e.clientY).clear();const a=[{k:"Group",v:c.labeltext||"All samples"},{k:"1st quartile",v:c.percentile[25]},{k:"Median",v:c.percentile[50]},{k:"3rd quartile",v:c.percentile[75]}];n(t.dottip.d.append("div"),a)})).on("mouseout",(()=>{t.dottip.hide()}));c.box.transition().duration(t.dur).attr("x",Math.max(0,t.x_scale(c.percentile[25]))).attr("width",Math.max(0,t.x_scale(c.percentile[75]))-Math.max(0,t.x_scale(c.percentile[25])));c.vlines=p.selectAll().data([c.percentile[9],c.percentile[25],c.percentile[50],c.percentile[75],c.percentile[91]]).enter().append("line").attr("x1",0).attr("x2",0).attr("y1",0).attr("y2",l).attr("stroke",t.boxcolor).attr("shape-rendering","crispEdges");c.vlines.transition().duration(t.dur).attr("x1",(e=>Math.max(0,t.x_scale(e)))).attr("x2",(e=>Math.max(0,t.x_scale(e))));if(s!=""){j(t,c)}}function F(t,e){let a=null;if(typeof e=="object"){a=e}else{for(const s of t.boxplots){if(s.id==e)a=s}}if(!a){console.log("cannot remove boxplot");return}a.handle.style("border-color","transparent");if(a.label.attr("fill")==t.p.hlcolor){j(t,a)}a.holder.transition().attr("transform","translate("+(t.width+20)+","+a.yoff+")").each((()=>a.holder.remove()));for(let e=0;e<t.boxplots.length;e++){if(t.boxplots[e].id==a.id){t.boxplots.splice(e,1);return}}}function j(t,e){if(t.busy)return;for(const a of t.boxplots){if(a.id!=e.id)a.highlight=false}e.highlight=!e.highlight;t.epdot.transition().duration(1e3).attr("r",(a=>{if(a[t.p.sampletype]in e.lookuphash)return e.highlight?t.dotsize*.7:t.dotsize/2;return e.highlight?t.dotsize*.2:t.dotsize/2})).attr("stroke",(a=>{if(a[t.p.sampletype]in e.lookuphash)return e.highlight?t.p.hlcolor:"black";return"black"})).attr("stroke-opacity",(a=>{if(a[t.p.sampletype]in e.lookuphash)return e.highlight?.4:.2;return e.highlight?.1:.2}));for(const e of t.boxplots){e.label.attr("fill",e.highlight?t.p.hlcolor:t.boxcolor);e.label2.attr("fill",e.highlight?t.p.hlcolor:t.boxcolor)}}function B(t,e,a){a.preventDefault();const s=a.clientY,i=e.yoff;const o=r(document.body);o.on("mousemove",(a=>{t.busy=true;e.yoff=i+a.clientY-s;e.holder.attr("transform","translate(0,"+e.yoff+")")})).on("mouseup",(()=>{o.on("mousemove",null).on("mouseup",null);setTimeout((()=>t.busy=false),100)}))}const P=300,A=500,I=400,R=700;const N=.6;const X=.2;class L{constructor(i){this.p=i.expp;if(this.p.cohort){if(!this.p.cohort.suncolor){this.p.cohort.suncolor=h(t)}}this.boxcolor="#006600";this.boxplots=[];this.const_all="All "+this.p.sampletype+"s";this.uselog=false;this.dotmoved=false;this.genename=i.genename;this.presize=i.presize;this.dsname=i.dsname;this.genome=i.genome;this.hostURL=i.block?i.block.hostURL:i.hostURL;this.samplecart=i.samplecart;if(i.block){const t=i.block.holder.node().getBoundingClientRect();this.presize={x:t.left+i.block.leftheadw+i.block.width+20,y:t.top,width:Math.min(A,Math.max(P,document.body.scrollWidth-t.left-t.width-100)),height:Math.min(R,Math.max(I,document.body.clientHeight-270))}}this.source=i.source;this.data=i.data;this.data.sort(((t,e)=>e.value-t.value));this.minvalue=0;this.maxvalue=0;if(this.data.length>0){this.minvalue=this.maxvalue=this.data[0].value}this.sampletype2value={};for(const t of this.data){const e=t.value;this.minvalue=Math.min(this.minvalue,e);this.maxvalue=Math.max(this.maxvalue,e);this.sampletype2value[t[this.p.sampletype]]=e}if(this.p.scaleminvalue!=undefined){this.minvalue=this.p.scaleminvalue}this.pane=l({x:this.presize.x,y:this.presize.y});this.pane.pane.classed("sja_ep_pane",true);this.dottip=new d({padding:"10px"});if(i.block){const t=r(this.pane.header.node().previousSibling);t.on("click",(()=>{this.epaintfold(i.block)}))}this.pane.body.style("padding","10px");const c=t=>{this.pane.body.append("p").text(t)};if(this.data.length==0){this.pane.header.text(this.p.name);c("No expression data for "+this.genename);return}this.pane.header.text(this.genename+" "+this.p.name+(this.dsname?" from "+this.dsname:""));S(this);this.treediv=this.pane.body.append("div").style("display","none").style("margin","20px 0px 30px 0px").style("padding","10px").style("background-color","#FFFFE8");this.treediv.append("div").style("font-size",".7em").style("color","#858585").style("text-align","center").text("Click on a row to show/hide boxplot");this.svg=this.pane.body.append("svg");if(this.samplecart){this.samplecartWrapper=this.pane.body.append("div");this.samplecart.setBtns({samplelst:this.grab&&this.grab.selectedsamples?this.grab.selectedsamples:[],basket:"Gene Expression",id:this.genename+(!this.grab?"":" FPKM:"+this.grab.min+"-"+this.grab.max),container:this.samplecartWrapper,reselectable:true,replaceable:false})}this.pane.body.append("div").style("text-align","right").append("span").text("drag to resize").attr("font-size",".8em").attr("font-family",e).attr("class","sja_clbtext").on("mousedown",(t=>{t.preventDefault();const e=t.clientX;const a=t.clientY;const s=this.width;const i=this.height;const o=r(document.body);o.on("mousemove",(t=>{this.render(s+t.clientX-e,i+t.clientY-a)}));o.on("mouseup",(()=>{o.on("mousemove",null).on("mouseup",null)}))}));this.sf_boxheight=o().domain([0,this.data.length]);this.sf_boxlabelfontsize=o();this.boxplots=[];if(this.svgg){this.svgg.remove()}this.svgg=this.svg.append("g");this.axisg=this.svgg.append("g");this.grabbar=this.svgg.append("rect").attr("x",0).attr("y",0).attr("fill","white").attr("fill-opacity",0).on("mousedown",(t=>{if(!this.p.cohort){console.log("no .p.cohort");return}this.busy=true;const e=v(t,this.grabbar.node())[0];const a=Number.parseFloat(this.x_scale.invert(e).toFixed(1));this.grab.x=e;this.grab.width=1;this.grab.shade.attr("transform","translate("+e+","+this.grab.y+")");this.grab.shadebox.attr("width",2).attr("height",this.grab.height).attr("stroke-opacity",.7).attr("fill-opacity",.1);this.grab.shadehandle1.attr("fill-opacity",.5);this.grab.shadehandle2.attr("x",2).attr("fill-opacity",.5);_(this,a,Number.parseFloat(this.x_scale.invert(e+1).toFixed(1)));const s=r(document.body);s.on("mousemove",(t=>{t.preventDefault();let s=v(t,this.grabbar.node())[0];s=Math.max(-this.dotsize,s);s=Math.min(this.width+this.dotsize,s);this.grab.width=Math.max(1,Math.abs(s-e));this.grab.shadebox.attr("width",this.grab.width);this.grab.shadehandle2.attr("x",this.grab.width);if(s<e){this.grab.x=s;this.grab.shade.attr("transform","translate("+this.grab.x+","+this.grab.y+")")}_(this,a,Number.parseFloat(this.x_scale.invert(s).toFixed(1)))}));s.on("mouseup",(()=>{this.busy=false;s.on("mousemove",null).on("mouseup",null)}))}));this.verticalline=this.svgg.append("line").attr("stroke",this.boxcolor).attr("stroke-opacity",.1).attr("shape-rendering","crispEdges");this.dur=2e3;this.boxbag=this.svgg.append("g");this.graph=this.svgg.append("g");this.sung=this.svgg.append("g");this.grab={shade:this.sung.append("g"),holder:this.sung.append("g")};this.grab.shadebox=this.grab.shade.append("rect").attr("stroke",this.p.hlcolor).attr("stroke-width",1).attr("fill",this.p.hlcolor).style("cursor","move").on("mousedown",(t=>{if(!this.p.cohort){return}this.busy=true;let e=t.clientX;const a=r(document.body);a.on("mousemove",(t=>{t.preventDefault();const a=t.clientX;this.grab.x+=a-e;e=a;this.grab.shade.attr("transform","translate("+this.grab.x+","+this.grab.y+")");_(this,Number.parseFloat(this.x_scale.invert(this.grab.x).toFixed(1)),Number.parseFloat(this.x_scale.invert(this.grab.x+this.grab.width).toFixed(1)))})).on("mouseup",(()=>{this.busy=false;a.on("mousemove",null).on("mouseup",null)}))}));this.grab.shadehandle1=this.grab.shade.append("rect").attr("x",-5).attr("width",5).attr("height",40).attr("fill",this.p.hlcolor).attr("fill-opacity",0).style("cursor","ew-resize").on("mousedown",(t=>{this.busy=true;let e=t.clientX;const a=r(document.body);a.on("mousemove",(t=>{t.preventDefault();const a=t.clientX;this.grab.width+=e-a;if(this.grab.width<=0){this.grab.width-=e-a;return}this.grab.x+=a-e;e=a;this.grab.shade.attr("transform","translate("+this.grab.x+","+this.grab.y+")");this.grab.shadebox.attr("width",this.grab.width);this.grab.shadehandle2.attr("x",this.grab.width);_(this,Number.parseFloat(this.x_scale.invert(this.grab.x).toFixed(1)),Number.parseFloat(this.x_scale.invert(this.grab.x+this.grab.width).toFixed(1)))})).on("mouseup",(()=>{this.busy=false;a.on("mousemove",null).on("mouseup",null)}))}));this.grab.shadehandle2=this.grab.shade.append("rect").attr("x",0).attr("width",5).attr("height",40).attr("fill",this.p.hlcolor).attr("fill-opacity",0).style("cursor","ew-resize").on("mousedown",(t=>{let e=t.clientX;const a=r(document.body);a.on("mousemove",(t=>{t.preventDefault();const a=t.clientX;this.grab.width+=a-e;if(this.grab.width<=0){this.grab.width-=a-e;return}e=a;this.grab.shadebox.attr("width",this.grab.width);this.grab.shadehandle2.attr("x",this.grab.width);_(this,Number.parseFloat(this.x_scale.invert(this.grab.x).toFixed(1)),Number.parseFloat(this.x_scale.invert(this.grab.x+this.grab.width).toFixed(1)))})).on("mouseup",(()=>{this.busy=false;a.on("mousemove",null).on("mouseup",null)}))}));this.epdotg=this.graph.selectAll().data(this.data).enter().append("g");this.epdot=this.epdotg.append("circle").attr("fill",this.p.hlcolor).attr("fill-opacity",0).attr("stroke","black").attr("stroke-width",2).attr("stroke-opacity",X).each((function(t){t.circle=this})).on("mouseover",((t,e)=>{if(this.busy)return;e.circle.setAttribute("transform","scale(1.5)");this.dottip.clear();const a=[{k:this.p.datatype,v:'<span style="font-size:150%">'+e.value+"</span>"}];if(this.p.attrlst){for(const t of this.p.attrlst){a.push({k:t.label||t.k,v:e[t.k]})}}const s=this.getsampleinfo(e,a);n(this.dottip.d,a).style("zoom",.7);this.dottip.show(t.clientX,t.clientY);if(s){this.dottip.d.append("div").text("Full details").attr("class","sja_menuoption").on("click",(()=>{Y(e,this.p.cohort,t.clientX-100,t.clientY-100)}))}})).on("mouseout",((t,e)=>{e.circle.setAttribute("transform","scale(1)")})).on("mousedown",((t,e)=>{t.preventDefault();const a=t.clientY;const s=r(document.body);const i=this.data[Math.floor(this.data.length/2)].value;if(e.value<i){const t=this.dotgraph_y;s.on("mousemove",(e=>{this.busy=true;this.dotmoved=true;this.dotgraph_y=t+e.clientY-a;this.graph.attr("transform","translate(0,"+this.dotgraph_y+")")}))}else{const t=this.heightmove;s.on("mousemove",(e=>{this.dotmoved=true;this.heightmove=t+a-e.clientY;const s=this.heightmove/this.data.length;this.epdotg.attr("transform",((t,e)=>{t._y=this.height-this.heightmove+e*s;return"translate("+Math.max(0,this.x_scale(t.value))+","+t._y+")"}))}))}s.on("mouseup",(()=>{setTimeout((()=>this.busy=false),50);s.on("mousemove",null).on("mouseup",null)}))}));this.render();const f=this.treediv.append("div").style("margin","10px").style("padding","2px").style("border","solid 1px transparent").html("All samples "+this.data.length).attr("class","sja_clb").on("click",(()=>{let t=true;for(const e of this.boxplots){if(e.id=="all")t=false}if(t){z(this,this.data,"","all",f)}else{F(this,"all")}}));if(this.p.cohort){if(this.p.cohort&&this.p.cohort.annotation&&this.p.cohort.key4annotation){for(const t of this.data){const e=t[this.p.cohort.key4annotation];if(e){const a=this.p.cohort.annotation[e];if(a){if(this.p.cohort.levels){for(const e of this.p.cohort.levels){t[e.k]=a[e.k];if(e.full){t[e.full]=a[e.full]}}}else{for(const e in a){t[e]=a[e]}}}}}}const t=this.treediv.append("div").style("margin","10px").style("height","400px").style("overflow-y","scroll").style("resize","vertical");const e=a(this.data,this.p.cohort.levels);const i=p(s()(e));i.sum((t=>t.value));i.eachBefore((e=>{if(!e.parent)return;const a=t.append("div").style("margin","2px").style("padding","2px").style("border","solid 1px transparent").attr("class","sja_clb");for(let t=1;t<e.depth;t++){a.append("span").style("color","#ccc").style("padding","0px 15px").text("|")}const s=e.data.data;a.append("span").html(s.name+" ");if(s.full){a.append("span").html(s.full+" ").style("font-size",".7em").style("color","#858585")}if(s.lst&&s.lst.length){a.append("span").text(s.lst.length);a.on("click",(()=>{let t=true;for(const e of this.boxplots){if(e.id==s.id)t=false}if(t){z(this,s.lst,s.name,s.id,a)}else{F(this,s.id)}}))}}))}else{this.treediv.append("div").style("margin","10px").text("Cannot stratify sample: no cohort information.")}z(this,this.data,"","all",f)}epaintfold(t){if(!this.handle){const e=this.genome.datasets[this.dsname];if(!e){alert("invalid dataset name: "+this.dsname);return}this.handle=t.ds2handle[this.dsname].handle.append("div").classed("sja_opaque8",true).style("background-color","#999").style("color","white").style("padding","2px 4px").style("margin-left","1px").text("e");this.handle.on("click",(()=>{this.pane.pane.style("display","block");c(this.handle,this.pane.pane);this.handle.style("display","none")}))}this.handle.style("display","inline-block");c(this.pane.pane,this.handle);this.pane.pane.style("display","none")}makescale_ep(){const t=this.axish-2;if(this.uselog){this.x_scale=w().domain([1,this.maxvalue]).range([0,this.width])}else{this.x_scale=o().domain([this.minvalue,this.maxvalue]).range([0,this.width])}const e=k().scale(this.x_scale).tickSizeInner(this.tickh);if(this.uselog){e.ticks(6,",.0f")}else{let a;this.axisg.append("text").text(Math.ceil(this.maxvalue)).attr("font-size",t-this.tickh).each((function(){a=this.getBBox().width})).remove();e.ticks(Math.floor(this.width/(a+20)))}if(this.axis){this.axis.remove()}this.axis=this.axisg.append("g").attr("transform","translate(0,"+t+")").call(e);f({axis:this.axis,fontsize:t-this.tickh,showline:true})}render(t,a){if(!t){t=this.presize.width;a=this.presize.height}this.width=t;this.width2=t*.05;this.dotsize=Math.max(13,t/30);this.height=a;this.sf_boxheight.range([10,this.height/8]);const s=Math.min(this.data.length*.7,300);this.sf_boxlabelfontsize.domain([0,Math.log(s),Math.log(this.data.length)]).range([8,this.sf_boxheight(s)/2,1+this.sf_boxheight(s)/2]);this.heightmove=this.height;this.rowheight_reset();this.svgg.attr("transform","translate("+this.dotsize+",0)");this.axish=Math.max(18,this.width*.04);this.tickh=this.axish*.3;this.makescale_ep();this.grabbar.attr("width",this.width);this.grabbar.attr("height",this.axish);const i=this.svgg.append("text").text(this.data.length).attr("font-family",e).attr("font-size",this.sf_boxlabelfontsize(Math.log(this.data.length)));this.width2_=i.node().getBBox().width+3;i.remove();const o=this.svgg.append("text").text("COUNT").attr("font-size",1).attr("font-family",e);const r=Math.max(8,(this.width2_-3)/o.node().getBBox().width);o.remove();this.axispad=5+r+this.dotsize/2;this.verticalline.attr("x1",this.width+this.width2-this.width2_).attr("y1",this.axish+5).attr("x2",this.width+this.width2-this.width2_).attr("y2",this.axish+this.height+this.axispad);this.dotgraph_y=this.axish+this.axispad;this.dotgraph_y_default=this.dotgraph_y;this.boxbag.attr("transform","translate(0,"+this.dotgraph_y+")");this.graph.attr("transform","translate(0,"+this.dotgraph_y+")");this.sung.attr("transform","translate(0,"+this.dotgraph_y+")");this.grab.y=-this.dotgraph_y-10;this.grab.height=this.height+this.dotgraph_y+30;this.grab.holder.attr("transform","translate("+this.width/2+","+this.height/2+")");this.grab.shadehandle1.attr("y",12+this.axish);this.grab.shadehandle2.attr("y",12+this.axish);this.epdotg.attr("transform",((t,e)=>{t._y=e*this.rowheight;return"translate(0,"+t._y+")"}));this.epdot.attr("r",this.dotsize/2);this.epdotg.attr("transform",(t=>"translate("+Math.max(0,this.x_scale(t.value))+","+t._y+")"));if(this.grab.x){let t=this.x_scale(this.grab.min),e=this.x_scale(this.grab.max);this.grab.x=t;this.grab.width=e-t;this.grab.shade.attr("transform","translate("+t+","+this.grab.y+")");this.grab.shadebox.attr("width",this.grab.width).attr("height",this.grab.height);this.grab.shadehandle2.attr("x",this.grab.width);_(this,this.grab.min,this.grab.max)}for(const t of this.boxplots){const e=this.sf_boxlabelfontsize(Math.log(t.lst.length));const a=this.sf_boxheight(t.lst.length);t.holder.attr("transform","translate(0,"+t.yoff+")");t.hline.attr("y1",a/2).attr("y2",a/2).attr("x1",Math.max(0,this.x_scale(t.percentile[9]))).attr("x2",Math.max(0,this.x_scale(t.percentile[91])));t.label.attr("x",this.width+this.width2-this.width2_-3).attr("y",a/2).attr("font-size",e);t.label2.attr("x",this.width+this.width2-this.width2_+3).attr("y",a/2).attr("font-size",e);t.connline.attr("y1",a/2).attr("y2",a/2).attr("x1",Math.max(0,this.x_scale(t.percentile[91]))).attr("x2",Math.max(0,this.width+this.width2-t.labelwidth-this.width2_-3));t.box.attr("height",a).attr("x",Math.max(0,this.x_scale(t.percentile[25]))).attr("width",Math.max(0,this.x_scale(t.percentile[75]))-Math.max(0,this.x_scale(t.percentile[25])));t.vlines.attr("x1",(t=>Math.max(0,this.x_scale(t)))).attr("x2",(t=>Math.max(0,this.x_scale(t)))).attr("y1",0).attr("y2",a)}this.svg.attr("width",this.width+this.width2+this.dotsize).attr("height",this.height+this.axish+this.axispad+this.dotsize/2)}getsampleinfo(t,e){if(this.p.cohort){if(this.p.cohort.annotation&&this.p.cohort.key4annotation){const a=t[this.p.cohort.key4annotation];if(a){e.push({k:this.p.cohort.key4annotation,v:a});const t=this.p.cohort.annotation[a];if(t){let a=0;for(const e in t)a++;if(this.p.cohort.levels){for(const a of this.p.cohort.levels){e.push({k:a.label||a.k,v:t[a.k]==undefined?"":t[a.k]})}return a>this.p.cohort.levels.length}let s=0;for(const i in t){e.push({k:i,v:t[i]});if(++s==a)return true}return false}}}else if(this.p.cohort.levels){for(const a of this.p.cohort.levels){const s=t[a.k];if(!s)continue;e.push({k:a.label||a.k,v:t[a.k]+(a.full?t[a.full]?' <span style="font-size:.8em;color:#858585">'+t[a.full]+"</span>":"":"")})}return false}}for(const a in t){if(a=="circle"||a=="_y")continue;if(typeof a=="string"){const s=t[a];if(s){e.push({k:a,v:s})}}}return false}rowheight_reset(){if(this.data){this.rowheight=this.height/this.data.length;return}this.rowheight=0}dot_appendtext(t,a){const s=[];t.append("text").text((t=>a.get(t[this.p.sampletype]))).attr("font-family",e).attr("font-size",this.dotsize).each((function(t){t.bb=this.getBBox()})).each((t=>{const e=this.x_scale(t.value);const a=e-this.dotsize>t.bb.width;let i=t._y-t.bb.height/2,o=i+t.bb.height;for(const e of s){if(e.onleft==a&&Math.max(e.y1,i)<Math.min(e.y2,o)){i=e.y2;o=i+t.bb.height}}delete t.bb;t.mafrect={y1:i,y2:o,onleft:a};s.push(t.mafrect)})).attr("class","sja_svgtext").attr("dominant-baseline","central").attr("fill",this.p.hlcolor).attr("text-anchor",(t=>t.mafrect.onleft?"end":"start")).attr("x",(t=>(t.mafrect.onleft?-1:1)*this.dotsize)).attr("y",(t=>t.mafrect.y1-t._y+this.dotsize/2)).on("click",((t,e)=>{r(e.circle).attr("stroke-width",1).attr("stroke-opacity",X).attr("stroke","black").attr("r",this.dotsize/2);e.showtext=false;r(t.target).remove()})).attr("font-size",1).transition().attr("font-size",this.dotsize)}may_hl(t,e){if(!this.data)return;const a=new Set;let s=true;for(const e of t){const t=e[this.p.sampletype];if(!t)continue;a.add(t);if(this.sampletype2value[t]){s=false}}if(s)return;this.epdot.filter((t=>a.has(t[this.p.sampletype]))).attr("r",e?this.dotsize*.8:this.dotsize/2).attr("stroke",e?this.p.hlcolor:"black").attr("stroke-opacity",e?N:X);const i=this.p.maf;if(!i)return;const o=new Map;for(const e of t){const t=e[this.p.sampletype];const a=this.p.maf.get(e);if(!a)continue;if(typeof a=="string"){o.set(t,a)}else{o.set(t,a.v2==0?"No "+this.p.maf.label+": site not covered":this.p.maf.label+": "+(a.f*100).toFixed(0)+"% ("+a.v1+"/"+a.v2+")")}}const r=this.epdotg.filter((t=>o.has(t[this.p.sampletype])&&!t.showtext));if(e){this.dot_appendtext(r,o)}else{r.select("text").remove()}}}function U(t,e){const a=t.genome.datasets[t.dsname];if(a.dbexpression){const s={db:a.dbexpression.dbfile,tablename:a.dbexpression.tablename,keyname:a.dbexpression.keyname,key:e};fetch(new Request(t.hostURL+"/dbdata",{method:"POST",body:JSON.stringify(s)})).then((t=>t.json())).then((s=>{if(s.error)throw{message:s.error};if(a.dbexpression.tidy){a.dbexpression.tidy(s.rows)}const i=t.pane.pane.node().getBoundingClientRect();new L({hostURL:t.hostURL,data:s.rows,expp:t.p,presize:{x:i.left+30,y:i.top+50,width:t.width,height:t.height},genome:t.genome,dsname:t.dsname,genename:e,samplecart:t.samplecart})})).catch((t=>{window.alert(t.message);if(t.stack)console.log(t.stack)}));return}fetch(new Request(t.hostURL+"/dsdata",{method:"POST",body:JSON.stringify({genome:t.genome.name,dsname:t.dsname,expressiononly:1,genename:e})})).then((t=>t.json())).then((a=>{if(a.error)throw{message:a.error};const s=t.pane.pane.node().getBoundingClientRect();new L({hostURL:t.hostURL,data:a.data[0].lst,expp:t.p,presize:{x:s.left+30,y:s.top+50,width:t.width,height:t.height},genome:t.genome,dsname:t.dsname,genename:e,samplecart:t.samplecart})})).catch((t=>{window.alert(t.message);if(t.stack)console.log(t.stack)}))}function Y(t,e,a,s){const i=l({x:a,y:s});const o=t[e.key4annotation];i.header.text(o);const r=[];const h=e.annotation[o];for(const t in h){r.push({k:t,v:h[t]})}n(i.body,r)}function S(t){const e=t.pane.body.append("div").style("margin-bottom","10px");e.append("button").text("Cohort").on("click",(()=>{if(t.treediv.style("display")=="none"){g(t.treediv)}else{m(t.treediv)}}));e.append("button").text("Log10").on("click",(()=>{const e=700;t.uselog=!t.uselog;t.makescale_ep();t.epdotg.transition().duration(e).attr("transform",((e,a)=>"translate("+(t.uselog&&e.value==0?0:Math.max(0,t.x_scale(e.value)))+","+e._y+")"));for(const a of t.boxplots){a.vlines.transition().duration(e).attr("x1",(e=>Math.max(0,t.x_scale(e)))).attr("x2",(e=>Math.max(0,t.x_scale(e))));a.box.transition().duration(e).attr("x",Math.max(0,t.x_scale(a.percentile[25]))).attr("width",Math.max(0,t.x_scale(a.percentile[75]))-Math.max(0,t.x_scale(a.percentile[25])));a.hline.transition().duration(e).attr("x1",Math.max(0,t.x_scale(a.percentile[9]))).attr("x2",Math.max(0,t.x_scale(a.percentile[91])));a.connline.transition().duration(e).attr("x1",Math.max(0,t.x_scale(a.percentile[91]))).attr("x2",t.width+t.width2-a.labelwidth-t.width2_-3)}if(t.grab.x){let a=t.x_scale(t.grab.min),s=t.x_scale(t.grab.max);t.grab.x=a;t.grab.width=s-a;t.grab.shade.transition().duration(e).attr("transform","translate("+a+","+t.grab.y+")");t.grab.shadebox.transition().duration(e).attr("width",t.grab.width);t.grab.shadehandle2.transition().duration(e).attr("x",t.grab.width)}}));e.append("button").text("SVG").on("click",(()=>{x(t.svg.node(),t.genename+"_expression")}));e.append("button").text("Data").on("click",(()=>{const e=[t.p.sampletype,t.p.datatype];const a=[];if(t.p.attrlst){for(const s of t.p.attrlst){e.push(s.k);a.push(s.k)}}if(t.p.cohort){for(const s of t.p.cohort.levels){e.push(s.k);a.push(s.k)}}const s=[];for(const e of t.data){const i=[e[t.p.sampletype],e.value];for(const t of a){i.push(e[t]||"")}s.push(i.join("\t"))}u(t.genename+" "+t.p.name+" data",[{text:e.join("\t")+"\n"+s.join("\n")}])}));e.append("input").attr("placeholder","Sample").style("width","60px").style("margin-left","5px").on("keyup",(e=>{const a=e.target.value;if(a==""){t.epdot.attr("r",t.dotsize/2).attr("stroke","black").attr("stroke-opacity",X);return}const s=a.toLowerCase();const i=new Set;for(const e in t.sampletype2value){if(e.toLowerCase().indexOf(s)!=-1){i.add(e)}}t.epdot.filter((e=>i.has(e[t.p.sampletype]))).attr("r",t.dotsize).attr("stroke",t.p.hlcolor).attr("stroke-opacity",N);t.epdot.filter((e=>!i.has(e[t.p.sampletype]))).attr("r",t.dotsize/2).attr("stroke","black").attr("stroke-opacity",X)}));e.append("input").attr("placeholder","Gene").style("width","60px").style("margin-left","5px").on("keyup",(e=>{const a=e.target.value;if(e.code=="Enter"){U(t,a);e.target.value="";return}}));if(t.p.gtexlink){e.append("span").html(" <a target=_blank href=https://www.gtexportal.org/home/gene/"+t.genename+">GTeX normal</a>")}}export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as i}from"./app-
|
|
1
|
+
import{P as i}from"./app-71453429.js";async function o({line:o,genome:t,positionType:r}){const n=o.split(",");let e=null,s=null,m=null,p=null,a=null,l=null,N=null,c=null;if(r=="codon"){e=Number.parseInt(n[2].trim());if(Number.isNaN(e))throw"N-term codon position is not integer";s=Number.parseInt(n[5].trim());if(Number.isNaN(s))throw"C-term codon position is not integer"}else if(r=="rna"){m=Number.parseInt(n[2].trim());if(Number.isNaN(m))throw"N-term RNA position is not integer";p=Number.parseInt(n[5].trim());if(Number.isNaN(p))throw"C-term RNA position is not integer"}else if(r=="genomic"){let o=n[2].trim().split(":");if(o.length!=2)throw"N-term genomic position format is not chr:position";a=o[0];N=Number.parseInt(o[1]);if(Number.isNaN(N))throw"invalid N-term genomic position";N--;const r=i(t,a,N,N);if(r)throw"N-term genomic position error: "+r;o=n[5].trim().split(":");if(o.length!=2)throw"C-term genomic position format is not chr:position";l=o[0];c=Number.parseInt(o[1]);if(Number.isNaN(c))throw": invalid C-term genomic position";c--;const e=i(block.genome,l,c,c);if(e)throw"C-term genomic position error: "+e}else{throw"unknown positionType"}const u=n[1].trim().toUpperCase();const f=n[4].trim().toUpperCase();const h={class:"Fuserna",dt:2,isoform:u,pairlst:[{a:{name:n[0].trim(),isoform:u,codon:e,rnaposition:m,chr:a,position:N},b:{name:n[3].trim(),isoform:f,codon:s,rnaposition:p,chr:l,position:c}}]};if(n[6]){const i=Number.parseInt(n[6].trim());if(!Number.isNaN(i)){h.pairlst[0].interstitial={aalen:i}}}return h}export{o as parseFusion};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{appInit as e}from"./plot.app-
|
|
1
|
+
import{appInit as e}from"./plot.app-c841507a.js";import{q as t,aS as r}from"./app-71453429.js";import{T as s}from"./FilterRxComp-fc769f34.js";import"./recover-b1ec4fed.js";import"./FilterStateless-8f30f856.js";import"./app-fb676934.js";import"./termInfo-4c759483.js";import"./table-1dae543a.js";import"./termsetting-636d2271.js";import"path";const i="hg38";const o="GDC";async function n(n,p,l){try{const p=l[i];if(!p)throw i+" missing";const a=n.settings||{};if(typeof a!="object")throw"arg.settings{} not object";if(!a.hierCluster)a.hierCluster={};if(typeof a.hierCluster!="object")throw"arg.settings.hierCluster{} not object";if(!Number.isInteger(a.hierCluster.maxGenes))a.hierCluster.maxGenes=100;if(n.filter0&&typeof n.filter0!="object")throw"arg.filter0 not object";const f=await e({debug:n.debug,holder:t(n.holder).select(".sja_root_holder"),genome:p,state:{genome:i,dslabel:o,termfilter:{filter0:n.filter0},plots:[{chartType:"geneset",toolName:"Gene Expression Clustering",settings:{maxGenes:a.hierCluster.maxGenes}}]},app:n.opts?.app||{},hierCluster:r({reactsTo(e){if(e.type.startsWith("plot_"))return e.id===this.id;if(e.type.startsWith("filter"))return true;if(e.type=="app_refresh")return true},callbacks:{"firstRender.gdcHierCluster":async e=>{e.on("firstRender.gdcHierCluster",null);if(!d)return;f.dispatch({type:"plot_delete",id:d.id});d=undefined}}},n.opts?.hierCluster||{}),matrix:n.opts?.matrix||{},geneset:{mode:"expression",genome:p,genes:n.genes,reactsTo(e){if(e.type.startsWith("plot_"))return e.id===this.id;if(e.type.startsWith("filter"))return true;if(e.type=="app_refresh")return true},showWaitMessage(e){e.style("margin","20px");e.append("div").text("Loading genes that are top variably expressed in current cohort...");e.append("div").style("font-size",".8em").html(`\n\t\t\t\t\t\tGenes are selected from 738 Cancer Gene Census genes.<br>\n\t\t\t\t\t\tOnly up to 1000 cases with gene expression data will be used to select genes.\n\t\t\t\t\t`)},async callback(e,t){if(!e)return;d=e;if(!c){const e=f.getState().plots.find((e=>e.chartType=="hierCluster"));if(e)c=f.getComponents(`plots.${e.id}`)}const r=[{name:"Gene Expression",type:"hierCluster",lst:t},...n.termgroups||[]];if(c){f.dispatch({type:"plot_edit",id:c.id,config:{termgroups:r}})}else{f.dispatch({type:"plot_create",config:{chartType:"hierCluster",termgroups:r,divideBy:n.divideBy||undefined,settings:a,dataType:s.GENE_EXPRESSION}})}}},recover:{undoHtml:"Undo",redoHtml:"Redo",resetHtml:"Restore",hide(e){return e.plots[0]?.chartType!="hierCluster"},adjustTrackedState:e=>{const t=structuredClone(e);delete t.termfilter.filter0;if(t.plots){for(const e of t.plots){if(!e.termgroups)continue;for(const t of e.termgroups){if(!t.lst)continue;for(const e of t.lst){if(!e?.term)continue;delete e.term.category2samplecount;delete e.term.values}}}}return t}}});let c,d;const u={type:"hierCluster",update:async e=>{if(!c){const e=f.getState().plots.find((e=>e.chartType=="hierCluster"));if(e)c=f.getComponents(`plots.${e.id}`)}if("filter0"in e){f.dispatch({type:"filter_replace",filter0:e.filter0})}else if(c){f.dispatch({type:"plot_edit",id:c.id,config:e})}}};return u}catch(e){throw e}}export{n as init};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aC as e,M as t,aD as a}from"./app-
|
|
1
|
+
import{aC as e,M as t,aD as a}from"./app-71453429.js";import{T as o}from"./FilterRxComp-fc769f34.js";import"./table-1dae543a.js";class s{init(a){this.callback=a.callback;this.app=a.app;const o=e({tip:new t({padding:"0px"}),genome:a.genomeObj,row:a.holder,geneOnly:true,callback:()=>this.selectGene(o.geneSymbol),hideHelp:true,focusOff:true})}selectGene(e){return a(this,void 0,void 0,(function*(){if(!e)throw new Error("No gene selected");this.callback({gene:e,type:o.GENE_EXPRESSION,name:e})}))}}export{s as SearchHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aS as t,az as e,S as o,bP as n}from"./app-
|
|
1
|
+
import{aS as t,az as e,S as o,bP as n}from"./app-71453429.js";const r={clusterMethod:"average",distanceMethod:"euclidean"};const a=["average","complete","mcquitty"];const i=["euclidean","maximum","manhattan","canberra"];class d{constructor(){this.type="geneExpression"}async init(t){const e=this.opts.holder.append("div");this.dom={holder:e,controlsDiv:e.append("div"),canvas:e.append("canvas"),colorScaleDiv:e.append("div")};this.makeControls();this.components={}}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found`}return{config:e}}async main(){const t=this.getParam();const e=await o("mds3",{body:t});g(e,this)}getParam(){console.log(this.state.config.genes);const t={genome:this.app.opts.state.vocab.genome,dslabel:this.app.opts.state.vocab.dslabel,geneExpression:1,genes:this.state.config.genes,clusterMethod:this.state.config.clusterMethod};return t}makeControls(){const t=this.dom.controlsDiv.append("select");for(const e of a)t.append("option").text(e);this.dom.clusterMethodSelect=t;t.on("change",(()=>{this.app.dispatch({type:"plot_edit",id:this.id,config:{clusterMethod:a[t.property("selectedIndex")]}})}))}}async function s(e,o){try{const o=structuredClone(r);return t(o,e)}catch(t){throw`${t} [geneExpression getPlotConfig()]`}}const c=e(d);const l=c;function h(t,e){t.append("div").attr("class","sja_menuoption sja_sharp_border").text("Clustering analysis").on("click",(()=>{e.dom.tip.hide();e.prepPlot({config:{chartType:"geneExpression"}})}))}function g(t,e){e.dom.clusterMethodSelect.property("selectedIndex",a.indexOf(e.state.config.clusterMethod));e.dom.distanceMethodSelect.property("selectedIndex",i.indexOf(e.state.config.distanceMethod));const o=t.clustering;console.log(o);o.d={minColor:"#0c306b",maxColor:"#ffcc00",xDendrogramHeight:150,yDendrogramHeight:150};o.d.colorScale=n(o.d.minColor,o.d.maxColor);const r=e.dom.canvas.node().getContext("2d");o.d.rowHeight=y(o);o.d.colWidth=u(o);w(r,o);e.dom.canvas.attr("width",o.d.xDendrogramHeight+o.d.xLabHeight+o.d.colWidth*o.matrix[0].length).attr("height",o.d.yDendrogramHeight+o.d.yLabHeight+o.d.rowHeight*o.matrix.length);f(o,r);p(o,r);x(r,o);M(e,o)}function x(t,e){try{e.row_dendro.map(m)}catch(t){throw"row_dendro error: "+t}try{e.col_dendro.map(m)}catch(t){throw"col_dendro error: "+t}for(const t of e.row_dendro){let e=t.x1;t.x1=t.y1;t.y1=e;e=t.x2;t.x2=t.y2;t.y2=e}{let t=0;for(const o of e.row_dendro)t=Math.max(t,o.x1,o.x2);const o=e.d.xDendrogramHeight/t;for(const n of e.row_dendro){n.x1=o*(t-n.x1);n.x2=o*(t-n.x2);n.y1*=e.d.rowHeight;n.y2*=e.d.rowHeight}}{let t=0;for(const o of e.col_dendro)t=Math.max(t,o.y1,o.y2);const o=e.d.yDendrogramHeight/t;for(const n of e.col_dendro){n.y1=o*(t-n.y1);n.y2=o*(t-n.y2);n.x1*=e.d.colWidth;n.x2*=e.d.colWidth}}t.strokeStyle="black";let o=e.d.yDendrogramHeight+e.d.yLabHeight;for(const n of e.row_dendro){t.beginPath();const e=Math.min(n.x1,n.x2),r=Math.max(n.x1,n.x2),a=Math.min(n.y1,n.y2),i=Math.max(n.y1,n.y2);t.moveTo(e,a+o);t.lineTo(e,i+o);if(n.x1>n.x2&&n.y1>n.y2||n.x1<n.x2&&n.y1<n.y2){t.lineTo(r,i+o)}else{t.moveTo(e,a+o);t.lineTo(r,a+o)}t.stroke();t.closePath()}o=e.d.xDendrogramHeight+e.d.xLabHeight;for(const n of e.col_dendro){t.beginPath();const e=Math.min(n.x1,n.x2),r=Math.max(n.x1,n.x2),a=Math.min(n.y1,n.y2),i=Math.max(n.y1,n.y2);t.moveTo(o+e,a);t.lineTo(o+r,a);if(n.x1>n.x2&&n.y1>n.y2||n.x1<n.x2&&n.y1<n.y2){t.lineTo(o+r,i)}else{t.moveTo(o+e,a);t.lineTo(o+e,i)}t.stroke();t.closePath()}}function m(t){if(t.r1<0)throw`r.r1<0 ${t.r1}`;if(t.r2<0)throw`r.r2<0 ${t.r2}`;if(t.x1<1)throw`r.x1<1 ${t.x1}`;if(t.x2<1)throw`r.x2<1 ${t.x2}`;t.x1-=.5;t.x2-=.5;if(t.y1<0)throw`r.y1<0 ${t.y1}`;if(t.y2<0)throw`r.y2<0 ${t.y2}`}function f(t,e){if(t.d.xLabHeight){e.font=t.d.rowHeight+"px Arial";e.textAlign="end";e.fillStyle="black";for(const[o,n]of t.row_names_index.entries()){e.fillText(t.geneNameLst[n-1],t.d.xDendrogramHeight+t.d.xLabHeight,t.d.yDendrogramHeight+t.d.yLabHeight+t.d.rowHeight*(o+1))}}}function p(t,e){for(let o=0;o<t.row_names_index.length;o++){const n=t.matrix[t.row_names_index[o]-1];const[r,a]=H(n);for(let i=0;i<t.col_names_index.length;i++){const d=n[t.col_names_index[i]-1];e.fillStyle=t.d.colorScale((d-r)/(a-r));e.fillRect(t.d.xDendrogramHeight+t.d.xLabHeight+t.d.colWidth*i,t.d.yDendrogramHeight+t.d.yLabHeight+t.d.rowHeight*o,t.d.colWidth,t.d.rowHeight)}}}function y(t){const e=500/t.matrix.length;if(e>20)return 20;if(e<10)return 10;return Math.ceil(e)}function u(t){const e=2e3/t.matrix[0].length;if(e>10)return 10;return Math.ceil(e)}function w(t,e){if(e.geneNameLst&&e.d.rowHeight>=7){t.font=e.d.rowHeight+"px Arial";let o=0;for(const n of e.geneNameLst){o=Math.max(o,t.measureText(n).width)}e.d.xLabHeight=o}else{e.d.xLabHeight=0}if(e.sampleNameLst&&e.d.colWidth>=7){t.font=e.d.colWidth+"px Arial";let o=0;for(const n of e.sampleNameLst){o=Math.max(o,t.measureText(n).width)}e.d.yLabHeight=o}else{e.d.yLabHeight=0}}function H(t){let e=null,o;for(const n of t){if(e==null){e=n;o=n}else{e=Math.min(e,n);o=Math.max(o,n)}}return[e,o]}function M(t,e){t.dom.colorScaleDiv.selectAll("*").remove();const o=100,n=20;t.dom.colorScaleDiv.append("span").text("Min");const r=t.dom.colorScaleDiv.append("svg");t.dom.colorScaleDiv.append("span").text("Max");const a=r.append("defs").append("linearGradient").attr("id","grad");a.append("stop").attr("offset","0%").attr("stop-color",e.d.minColor);a.append("stop").attr("offset","100%").attr("stop-color",e.d.maxColor);r.append("rect").attr("width",o).attr("height",n).attr("fill","url(#grad)");r.attr("width",o).attr("height",n)}export{l as componentInit,c as geneExpressionInit,s as getPlotConfig,h as makeChartBtnMenu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aD as e,aS as t}from"./app-
|
|
1
|
+
import{aD as e,aS as t}from"./app-71453429.js";function n(e){switch(e){case"./numeric.binary.ts":return import("./numeric.binary-d67da945.js");case"./numeric.continuous.ts":return import("./numeric.continuous-9a0c88bc.js");case"./numeric.discrete.ts":return import("./numeric.discrete-921f7097.js");case"./numeric.spline.ts":return import("./numeric.spline-649308d5.js");case"./numeric.toggle.ts":return import("./numeric.toggle-52789fd2.js");default:return new Promise((function(t,n){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(n.bind(null,new Error("Unknown variable dynamic import: "+e)))}))}}function r(t){return e(this,void 0,void 0,(function*(){const e=t.opts.numericEditMenuVersion;const n=e.length>1?"toggle":e[0];const r=yield o(n);return yield r.getHandler(t)}))}function i(n,r,i=null){var o;return e(this,void 0,void 0,(function*(){if(typeof n.term.gene!="string"||!n.term.gene)throw"geneExpression tw.term.gene must be non-empty string";if(!n.term.name)n.term.name=n.term.gene;if(!((o=n.q)===null||o===void 0?void 0:o.mode))n.q={mode:"continuous"};if(i)t(n.q,i);if(!n.term.bins){const e=yield r.getDefaultBins({tw:n});if("error"in e)throw e.error;n.term.bins=e;const t=n.q.mode;n.q=structuredClone(n.term.bins.default);n.q.mode=t}return n}))}function o(t){return e(this,void 0,void 0,(function*(){try{return yield n(`./numeric.${t}.ts`)}catch(e){if(e.stack)console.log(e.stack);throw`Type numeric.${t} does not exist [handlers/numeric.ts importSubtype()]`}}))}export{i as fillTW,r as getHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./table-
|
|
1
|
+
import{r as e}from"./table-1dae543a.js";import{M as t,aS as s,az as a,bo as l,S as o}from"./app-71453429.js";import{controlsInit as i}from"./controls-0467d2ec.js";import"./controls.btns-ad7b28a2.js";import"./controls.config-6cf816fb.js";import"./controls.overlay-3a55c2ec.js";import"./termsetting-636d2271.js";import"path";import"./FilterRxComp-fc769f34.js";import"./controls.term1-59f4cd60.js";import"./controls.divide-3c0d52d7.js";new t;class n{constructor(){this.type="geneORA"}async init(e){e.plots.find((e=>e.id===this.id));const t=this.opts.holder.append("div").style("display","inline-block");const s=this.opts.holder.append("div").style("display","inline-block").style("margin-left","50px");const a=s.append("div").style("display","inline-block");const l=s.append("div").style("display","inline-block").style("vertical-align","top").style("margin-top","50px");const o=this.opts.holder.append("div").style("margin-left","50px");this.dom={holder:a,header:this.opts.header,controlsDiv:t,detailsDiv:l,tableDiv:o}}async setControls(){this.dom.controlsDiv.selectAll("*").remove();const e=[{label:"P-value filter cutoff (linear scale)",type:"number",chartType:"geneORA",settingsKey:"pvalue",title:"P-value significance",min:0,max:1},{label:"P-value filter type",type:"radio",chartType:"geneORA",settingsKey:"adjusted_original_pvalue",title:"Toggle between original and adjusted pvalues for volcano plot",options:[{label:"adjusted",value:"adjusted"},{label:"original",value:"original"}]}];const t={label:"Gene set group",type:"dropdown",chartType:"geneORA",settingsKey:"pathway",title:"Display table showing original and adjusted pvalues corresponding to each significant pathway",boxLabel:"",options:[{label:"BP: subset of GO",value:"BP: subset of GO"},{label:"MF: subset of GO",value:"MF: subset of GO"},{label:"CC: subset of GO",value:"CC: subset of GO"},{label:"WikiPathways subset of CP",value:"WikiPathways subset of CP"},{label:"REACTOME subset of CP",value:"REACTOME subset of CP"},{label:"H: hallmark gene sets",value:"H: hallmark gene sets"}]};if(!this.settings.pathway){t.options.unshift({label:"-",value:"-"});this.settings.pathway="-"}e.push(t);this.components={controls:await i({app:this.app,id:this.id,holder:this.dom.controlsDiv,inputs:e})};this.components.controls.on("downloadClick.geneORA",(()=>{downloadTable(this.table_rows,this.table_cols)}))}getState(e){const t=e.plots.find((e=>e.id===this.id));if(!t)throw`No plot with id='${this.id}' found`;return{config:t}}async main(){this.config=JSON.parse(JSON.stringify(this.state.config));this.settings=this.config.settings.geneORA;await this.setControls();this.dom.header.style("opacity",.6).style("padding-left","10px").style("font-size","0.75em").text("GENE SET OVERREPRESENTATION ANALYSIS");r(this)}}async function r(t){if(t.settings.pathway!="-"){t.dom.detailsDiv.selectAll("*").remove();t.config.geneORAparams.geneSetGroup=t.settings.pathway;const s=await g(t.config.geneORAparams);const a=l({holder:t.dom.detailsDiv});const[o,i]=a.addRow();i.style("text-align","center").style("font-size","0.8em").style("opacity","0.8").text("COUNT");const n=[{label:"Sample genes",values:t.config.geneORAparams.sample_genes.split(",").length},{label:"Background genes",values:t.config.geneORAparams.background_genes.split(",").length},{label:"Pathways analyzed",values:s.num_pathways}];for(const e of n){const[t,s]=a.addRow();t.text(e.label);s.style("text-align","end").text(e.values)}t.gene_ora_table_cols=[{label:"Gene set group"},{label:"Original p-value (linear scale)"},{label:"Adjusted p-value (linear scale)"}];t.gene_ora_table_rows=[];for(const e of s.pathways){if(t.settings.adjusted_original_pvalue=="adjusted"&&t.settings.pvalue>=e.p_value_adjusted){t.gene_ora_table_rows.push([{value:e.pathway_name},{value:e.p_value_original.toPrecision(4)},{value:e.p_value_adjusted.toPrecision(4)}])}else if(t.settings.adjusted_original_pvalue=="original"&&t.settings.pvalue>=e.p_value_original){t.gene_ora_table_rows.push([{value:e.pathway_name},{value:e.p_value_original.toPrecision(4)},{value:e.p_value_adjusted.toPrecision(4)}])}}t.dom.tableDiv.selectAll("*").remove();const r=t.dom.tableDiv.append("div");e({columns:t.gene_ora_table_cols,rows:t.gene_ora_table_rows,div:r,showLines:true,maxHeight:"30vh",resize:true})}}async function p(e,t){try{const t={settings:{geneORA:{pvalue:1,adjusted_original_pvalue:"adjusted",pathway:undefined},controls:{isOpen:true}}};return s(t,e)}catch(e){throw`${e} [geneORA getPlotConfig()]`}}const d=a(n);const c=d;function u(e,t){t.prepPlot({config:{chartType:"geneORA"}})}async function g(e){return await o("genesetOverrepresentation",{body:e})}export{c as componentInit,d as geneORAInit,p as getPlotConfig,u as makeChartBtnMenu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aC as e,M as t,aD as a}from"./app-
|
|
1
|
+
import{aC as e,M as t,aD as a}from"./app-71453429.js";class n{init(a){this.callback=a.callback;const n=e({tip:new t({padding:"0px"}),genome:a.genomeObj,row:a.holder,callback:()=>this.selectGene(n),hideHelp:true,focusOff:true})}selectGene(e){return a(this,void 0,void 0,(function*(){if(e.geneSymbol){this.callback({id:e.geneSymbol,gene:e.geneSymbol,name:e.geneSymbol,type:"geneVariant"})}else if(e.chr&&e.start&&e.stop){const{chr:t,start:a,stop:n}=e;const s=`${t}:${a+1}-${n}`;this.callback({id:s,chr:t,start:a,stop:n,name:s,type:"geneVariant"})}else{throw"no gene or position specified"}}))}}export{n as SearchHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{O as e,aD as t,aS as n,E as i,L as s,af as o,J as a,K as l}from"./app-
|
|
1
|
+
import{O as e,aD as t,aS as n,E as i,L as s,af as o,J as a,K as l}from"./app-71453429.js";import{m as r}from"./radiobutton-09bff425.js";function d(n){return{getPillName(){return n.term.name},getPillStatus(){var t,i,s,o;if(n.q.groupsetting.inuse){const o=[];o.push(e[n.q.dt]);const a=(i=(t=n.vocabApi.termdbConfig.assayAvailability)===null||t===void 0?void 0:t.byDt[n.q.dt])===null||i===void 0?void 0:i.byOrigin;if(a)o.push(((s=a[n.q.origin])===null||s===void 0?void 0:s.label)||n.q.origin);const l=n.term.groupsetting.lst[n.q.groupsetting.predefined_groupset_idx];o.push(l.name);return{text:o.join(" - ")}}else{return{text:((o=n.q.exclude)===null||o===void 0?void 0:o.length)?"matching variants":"any variant class"}}},showEditMenu(e){return t(this,void 0,void 0,(function*(){yield p(n,e)}))}}}function u(e,t,s=null){var o,a,l,r;if(!e.term.gene&&!(e.term.chr&&Number.isInteger(e.term.start)&&Number.isInteger(e.term.stop))){if(e.term.name)e.term.gene=e.term.name;else throw"no gene or position specified"}if(!e.term.name)e.term.name=e.term.gene||`${e.term.chr}:${e.term.start+1}-${e.term.stop}`;if(!e.term.id)e.term.id=e.term.name;if(!("type"in e.q))e.q.type="values";if(s){s.isAtomic=true;n(e.q,s)}const d=new Set(["D","F","I","L","M","N","P","ProteinAltering","Fuserna","SV"]);const u=new Set(["F","L","N","SV"]);if(!e.term.groupsetting){e.term.groupsetting={disabled:false};const t=[{name:"Mutated vs. wildtype",groups:[{name:"Mutated",values:Object.keys(i).filter((e=>e!="WT"&&e!="Blank")).map((e=>({key:e,dt:i[e].dt,label:i[e].label})))},{name:"Wildtype",values:[{key:"WT",label:"Wildtype"}]},{name:"Not tested",values:[{key:"Blank",label:"Not tested"}]}]},{name:"Protein-changing vs. rest",groups:[{name:"Protein-changing",values:Object.keys(i).filter((e=>d.has(e))).map((e=>({key:e,dt:i[e].dt,label:i[e].label})))},{name:"Rest",values:Object.keys(i).filter((e=>!d.has(e)&&e!="Blank")).map((e=>({key:e,dt:i[e].dt,label:i[e].label})))},{name:"Not tested",values:[{key:"Blank",label:"Not tested"}]}]},{name:"Truncating vs. rest",groups:[{name:"Truncating",values:Object.keys(i).filter((e=>u.has(e))).map((e=>({key:e,dt:i[e].dt,label:i[e].label})))},{name:"Rest",values:Object.keys(i).filter((e=>!u.has(e)&&e!="Blank")).map((e=>({key:e,dt:i[e].dt,label:i[e].label})))},{name:"Not tested",values:[{key:"Blank",label:"Not tested"}]}]}];e.term.groupsetting.lst=t}if(!e.q.groupsetting)e.q.groupsetting={};delete e.q.groupsetting.disabled;if(!("inuse"in e.q.groupsetting))e.q.groupsetting.inuse=false;if(e.q.groupsetting.inuse){const n=g(t.termdbConfig.queries);if(!e.q.dt)e.q.dt=n[0];const i=(a=(o=t.termdbConfig.assayAvailability)===null||o===void 0?void 0:o.byDt[e.q.dt])===null||a===void 0?void 0:a.byOrigin;if(i){if(!e.q.origin||!(e.q.origin in i))e.q.origin=Object.keys(i)[0]}const s=f(e.q.dt);if(!e.q.groupsetting.predefined_groupset_idx||!s.includes(e.q.groupsetting.predefined_groupset_idx))e.q.groupsetting.predefined_groupset_idx=s[0]}{const n=(l=t.termdbConfig.customTwQByType)===null||l===void 0?void 0:l.geneVariant;if(n&&e.term.name){Object.assign(e.q,n.default||{},((r=n.byGene)===null||r===void 0?void 0:r[e.term.name])||{},e.q)}}if("cnvMaxLength"in e.q){if(!Number.isInteger(e.q.cnvMaxLength))throw"cnvMaxLength is not integer"}else{e.q.cnvMaxLength=2e6}if("cnvGainCutoff"in e.q){if(!Number.isFinite(e.q.cnvGainCutoff))throw"cnvGainCutoff is not finite";if(e.q.cnvGainCutoff&&e.q.cnvGainCutoff<0)throw"cnvGainCutoff is not positive"}else{e.q.cnvGainCutoff=.2}if("cnvLossCutoff"in e.q){if(!Number.isFinite(e.q.cnvLossCutoff))throw"cnvLossCutoff is not finite";if(e.q.cnvLossCutoff&&e.q.cnvLossCutoff>0)throw"cnvLossCutoff is not negative"}else{e.q.cnvLossCutoff=-.2}}function p(t,n){const i=n.append("div").style("padding","5px").style("cursor","pointer");i.append("div").style("font-size","1.2rem").text(t.term.name);const s=i.append("div").style("margin-top","10px");const o=i.append("div").style("margin-left","30px").style("display","none");const a=o.append("div").style("margin-top","15px");const l=o.append("div").style("margin-top","15px");const d=o.append("div").style("margin-top","15px");s.append("div").style("font-weight","bold").text("Group variants");const u=r({holder:s,options:[{label:"No variant grouping",value:false,checked:!t.q.groupsetting.inuse},{label:"Assign variants to groups",value:true,checked:t.q.groupsetting.inuse}],callback:e=>{if(e){t.q.groupsetting.inuse=true;p()}else{t.q.groupsetting.inuse=false;delete t.q.dt;delete t.q.origin;o.style("display","none")}}});if(u.inputs.filter(":checked").datum().value)p();function p(){o.style("display","block");c();v();m()}function c(){a.selectAll("*").remove();a.append("div").style("font-weight","bold").text("Variant type");const n=g(t.vocabApi.termdbConfig.queries);if(!t.q.dt)t.q.dt=n[0];r({holder:a,options:n.map((n=>({label:e[n],value:n,checked:n==t.q.dt}))),callback:e=>{t.q.dt=e;v();m()}})}function v(){var e,n;const i=(n=(e=t.vocabApi.termdbConfig.assayAvailability)===null||e===void 0?void 0:e.byDt[t.q.dt])===null||n===void 0?void 0:n.byOrigin;if(!i){l.style("display","none");return}if(!t.q.origin||!(t.q.origin in i))t.q.origin=Object.keys(i)[0];l.style("display","block");l.selectAll("*").remove();l.append("div").style("font-weight","bold").text("Variant origin");r({holder:l,options:Object.keys(i).map((e=>({label:i[e].label,value:e,checked:e==t.q.origin}))),callback:e=>{t.q.origin=e}})}function m(){const e=f(t.q.dt);if(!t.q.groupsetting.predefined_groupset_idx||!e.includes(t.q.groupsetting.predefined_groupset_idx))t.q.groupsetting.predefined_groupset_idx=e[0];d.selectAll("*").remove();d.append("div").style("font-weight","bold").text("Variant grouping");r({holder:d,options:e.map((e=>{const n=t.term.groupsetting.lst[e];return{label:n.name,value:e,checked:e==t.q.groupsetting.predefined_groupset_idx}})),callback:e=>{t.q.groupsetting.predefined_groupset_idx=e}})}i.append("button").style("margin-top","10px").text("Apply").on("click",(()=>{t.runCallback()}))}function g(e){const t=[];for(const n of Object.keys(e)){if(n=="snvindel")t.push(s);else if(n=="cnv")t.push(o);else if(n=="svfusion")t.push(a);else if(n=="sv")t.push(l);else continue}return t}function f(e){const t=e==s||e==l?[0,1,2]:e==o?[0]:e==a?[0,1]:null;return t}export{u as fillTW,d as getHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,e as t,b as n,c as s}from"./uiUtils-
|
|
1
|
+
import{a as e,e as t,b as n,c as s}from"./uiUtils-74700a01.js";import{o as a,q as o,R as p,aR as i}from"./app-71453429.js";function l(t,n){const s=t.append("div").style("margin","20px 20px 20px 40px").style("font-family","'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif").style("place-items","center left").style("overflow","hidden").classed("sjpp-app-ui",true);const a={};r(s,a);const o=s.append("div").style("display","flex").style("align-items","center").style("margin","10px");c(o,n,a);d(o,a);const p=s.append("div").style("display","flex").style("align-items","center").style("margin","40px 0px 40px 130px");y(p,a,t);e(p,a,".genefusion_input").style("margin","0px 10px");m(s);return a}function r(e,n){const s=t({div:e,cols:50,placeholder:"Example: PAX5,chr9,37002646,-::JAK2,chr9,5081726,+"}).style("border","1px solid rgb(138, 177, 212)").style("margin","0px 0px 0px 20px").classed("genefusion_input",true).on("keyup",(async()=>{n.data=s.property("value").trim()}))}async function c(e,t,s){const a=e.append("div").style("margin-left","40px");const o=n(a,t).style("border","1px solid rgb(138, 177, 212)");s.genome=o.node()}async function d(e,t){const n=e.append("div");const s=n.append("select").style("border-radius","5px").style("padding","5px 10px").style("margin","1px 10px 1px 10px");s.append("option").text("Codon position").property("value","codon");s.append("option").text("RNA position").property("value","rna");s.append("option").text("Genomic position").property("value","genomic").attr("selected",true);t.posType=s.node()}function y(e,t,n){const p=s({div:e,text:"Submit"});const i=e.append("div");p.style("display","block").on("click",(()=>{if(!t.data||t.data==undefined){const e=i.append("div").style("display","inline-block").style("max-width","20vw");a(e,"Please provide data");setTimeout((()=>e.remove()),3e3)}else{o(".sjpp-app-ui").remove();const e={host:window.location.origin,nobox:true,noheader:true,parseurl:false,genome:t.genome.options[t.genome.selectedIndex].text};u(t,n,e)}}))}function m(e){e.append("div").style("margin","10px").style("opacity","0.65").html(`Limited to two-gene fusion products.<br>\n\t\tOne product per line.<br>\n\t\tEach line has eight fields. four fields for each gene. For each gene join the following fields separated by a comma:\n\t\t<ol><li>Gene symbol</li>\n\t\t<li>Chromosome</li>\n\t\t<li>Position</li>\n\t\t<li>Strand</li>\n\t\t</ol>\n\t\tSeparate the two genes by a double colon (::). <br><br>\n\t\tExample: <br>\n\t\t<p style="margin-left: 10px">\n\t\tPAX5,chr9,37002646,-::JAK2,chr9,5081726,+<br>\n\t\tZCCHC7,chr9,37257786,-::PAX5,chr9,37024824,-<br>\n\t\tBCR,chr22,23524427,+::ABL1,chr9,133729449,+<p>`)}function u(e,t,n){if(e.data.split(/[\r\n]/).length==1){const s=e.data.trim().split("::");const a=s[0].split(",");const o=s[1].split(",");return x(t,n,a,o)}const s=t.append("div").append("select").style("border-radius","5px").style("padding","5px 10px").style("margin","1px 10px 1px 10px");s.append("option").text(`Select Fusion (${e.data.split(/[\r\n]/).length})`);const a=t.append("div").style("margin","20px");const o=new Map;for(const t of e.data.split(/[\r\n]/)){const e=t.trim().split("::");const n=e[0].split(",");const s=e[1].split(",");o.set(`${n[0]}-${s[0]}`,[n,s])}for(const e of o){s.append("option").property("value",e[0]).text(e[0])}s.on("change",(()=>{a.selectAll("*").remove();const e=o.get(s.property("value"));x(a,n,e[0],e[1])}))}function x(e,t,n,s){const a=[{label:n[0],callback:async(e,a)=>{p(a.contentHolder);const o={holder:a.contentHolder.append("div").style("margin","20px").node(),gene:n[0],tracks:[{type:"mds3",name:n[0],custom_variants:[{gene1:n[0],chr1:n[1],pos1:parseInt(n[2]),strand1:n[3],gene2:s[0],chr2:s[1],pos2:parseInt(s[2]),strand2:s[3],dt:2,class:"Fuserna"}]}]};runproteinpaint(Object.assign(t,o));delete a.callback}},{label:s[0],callback:async(e,a)=>{p(a.contentHolder);const o={holder:a.contentHolder.append("div").style("margin","20px").node(),gene:s[0],tracks:[{type:"mds3",name:s[0],custom_variants:[{gene1:n[0],chr1:n[1],pos1:parseInt(n[2]),strand1:n[3],gene2:s[0],chr2:s[1],pos2:parseInt(s[2]),strand2:s[3],dt:2,class:"Fuserna"}]}]};runproteinpaint(Object.assign(t,o));delete a.callback}}];new i({holder:e,tabs:a}).main()}export{l as init_geneFusionUI};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{az as e,aS as t,S as s}from"./app-
|
|
1
|
+
import{az as e,aS as t,S as s}from"./app-71453429.js";import{k as i}from"./recover-b1ec4fed.js";import{f as o}from"./termsetting-636d2271.js";import"./FilterRxComp-fc769f34.js";import"./table-1dae543a.js";import"./FilterStateless-8f30f856.js";import"./app-fb676934.js";import"./termInfo-4c759483.js";import"path";class a{constructor(e){this.type="geneset";this.dom={holder:e.holder.style("position","relative").style("min-height","300px"),body:e.holder.append("div"),loadingOverlay:e.holder.append("div").attr("class","sjpp-spinner").style("display","none").style("position","absolute").style("background-color","#fff").style("z-index",10).style("opacity","0.5")}}init(){if(this.opts.reactsTo)this.reactsTo=this.opts.reactsTo}getState(e){const t=e.plots.find((e=>e.id===this.id));return{vocab:e.vocab,filter0:e.termfilter.filter0,config:t}}async main(){this.dom.body.selectAll("*").remove();this.dom.loadingOverlay.style("display","");this.noWait().catch(console.warn)}async noWait(){const e=new AbortController;try{const[t,s]=await this.api.detectStale((()=>this.getGenes({signal:e.signal})),{abortCtrl:e});if(s)return;if(!t?.length)this.render();else this.opts.callback(this.api,t)}catch(e){if(e=="stale sequenceId"||e.name=="AbortError")return;else{if(this.opts.showWaitMessage){this.dom.body.style("margin","20px").html(e)}throw e}}}async getGenes({signal:e}){this.opts.genes;const t=this.state.config.settings;if(this.opts.genes){if(!Array.isArray(this.opts.genes)||this.opts.genes.length==0)throw".genes[] is not non-empty array";return await this.getTwLst(this.opts.genes)}let i;if(this.opts.showWaitMessage){i=this.dom.body.append("div").style("margin","20px");this.opts.showWaitMessage(i)}let o;if(this.opts.mode=="mutation"){const i={};if(t.maxGenes)i.maxGenes=t.maxGenes;if(t.geneFilter)i.geneFilter=t.geneFilter;if(this.state.filter0)i.filter0=this.state.filter0;o=await s("gdc/topMutatedGenes",{body:i,signal:e},{cacheAs:"decoded"})}else if(this.opts.mode=="expression"){const i={genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,maxGenes:t.maxGenes};if(this.state.filter0)i.filter0=this.state.filter0;o=await s("termdb/topVariablyExpressedGenes",{body:i,signal:e},{cacheAs:"decoded"})}if(!o)throw"invalid server response";if(o.error)throw o.error;if(!o.genes)return[];i.remove();this.dom.loadingOverlay?.style("display","none");return await this.getTwLst(o.genes)}async getTwLst(e){return await Promise.all(e.map((async e=>typeof e=="string"?await o({term:{gene:e,type:"geneVariant"}},this.app.vocabApi):await o({term:{gene:e.gene||e.name,type:"geneVariant"}},this.app.vocabApi))))}async render(){if(!this.dom?.holder)return;this.dom.body.append("p").text(`No default genes. Please change the cohort or define a gene set to launch ${this.state.config.toolName}.`);i({holder:this.dom.body.append("div"),genome:this.opts.genome,mode:this.opts.mode,vocabApi:this.app.vocabApi,callback:async e=>{const t=await Promise.all(e.geneList.map((async e=>o({term:{gene:e.gene||e.name||e,type:"geneVariant"}},this.app.vocabApi))));this.opts.callback(this.api,t)}});this.dom.loadingOverlay?.style("display","none")}destroy(){this.dom.holder.selectAll("*").remove();this.dom.holder.remove();for(const e in this.dom){delete this.dom[e]}}}const n=e(a);const r=n;async function l(e={},s){const i=t({chartType:"geneset"},e);return i}export{r as componentInit,n as genesetInit,l as getPlotConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as t,az as e,aC as s,aS as a,ac as o,S as i,b8 as n}from"./app-
|
|
1
|
+
import{M as t,az as e,aC as s,aS as a,ac as o,S as i,b8 as n}from"./app-71453429.js";import{g as r}from"./FilterRxComp-fc769f34.js";import{mayUpdateGroupTestMethodsIdx as l,gbControlsInit as c}from"./genomeBrowser.controls-bef8bf99.js";import"./table-1dae543a.js";import"./checkbox-0e5c659f.js";import"./FilterStateless-8f30f856.js";import"./app-fb676934.js";import"./termInfo-4c759483.js";const p=new t({padding:"0px"});class f{constructor(){this.type="genomeBrowser"}async init(){const e=this.opts.holder.append("div");this.opts.header.append("div").style("opacity",.6).style("padding-left","10px").style("font-size","0.75em").text("GENOME BROWSER");const s=e.append("div");const a=e.append("div").style("margin-left","25px");a.append("span").html(" ");this.dom={tip:new t,holder:e,errDiv:s,loadingDiv:a.append("span").text("Loading..."),controlsDiv:e.append("div").style("margin-left","25px"),blockHolder:e.append("div")};this.components={gbControls:await c({app:this.app,id:this.id,holder:this.dom.controlsDiv})}}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e)throw`No plot with id='${this.id}' found`;return{config:e,termdbConfig:t.termdbConfig,filter:r(t.termfilter.filter)}}async main(){this.dom.loadingDiv.style("display","inline");try{if(this.state.config?.snvindel?.details){await this.launchCustomMds3tk()}else if(this.state.config?.trackLst){await this.launchBlockWithTracks(this.state.config.trackLst)}else{const t={type:"mds3",dslabel:this.app.opts.state.vocab.dslabel,newChartHolder:this.opts.plotDiv};if(this.state.filter?.lst?.length>0){t.filterObj=this.state.filter}await this.launchBlockWithTracks([t])}this.updateLDtrack()}catch(t){o(this.dom.errDiv,t.message||t);if(t.stack)console.log(t.stack)}this.dom.loadingDiv.style("display","none")}async launchCustomMds3tk(){const t=await this.preComputeData();this.mayDisplaySampleCountInControls(t);if(this.blockInstance){const e=this.blockInstance.tklst.find((t=>t.type=="mds3"));e.custom_variants=t.mlst;b(this,e.skewer.viewModes.find((t=>t.type=="numeric")));e.load();return}const e={type:"numeric",inuse:true,byAttribute:"nm_axis_value"};b(this,e);const s={type:"mds3",dslabel:this.app.opts.state.vocab.dslabel,name:"Variants",custom_variants:t.mlst,skewerModes:[e]};await this.launchBlockWithTracks([s])}mayDisplaySampleCountInControls(t){if(Number.isInteger(t.totalSampleCount_group1)||Number.isInteger(t.totalSampleCount_group2)){const e={appState:{plots:[{id:this.components.gbControls.id,_partialData:{groupSampleCounts:[t.totalSampleCount_group1,t.totalSampleCount_group2],pop2average:t.pop2average}}]}};this.components.gbControls.update(e)}}async preComputeData(){const t={genome:this.app.opts.state.vocab.genome,dslabel:this.app.opts.state.vocab.dslabel,for:"mds3variantData",chr:this.state.config.geneSearchResult.chr,start:this.state.config.geneSearchResult.start,stop:this.state.config.geneSearchResult.stop,details:this.state.config.snvindel.details,filter:this.state.filter,variantFilter:this.state.config.variantFilter?.filter};const e=await i("termdb",{body:t});if(e.error)throw e.error;return e}async launchBlockWithTracks(t){this.dom.blockHolder.selectAll("*").remove();const e={holder:this.dom.blockHolder,genome:this.app.opts.genome,nobox:true,tklst:await this.getTracks2show(t),debugmode:true};if(this.state.termdbConfig?.queries.defaultBlock2GeneMode&&this.state.config.geneSearchResult.geneSymbol){e.query=this.state.config.geneSearchResult.geneSymbol;const t=await import("./app-71453429.js").then((function(t){return t.c3}));await t.default(e);this.blockInstance=e.__blockInstance;this.opts.header.text(e.query);return}e.chr=this.state.config.geneSearchResult.chr;e.start=this.state.config.geneSearchResult.start;e.stop=this.state.config.geneSearchResult.stop;n(this.app.opts.genome,e.tklst);e.onCoordinateChange=async t=>{await this.app.dispatch({type:"plot_edit",id:this.id,config:{geneSearchResult:{chr:t[0].chr,start:t[0].start,stop:t[0].stop}}})};const s=await import("./block-4f585abe.js").then((function(t){return t.c}));this.blockInstance=new s.Block(e)}async getTracks2show(t){const e=[];for(const s of t){if(s.isfacet){const t=JSON.parse(JSON.stringify(s));if(!this.app.opts.genome.tkset)this.app.opts.genome.tkset=[];if(!t.tklst)throw".tklst[] missing from a facet table";if(!Array.isArray(t.tklst))throw".tklst[] not an array from a facet table";for(const s of t.tklst){if(!s.assay)throw".assay missing from a facet track";if(!s.sample)throw".sample missing from a facet track";s.tkid=Math.random().toString();if(s.defaultShown)e.push(s)}this.app.opts.genome.tkset.push(t)}else{e.push(s)}}return e}updateLDtrack(){if(!this.state.config.ld)return;if(!this.blockInstance)return;for(const t of this.state.config.ld.tracks){const e=this.blockInstance.tklst.findIndex((e=>e.file==t.file0));if(t.shown){if(e==-1){const e={type:"ld",name:t.name,file:t.file0};const s=this.blockInstance.block_addtk_template(e);this.blockInstance.tk_load(s)}continue}if(e==-1)continue;this.blockInstance.tk_remove(e)}}}const d=e(f);const h=d;async function u(t,e){try{return await g(e.vocabApi,t)}catch(t){throw`${t} [genomeBrowser getPlotConfig()]`}}function m(t,e){const a=e.app.opts.genome;if(typeof a!="object")throw"chartsInstance.app.opts.genome not an object and needed for gene search box";const o={tip:p,genome:a,row:t.append("div").style("margin","10px"),geneOnly:e.state.termdbConfig.queries.defaultBlock2GeneMode,callback:async()=>{try{const t=await g(e.app.vocabApi);t.chartType="genomeBrowser";t.geneSearchResult=i;const s={config:t};e.prepPlot(s)}catch(e){t.append("div").text("Error: "+(e.message||e));console.log(e)}}};if(!e.state.termdbConfig.queries.defaultBlock2GeneMode){o.defaultCoord=e.state.termdbConfig.queries.defaultCoord}const i=s(o)}async function g(t,e){const s=await t.getMds3queryDetails();const o=await t.get_variantFilter();if(o?.filter){s.variantFilter=o}const i=e?a(s,e):s;if(i.snvindel?.details){l({state:{config:i}},i.snvindel.details)}return i}function b(t,e){delete e.tooltipPrintValue;const[s,a]=t.state.config.snvindel.details.groups;if(s&&a){if(s.type=="info"||a.type=="info"){e.label="Value difference";return}const o=t.state.config.snvindel.details.groupTestMethods[t.state.config.snvindel.details.groupTestMethodsIdx];e.label=o.axisLabel||o.name;if(o.name=="Allele frequency difference"){e.tooltipPrintValue=t=>[{k:"AF diff",v:t.nm_axis_value}]}else if(o.name=="Fisher's exact test"){e.tooltipPrintValue=t=>[{k:"p-value",v:t.p_value}]}else;return}if(s.type=="info"){const a=t.state.config.variantFilter?.terms?.find((t=>t.id==s.infoKey));e.label=a?.name||s.infoKey;e.tooltipPrintValue=t=>[{k:e.label,v:t.info[s.infoKey]}];return}if(s.type=="filter"){e.label="Allele frequency";e.tooltipPrintValue=t=>[{k:"Allele frequency",v:t.nm_axis_value}];return}if(s.type=="population"){e.label="Allele frequency";e.tooltipPrintValue=t=>[{k:"Allele frequency",v:t.nm_axis_value}];return}throw"unknown type of the only group"}export{h as componentInit,d as genomeBrowserInit,u as getPlotConfig,m as makeChartBtnMenu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as t,az as e,aR as i}from"./app-f91922b4.js";import{m as n}from"./checkbox-0e5c659f.js";import{f as s}from"./FilterStateless-ad3df967.js";import{g as o,a}from"./FilterRxComp-0e75dd8d.js";import{appInit as r}from"./app-bfce9bf5.js";import"./table-d6c411fd.js";import"./termInfo-96285f4a.js";const l=new t({padding:"0px"});class p{constructor(t){this.type="gbControls";this.filterUI={}}async init(t){this.initUI(this.getState(t))}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e)throw`No plot with id='${this.id}' found`;if(e._partialData){this._partialData=e._partialData;return}return{config:e,termdbConfig:t.termdbConfig,filter:o(t.termfilter.filter)}}async main(){const t=this.state.config.snvindel?.details?.groups;if(t){this.render1group(0);this.render1group(1);if(this.state.config.snvindel.details.groupTestMethods){this.renderTestMethod()}}if(this.state.config.variantFilter){if(!this.variantFilterRendered){this.variantFilterRendered=true;this.makeVariantFilter()}}}async makeVariantFilter(){s({joinWith:this.state.config.variantFilter.opts.joinWith,emptyLabel:"+Add Filter",holder:this.dom.variantFilterHolder,vocab:{terms:this.state.config.variantFilter.terms},callback:async t=>{await this.app.dispatch({type:"plot_edit",id:this.id,config:{variantFilter:{filter:t}}})}}).main(this.state.config.variantFilter.filter)}render1group(t){const e=this.state.config.snvindel.details.groups[t];const i=t==0?this.dom.group1div:this.dom.group2div;let n=false;if(e?.type=="filter"&&this.filterUI[t]){n=true}else{delete this.filterUI[t];i.selectAll("*").remove()}if(!e){h(this,t,i);return}if(!n)m(this,t,i);if(e.type=="info")return c(this,t,e,i);if(e.type=="population")return f(this,t,e,i);if(e.type=="filter")return u(this,t,e,i);throw"render1group: unknown group type"}renderTestMethod(){const t=this.dom.testMethodDiv;t.selectAll("*").remove();const[e,i]=this.state.config.snvindel.details.groups;if(!i){return}t.append("span").text("TEST METHOD").style("font-size",".8em").style("opacity",.6);if(e.type!="filter"&&i.type!="filter"){t.append("span").style("padding-left","10px").text("Value difference").style("opacity",.6);return}const n=t.append("select").style("margin-left","10px").on("change",(()=>{this.app.dispatch({type:"plot_edit",id:this.id,config:{snvindel:{details:{groupTestMethodsIdx:n.property("selectedIndex")}}}})}));for(const t of this.state.config.snvindel.details.groupTestMethods){n.append("option").text(t.name)}n.property("selectedIndex",this.state.config.snvindel.details.groupTestMethodsIdx)}initUI(t){this.dom={};const e=[];if(t.config.snvindel?.details){e.push({label:"Variant values",active:true})}if(t.config.variantFilter){e.push({label:"Variant filter"})}if(t.config.ld){e.push({label:"LD map"})}if(e.length==0){return}const s=new i({holder:this.opts.holder.append("div").style("border-bottom","solid 1px #ccc").style("padding-bottom","20px"),tabs:e});s.main();{const t=e[0].contentHolder.append("div");this.dom.group1div=t.append("div");this.dom.group2div=t.append("div");this.dom.testMethodDiv=t.append("div").style("margin-top","3px")}let o=1;if(t.config.variantFilter){this.dom.variantFilterHolder=e[o++].contentHolder.append("div").style("white-space","normal")}if(t.config.ld){const i=structuredClone(t.config.ld.tracks);const s=e[o++].contentHolder.append("div");s.append("div").text("Show/hide linkage disequilibrium map from an ancestry:").style("opacity",.5);for(const[t,e]of i.entries()){n({labeltext:e.name,checked:e.shown,holder:s,callback:()=>{i[t].shown=!i[t].shown;this.app.dispatch({type:"plot_edit",id:this.id,config:{ld:{tracks:i}}})}})}}}}const d=e(p);function c(t,e,i,n){let s=i.infoKey;if(t.state.config.variantFilter?.terms){const e=t.state.config.variantFilter.terms.find((t=>t.id==i.infoKey));if(e&&e.name)s=e.name}n.append("span").text(s).attr("class","sja_menuoption").on("click",(n=>{if(t.state.config.variantFilter.terms.length<=1){return}l.clear().showunder(n.target).d.append("div").text("Replace with:").style("margin","10px").style("font-size",".8em");for(const n of t.state.config.variantFilter.terms){if(n.type!="integer"&&n.type!="float")continue;if(n.id==i.infoKey)continue;l.d.append("div").text(n.name).attr("class","sja_menuoption").on("click",(()=>{l.hide();const i=structuredClone(t.state.config.snvindel.details.groups);i[e].infoKey=n.id;i[e].type="info";t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:{groups:i}}}})}))}}));n.append("span").text("PER-VARIANT NUMERICAL VALUES").style("font-size",".7em").style("opacity",.6).style("margin-left","10px")}function f(t,e,i,n){n.append("span").text(i.label).attr("class","sja_menuoption").on("click",(n=>{if(t.state.config.snvindel.populations.length<=1){return}l.clear().showunder(n.target).d.append("div").text("Replace with:").style("margin","10px").style("font-size",".8em");for(const n of t.state.config.snvindel.populations){if(n.key==i.key)continue;l.d.append("div").text(n.label).attr("class","sja_menuoption").on("click",(()=>{l.hide();const i=structuredClone(t.state.config.snvindel.details.groups);i[e]=structuredClone(n);i[e].type="population";t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:{groups:i}}}})}))}}));n.append("span").text(`POPULATION${i.adjust_race?", RACE ADJUSTED":""}`).style("font-size",".7em").style("margin-left","10px").style("opacity",.6);if(t._partialData?.pop2average){if(t.state.config.snvindel.details.groups[e==1?0:1]?.type=="filter"){const s=[];for(const e in t._partialData.pop2average){const i=t._partialData.pop2average[e];if(!Number.isFinite(i))continue;s.push(`${e}=${i.toFixed(2)}`)}if(s.length){n.append("span").text(`Group ${e==1?1:2} average admixture: ${s.join(", ")}`).style("margin-left","20px").attr("class","sja_clbtext").on("click",(t=>{l.clear().showunder(t.target).d.append("div").style("margin","10px").style("width","500px").html(`These are average admixture coefficients based on current Group ${e==1?1:2} samples.\n\t\t\t\t\t\tThey are used to adjust variant allele counts of matching ancestries from <span class=sja_menuoption style="padding:2px 5px">${i.label}</span>,\n\t\t\t\t\t\tso that the adjusted allele counts can be compared against Group ${e==1?1:2} allele counts.\n\t\t\t\t\t\tThis allows to account for ancestry composition difference between the two groups.\n\t\t\t\t\t\t`)}))}}}}async function u(t,e,i,n){if(!t.filterUI[e]){t.filterUI[e]=await s({holder:n,vocab:t.app.opts.state.vocab,emptyLabel:"Entire cohort",termdbConfig:t.state.termdbConfig,callback:async i=>{const n=JSON.parse(JSON.stringify(t.state.config.snvindel.details.groups));n[e].filter=i;t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:{groups:n}}}})}})}t.filterUI[e].main(g(t,i));n.select(".sjpp-gb-filter-count").remove();const o=t._partialData?.groupSampleCounts?.[e];if(Number.isInteger(o)){n.append("span").attr("class","sjpp-gb-filter-count").style("margin-left","10px").style("opacity",.5).style("font-size",".9em").text("n="+o)}}function g(t,e){const i=structuredClone(t.state.filter||{type:"tvslst",in:true,join:"",lst:[]});const n=structuredClone(e.filter);n.tag="filterUiRoot";i.lst.push(n);i.join="and";return i}function h(t,e,i){i.append("div").style("display","inline-block").text("Create Group 2").attr("class","sja_clbtext").style("margin","10px").on("click",(i=>{l.showunder(i.target).clear();y(t,e,l.d)}))}function m(t,e,i){i.append("div").style("display","inline-block").text("Group "+(e+1)).attr("class","sja_menuoption").style("margin-right","10px").on("click",(i=>{l.showunder(i.target).clear();if(e==0){y(t,0,l.d);return}l.d.append("div").text("Change").attr("class","sja_menuoption").style("border-radius","0px").on("click",(()=>{y(t,1,l.clear().d)}));l.d.append("div").text("Delete").attr("class","sja_menuoption").style("border-radius","0px").on("click",(()=>{l.hide();const e=[t.state.config.snvindel.details.groups[0]];t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:{groups:e}}}})}))}))}function y(t,e,n){const s={holder:n.append("div").style("margin","5px"),tabs:t.state.config.snvindel.details.groupTypes.map((t=>({label:t.name}))),tabsPosition:"vertical",linePosition:"right"};new i(s).main();for(const[i,n]of t.state.config.snvindel.details.groupTypes.entries()){const o=s.tabs[i];o.contentHolder.style("margin","10px");if(n.type=="info"){if(!t.state.config.variantFilter?.terms)throw"looking for snvindel info fields but self.state.config.variantFilter.terms[] missing";for(const i of t.state.config.variantFilter.terms){if(i.type!="integer"&&i.type!="float")continue;o.contentHolder.append("div").text(i.name).attr("class","sja_menuoption").on("click",(()=>{l.hide();const n={type:"info",infoKey:i.id};const s=v(t,n,e);x(t,s);t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:s}}})}))}continue}if(n.type=="population"){if(!t.state.config.snvindel.populations)throw"state.config.snvindel.populations missing";for(const i of t.state.config.snvindel.populations){o.contentHolder.append("div").text(i.label).attr("class","sja_menuoption").on("click",(()=>{l.hide();const n={type:"population",key:i.key,label:i.label,allowto_adjust_race:i.allowto_adjust_race,adjust_race:i.adjust_race};const s=v(t,n,e);x(t,s);t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:s}}})}))}continue}if(n.type=="filter"){const i={holder:o.contentHolder,vocabApi:t.app.vocabApi,state:{termfilter:{filter:t.state.filter}},tree:{click_term2select_tvs:i=>{l.hide();const n={type:"filter",filter:{in:true,join:"",type:"tvslst",lst:[{type:"tvs",tvs:i}]}};const s=v(t,n,e);x(t,s);t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:s}}})}}};const n=b(t);if(Number.isInteger(n))i.state.activeCohort=n;r(i);continue}throw"unknown group type"}}function v(t,e,i){const n={groups:JSON.parse(JSON.stringify(t.state.config.snvindel.details.groups))};n.groups[i]=e;return n}function x(t,e){if(e.groups.length!=2)return;const[i,n]=e.groups;if(i.type=="info"||n.type=="info"||i.type=="population"&&n.type=="population"){const i=t.state.config.snvindel.details.groupTestMethods.findIndex((t=>t.name=="Allele frequency difference"));if(i==-1)throw"Allele frequency difference not found";e.groupTestMethodsIdx=i}}function b(t){if(!t.state.config.filter)return;const e=a(t.config.filter,"cohortFilter");if(e&&t.state.termdbConfig.selectCohort){const i=e.tvs.values.map((t=>t.key)).sort().join(",");const n=t.state.termdbConfig.selectCohort.values.findIndex((t=>t.keys.sort().join(",")==i));if(n==-1)throw"subcohort key is not in selectCohort.values[]";return n}}export{d as gbControlsInit,x as mayUpdateGroupTestMethodsIdx};
|
|
1
|
+
import{M as t,az as e,aR as i}from"./app-71453429.js";import{m as n}from"./checkbox-0e5c659f.js";import{f as s}from"./FilterStateless-8f30f856.js";import{g as o,a}from"./FilterRxComp-fc769f34.js";import{appInit as r}from"./app-fb676934.js";import"./table-1dae543a.js";import"./termInfo-4c759483.js";const l=new t({padding:"0px"});class p{constructor(t){this.type="gbControls";this.filterUI={}}async init(t){this.initUI(this.getState(t))}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e)throw`No plot with id='${this.id}' found`;if(e._partialData){this._partialData=e._partialData;return}return{config:e,termdbConfig:t.termdbConfig,filter:o(t.termfilter.filter)}}async main(){const t=this.state.config.snvindel?.details?.groups;if(t){this.render1group(0);this.render1group(1);if(this.state.config.snvindel.details.groupTestMethods){this.renderTestMethod()}}if(this.state.config.variantFilter){if(!this.variantFilterRendered){this.variantFilterRendered=true;this.makeVariantFilter()}}}async makeVariantFilter(){s({joinWith:this.state.config.variantFilter.opts.joinWith,emptyLabel:"+Add Filter",holder:this.dom.variantFilterHolder,vocab:{terms:this.state.config.variantFilter.terms},callback:async t=>{await this.app.dispatch({type:"plot_edit",id:this.id,config:{variantFilter:{filter:t}}})}}).main(this.state.config.variantFilter.filter)}render1group(t){const e=this.state.config.snvindel.details.groups[t];const i=t==0?this.dom.group1div:this.dom.group2div;let n=false;if(e?.type=="filter"&&this.filterUI[t]){n=true}else{delete this.filterUI[t];i.selectAll("*").remove()}if(!e){h(this,t,i);return}if(!n)m(this,t,i);if(e.type=="info")return c(this,t,e,i);if(e.type=="population")return f(this,t,e,i);if(e.type=="filter")return u(this,t,e,i);throw"render1group: unknown group type"}renderTestMethod(){const t=this.dom.testMethodDiv;t.selectAll("*").remove();const[e,i]=this.state.config.snvindel.details.groups;if(!i){return}t.append("span").text("TEST METHOD").style("font-size",".8em").style("opacity",.6);if(e.type!="filter"&&i.type!="filter"){t.append("span").style("padding-left","10px").text("Value difference").style("opacity",.6);return}const n=t.append("select").style("margin-left","10px").on("change",(()=>{this.app.dispatch({type:"plot_edit",id:this.id,config:{snvindel:{details:{groupTestMethodsIdx:n.property("selectedIndex")}}}})}));for(const t of this.state.config.snvindel.details.groupTestMethods){n.append("option").text(t.name)}n.property("selectedIndex",this.state.config.snvindel.details.groupTestMethodsIdx)}initUI(t){this.dom={};const e=[];if(t.config.snvindel?.details){e.push({label:"Variant values",active:true})}if(t.config.variantFilter){e.push({label:"Variant filter"})}if(t.config.ld){e.push({label:"LD map"})}if(e.length==0){return}const s=new i({holder:this.opts.holder.append("div").style("border-bottom","solid 1px #ccc").style("padding-bottom","20px"),tabs:e});s.main();{const t=e[0].contentHolder.append("div");this.dom.group1div=t.append("div");this.dom.group2div=t.append("div");this.dom.testMethodDiv=t.append("div").style("margin-top","3px")}let o=1;if(t.config.variantFilter){this.dom.variantFilterHolder=e[o++].contentHolder.append("div").style("white-space","normal")}if(t.config.ld){const i=structuredClone(t.config.ld.tracks);const s=e[o++].contentHolder.append("div");s.append("div").text("Show/hide linkage disequilibrium map from an ancestry:").style("opacity",.5);for(const[t,e]of i.entries()){n({labeltext:e.name,checked:e.shown,holder:s,callback:()=>{i[t].shown=!i[t].shown;this.app.dispatch({type:"plot_edit",id:this.id,config:{ld:{tracks:i}}})}})}}}}const d=e(p);function c(t,e,i,n){let s=i.infoKey;if(t.state.config.variantFilter?.terms){const e=t.state.config.variantFilter.terms.find((t=>t.id==i.infoKey));if(e&&e.name)s=e.name}n.append("span").text(s).attr("class","sja_menuoption").on("click",(n=>{if(t.state.config.variantFilter.terms.length<=1){return}l.clear().showunder(n.target).d.append("div").text("Replace with:").style("margin","10px").style("font-size",".8em");for(const n of t.state.config.variantFilter.terms){if(n.type!="integer"&&n.type!="float")continue;if(n.id==i.infoKey)continue;l.d.append("div").text(n.name).attr("class","sja_menuoption").on("click",(()=>{l.hide();const i=structuredClone(t.state.config.snvindel.details.groups);i[e].infoKey=n.id;i[e].type="info";t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:{groups:i}}}})}))}}));n.append("span").text("PER-VARIANT NUMERICAL VALUES").style("font-size",".7em").style("opacity",.6).style("margin-left","10px")}function f(t,e,i,n){n.append("span").text(i.label).attr("class","sja_menuoption").on("click",(n=>{if(t.state.config.snvindel.populations.length<=1){return}l.clear().showunder(n.target).d.append("div").text("Replace with:").style("margin","10px").style("font-size",".8em");for(const n of t.state.config.snvindel.populations){if(n.key==i.key)continue;l.d.append("div").text(n.label).attr("class","sja_menuoption").on("click",(()=>{l.hide();const i=structuredClone(t.state.config.snvindel.details.groups);i[e]=structuredClone(n);i[e].type="population";t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:{groups:i}}}})}))}}));n.append("span").text(`POPULATION${i.adjust_race?", RACE ADJUSTED":""}`).style("font-size",".7em").style("margin-left","10px").style("opacity",.6);if(t._partialData?.pop2average){if(t.state.config.snvindel.details.groups[e==1?0:1]?.type=="filter"){const s=[];for(const e in t._partialData.pop2average){const i=t._partialData.pop2average[e];if(!Number.isFinite(i))continue;s.push(`${e}=${i.toFixed(2)}`)}if(s.length){n.append("span").text(`Group ${e==1?1:2} average admixture: ${s.join(", ")}`).style("margin-left","20px").attr("class","sja_clbtext").on("click",(t=>{l.clear().showunder(t.target).d.append("div").style("margin","10px").style("width","500px").html(`These are average admixture coefficients based on current Group ${e==1?1:2} samples.\n\t\t\t\t\t\tThey are used to adjust variant allele counts of matching ancestries from <span class=sja_menuoption style="padding:2px 5px">${i.label}</span>,\n\t\t\t\t\t\tso that the adjusted allele counts can be compared against Group ${e==1?1:2} allele counts.\n\t\t\t\t\t\tThis allows to account for ancestry composition difference between the two groups.\n\t\t\t\t\t\t`)}))}}}}async function u(t,e,i,n){if(!t.filterUI[e]){t.filterUI[e]=await s({holder:n,vocab:t.app.opts.state.vocab,emptyLabel:"Entire cohort",termdbConfig:t.state.termdbConfig,callback:async i=>{const n=JSON.parse(JSON.stringify(t.state.config.snvindel.details.groups));n[e].filter=i;t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:{groups:n}}}})}})}t.filterUI[e].main(g(t,i));n.select(".sjpp-gb-filter-count").remove();const o=t._partialData?.groupSampleCounts?.[e];if(Number.isInteger(o)){n.append("span").attr("class","sjpp-gb-filter-count").style("margin-left","10px").style("opacity",.5).style("font-size",".9em").text("n="+o)}}function g(t,e){const i=structuredClone(t.state.filter||{type:"tvslst",in:true,join:"",lst:[]});const n=structuredClone(e.filter);n.tag="filterUiRoot";i.lst.push(n);i.join="and";return i}function h(t,e,i){i.append("div").style("display","inline-block").text("Create Group 2").attr("class","sja_clbtext").style("margin","10px").on("click",(i=>{l.showunder(i.target).clear();y(t,e,l.d)}))}function m(t,e,i){i.append("div").style("display","inline-block").text("Group "+(e+1)).attr("class","sja_menuoption").style("margin-right","10px").on("click",(i=>{l.showunder(i.target).clear();if(e==0){y(t,0,l.d);return}l.d.append("div").text("Change").attr("class","sja_menuoption").style("border-radius","0px").on("click",(()=>{y(t,1,l.clear().d)}));l.d.append("div").text("Delete").attr("class","sja_menuoption").style("border-radius","0px").on("click",(()=>{l.hide();const e=[t.state.config.snvindel.details.groups[0]];t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:{groups:e}}}})}))}))}function y(t,e,n){const s={holder:n.append("div").style("margin","5px"),tabs:t.state.config.snvindel.details.groupTypes.map((t=>({label:t.name}))),tabsPosition:"vertical",linePosition:"right"};new i(s).main();for(const[i,n]of t.state.config.snvindel.details.groupTypes.entries()){const o=s.tabs[i];o.contentHolder.style("margin","10px");if(n.type=="info"){if(!t.state.config.variantFilter?.terms)throw"looking for snvindel info fields but self.state.config.variantFilter.terms[] missing";for(const i of t.state.config.variantFilter.terms){if(i.type!="integer"&&i.type!="float")continue;o.contentHolder.append("div").text(i.name).attr("class","sja_menuoption").on("click",(()=>{l.hide();const n={type:"info",infoKey:i.id};const s=v(t,n,e);x(t,s);t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:s}}})}))}continue}if(n.type=="population"){if(!t.state.config.snvindel.populations)throw"state.config.snvindel.populations missing";for(const i of t.state.config.snvindel.populations){o.contentHolder.append("div").text(i.label).attr("class","sja_menuoption").on("click",(()=>{l.hide();const n={type:"population",key:i.key,label:i.label,allowto_adjust_race:i.allowto_adjust_race,adjust_race:i.adjust_race};const s=v(t,n,e);x(t,s);t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:s}}})}))}continue}if(n.type=="filter"){const i={holder:o.contentHolder,vocabApi:t.app.vocabApi,state:{termfilter:{filter:t.state.filter}},tree:{click_term2select_tvs:i=>{l.hide();const n={type:"filter",filter:{in:true,join:"",type:"tvslst",lst:[{type:"tvs",tvs:i}]}};const s=v(t,n,e);x(t,s);t.app.dispatch({type:"plot_edit",id:t.id,config:{snvindel:{details:s}}})}}};const n=b(t);if(Number.isInteger(n))i.state.activeCohort=n;r(i);continue}throw"unknown group type"}}function v(t,e,i){const n={groups:JSON.parse(JSON.stringify(t.state.config.snvindel.details.groups))};n.groups[i]=e;return n}function x(t,e){if(e.groups.length!=2)return;const[i,n]=e.groups;if(i.type=="info"||n.type=="info"||i.type=="population"&&n.type=="population"){const i=t.state.config.snvindel.details.groupTestMethods.findIndex((t=>t.name=="Allele frequency difference"));if(i==-1)throw"Allele frequency difference not found";e.groupTestMethodsIdx=i}}function b(t){if(!t.state.config.filter)return;const e=a(t.config.filter,"cohortFilter");if(e&&t.state.termdbConfig.selectCohort){const i=e.tvs.values.map((t=>t.key)).sort().join(",");const n=t.state.termdbConfig.selectCohort.values.findIndex((t=>t.keys.sort().join(",")==i));if(n==-1)throw"subcohort key is not in selectCohort.values[]";return n}}export{d as gbControlsInit,x as mayUpdateGroupTestMethodsIdx};
|