@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{az as e,q as t,aY as s,aB as i,aD as r,aR as a,ae as l,k as o,ac as n,aA as p,M as d,S as c,aQ as h}from"./app-f91922b4.js";import{g as m,e as u,h as y,a as f,f as b,T as v,t as _,s as g,j as T,k as x,v as S}from"./FilterRxComp-0e75dd8d.js";import{termInfoInit as k}from"./termInfo-96285f4a.js";import"./table-d6c411fd.js";const I="25px";const A="root";const C=20;const w="400px";const N="termdiv",E="termchilddiv",D="termbtn",O="termlabel",B="termloading",L="termcheck";class j{constructor(e){this.type="tree";P(this);R(this);this.loadingTermSet=new Set;this.termsByCohort={};this.expandAll="expandAll"in e?e.expandAll:false}init(){this.dom={holder:this.opts.holder.append("div")}}reactsTo(e){if(e.type.startsWith("tree_"))return true;if(e.type.startsWith("filter_"))return true;if(e.type.startsWith("cohort_"))return true;if(e.type.startsWith("info_"))return true;if(e.type.startsWith("submenu_"))return true;if(e.type=="app_refresh")return true;if(e.type=="set_term_type_group")return true}getState(e){const t=m(e.termfilter.filter);const s={isVisible:!e.submenu.term,activeCohort:e.activeCohort,expandedTermIds:e.tree.expandedTermIds,selectedTerms:e.selectedTerms,termfilter:{filter:t},usecase:e.tree.usecase,termTypeGroup:e.termTypeGroup};if(e.termdbConfig.selectCohort){s.toSelectCohort=true;const t=e.termdbConfig.selectCohort.values[e.activeCohort];if(t){s.cohortValuelst=t.keys}}return s}async main(){if(this.state.termTypeGroup!=u.DICTIONARY_VARIABLES){this.dom.holder.style("display","none");return}if(!this.state.isVisible){this.dom.holder.style("display","none");return}if(this.state.toSelectCohort){if(!this.state.cohortValuelst){return}}this.termsById=this.getTermsById();const e=this.termsById[A];e.terms=await this.requestTermRecursive(e);this.dom.holder.style("display","block");await this.renderBranch(e,this.dom.holder);this.dom.holder.selectAll(".termbtn, .sja_tree_click_term").attr("tabindex",0).attr("data-testid","sjpp_termdbbutton").on("keyup",(e=>{if(e.key=="Enter")e.target.click()}))}getTermsById(){if(!(this.state.activeCohort in this.termsByCohort)){this.termsByCohort[this.state.activeCohort]={[A]:{id:A,__tree_isroot:true}}}return this.termsByCohort[this.state.activeCohort]}async requestTermRecursive(e){const t=await this.app.vocabApi.getTermChildren(e,this.state.toSelectCohort?this.state.cohortValuelst:null);if(t.error)throw t.error;if(!t.lst||t.lst.length==0){return[]}const s=[];for(const e of t.lst){const t=Object.assign({},e);s.push(t);if(this.state.expandedTermIds.includes(t.id)){t.terms=await this.requestTermRecursive(t)}else{const e=this.termsById[t.id];if(e&&e.terms){t.terms=e.terms}}this.termsById[t.id]=t}return s}bindKey(e){return e.id}}const V=e(j);function R(e){e.renderBranch=(t,s,i)=>{if(!t||!t.terms)return;if(t.terms.length>=C){if(s.classed("sjpp_show_scrollbar"));else{s.style("max-height",w).style("padding","10px").style("resize","vertical").classed("sjpp_show_scrollbar",true)}}if(e.opts.disable_terms){t.terms.forEach((t=>{if(t.disabled)e.opts.disable_terms.push(t)}))}e.included_terms=[];if(e.state.usecase){for(const s of t.terms){if(y(s,e.state.usecase).size){e.included_terms.push(s)}}}else{e.included_terms.push(...t.terms)}if(!(t.id in e.termsById)||!e.included_terms.length){s.style("display","none");return}if(e.loadingTermSet.has(t.id)){e.loadingTermSet.delete(t.id);s.select("."+B).remove()}const r=e.state.expandedTermIds;if(!r.includes(t.id)){s.style("display","none");if(i)i.text("+");return}s.style("display","block");if(i)i.text("-");const a=s.selectAll("."+N).data(e.included_terms,e.bindKey);a.exit().each(e.hideTerm);a.each(e.updateTerm);a.enter().append("div").each(e.addTerm);for(const i of t.terms){if(r.includes(i.id)){e.renderBranch(i,s.selectAll("."+E).filter((e=>e.id==i.id)),s.selectAll("."+D).filter((e=>e.id==i.id)))}}};e.hideTerm=function(s){if(s.id in e.termsById&&e.state.expandedTermIds.includes(s.id))return;t(this).style("display","none")};e.updateTerm=function(s){const i=t(this);if(!(s.id in e.termsById)){i.style("display","none");return}const r=e.opts.disable_terms?.includes(s.id);const a=y(s,e.state.usecase);i.style("display","");const l=e.state.expandedTermIds.includes(s.id);i.select("."+D).text(l?"-":"+");i.select("."+E).style("display",l?"block":"none");const o=e.state.selectedTerms.find((e=>e.name===s.name&&e.type===s.type));i.select("."+O).style("background-color",!a.has("plot")||r?"":o?"rgba(255, 194, 10,0.5)":"#cfe2f3");i.select("."+L).style("display",a.has("plot")&&o&&!r?"inline-block":"none")};e.addTerm=async function(s){const i=e.opts.disable_terms?.includes(s.id);const r=y(s,e.state.usecase);const a=t(this).attr("class",N).style("margin",s.isleaf?"":"2px").style("padding","0px 5px");if(r.has("branch")){a.append("div").attr("class","sja_menuoption "+D).style("display","inline-block").style("padding","4px 9px").style("font-family","courier").text("+").on("click",(t=>{t.stopPropagation();e.toggleBranch(s)}));if(e.expandAll)e.toggleBranch(s)}const l=e.state.selectedTerms.find((e=>e.name===s.name&&e.type===s.type));const o=a.append("div").attr("class",O).style("display","inline-block").style("padding","5px").style("opacity",i?.4:null).text(s.name);let n;if(s.hashtmldetail){n=a.append("div").style("display","inline-block")}if(r.size>0){if(i){o.attr("class","sja_tree_click_term_disabled "+O).style("padding","5px 8px").style("margin","1px 0px").style("opacity",.4)}else if(r.has("plot")){o.attr("class","ts_pill sja_filter_tag_btn sja_tree_click_term "+O).style("color","black").style("padding","5px 8px").style("border-radius","6px").style("background-color",l?"rgba(255, 194, 10,0.5)":"#cfe2f3").style("margin","1px 0px").style("cursor","default").on("click",(()=>e.clickTerm(s)))}if(s.samplecount!==undefined){a.append("div").style("font-size",".8em").style("display","inline-block").style("margin-left","5px").style("color",s.samplecount?"#777":"#ddd").text("n="+s.samplecount)}}if(s.hashtmldetail){k({vocabApi:e.app.vocabApi,icon_holder:n,content_holder:a.append("div"),id:s.id,state:{term:s}})}if(e.opts.submit_lst){a.append("div").attr("class",L).style("color","#008000").style("display",l?"inline-block":"none").html("✓")}if(!s.isleaf){a.append("div").attr("class",E).style("padding-left",I)}}}function P(e){e.toggleBranch=function(s){if(s.isleaf)return;const i=e.termsById[s.id];if(!i)throw"invalid term id";if(!i.terms){if(e.loadingTermSet.has(i.id))return;e.loadingTermSet.add(i.id);t(this.parentNode).selectAll("."+E).filter((e=>e.id===i.id)).style("display","block").append("div").text("Loading...").attr("class",B).style("opacity",.5).style("padding","5px")}const r=e.state.expandedTermIds.includes(s.id);const a=r?"tree_collapse":"tree_expand";e.app.dispatch({type:a,termId:s.id})};e.clickTerm=async t=>{if(e.opts.click_term2select_tvs){e.app.dispatch({type:"submenu_set",submenu:{term:t,type:"tvs"}});return}if(e.opts.click_term_wrapper){e.opts.click_term_wrapper(t);return}if(e.opts.submit_lst){const s=e.state.selectedTerms.findIndex((e=>e.name===t.name));if(s==-1){e.app.dispatch({type:"app_refresh",state:{selectedTerms:[...e.state.selectedTerms,t]}})}else{const t=e.state.selectedTerms.slice(0);t.splice(s,1);e.app.dispatch({type:"app_refresh",state:{selectedTerms:t}})}return}throw"missing term click callback"}}const G={header_mode:"search_only",activeCohort:0,tree:{usecase:{},expandedTermIds:[]},submenu:{},search:{isVisible:true},selectedTerms:[],termfilter:{filter:{type:"tvslst",in:true,join:"",lst:[]}}};class U{constructor(e){this.type="store";this.defaultState=G;s(this,e);this.prevGeneratedId=0}validateOpts(e){if(!e.state)throw".state{} missing";const t=e.state;if(t.vocab){if(t.vocab.dslabel){if(!t.vocab.genome)throw".state[.vocab].genome missing"}else if(t.vocab.genome){if(!t.vocab.dslabel)throw".state[.vocab].dslabel missing"}else{if(!Array.isArray(t.vocab.terms))throw"vocab.terms must be an array of objects"}}}validateState(){const e=this.state;if(e.tree.expandedTermIds.length==0){e.tree.expandedTermIds.push(A)}else{if(e.tree.expandedTermIds[0]!=A){e.tree.expandedTermIds.unshift(A)}}}async init(){this.state.termdbConfig=await this.app.vocabApi.getTermdbConfig();let e=f(this.state.termfilter.filter,"filterUiRoot");if(!e){this.state.termfilter.filter.tag="filterUiRoot";e=this.state.termfilter.filter}if(this.state.termdbConfig.selectCohort){let t=f(this.state.termfilter.filter,"cohortFilter");if(!t){t={tag:"cohortFilter",type:"tvs",tvs:{term:JSON.parse(JSON.stringify(this.state.termdbConfig.selectCohort.term)),values:this.state.activeCohort==-1?[]:this.state.termdbConfig.selectCohort.values[this.state.activeCohort].keys.map((e=>({key:e,label:e})))}};this.state.termfilter.filter={type:"tvslst",in:true,join:"and",lst:[t,e]}}else{const e=(e,t)=>e<t?-1:1;t.tvs.values.sort(((e,t)=>e.key<t.key?-1:1));const s=JSON.stringify(t.tvs.values.map((e=>e.key)).sort(e));const i=this.state.termdbConfig.selectCohort.values.findIndex((t=>s==JSON.stringify(t.keys.sort(e))));if(this.state.activeCohort!==-1&&this.state.activeCohort!==0&&i!==this.state.activeCohort){console.log("Warning: cohortFilter will override the state.activeCohort due to mismatch")}this.state.activeCohort=i}}else{this.state.activeCohort=-1;if(this.state.header_mode==="with_cohortHtmlSelect"){console.warn(`no termdbConfig.selectCohort to use for state.header_mode = 'with_cohortHtmlSelect'`);this.state.header_mode="search_only"}}}fromJson(e){const t=JSON.parse(e);return t}setId(e){e.$id=this.prevGeneratedId++;if(e.$lst){for(const t of e.$lst){this.setId(t)}}}}U.prototype.actions={app_refresh(e={}){this.state=this.copyMerge(this.toJson(this.state),e.state?e.state:{},this.replaceKeyVals)},cohort_set(e){this.state.activeCohort=e.activeCohort;const t=this.state.termdbConfig.selectCohort.values[e.activeCohort];const s=f(this.state.termfilter.filter,"cohortFilter");if(!s)throw`No item tagged with 'cohortFilter'`;s.tvs.values=t.keys.map((e=>({key:e,label:e})))},tree_expand(e){if(this.state.tree.expandedTermIds.includes(e.termId))return;this.state.tree.expandedTermIds.push(e.termId)},tree_collapse(e){const t=this.state.tree.expandedTermIds.indexOf(e.termId);if(t==-1)return;this.state.tree.expandedTermIds.splice(t,1)},filter_replace(e){const t=e.filter?e.filter:{type:"tvslst",join:"",in:1,lst:[]};if(!e.filter.tag){this.state.termfilter.filter=t}else{const s=f(this.state.termfilter.filter,e.filter.tag);if(!s)throw`cannot replace missing filter with tag '${e.filter.tag}'`;const i=b(this.state.termfilter.filter,s.$id);if(i==s){this.state.termfilter.filter=t}else{const e=i.lst.indexOf(s);i.lst[e]=t}}},submenu_set(e){const t=e.submenu&&e.submenu.term;if(!t){this.state.submenu={};this.state.tree.expandedTermIds=[A]}else{const s=[A];if(t.__ancestors){s.push(...t.__ancestors)}if(y(t).has("plot")){Object.assign(this.state.submenu,e.submenu)}else{s.push(t.id);delete this.state.submenu.term}this.state.tree.expandedTermIds=s}},set_term_type_group({value:e}){this.state.termTypeGroup=e}};const M=i(U);function Y(e){switch(e){case"./handlers/geneExpression.ts":return import("./geneExpression-d6494fd3.js");case"./handlers/geneVariant.ts":return import("./geneVariant-3df05e0c.js");case"./handlers/snplocus.ts":return import("./snplocus-90e52cf4.js");case"./handlers/snplst.ts":return import("./snplst-7c59f059.js");default:return new Promise((function(t,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+e)))}))}}const q={matrix:[u.SNP_LOCUS,u.SNP_LIST],filter:[u.SNP_LOCUS,u.SNP_LIST],dictionary:[u.SNP_LOCUS,u.SNP_LIST],summary:[u.SNP_LOCUS,u.SNP_LIST],barchart:[u.SNP_LOCUS,u.SNP_LIST],violin:[u.SNP_LOCUS,u.SNP_LIST],sampleScatter:[u.SNP_LOCUS,u.SNP_LIST],cuminc:[u.SNP_LOCUS,u.SNP_LIST,u.MUTATION_CNV_FUSION,u.GENE_EXPRESSION,u.METABOLITE_INTENSITY],dataDownload:[u.MUTATION_CNV_FUSION,u.GENE_EXPRESSION,u.METABOLITE_INTENSITY],survival:[u.SNP_LOCUS,u.SNP_LIST],default:[u.SNP_LOCUS,u.SNP_LIST],regression:[u.SNP_LIST,u.SNP_LOCUS,u.GENE_EXPRESSION,u.METABOLITE_INTENSITY],metaboliteIntensity:[u.SNP_LOCUS,u.SNP_LIST,u.MUTATION_CNV_FUSION,u.DICTIONARY_VARIABLES,u.GENE_EXPRESSION]};class ${constructor(e){this.type="termTypeSearch";this.genomeObj=e.genome;this.click_term=e.click_term;this.submit_lst=e.submit_lst;const t=e.topbar.append("div").append("div").style("width","99%").style("display","flex").style("flex-wrap","wrap").style("gap","5px").style("min-height","20px").style("border","solid 1px #aaa").style("margin","10px 0px").style("padding","6px 2px").style("min-height","30px");this.types=[];this.tabs=[];this.handlerByType={};this.dom={holder:e.holder,topbar:e.topbar,selectedTermsDiv:t,submitDiv:e.submitDiv}}init(e){var t;return r(this,void 0,void 0,(function*(){this.types=((t=this.app.vocabApi.termdbConfig)===null||t===void 0?void 0:t.allowedTermTypes)||["categorical"];if(!this.types)return;const s=this.getState(e);yield this.addTabsAllowed(s);if(this.submit_lst)this.dom.clearbt=this.dom.submitDiv.append("button").style("margin-left","5px").text("Clear").on("click",(()=>this.selectTerms([])));if(this.tabs.length==0)throw"No term types allowed for this use case";this.app.dispatch({type:"set_term_type_group",value:this.tabs[0].termTypeGroup});if(this.tabs.length==1&&this.tabs[0].termTypeGroup==u.DICTIONARY_VARIABLES)return;new a({holder:this.dom.holder,tabsPosition:"vertical",linePosition:"right",tabs:this.tabs}).main();for(const[e,t]of this.tabs.entries()){const t=this.tabs[e].contentHolder.style("padding-left","20px");t.append("div")}}))}reactsTo(e){if(e.type.startsWith("submenu_"))return true;if(e.type=="set_term_type_group")return true;if(e.type=="app_refresh")return true}main(){this.dom.holder.style("display",this.state.isVisible?"inline-block":"none");this.dom.topbar.style("display",this.state.isVisible?"inline-block":"none");if(this.submit_lst){this.renderTermsSelected();this.dom.selectedTermsDiv.style("display",this.state.selectedTerms.length>0?"inline-block":"none")}else this.dom.selectedTermsDiv.style("display","none");this.renderTermsSelected();if(this.dom.clearbt)this.dom.clearbt.property("disabled",this.state.selectedTerms.length==0)}renderTermsSelected(){this.dom.selectedTermsDiv.selectAll("*").remove();this.dom.selectedTermsDiv.selectAll("div").data(this.state.selectedTerms).enter().append("div").attr("title","click to delete").attr("class","sja_menuoption").attr("tabindex",0).style("position","relative").style("display","inline-block").style("padding","5px 16px 5px 9px").style("margin-left","5px").each(e).on("click",((e,t)=>this.deleteTerm(e,t))).on("mouseover",(function(e){const s=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-x-lg" viewBox="0 0 16 16">\n\t\t\t\t<path stroke='#f00' d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>\n\t\t\t\t</svg>`;const i=t(e.target);i.append("div").style("margin-left","4px").classed("sjpp_deletebt",true).style("display","inline-block").style("position","absolute").style("right","0px").style("top","0px").style("transform","scale(0.6)").style("pointer-events","none").html(s)})).on("mouseout",(function(e){t(e.target).select(".sjpp_deletebt").remove()}));function e(e){const s=t(this).style("border-radius","5px");s.insert("div").style("display","inline-block").html(e.name)}}deleteTerm(e,t){const s=this.state.selectedTerms.findIndex((e=>e.name===t.name));if(s!=-1){const e=[...this.state.selectedTerms];e.splice(s,1);this.app.dispatch({type:"app_refresh",state:{selectedTerms:e}})}}getState(e){return{dslabel:e.dslabel,termTypeGroup:e.termTypeGroup,usecase:e.tree.usecase,isVisible:!e.submenu.term,selectedTerms:e.selectedTerms,termfilter:e.termfilter}}addTabsAllowed(e){var t;return r(this,void 0,void 0,(function*(){for(const s of this.types){const i=_[s];let r=i;if(s==v.GENE_VARIANT){const e=[];if(this.app.vocabApi.termdbConfig.queries.snvindel)e.push("Mutation");if(this.app.vocabApi.termdbConfig.queries.cnv)e.push("CNV");if(this.app.vocabApi.termdbConfig.queries.svfusion)e.push("Fusion");if(e.length==0)continue;r=e.join("/")}if(i&&!this.tabs.some((e=>e.label==i))){if(e.usecase.target=="regression"&&s==v.GENE_VARIANT){if(e.usecase.detail!="independent")continue}if(e.usecase.target=="sampleScatter"&&s==v.GENE_VARIANT){if(e.usecase.detail=="numeric")continue}if(e.usecase.target=="survival"&&i!=u.DICTIONARY_VARIABLES){if(e.usecase.detail=="term")continue}if(e.usecase.target&&((t=q[e.usecase.target])===null||t===void 0?void 0:t.includes(i)))continue;try{if(!this.usesDefaultSearch(i)){const e=yield Y(`./handlers/${s}.ts`);this.handlerByType[s]=yield new e.SearchHandler;if(!this.handlerByType[s].init)throw"init not implemented"}this.addLoadTopTerms(s)}catch(e){throw`error with handler='./handlers/${s}.ts': ${e}`}this.tabs.push({label:r,callback:()=>this.setTermTypeGroup(s,i),termTypeGroup:i})}}}))}usesDefaultSearch(e){return e==u.DICTIONARY_VARIABLES||e==u.METABOLITE_INTENSITY}addLoadTopTerms(e){return r(this,void 0,void 0,(function*(){if(e==v.METABOLITE_INTENSITY)this.dom.submitDiv.append("button").style("margin-left","5px").text("Load top terms").on("click",(()=>r(this,void 0,void 0,(function*(){const t={filter0:this.state.termfilter.filter0,filter:this.state.termfilter.filter,type:e};const s=yield this.app.vocabApi.getTopTermsByType(t);this.selectTerms(s.terms)}))))}))}selectTerms(e){this.app.dispatch({type:"app_refresh",state:{selectedTerms:e}})}setTermTypeGroup(e,t){return r(this,void 0,void 0,(function*(){yield this.app.dispatch({type:"set_term_type_group",value:t});const s=this.tabs.find((e=>e.termTypeGroup==t));const i=s.contentHolder;i.selectAll("*").remove();if(s.termTypeGroup!=u.DICTIONARY_VARIABLES&&s.termTypeGroup!=u.METABOLITE_INTENSITY){const t=this.handlerByType[e];yield t.init({holder:i,app:this.app,genomeObj:this.genomeObj,callback:e=>this.selectTerm(e)})}}))}selectTerm(e){if(this.click_term)this.click_term(e);else if(this.submit_lst){this.app.dispatch({type:"app_refresh",state:{selectedTerms:[...this.state.selectedTerms,e]}})}else this.app.dispatch({type:"submenu_set",submenu:{term:e,type:"tvs"}})}}const F=e($);class z{constructor(e){this.type="submenu";this.dom={holder:e.holder};K(this)}reactsTo(e){if(e.type.startsWith("submenu_"))return true;if(e.type=="app_refresh")return true}getState(e){return{type:e.submenu.type,term:e.submenu.term,termfilter:e.termfilter}}main(){if(!this.state.term){this.dom.holder.style("display","none");return}if(this.state.type=="tvs")this.showTvsMenu(this.state.term);else throw`unsupported submenu.type='${this.state.type}'`}}const W=e(z);function K(e){e.showTvsMenu=function(t){e.dom.holder.selectAll("*").remove();e.dom.holder.style("display","block").append("div").style("margin","20px").append("span").html("« Back to variable selection").attr("class","sja_clbtext").on("click",(()=>e.app.dispatch({type:"submenu_set",submenu:{}})));g({term:t,filter:e.state.termfilter.filter,holder:e.dom.holder.append("div"),vocabApi:e.app.vocabApi,debug:e.app.debug,getCategoriesArguments:e.app.opts.getCategoriesArguments,callback:e.app.opts.tree.click_term2select_tvs})}}class H{constructor(e){this.type="search";this.customEvents=["postSearch"];X(this);Q(this);this.dom={holder:e.holder};this.isVisible="isVisible"in e?e.isVisible:true}async init(e){this.initUI(this.getState(e))}reactsTo(e){if(e.type=="set_term_type_group")return true;if(e.type=="app_refresh")return true;const t=e.type.split("_")[0];return["search","cohort","submenu"].includes(t)}getState(e){return{isVisible:!e.submenu.term&&this.isVisible,cohortStr:e.activeCohort==-1||!e.termdbConfig.selectCohort?"":e.termdbConfig.selectCohort.values[e.activeCohort].keys.slice().sort().join(","),allowedTermTypes:e.termdbConfig?.allowedTermTypes||[],expandedTermIds:e.tree.expandedTermIds,selectedTerms:e.selectedTerms,usecase:e.tree.usecase,search:e.search,isGeneSetTermdb:e.termdbConfig.isGeneSetTermdb,termTypeGroup:e.termTypeGroup}}isTermTypeSupported(){const e=this.state.termTypeGroup;if(e==u.DICTIONARY_VARIABLES)return true;if(e==u.METABOLITE_INTENSITY)return true;return false}async main(){if(!this.isTermTypeSupported()){this.dom.holder.style("display","none");return}this.dom.input.node().value="";this.dom.input.attr("placeholder","Search "+this.state.termTypeGroup);this.clear();this.dom.holder.style("display",this.state.isVisible?"block":"none")}async doSearch(e){if(!e||e.length<3){this.clear();this.bus.emit("postSearch",[]);return}const t=await this.app.vocabApi.findTerm(e,this.state.cohortStr,this.state.usecase,this.state.termTypeGroup);this.currData=t;if(!t.lst||t.lst.length==0){this.noResult()}else{this.showTerms(t)}this.bus.emit("postSearch",t)}}const J=e(H);function X(e){e.initUI=t=>{e.dom.holder.style("display",e.search&&e.search.isVisible==false?"none":"block");const s=e.dom.holder.append("div").style("text-align","left");e.dom.input=s.append("input").attr("type","search").attr("class","tree_search").style("width","250px").style("margin","10px").style("display","inline-block").on("input",l.debounce(e.onInput,300)).on("keyup",e.onKeyup);e.dom.resultCntDiv=s.append("div").style("display","none");if(e.opts.focus!="off")e.dom.input.node().focus();e.dom.resultDiv=(e.opts.resultsHolder||e.dom.holder).append("div").attr("class","sjpp_show_scrollbar").style("max-height","35vh").style("display","none").style("grid-template-columns","auto auto");const i=e.dom.resultDiv.append("div");const r=e.dom.resultDiv.append("div");e.dom.resultDiv_genes=i.append("div").style("border-left","solid 1px rgb(133,182,225)").style("margin","0px 0px 10px 10px").style("padding-left","5px");e.dom.resultDiv_terms=r.append("div").style("border-left",e.opts.resultsHolder?"":"solid 1px rgb(133,182,225)").style("margin","0px 0px 10px 10px").style("padding-left","5px")};e.getPrompt=e=>{const t=e.allowedTermTypes.includes("geneVariant")&&y({type:"geneVariant"},e.usecase).has("plot");if(t)return" variables or genes";if(e.isGeneSetTermdb)return" gene sets";return" variables"};e.noResult=()=>{e.clear();e.dom.resultDiv.style("display","inline-grid");e.dom.resultDiv_terms.append("div").style("padding","3px 3px 3px 0px").style("opacity",.5).text("No match"+(e.app.vocabApi.termdbConfig?.queries?.snvindel?.allowSNPs?". Press ENTER to search SNP":""))};e.showTerms=t=>{if(e.opts.disable_terms){t.lst.forEach((t=>{if(t.disabled)e.opts.disable_terms.push(t)}))}e.clear();e.dom.resultDiv.style("display","inline-grid");const s=[],i=[];for(const e of t.lst){if(e.type=="geneVariant"){s.push(e)}else{i.push(e)}}if(s.length){e.dom.resultDiv_genes.append("table").selectAll().data(s).enter().append("tr").each(e.showTerm)}if(i.length){e.dom.resultDiv_terms.append("table").selectAll().data(i).enter().append("tr").each(e.showTerm)}if(t.lst.length>1)e.dom.resultCntDiv.style("display","inline-block").text(`${t.lst.length} results`);e.focusableResults=[...e.dom.resultDiv.node().querySelectorAll(".sja_tree_click_term, .sja_menuoption")]};e.showTerm=function(s){const i=t(this);const r=i.append("td").text(s.name);const a=y(s,e.state.usecase);if((e.opts.click_term||e.app.opts?.tree?.click_term_wrapper)&&a.has("plot")){if(s&&e.opts.disable_terms?.find((e=>T(s,e)))){r.attr("class","sja_tree_click_term_disabled").style("display","block").style("padding","5px 8px").style("margin","1px 0px").style("opacity",.4)}else{r.attr("class","ts_pill sja_filter_tag_btn sja_tree_click_term").attr("tabindex",0).style("display","block").style("color","black").style("padding","5px 8px").style("border-radius","6px").style("background-color",s.type=="geneVariant"?"rgba(251,171,96,0.5)":"#cfe2f3").style("margin","1px 0px").style("cursor","default").on("click",(()=>{if(e.opts.click_term){e.opts.click_term(s)}else{e.app.opts.tree.click_term_wrapper(s)}e.clear();e.dom.input.property("value","")})).on("keyup",e.navInputValueByKeyboard)}if(s.samplecount!==undefined){i.append("td").append("div").style("font-size",".8em").style("display","inline-block").style("margin-left","5px").style("color",s.samplecount?"#777":"#ddd").text("n="+s.samplecount)}}else{r.attr("class","sja_menuoption").attr("tabindex",0).on("click",(()=>{e.clear();e.dom.input.property("value","");const t=[A];if(s.type=="geneVariant"&&e.opts.handleGeneVariant){e.opts.handleGeneVariant(s)}else if(x(s.type)){e.app.dispatch({type:"app_refresh",state:{selectedTerms:[...e.state.selectedTerms,s]}})}else{if(s.__ancestors){t.push(...s.__ancestors)}if(!e.app.vocabApi.graphable(s))t.push(s.id);e.app.dispatch({type:"app_refresh",state:{tree:{expandedTermIds:t}}})}})).on("keyup",e.navInputValueByKeyboard)}i.append("td").text(s.type=="geneVariant"?"gene variant":(s.__ancestorNames||[]).join(" > ")).style("opacity",.5).style("font-size",".7em")};e.clear=()=>{e.dom.resultDiv_genes.selectAll("*").remove();e.dom.resultDiv_terms.selectAll("*").remove();e.dom.resultDiv.style("display","none");e.dom.resultCntDiv.style("display","none")}}function Q(e){e.onKeyup=t=>{if(t.key=="ArrowDown"&&e.currData?.lst?.length){e.dom.resultDiv.select(".sja_tree_click_term, .sja_menuoption").node().focus();return}if(!o(t))return;e.onInput(t)};e.onInput=async t=>{const s=e.dom.input.property("value");try{await e.doSearch(s)}catch(t){e.clear();e.dom.resultDiv.style("display","inline-grid");n(e.dom.resultDiv_terms,"Error: "+(t.message||t));if(t.stack)console.log(t.stack)}};e.navInputValueByKeyboard=t=>{if(t.key=="Enter")t.target.click();else if(t.key.startsWith("Arrow")){const s=e.focusableResults.findIndex((e=>e===t.target));if(t.key=="ArrowDown"){if(s<e.focusableResults.length-1)e.focusableResults[s+1].focus();else e.focusableResults[0].focus()}else if(t.key=="ArrowUp"){if(s!=0)e.focusableResults[s-1].focus();else e.focusableResults[e.focusableResults.length-1].focus()}}}}class Z{constructor(e){this.type="app";if(!e.holder)t("body").append("div");const s=e.holder.append("div").style("display",e.tree?.submit_lst?"":"none").style("text-align","center").style("margin","10px 5px");const i=s.append("button").property("disabled",true).text(this.noSelectionPrompt).on("click",(()=>this.opts.tree?.submit_lst(this.state.selectedTerms)));const r=e.holder.append("div");const a=r.append("div").style("display","inline-block");const l=r.append("div").style("display","inline-block").style("vertical-align","top");this.dom={topbar:r,holder:e.holder,termTypeSearchDiv:a,searchDiv:l.append("div"),treeDiv:l.append("div"),customTermDiv:l.append("div").style("margin","10px"),submitDiv:s,submitBtn:i,filterDiv:r.append("div").style("display","none"),errdiv:e.holder.append("div"),tip:new d({padding:"5px"})}}validateOpts(e){if(e.vocabApi);else if(e.state&&e.state.vocab){if(typeof e.state.vocab!="object")throw"opts.state.vocab{} is not an object"}else if(e.state&&e.state.genome){const t=e.state;if(!t.vocab)t.vocab={};t.vocab.genome=t.genome;delete t.genome;if(t.dslabel){t.vocab.dslabel=t.dslabel;delete t.dslabel}}else{throw"neither state.vocab{} or opts.vocabApi provided"}if(e.tree){if(e.tree.disable_terms&&!e.tree.click_term&&!e.tree.click_term2select_tvs&&(!e.barchart||!e.barchart.bar_click_override)){throw`opts.tree.disable_terms is used only when opts.tree.click_term, opts.tree.click_term2select_tvs, or opts.barchart.bar_click_override is set`}if(!e.search)e.search={};if(e.tree.click_term2select_tvs){e.search.click_term=e=>this.api.dispatch({type:"submenu_set",submenu:{term:e,type:"tvs"}})}if(e.tree.click_term){e.tree.click_term_wrapper=async t=>{if(this.state.termdbConfig.termMatch2geneSet){const e=await c("termdb",{body:{genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,genesetByTermId:t.id}});t._geneset=e}e.tree.click_term(t)}}if(e.tree.disable_terms)e.search.disable_terms=e.tree.disable_terms}return e}async preApiFreeze(e){try{if(this.opts.vocabApi){e.vocabApi=this.opts.vocabApi}else{const t={vocab:this.opts.state.vocab||{genome:this.opts.state.genome,dslabel:this.opts.state.dslabel}};e.vocabApi=await S({app:this.api,state:t,fetchOpts:this.opts.fetchOpts})}e.appInit=ee}catch(e){console.log(e);throw e}}async init(){try{this.store=await M({app:this.api,state:this.opts.state});this.state=await this.store.copyState();await this.setComponents();await this.api.dispatch()}catch(e){this.printError(e)}}async setComponents(){try{const e=this.state.nav?.header_mode;const t={search:J({app:this.api,holder:this.dom.searchDiv,isVisible:e!=="hide_search"}),termTypeSearch:F({app:this.api,holder:this.dom.termTypeSearchDiv,topbar:this.dom.topbar,genome:this.opts.vocabApi?.app?.opts?.genome,click_term:this.opts.tree?.click_term,submit_lst:this.opts.tree?.submit_lst,submitDiv:this.dom.submitDiv}),tree:V({app:this.api,holder:this.dom.treeDiv,headerDiv:this.dom.headerDiv,expandAll:e=="hide_search"})};if(this.opts.tree&&this.opts.tree.click_term2select_tvs){t.submenu=W({app:this.api,holder:this.dom.holder.append("div").style("display","none")})}this.components=await h(t)}catch(e){throw e}}async main(){this.api.vocabApi.main();const e=this.state.selectedTerms.length;this.dom.submitBtn.property("disabled",!e).text(!e?"Search or click term(s)":`Submit ${e} term${e>1?"s":""}`);await this.mayShowCustomTerms();this.dom.holder.selectAll("search, .termbtn, button").attr("tabindex",0);this.dom.holder.selectAll(".termbtn").on("keyup",(e=>{if(e.key=="Enter")e.target.click()}))}printError(e){n(this.dom.errdiv,"Error: "+(e.message||e));if(e.stack)console.log(e.stack)}async mayShowCustomTerms(){if(Object.keys(this.state.submenu).length)return this.dom.customTermDiv.style("display","none");const e=await this.api.vocabApi.getCustomTerms();if(!Array.isArray(e)||e.length==0)return this.dom.customTermDiv.style("display","none");const t=[];for(const s of e){const e=y(s.term,this.state.tree.usecase);if(e.has("plot"))t.push(s)}if(t.length==0)return this.dom.customTermDiv.style("display","none");this.dom.customTermDiv.selectAll("*").remove();this.dom.customTermDiv.append("div").text("CUSTOM VARIABLES").style("font-size",".7em");for(const e of t){this.dom.customTermDiv.append("div").style("margin-bottom","3px").append("div").text(e.term.name).attr("class","sja_filter_tag_btn").style("padding","3px 6px").style("border-radius","6px").on("click",(()=>{if(!this.opts.tree)return;if(this.opts.tree.click_term){this.opts.tree.click_term(e);return}if(this.opts.tree.click_term2select_tvs){this.api.dispatch({type:"submenu_set",submenu:{term:e.term,type:"tvs"}});return}}))}}}const ee=p(Z);export{ee as appInit};
|
|
1
|
+
import{az as e,q as t,aY as s,aB as i,aD as r,aR as a,ae as l,k as o,ac as n,aA as p,M as d,S as c,aQ as h}from"./app-71453429.js";import{g as m,e as u,h as y,a as f,f as b,T as v,t as _,s as g,j as T,k as x,v as S}from"./FilterRxComp-fc769f34.js";import{termInfoInit as k}from"./termInfo-4c759483.js";import"./table-1dae543a.js";const I="25px";const A="root";const C=20;const w="400px";const N="termdiv",E="termchilddiv",D="termbtn",O="termlabel",B="termloading",L="termcheck";class j{constructor(e){this.type="tree";P(this);R(this);this.loadingTermSet=new Set;this.termsByCohort={};this.expandAll="expandAll"in e?e.expandAll:false}init(){this.dom={holder:this.opts.holder.append("div")}}reactsTo(e){if(e.type.startsWith("tree_"))return true;if(e.type.startsWith("filter_"))return true;if(e.type.startsWith("cohort_"))return true;if(e.type.startsWith("info_"))return true;if(e.type.startsWith("submenu_"))return true;if(e.type=="app_refresh")return true;if(e.type=="set_term_type_group")return true}getState(e){const t=m(e.termfilter.filter);const s={isVisible:!e.submenu.term,activeCohort:e.activeCohort,expandedTermIds:e.tree.expandedTermIds,selectedTerms:e.selectedTerms,termfilter:{filter:t},usecase:e.tree.usecase,termTypeGroup:e.termTypeGroup};if(e.termdbConfig.selectCohort){s.toSelectCohort=true;const t=e.termdbConfig.selectCohort.values[e.activeCohort];if(t){s.cohortValuelst=t.keys}}return s}async main(){if(this.state.termTypeGroup!=u.DICTIONARY_VARIABLES){this.dom.holder.style("display","none");return}if(!this.state.isVisible){this.dom.holder.style("display","none");return}if(this.state.toSelectCohort){if(!this.state.cohortValuelst){return}}this.termsById=this.getTermsById();const e=this.termsById[A];e.terms=await this.requestTermRecursive(e);this.dom.holder.style("display","block");await this.renderBranch(e,this.dom.holder);this.dom.holder.selectAll(".termbtn, .sja_tree_click_term").attr("tabindex",0).attr("data-testid","sjpp_termdbbutton").on("keyup",(e=>{if(e.key=="Enter")e.target.click()}))}getTermsById(){if(!(this.state.activeCohort in this.termsByCohort)){this.termsByCohort[this.state.activeCohort]={[A]:{id:A,__tree_isroot:true}}}return this.termsByCohort[this.state.activeCohort]}async requestTermRecursive(e){const t=await this.app.vocabApi.getTermChildren(e,this.state.toSelectCohort?this.state.cohortValuelst:null);if(t.error)throw t.error;if(!t.lst||t.lst.length==0){return[]}const s=[];for(const e of t.lst){const t=Object.assign({},e);s.push(t);if(this.state.expandedTermIds.includes(t.id)){t.terms=await this.requestTermRecursive(t)}else{const e=this.termsById[t.id];if(e&&e.terms){t.terms=e.terms}}this.termsById[t.id]=t}return s}bindKey(e){return e.id}}const V=e(j);function R(e){e.renderBranch=(t,s,i)=>{if(!t||!t.terms)return;if(t.terms.length>=C){if(s.classed("sjpp_show_scrollbar"));else{s.style("max-height",w).style("padding","10px").style("resize","vertical").classed("sjpp_show_scrollbar",true)}}if(e.opts.disable_terms){t.terms.forEach((t=>{if(t.disabled)e.opts.disable_terms.push(t)}))}e.included_terms=[];if(e.state.usecase){for(const s of t.terms){if(y(s,e.state.usecase).size){e.included_terms.push(s)}}}else{e.included_terms.push(...t.terms)}if(!(t.id in e.termsById)||!e.included_terms.length){s.style("display","none");return}if(e.loadingTermSet.has(t.id)){e.loadingTermSet.delete(t.id);s.select("."+B).remove()}const r=e.state.expandedTermIds;if(!r.includes(t.id)){s.style("display","none");if(i)i.text("+");return}s.style("display","block");if(i)i.text("-");const a=s.selectAll("."+N).data(e.included_terms,e.bindKey);a.exit().each(e.hideTerm);a.each(e.updateTerm);a.enter().append("div").each(e.addTerm);for(const i of t.terms){if(r.includes(i.id)){e.renderBranch(i,s.selectAll("."+E).filter((e=>e.id==i.id)),s.selectAll("."+D).filter((e=>e.id==i.id)))}}};e.hideTerm=function(s){if(s.id in e.termsById&&e.state.expandedTermIds.includes(s.id))return;t(this).style("display","none")};e.updateTerm=function(s){const i=t(this);if(!(s.id in e.termsById)){i.style("display","none");return}const r=e.opts.disable_terms?.includes(s.id);const a=y(s,e.state.usecase);i.style("display","");const l=e.state.expandedTermIds.includes(s.id);i.select("."+D).text(l?"-":"+");i.select("."+E).style("display",l?"block":"none");const o=e.state.selectedTerms.find((e=>e.name===s.name&&e.type===s.type));i.select("."+O).style("background-color",!a.has("plot")||r?"":o?"rgba(255, 194, 10,0.5)":"#cfe2f3");i.select("."+L).style("display",a.has("plot")&&o&&!r?"inline-block":"none")};e.addTerm=async function(s){const i=e.opts.disable_terms?.includes(s.id);const r=y(s,e.state.usecase);const a=t(this).attr("class",N).style("margin",s.isleaf?"":"2px").style("padding","0px 5px");if(r.has("branch")){a.append("div").attr("class","sja_menuoption "+D).style("display","inline-block").style("padding","4px 9px").style("font-family","courier").text("+").on("click",(t=>{t.stopPropagation();e.toggleBranch(s)}));if(e.expandAll)e.toggleBranch(s)}const l=e.state.selectedTerms.find((e=>e.name===s.name&&e.type===s.type));const o=a.append("div").attr("class",O).style("display","inline-block").style("padding","5px").style("opacity",i?.4:null).text(s.name);let n;if(s.hashtmldetail){n=a.append("div").style("display","inline-block")}if(r.size>0){if(i){o.attr("class","sja_tree_click_term_disabled "+O).style("padding","5px 8px").style("margin","1px 0px").style("opacity",.4)}else if(r.has("plot")){o.attr("class","ts_pill sja_filter_tag_btn sja_tree_click_term "+O).style("color","black").style("padding","5px 8px").style("border-radius","6px").style("background-color",l?"rgba(255, 194, 10,0.5)":"#cfe2f3").style("margin","1px 0px").style("cursor","default").on("click",(()=>e.clickTerm(s)))}if(s.samplecount!==undefined){a.append("div").style("font-size",".8em").style("display","inline-block").style("margin-left","5px").style("color",s.samplecount?"#777":"#ddd").text("n="+s.samplecount)}}if(s.hashtmldetail){k({vocabApi:e.app.vocabApi,icon_holder:n,content_holder:a.append("div"),id:s.id,state:{term:s}})}if(e.opts.submit_lst){a.append("div").attr("class",L).style("color","#008000").style("display",l?"inline-block":"none").html("✓")}if(!s.isleaf){a.append("div").attr("class",E).style("padding-left",I)}}}function P(e){e.toggleBranch=function(s){if(s.isleaf)return;const i=e.termsById[s.id];if(!i)throw"invalid term id";if(!i.terms){if(e.loadingTermSet.has(i.id))return;e.loadingTermSet.add(i.id);t(this.parentNode).selectAll("."+E).filter((e=>e.id===i.id)).style("display","block").append("div").text("Loading...").attr("class",B).style("opacity",.5).style("padding","5px")}const r=e.state.expandedTermIds.includes(s.id);const a=r?"tree_collapse":"tree_expand";e.app.dispatch({type:a,termId:s.id})};e.clickTerm=async t=>{if(e.opts.click_term2select_tvs){e.app.dispatch({type:"submenu_set",submenu:{term:t,type:"tvs"}});return}if(e.opts.click_term_wrapper){e.opts.click_term_wrapper(t);return}if(e.opts.submit_lst){const s=e.state.selectedTerms.findIndex((e=>e.name===t.name));if(s==-1){e.app.dispatch({type:"app_refresh",state:{selectedTerms:[...e.state.selectedTerms,t]}})}else{const t=e.state.selectedTerms.slice(0);t.splice(s,1);e.app.dispatch({type:"app_refresh",state:{selectedTerms:t}})}return}throw"missing term click callback"}}const G={header_mode:"search_only",activeCohort:0,tree:{usecase:{},expandedTermIds:[]},submenu:{},search:{isVisible:true},selectedTerms:[],termfilter:{filter:{type:"tvslst",in:true,join:"",lst:[]}}};class U{constructor(e){this.type="store";this.defaultState=G;s(this,e);this.prevGeneratedId=0}validateOpts(e){if(!e.state)throw".state{} missing";const t=e.state;if(t.vocab){if(t.vocab.dslabel){if(!t.vocab.genome)throw".state[.vocab].genome missing"}else if(t.vocab.genome){if(!t.vocab.dslabel)throw".state[.vocab].dslabel missing"}else{if(!Array.isArray(t.vocab.terms))throw"vocab.terms must be an array of objects"}}}validateState(){const e=this.state;if(e.tree.expandedTermIds.length==0){e.tree.expandedTermIds.push(A)}else{if(e.tree.expandedTermIds[0]!=A){e.tree.expandedTermIds.unshift(A)}}}async init(){this.state.termdbConfig=await this.app.vocabApi.getTermdbConfig();let e=f(this.state.termfilter.filter,"filterUiRoot");if(!e){this.state.termfilter.filter.tag="filterUiRoot";e=this.state.termfilter.filter}if(this.state.termdbConfig.selectCohort){let t=f(this.state.termfilter.filter,"cohortFilter");if(!t){t={tag:"cohortFilter",type:"tvs",tvs:{term:JSON.parse(JSON.stringify(this.state.termdbConfig.selectCohort.term)),values:this.state.activeCohort==-1?[]:this.state.termdbConfig.selectCohort.values[this.state.activeCohort].keys.map((e=>({key:e,label:e})))}};this.state.termfilter.filter={type:"tvslst",in:true,join:"and",lst:[t,e]}}else{const e=(e,t)=>e<t?-1:1;t.tvs.values.sort(((e,t)=>e.key<t.key?-1:1));const s=JSON.stringify(t.tvs.values.map((e=>e.key)).sort(e));const i=this.state.termdbConfig.selectCohort.values.findIndex((t=>s==JSON.stringify(t.keys.sort(e))));if(this.state.activeCohort!==-1&&this.state.activeCohort!==0&&i!==this.state.activeCohort){console.log("Warning: cohortFilter will override the state.activeCohort due to mismatch")}this.state.activeCohort=i}}else{this.state.activeCohort=-1;if(this.state.header_mode==="with_cohortHtmlSelect"){console.warn(`no termdbConfig.selectCohort to use for state.header_mode = 'with_cohortHtmlSelect'`);this.state.header_mode="search_only"}}}fromJson(e){const t=JSON.parse(e);return t}setId(e){e.$id=this.prevGeneratedId++;if(e.$lst){for(const t of e.$lst){this.setId(t)}}}}U.prototype.actions={app_refresh(e={}){this.state=this.copyMerge(this.toJson(this.state),e.state?e.state:{},this.replaceKeyVals)},cohort_set(e){this.state.activeCohort=e.activeCohort;const t=this.state.termdbConfig.selectCohort.values[e.activeCohort];const s=f(this.state.termfilter.filter,"cohortFilter");if(!s)throw`No item tagged with 'cohortFilter'`;s.tvs.values=t.keys.map((e=>({key:e,label:e})))},tree_expand(e){if(this.state.tree.expandedTermIds.includes(e.termId))return;this.state.tree.expandedTermIds.push(e.termId)},tree_collapse(e){const t=this.state.tree.expandedTermIds.indexOf(e.termId);if(t==-1)return;this.state.tree.expandedTermIds.splice(t,1)},filter_replace(e){const t=e.filter?e.filter:{type:"tvslst",join:"",in:1,lst:[]};if(!e.filter.tag){this.state.termfilter.filter=t}else{const s=f(this.state.termfilter.filter,e.filter.tag);if(!s)throw`cannot replace missing filter with tag '${e.filter.tag}'`;const i=b(this.state.termfilter.filter,s.$id);if(i==s){this.state.termfilter.filter=t}else{const e=i.lst.indexOf(s);i.lst[e]=t}}},submenu_set(e){const t=e.submenu&&e.submenu.term;if(!t){this.state.submenu={};this.state.tree.expandedTermIds=[A]}else{const s=[A];if(t.__ancestors){s.push(...t.__ancestors)}if(y(t).has("plot")){Object.assign(this.state.submenu,e.submenu)}else{s.push(t.id);delete this.state.submenu.term}this.state.tree.expandedTermIds=s}},set_term_type_group({value:e}){this.state.termTypeGroup=e}};const M=i(U);function Y(e){switch(e){case"./handlers/geneExpression.ts":return import("./geneExpression-501e95c0.js");case"./handlers/geneVariant.ts":return import("./geneVariant-7ab521d6.js");case"./handlers/snplocus.ts":return import("./snplocus-90e52cf4.js");case"./handlers/snplst.ts":return import("./snplst-7c59f059.js");default:return new Promise((function(t,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+e)))}))}}const q={matrix:[u.SNP_LOCUS,u.SNP_LIST],filter:[u.SNP_LOCUS,u.SNP_LIST],dictionary:[u.SNP_LOCUS,u.SNP_LIST],summary:[u.SNP_LOCUS,u.SNP_LIST],barchart:[u.SNP_LOCUS,u.SNP_LIST],violin:[u.SNP_LOCUS,u.SNP_LIST],sampleScatter:[u.SNP_LOCUS,u.SNP_LIST],cuminc:[u.SNP_LOCUS,u.SNP_LIST,u.MUTATION_CNV_FUSION,u.GENE_EXPRESSION,u.METABOLITE_INTENSITY],dataDownload:[u.MUTATION_CNV_FUSION,u.GENE_EXPRESSION,u.METABOLITE_INTENSITY],survival:[u.SNP_LOCUS,u.SNP_LIST],default:[u.SNP_LOCUS,u.SNP_LIST],regression:[u.SNP_LIST,u.SNP_LOCUS,u.GENE_EXPRESSION,u.METABOLITE_INTENSITY],metaboliteIntensity:[u.SNP_LOCUS,u.SNP_LIST,u.MUTATION_CNV_FUSION,u.DICTIONARY_VARIABLES,u.GENE_EXPRESSION]};class ${constructor(e){this.type="termTypeSearch";this.genomeObj=e.genome;this.click_term=e.click_term;this.submit_lst=e.submit_lst;const t=e.topbar.append("div").append("div").style("width","99%").style("display","flex").style("flex-wrap","wrap").style("gap","5px").style("min-height","20px").style("border","solid 1px #aaa").style("margin","10px 0px").style("padding","6px 2px").style("min-height","30px");this.types=[];this.tabs=[];this.handlerByType={};this.dom={holder:e.holder,topbar:e.topbar,selectedTermsDiv:t,submitDiv:e.submitDiv}}init(e){var t;return r(this,void 0,void 0,(function*(){this.types=((t=this.app.vocabApi.termdbConfig)===null||t===void 0?void 0:t.allowedTermTypes)||["categorical"];if(!this.types)return;const s=this.getState(e);yield this.addTabsAllowed(s);if(this.submit_lst)this.dom.clearbt=this.dom.submitDiv.append("button").style("margin-left","5px").text("Clear").on("click",(()=>this.selectTerms([])));if(this.tabs.length==0)throw"No term types allowed for this use case";this.app.dispatch({type:"set_term_type_group",value:this.tabs[0].termTypeGroup});if(this.tabs.length==1&&this.tabs[0].termTypeGroup==u.DICTIONARY_VARIABLES)return;new a({holder:this.dom.holder,tabsPosition:"vertical",linePosition:"right",tabs:this.tabs}).main();for(const[e,t]of this.tabs.entries()){const t=this.tabs[e].contentHolder.style("padding-left","20px");t.append("div")}}))}reactsTo(e){if(e.type.startsWith("submenu_"))return true;if(e.type=="set_term_type_group")return true;if(e.type=="app_refresh")return true}main(){this.dom.holder.style("display",this.state.isVisible?"inline-block":"none");this.dom.topbar.style("display",this.state.isVisible?"inline-block":"none");if(this.submit_lst){this.renderTermsSelected();this.dom.selectedTermsDiv.style("display",this.state.selectedTerms.length>0?"inline-block":"none")}else this.dom.selectedTermsDiv.style("display","none");this.renderTermsSelected();if(this.dom.clearbt)this.dom.clearbt.property("disabled",this.state.selectedTerms.length==0)}renderTermsSelected(){this.dom.selectedTermsDiv.selectAll("*").remove();this.dom.selectedTermsDiv.selectAll("div").data(this.state.selectedTerms).enter().append("div").attr("title","click to delete").attr("class","sja_menuoption").attr("tabindex",0).style("position","relative").style("display","inline-block").style("padding","5px 16px 5px 9px").style("margin-left","5px").each(e).on("click",((e,t)=>this.deleteTerm(e,t))).on("mouseover",(function(e){const s=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-x-lg" viewBox="0 0 16 16">\n\t\t\t\t<path stroke='#f00' d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>\n\t\t\t\t</svg>`;const i=t(e.target);i.append("div").style("margin-left","4px").classed("sjpp_deletebt",true).style("display","inline-block").style("position","absolute").style("right","0px").style("top","0px").style("transform","scale(0.6)").style("pointer-events","none").html(s)})).on("mouseout",(function(e){t(e.target).select(".sjpp_deletebt").remove()}));function e(e){const s=t(this).style("border-radius","5px");s.insert("div").style("display","inline-block").html(e.name)}}deleteTerm(e,t){const s=this.state.selectedTerms.findIndex((e=>e.name===t.name));if(s!=-1){const e=[...this.state.selectedTerms];e.splice(s,1);this.app.dispatch({type:"app_refresh",state:{selectedTerms:e}})}}getState(e){return{dslabel:e.dslabel,termTypeGroup:e.termTypeGroup,usecase:e.tree.usecase,isVisible:!e.submenu.term,selectedTerms:e.selectedTerms,termfilter:e.termfilter}}addTabsAllowed(e){var t;return r(this,void 0,void 0,(function*(){for(const s of this.types){const i=_[s];let r=i;if(s==v.GENE_VARIANT){const e=[];if(this.app.vocabApi.termdbConfig.queries.snvindel)e.push("Mutation");if(this.app.vocabApi.termdbConfig.queries.cnv)e.push("CNV");if(this.app.vocabApi.termdbConfig.queries.svfusion)e.push("Fusion");if(e.length==0)continue;r=e.join("/")}if(i&&!this.tabs.some((e=>e.label==i))){if(e.usecase.target=="regression"&&s==v.GENE_VARIANT){if(e.usecase.detail!="independent")continue}if(e.usecase.target=="sampleScatter"&&s==v.GENE_VARIANT){if(e.usecase.detail=="numeric")continue}if(e.usecase.target=="survival"&&i!=u.DICTIONARY_VARIABLES){if(e.usecase.detail=="term")continue}if(e.usecase.target&&((t=q[e.usecase.target])===null||t===void 0?void 0:t.includes(i)))continue;try{if(!this.usesDefaultSearch(i)){const e=yield Y(`./handlers/${s}.ts`);this.handlerByType[s]=yield new e.SearchHandler;if(!this.handlerByType[s].init)throw"init not implemented"}this.addLoadTopTerms(s)}catch(e){throw`error with handler='./handlers/${s}.ts': ${e}`}this.tabs.push({label:r,callback:()=>this.setTermTypeGroup(s,i),termTypeGroup:i})}}}))}usesDefaultSearch(e){return e==u.DICTIONARY_VARIABLES||e==u.METABOLITE_INTENSITY}addLoadTopTerms(e){return r(this,void 0,void 0,(function*(){if(e==v.METABOLITE_INTENSITY)this.dom.submitDiv.append("button").style("margin-left","5px").text("Load top terms").on("click",(()=>r(this,void 0,void 0,(function*(){const t={filter0:this.state.termfilter.filter0,filter:this.state.termfilter.filter,type:e};const s=yield this.app.vocabApi.getTopTermsByType(t);this.selectTerms(s.terms)}))))}))}selectTerms(e){this.app.dispatch({type:"app_refresh",state:{selectedTerms:e}})}setTermTypeGroup(e,t){return r(this,void 0,void 0,(function*(){yield this.app.dispatch({type:"set_term_type_group",value:t});const s=this.tabs.find((e=>e.termTypeGroup==t));const i=s.contentHolder;i.selectAll("*").remove();if(s.termTypeGroup!=u.DICTIONARY_VARIABLES&&s.termTypeGroup!=u.METABOLITE_INTENSITY){const t=this.handlerByType[e];yield t.init({holder:i,app:this.app,genomeObj:this.genomeObj,callback:e=>this.selectTerm(e)})}}))}selectTerm(e){if(this.click_term)this.click_term(e);else if(this.submit_lst){this.app.dispatch({type:"app_refresh",state:{selectedTerms:[...this.state.selectedTerms,e]}})}else this.app.dispatch({type:"submenu_set",submenu:{term:e,type:"tvs"}})}}const F=e($);class z{constructor(e){this.type="submenu";this.dom={holder:e.holder};K(this)}reactsTo(e){if(e.type.startsWith("submenu_"))return true;if(e.type=="app_refresh")return true}getState(e){return{type:e.submenu.type,term:e.submenu.term,termfilter:e.termfilter}}main(){if(!this.state.term){this.dom.holder.style("display","none");return}if(this.state.type=="tvs")this.showTvsMenu(this.state.term);else throw`unsupported submenu.type='${this.state.type}'`}}const W=e(z);function K(e){e.showTvsMenu=function(t){e.dom.holder.selectAll("*").remove();e.dom.holder.style("display","block").append("div").style("margin","20px").append("span").html("« Back to variable selection").attr("class","sja_clbtext").on("click",(()=>e.app.dispatch({type:"submenu_set",submenu:{}})));g({term:t,filter:e.state.termfilter.filter,holder:e.dom.holder.append("div"),vocabApi:e.app.vocabApi,debug:e.app.debug,getCategoriesArguments:e.app.opts.getCategoriesArguments,callback:e.app.opts.tree.click_term2select_tvs})}}class H{constructor(e){this.type="search";this.customEvents=["postSearch"];X(this);Q(this);this.dom={holder:e.holder};this.isVisible="isVisible"in e?e.isVisible:true}async init(e){this.initUI(this.getState(e))}reactsTo(e){if(e.type=="set_term_type_group")return true;if(e.type=="app_refresh")return true;const t=e.type.split("_")[0];return["search","cohort","submenu"].includes(t)}getState(e){return{isVisible:!e.submenu.term&&this.isVisible,cohortStr:e.activeCohort==-1||!e.termdbConfig.selectCohort?"":e.termdbConfig.selectCohort.values[e.activeCohort].keys.slice().sort().join(","),allowedTermTypes:e.termdbConfig?.allowedTermTypes||[],expandedTermIds:e.tree.expandedTermIds,selectedTerms:e.selectedTerms,usecase:e.tree.usecase,search:e.search,isGeneSetTermdb:e.termdbConfig.isGeneSetTermdb,termTypeGroup:e.termTypeGroup}}isTermTypeSupported(){const e=this.state.termTypeGroup;if(e==u.DICTIONARY_VARIABLES)return true;if(e==u.METABOLITE_INTENSITY)return true;return false}async main(){if(!this.isTermTypeSupported()){this.dom.holder.style("display","none");return}this.dom.input.node().value="";this.dom.input.attr("placeholder","Search "+this.state.termTypeGroup);this.clear();this.dom.holder.style("display",this.state.isVisible?"block":"none")}async doSearch(e){if(!e||e.length<3){this.clear();this.bus.emit("postSearch",[]);return}const t=await this.app.vocabApi.findTerm(e,this.state.cohortStr,this.state.usecase,this.state.termTypeGroup);this.currData=t;if(!t.lst||t.lst.length==0){this.noResult()}else{this.showTerms(t)}this.bus.emit("postSearch",t)}}const J=e(H);function X(e){e.initUI=t=>{e.dom.holder.style("display",e.search&&e.search.isVisible==false?"none":"block");const s=e.dom.holder.append("div").style("text-align","left");e.dom.input=s.append("input").attr("type","search").attr("class","tree_search").style("width","250px").style("margin","10px").style("display","inline-block").on("input",l.debounce(e.onInput,300)).on("keyup",e.onKeyup);e.dom.resultCntDiv=s.append("div").style("display","none");if(e.opts.focus!="off")e.dom.input.node().focus();e.dom.resultDiv=(e.opts.resultsHolder||e.dom.holder).append("div").attr("class","sjpp_show_scrollbar").style("max-height","35vh").style("display","none").style("grid-template-columns","auto auto");const i=e.dom.resultDiv.append("div");const r=e.dom.resultDiv.append("div");e.dom.resultDiv_genes=i.append("div").style("border-left","solid 1px rgb(133,182,225)").style("margin","0px 0px 10px 10px").style("padding-left","5px");e.dom.resultDiv_terms=r.append("div").style("border-left",e.opts.resultsHolder?"":"solid 1px rgb(133,182,225)").style("margin","0px 0px 10px 10px").style("padding-left","5px")};e.getPrompt=e=>{const t=e.allowedTermTypes.includes("geneVariant")&&y({type:"geneVariant"},e.usecase).has("plot");if(t)return" variables or genes";if(e.isGeneSetTermdb)return" gene sets";return" variables"};e.noResult=()=>{e.clear();e.dom.resultDiv.style("display","inline-grid");e.dom.resultDiv_terms.append("div").style("padding","3px 3px 3px 0px").style("opacity",.5).text("No match"+(e.app.vocabApi.termdbConfig?.queries?.snvindel?.allowSNPs?". Press ENTER to search SNP":""))};e.showTerms=t=>{if(e.opts.disable_terms){t.lst.forEach((t=>{if(t.disabled)e.opts.disable_terms.push(t)}))}e.clear();e.dom.resultDiv.style("display","inline-grid");const s=[],i=[];for(const e of t.lst){if(e.type=="geneVariant"){s.push(e)}else{i.push(e)}}if(s.length){e.dom.resultDiv_genes.append("table").selectAll().data(s).enter().append("tr").each(e.showTerm)}if(i.length){e.dom.resultDiv_terms.append("table").selectAll().data(i).enter().append("tr").each(e.showTerm)}if(t.lst.length>1)e.dom.resultCntDiv.style("display","inline-block").text(`${t.lst.length} results`);e.focusableResults=[...e.dom.resultDiv.node().querySelectorAll(".sja_tree_click_term, .sja_menuoption")]};e.showTerm=function(s){const i=t(this);const r=i.append("td").text(s.name);const a=y(s,e.state.usecase);if((e.opts.click_term||e.app.opts?.tree?.click_term_wrapper)&&a.has("plot")){if(s&&e.opts.disable_terms?.find((e=>T(s,e)))){r.attr("class","sja_tree_click_term_disabled").style("display","block").style("padding","5px 8px").style("margin","1px 0px").style("opacity",.4)}else{r.attr("class","ts_pill sja_filter_tag_btn sja_tree_click_term").attr("tabindex",0).style("display","block").style("color","black").style("padding","5px 8px").style("border-radius","6px").style("background-color",s.type=="geneVariant"?"rgba(251,171,96,0.5)":"#cfe2f3").style("margin","1px 0px").style("cursor","default").on("click",(()=>{if(e.opts.click_term){e.opts.click_term(s)}else{e.app.opts.tree.click_term_wrapper(s)}e.clear();e.dom.input.property("value","")})).on("keyup",e.navInputValueByKeyboard)}if(s.samplecount!==undefined){i.append("td").append("div").style("font-size",".8em").style("display","inline-block").style("margin-left","5px").style("color",s.samplecount?"#777":"#ddd").text("n="+s.samplecount)}}else{r.attr("class","sja_menuoption").attr("tabindex",0).on("click",(()=>{e.clear();e.dom.input.property("value","");const t=[A];if(s.type=="geneVariant"&&e.opts.handleGeneVariant){e.opts.handleGeneVariant(s)}else if(x(s.type)){e.app.dispatch({type:"app_refresh",state:{selectedTerms:[...e.state.selectedTerms,s]}})}else{if(s.__ancestors){t.push(...s.__ancestors)}if(!e.app.vocabApi.graphable(s))t.push(s.id);e.app.dispatch({type:"app_refresh",state:{tree:{expandedTermIds:t}}})}})).on("keyup",e.navInputValueByKeyboard)}i.append("td").text(s.type=="geneVariant"?"gene variant":(s.__ancestorNames||[]).join(" > ")).style("opacity",.5).style("font-size",".7em")};e.clear=()=>{e.dom.resultDiv_genes.selectAll("*").remove();e.dom.resultDiv_terms.selectAll("*").remove();e.dom.resultDiv.style("display","none");e.dom.resultCntDiv.style("display","none")}}function Q(e){e.onKeyup=t=>{if(t.key=="ArrowDown"&&e.currData?.lst?.length){e.dom.resultDiv.select(".sja_tree_click_term, .sja_menuoption").node().focus();return}if(!o(t))return;e.onInput(t)};e.onInput=async t=>{const s=e.dom.input.property("value");try{await e.doSearch(s)}catch(t){e.clear();e.dom.resultDiv.style("display","inline-grid");n(e.dom.resultDiv_terms,"Error: "+(t.message||t));if(t.stack)console.log(t.stack)}};e.navInputValueByKeyboard=t=>{if(t.key=="Enter")t.target.click();else if(t.key.startsWith("Arrow")){const s=e.focusableResults.findIndex((e=>e===t.target));if(t.key=="ArrowDown"){if(s<e.focusableResults.length-1)e.focusableResults[s+1].focus();else e.focusableResults[0].focus()}else if(t.key=="ArrowUp"){if(s!=0)e.focusableResults[s-1].focus();else e.focusableResults[e.focusableResults.length-1].focus()}}}}class Z{constructor(e){this.type="app";if(!e.holder)t("body").append("div");const s=e.holder.append("div").style("display",e.tree?.submit_lst?"":"none").style("text-align","center").style("margin","10px 5px");const i=s.append("button").property("disabled",true).text(this.noSelectionPrompt).on("click",(()=>this.opts.tree?.submit_lst(this.state.selectedTerms)));const r=e.holder.append("div");const a=r.append("div").style("display","inline-block");const l=r.append("div").style("display","inline-block").style("vertical-align","top");this.dom={topbar:r,holder:e.holder,termTypeSearchDiv:a,searchDiv:l.append("div"),treeDiv:l.append("div"),customTermDiv:l.append("div").style("margin","10px"),submitDiv:s,submitBtn:i,filterDiv:r.append("div").style("display","none"),errdiv:e.holder.append("div"),tip:new d({padding:"5px"})}}validateOpts(e){if(e.vocabApi);else if(e.state&&e.state.vocab){if(typeof e.state.vocab!="object")throw"opts.state.vocab{} is not an object"}else if(e.state&&e.state.genome){const t=e.state;if(!t.vocab)t.vocab={};t.vocab.genome=t.genome;delete t.genome;if(t.dslabel){t.vocab.dslabel=t.dslabel;delete t.dslabel}}else{throw"neither state.vocab{} or opts.vocabApi provided"}if(e.tree){if(e.tree.disable_terms&&!e.tree.click_term&&!e.tree.click_term2select_tvs&&(!e.barchart||!e.barchart.bar_click_override)){throw`opts.tree.disable_terms is used only when opts.tree.click_term, opts.tree.click_term2select_tvs, or opts.barchart.bar_click_override is set`}if(!e.search)e.search={};if(e.tree.click_term2select_tvs){e.search.click_term=e=>this.api.dispatch({type:"submenu_set",submenu:{term:e,type:"tvs"}})}if(e.tree.click_term){e.tree.click_term_wrapper=async t=>{if(this.state.termdbConfig.termMatch2geneSet){const e=await c("termdb",{body:{genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,genesetByTermId:t.id}});t._geneset=e}e.tree.click_term(t)}}if(e.tree.disable_terms)e.search.disable_terms=e.tree.disable_terms}return e}async preApiFreeze(e){try{if(this.opts.vocabApi){e.vocabApi=this.opts.vocabApi}else{const t={vocab:this.opts.state.vocab||{genome:this.opts.state.genome,dslabel:this.opts.state.dslabel}};e.vocabApi=await S({app:this.api,state:t,fetchOpts:this.opts.fetchOpts})}e.appInit=ee}catch(e){console.log(e);throw e}}async init(){try{this.store=await M({app:this.api,state:this.opts.state});this.state=await this.store.copyState();await this.setComponents();await this.api.dispatch()}catch(e){this.printError(e)}}async setComponents(){try{const e=this.state.nav?.header_mode;const t={search:J({app:this.api,holder:this.dom.searchDiv,isVisible:e!=="hide_search"}),termTypeSearch:F({app:this.api,holder:this.dom.termTypeSearchDiv,topbar:this.dom.topbar,genome:this.opts.vocabApi?.app?.opts?.genome,click_term:this.opts.tree?.click_term,submit_lst:this.opts.tree?.submit_lst,submitDiv:this.dom.submitDiv}),tree:V({app:this.api,holder:this.dom.treeDiv,headerDiv:this.dom.headerDiv,expandAll:e=="hide_search"})};if(this.opts.tree&&this.opts.tree.click_term2select_tvs){t.submenu=W({app:this.api,holder:this.dom.holder.append("div").style("display","none")})}this.components=await h(t)}catch(e){throw e}}async main(){this.api.vocabApi.main();const e=this.state.selectedTerms.length;this.dom.submitBtn.property("disabled",!e).text(!e?"Search or click term(s)":`Submit ${e} term${e>1?"s":""}`);await this.mayShowCustomTerms();this.dom.holder.selectAll("search, .termbtn, button").attr("tabindex",0);this.dom.holder.selectAll(".termbtn").on("keyup",(e=>{if(e.key=="Enter")e.target.click()}))}printError(e){n(this.dom.errdiv,"Error: "+(e.message||e));if(e.stack)console.log(e.stack)}async mayShowCustomTerms(){if(Object.keys(this.state.submenu).length)return this.dom.customTermDiv.style("display","none");const e=await this.api.vocabApi.getCustomTerms();if(!Array.isArray(e)||e.length==0)return this.dom.customTermDiv.style("display","none");const t=[];for(const s of e){const e=y(s.term,this.state.tree.usecase);if(e.has("plot"))t.push(s)}if(t.length==0)return this.dom.customTermDiv.style("display","none");this.dom.customTermDiv.selectAll("*").remove();this.dom.customTermDiv.append("div").text("CUSTOM VARIABLES").style("font-size",".7em");for(const e of t){this.dom.customTermDiv.append("div").style("margin-bottom","3px").append("div").text(e.term.name).attr("class","sja_filter_tag_btn").style("padding","3px 6px").style("border-radius","6px").on("click",(()=>{if(!this.opts.tree)return;if(this.opts.tree.click_term){this.opts.tree.click_term(e);return}if(this.opts.tree.click_term2select_tvs){this.api.dispatch({type:"submenu_set",submenu:{term:e.term,type:"tvs"}});return}}))}}}const ee=p(Z);export{ee as appInit};
|
package/dist/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{c2 as runproteinpaint}from"./app-
|
|
1
|
+
export{c2 as runproteinpaint}from"./app-71453429.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as e,bn as t,k as s,S as n,bo as a,aR as i,E as l,aC as o,bp as r,ac as c,b8 as d,ba as p}from"./app-f91922b4.js";import{r as f}from"./table-d6c411fd.js";import{m as u}from"./checkbox-0e5c659f.js";const y=new e({padding:""});const m="hg38";const h="GDC";const g=60;const b=[{title:"Entity ID",key:"entity_id"},{title:"Experimental Strategy",key:"experimental_strategy"},{title:"Sample Type",key:"sample_type"},{title:"Size",key:"file_size",width:"10vw"}];const k="You are attempting to access a Sequence Read file that you are not authorized to access. <a href=https://gdc.cancer.gov/access-data/obtaining-access-controlled-data target=_blank>Please request dbGaP Access to the project</a>.";async function v({genomes:e,holder:p,filter0:v,hideTokenInput:S=false,callbacks:A={},stream2download:F=false,inputValue:I,debugmode:T=false}){if(A.postRender&&typeof A.postRender!="function")throw"callbacks.postRender is not function";const E={dom:{tip:y}};const C=e[m];if(!C)throw"missing genome for "+m;const $={bam_files:[],runFlags:{runflag_caseFileList:1,runflag_gdcInput:1}};const j=t();const N=p.append("div").style("margin-left","30px").style("display","none");N.append("button").html("« Back To Input Form").on("click",(()=>{N.style("display","none");B.style("display","none").selectAll("*").remove();G.style("display","block")}));const G=p.append("div").style("margin-left","30px");const M=G.append("div");const B=p.append("div").style("display","none");if(!S)H();const D=await V();const O=G.append("div").style("padding","3px 10px").style("display","none");const[z,U,R]=Q();const P=I||j.get("gdc_id");if(P){D.property("value",P).node().dispatchEvent(new Event("search"))}else{delete $.runFlags.runflag_gdcInput;L()}function L(){if(!A.postRender)return;if(Object.keys($.runFlags).length==0){A.postRender(E)}}function H(){const e=M.insert("div").attr("class","sja-gdcbam-tokendiv");e.insert("div").style("display","inline-block").style("width","15vw").text("GDC Token File");const t=e.insert("div").style("display","inline-block");const s=t.append("input").attr("type","file").attr("aria-label","GDC token file");const n=t.append("span").style("margin-left","20px").style("display","none");s.on("change",(e=>{const t=e.target.files[0];if(!t){s.property("value","");return}if(!t.size){s.property("value","");w(n,"Blank file "+t.name);return}const a=new FileReader;a.onload=e=>{const t=e.target.result.trim();if(t.length<100){s.property("value","");w(n,"Does not look like a toke file (content too short)");return}if(t.length>1e3){s.property("value","");w(n,"Does not look like a toke file (content too long)");return}$.gdc_token=t};a.onerror=function(){s.property("value","");w(n,"Error reading file "+t.name);return};w(n);a.readAsText(t,"utf8")}));setTimeout((()=>s.node().focus()),1100)}async function V(){const e=M.insert("div");e.append("div").style("display","inline-block").style("width","15vw").style("padding-top","5px").text("Enter Search String").style("vertical-align","top");const t=e.append("div").style("display","inline-block");const i=t.append("input").attr("type","search").attr("size",45).attr("aria-label","Specify File Name / File UUID / Case ID / Case UUID").style("padding","3px 10px").property("placeholder","File Name / File UUID / Case ID / Case UUID").attr("class","sja-gdcbam-input").on("search",y).on("keyup",(e=>{if(s(e)){y();return}l.style("display","").text("Press ENTER to search");o.style("display","none")}));const l=t.append("span").style("padding-left","10px").style("display","none");const o=t.append("span").attr("class","sja-gdcbam-gdcid_error_div").style("display","none").style("padding","2px 5px");t.append("br");const r=t.append("div").attr("class","sja-gdcbam-listCaseFileHandle").style("margin","5px").style("display","inline-block").text("Looking for BAM files from current cohort...");q(r);const c=t.append("div").style("display","none").style("width","500px").style("margin","20px 3px").html(k);const d=G.append("div").style("display","none").style("margin","20px 20px 20px 40px");const p=d.append("div").attr("class","sja-gdcbam-onefiletable").style("display","none");const u=d.append("div").attr("class","sja-gdcbam-multifiletable").style("display","none");E.update=e=>{y(null,e?.filter0||v);q(r,e?.filter0||v)};async function y(e,t){U.selectAll("*").remove();R.style("display","none");z.style("display","inline-block");o.style("display","none");l.style("display","none");try{await m(Object.keys(t||{}).length?t:v||null)}catch(e){w(o,e.message||e);d.style("display","none");O.style("display","none")}L()}async function m(e){const t=i.property("value").trim();if(!t.length){d.style("display","none");U.selectAll("*").remove();O.style("display","none");return}i.attr("disabled",1);l.style("display","").text("Loading...");$.runFlags.runflag_gdcInput=1;const s={gdc_id:t};if(e)s.filter0=e;let a;try{a=await n("gdcbam",{body:s})}catch(e){throw e}finally{delete $.runFlags.runflag_gdcInput}i.attr("disabled",null);l.style("display","none");$.bam_files=[];if(a.error)throw"Error: "+a.error;if(!Array.isArray(a.file_metadata))throw"Error: .file_metadata[] missing";if(a.file_metadata.length==0){if(a.numFilesSkippedByWorkflow){throw`File${a.numFilesSkippedByWorkflow>1?"s":""} not viewable due to workflow type.`}throw"No viewable BAM files found"}c.style("display",a.userHasNoAccess?"block":"none");$.case_id=a.file_metadata[0].case_id;if(a.file_metadata.length==1){h(a)}else{g(a.file_metadata)}w(o);$.runFlags.ssmSearch=1;try{await X()}catch(e){throw e}finally{delete $.runFlags.ssmSearch}}function h(e,t){d.style("display","block");p.style("display","block").selectAll("*").remove();u.style("display","none");const s=e.file_metadata[0];const n={file_id:s.file_uuid,track_name:s.entity_id,about:[]};$.bam_files.push(n);const i=a({holder:p});for(const e of b){const[t,a]=i.addRow();t.text(e.title);a.html(e.url?`<a href=${e.url}${s.file_uuid} target=_blank>${s[e.key]}</a>`:s[e.key]);n.about.push({k:e.title,v:s[e.key]})}p.select("input").node()?.focus()}function g(e){const t=b.map((e=>({label:e.title,width:e.width})));const s=[];for(const[t,n]of e.entries()){const e=[];for(const t of b){if(t.url){e.push({html:`<a href=${e.url}${n.file_uuid} target=_blank>${n[e.key]}</a>`})}else{e.push({value:n[t.key]})}}s.push(e)}d.style("display","block");u.style("display","block").selectAll("*").remove();p.style("display","none");f({rows:s,columns:t,div:u,singleMode:F?true:false,noButtonCallback:(t,s)=>{const n=e[t];if(F){$.bam_files=[{file_id:n.file_uuid,track_name:n.sample_type+", "+n.experimental_strategy+", "+n.entity_id,about:b.map((e=>({k:e.title,v:n[e.key]})))}]}else{if(s.checked){$.bam_files.push({file_id:n.file_uuid,track_name:n.sample_type+", "+n.experimental_strategy+", "+n.entity_id,about:b.map((e=>({k:e.title,v:n[e.key]})))})}else{$.bam_files=$.bam_files.filter((e=>e.file_id!=n.file_uuid))}}}})}return i}async function q(e,t){$.runFlags.runflag_caseFileList=1;try{await W(e,t)}catch(t){e.text(t.message||t)}finally{delete $.runFlags.runflag_caseFileList}L()}async function W(e,t){const s=Object.keys(t||{}).length?t:v||null;const a={};if(s)a.filter0=s;const i=await n("gdcbam",{body:a});if(i.error)throw i.error;if(typeof i.case2files!="object")throw"wrong return";if(!i.restapihost)throw"data.restapihost is missing";$.restapihost=i.restapihost;e.text(`Or, Browse ${i.total} Available BAM Files`);const l=new Map;for(const e in i.case2files){for(const t of i.case2files[e]){const e=t.experimental_strategy;if(!l.has(e)){l.set(e,{count:1,checked:true})}else{l.get(e).count+=1}}}e.classed("sja_clbtext",true).attr("tabindex",0).on("keyup",(e=>{if(e.key=="Enter"){e.target.click()}})).on("click",(e=>{y.clear().showunder(e.target);{const e=y.d.append("div").style("margin","10px");for(const[s,n]of l){u({holder:e,labeltext:`${s}, ${n.count}`,divstyle:{display:"inline","margin-right":"15px"},checked:n.checked,callback:()=>{n.checked=!n.checked;o(t)}})}}const t=y.d.append("div").style("margin","10px").attr("class","sjpp_show_scrollbar").style("height","300px").style("resize","vertical");o(t)}));function o(e){e.selectAll("*").remove();const t=e.append("table").style("border-spacing","0px");const s=t.append("tr").style("position","sticky").style("top","0px").style("background-color","white").style("color","#888");s.append("td").text("CASE");s.append("td").text("BAM FILES, SELECT ONE TO VIEW");for(const e in i.case2files){const s=t.append("tr").attr("class","sja_clb_gray");s.append("td").style("vertical-align","top").style("color","#888").text(e);const n=s.append("td");for(const t of i.case2files[e]){if(!l.get(t.experimental_strategy).checked)continue;n.append("div").attr("class","sja_clbtext").attr("tabindex",0).html(`${t.sample_type}, ${t.experimental_strategy} <span style="font-size:.8em">${t.file_size}</span>`).on("click",(()=>{y.hide();D.property("value",t.file_uuid).node().dispatchEvent(new Event("search"))})).on("keyup",(e=>{if(e.key=="Enter")e.target.click()}))}}t.select(".sja_clbtext")?.node()?.focus()}}async function X(){delete $.ssmInput;O.style("display","block").selectAll("*").remove();const e=O.append("p").text("Searching for mutations...");const t=await n("termdb/singleSampleMutation",{body:{sample:"___"+$.case_id,genome:m,dslabel:h}});if(t.error)throw t.error;const s=t.mlst.filter((e=>e.dt==1));if(s.length==0){e.text("No mutations from this case.");if(F){const e=[{label:"Gene or position",callback:()=>$.useSsmOrGene="gene"},{label:"Unmapped reads",callback:()=>$.useSsmOrGene="unmapped"}];new i({holder:O,tabs:e}).main();await J(e[0].contentHolder);e[1].contentHolder.append("p").text("Only download unmapped reads from this BAM file.")}else{await J(O.append("div"))}return}e.remove();const a=[{label:`${s.length} variants${t.dt2total?.[0]?" ("+t.dt2total[0].total+" total)":""}`,callback:()=>{$.useSsmOrGene="ssm"}},{label:"Gene or position",callback:()=>{$.useSsmOrGene="gene"}}];if(F){a.push({label:"Unmapped reads",callback:()=>$.useSsmOrGene="unmapped"})}new i({holder:O,tabs:a}).main();Y(a[0].contentHolder,s);await J(a[1].contentHolder);if(a[2])a[2].contentHolder.append("p").text("Only download unmapped reads from this BAM file.")}function Y(e,t){const s=[{label:"Gene",width:"10vw"},{label:"Mutation"},{label:"Consequence"},{label:"Position"}];const n=new Map;for(const e of t){if(!n.has(e.gene))n.set(e.gene,[]);n.get(e.gene).push(e)}const a=[];for(const[e,t]of n){for(const s of t){const t=[];t.push({value:e,data:s});t.push({value:s.mname});t.push({value:l[s.class]?.label||"Unknown"});t.push({value:s.chr+":"+s.pos+" "+s.ref+">"+s.alt});a.push(t)}}f({rows:a,columns:s,div:e,noButtonCallback:(e,t)=>{const s=a[e][0].data;$.ssmInput={chr:s.chr,pos:s.pos-1,ref:s.ref,alt:s.alt}},singleMode:true});if(j.has("gdc_ssm")){for(const[e,t]of n){for(const e of t){if(e.mname==j.get("gdc_ssm")){$.ssmInput={chr:e.chr,pos:e.pos-1,ref:e.ref,alt:e.alt}}}}}e.select("input").node().focus()}async function J(e){const t=e.append("div").style("display","grid").style("grid-template-columns","300px auto");t.append("div").text("Enter gene, position, SNP, or variant");$.coordInput=o(await K(t));_(e)}async function K(e){const t={genome:C,tip:y,row:e.append("div"),allowVariant:true};if(j.has("gdc_pos")){const e=j.get("gdc_pos").split(/[:\-]/);if(e.length==3){t.defaultCoord={chr:e[0],start:Number(e[1]),stop:Number(e[2])}}}else if(j.has("gdc_var")){const e=await r(j.get("gdc_var"),C);if(e){t.defaultCoord=e}}return t}function Q(){const e=G.append("div");const t=e.insert("div").style("display","inline-block").append("button").style("margin","20px 20px 20px 40px").style("padding","10px 25px").style("border-radius","35px").text("Submit").on("click",(async()=>{try{s.selectAll("*").remove();x($,C,S);t.text("Loading ...");t.property("disabled",true);await Z()}catch(e){if(e=="Permission denied"){n.style("display","inline-block");t.style("display","none")}else{s.selectAll("*").remove();c(s,e)}}t.text("Submit");t.property("disabled",false)}));const s=e.insert("div").style("display","inline-block");const n=e.insert("div").style("display","none").style("margin","20px");n.append("div").text("Access Alert").style("font-size","1.5em").style("opacity",.4);n.append("div").style("border-top","solid 1px #eee").style("border-bottom","solid 1px #eee").style("padding","20px 0px").style("margin-top","5px").html(k);return[t,s,n]}async function Z(){const e=$;const t={nobox:1,genome:C,holder:B,debugmode:T};if(e.useSsmOrGene=="unmapped"){t.unmapped=1}else{if(e.position){t.chr=e.position.chr;t.start=e.position.start;t.stop=e.position.stop}else if(e.variant){t.chr=e.variant.chr;t.start=e.variant.pos-g;t.stop=e.variant.pos+g}else{throw"SV_EXPAND here"}}const s={"Content-Type":"application/json",Accept:"application/json"};if(e.gdc_token){s["X-Auth-Token"]=e.gdc_token}for(const[a,i]of e.bam_files.entries()){z.text(`Slicing BAM File ${a+1} of ${e.bam_files.length}...`);const l={downloadgdc:1,gdcFileUUID:i.file_id};if(t.unmapped){l.gdcFilePosition="unmapped";l.unmapped=1}else{l.gdcFilePosition=t.chr+":"+t.start+"-"+t.stop;l.regions=[{chr:t.chr,start:t.start,stop:t.stop}]}if(F){s.compression=false;const e=`${$.restapihost}/slicing/view/${i.file_id}?region=${l.gdcFilePosition}`;const n=await fetch(e,{method:"GET",headers:s});const a=await n.blob();const o=document.createElement("a");o.href=URL.createObjectURL(a);if(t.unmapped){o.download=i.track_name+".unmapped.bam"}else{o.download=`${i.track_name}.${t.chr}.${t.start}.${t.stop}.bam`}o.style.display="none";document.body.appendChild(o);o.click();document.body.removeChild(o);return}const o=await n("tkbam",{headers:s,body:l});if(o.error)throw o.error;{const e=i.about.find((e=>e.k=="Slice file size"));if(e)e.v=o.size;else i.about.push({k:"Slice file size",v:o.size})}if(o.time){const e=i.about.find((e=>e.k=="Stream time"));if(e)e.v=Math.round(o.time)+" seconds";else i.about.push({k:"Stream time",v:Math.round(o.time)+" seconds"})}if(o.truncated){if(!i.about.find((e=>e.k=="Truncated")))i.about.push({k:"Truncated",v:"BAM slice size exceeds limit and is truncated"})}else{const e=i.about.findIndex((e=>e.k=="Truncated"));if(e>0)i.about.splice(e,1)}}G.style("display","none");N.style("display","block");B.style("display","block");t.tklst=[];for(const s of e.bam_files){const n={type:"bam",name:s.track_name||"Sample BAM slice",gdcToken:e.gdc_token,gdcFile:{uuid:s.file_id,position:t.chr+":"+t.start+"-"+t.stop},aboutThisFile:s.about};if(e.variant){n.variants=[e.variant]}t.tklst.push(n)}d(C,t.tklst);const a=await import("./block-ec76524e.js").then((function(e){return e.c}));new a.Block(t)}return E}function _(e){e.append("div").style("opacity",.6).html(`<ul>\n\t\t<li>Enter gene, position, SNP, or variant.\n\t\tThe BAM file will be sliced at the given position and visualized.</li>\n\t\t<li>Position</li>\n\t\t<ul><li>Example: chr17:7676339-7676767</li>\n\t\t <li>Coordinates are hg38 and 1-based.</li>\n\t\t</ul>\n\t\t<li>SNP example: rs28934574</li>\n\t\t<li>Variant:</li>\n\t\t<ul>\n\t\t <li>Example: chr2.208248388.C.T</li>\n\t\t <li>Fields are separated by periods. Coordinate is hg38 and 1-based. Reference and alternative alleles are on forward strand.</li>\n\t\t</ul>\n\t\t<li>Supported HGVS formats for variants:</li>\n\t\t<ul>\n\t\t <li>SNV: chr2:g.208248388C>T</li>\n\t\t <li>MNV: chr2:g.119955155_119955159delinsTTTTT</li>\n\t\t <li>Insertion: chr5:g.171410539_171410540insTCTG</li>\n\t\t <li>Deletion: chr10:g.8073734delTTTAGA</li>\n\t\t</ul>\n\t\t</ul>`)}function w(e,t){e.style("display","inline-block").style("color",t?"red":"green").html(t?"❌ "+t:"✓")}function x(e,t,s=false){if(!s){if(!e.gdc_token)throw"GDC token missing";if(typeof e.gdc_token!=="string")throw"GDC token is not string"}if(!e.bam_files.length)throw"No BAM file selected";for(const t of e.bam_files){if(!t.file_id)throw"file uuid is missing";if(typeof t.file_id!=="string")throw"file uuid is not string"}if(e.useSsmOrGene=="unmapped"){return}delete e.position;delete e.variant;if(e.useSsmOrGene=="ssm"){const t=e.ssmInput;if(!t)throw"No variant selected";if(!t.chr)throw"ssmInput.chr missing";if(!Number.isInteger(t.pos))throw"ssmInput.pos not integer";if(!t.ref)throw"ssmInput.ref missing";if(!t.alt)throw"ssmInput.alt missing";e.variant=t;return}const n=e.coordInput;if(!n.chr)throw"No valid position or variant was entered";const[a,i]=p(t,[n.chr]);if(a+i==0)throw"Invalid chromosome name: "+n.chr;const l=a?"chr"+n.chr:n.chr;if(Number.isInteger(n.pos)){if(!n.ref)throw"Reference allele missing from variant string";if(!n.alt)throw"Alternative allele missing from variant string";e.variant={chr:l,pos:n.pos-1,ref:n.ref,alt:n.alt}}else{if(!Number.isInteger(n.start)||!Number.isInteger(n.stop))throw"non-integer start/stop";e.position={chr:l,start:n.start,stop:n.stop}}}export{v as bamsliceui};
|
|
1
|
+
import{M as e,bn as t,k as s,S as n,bo as a,aR as i,E as l,aC as o,bp as r,ac as c,b8 as d,ba as p}from"./app-71453429.js";import{r as f}from"./table-1dae543a.js";import{m as u}from"./checkbox-0e5c659f.js";const y=new e({padding:""});const m="hg38";const h="GDC";const g=60;const b=[{title:"Entity ID",key:"entity_id"},{title:"Experimental Strategy",key:"experimental_strategy"},{title:"Sample Type",key:"sample_type"},{title:"Size",key:"file_size",width:"10vw"}];const k="You are attempting to access a Sequence Read file that you are not authorized to access. <a href=https://gdc.cancer.gov/access-data/obtaining-access-controlled-data target=_blank>Please request dbGaP Access to the project</a>.";async function v({genomes:e,holder:p,filter0:v,hideTokenInput:S=false,callbacks:A={},stream2download:F=false,inputValue:I,debugmode:T=false}){if(A.postRender&&typeof A.postRender!="function")throw"callbacks.postRender is not function";const E={dom:{tip:y}};const C=e[m];if(!C)throw"missing genome for "+m;const $={bam_files:[],runFlags:{runflag_caseFileList:1,runflag_gdcInput:1}};const j=t();const N=p.append("div").style("margin-left","30px").style("display","none");N.append("button").html("« Back To Input Form").on("click",(()=>{N.style("display","none");B.style("display","none").selectAll("*").remove();G.style("display","block")}));const G=p.append("div").style("margin-left","30px");const M=G.append("div");const B=p.append("div").style("display","none");if(!S)H();const D=await V();const O=G.append("div").style("padding","3px 10px").style("display","none");const[z,U,R]=Q();const P=I||j.get("gdc_id");if(P){D.property("value",P).node().dispatchEvent(new Event("search"))}else{delete $.runFlags.runflag_gdcInput;L()}function L(){if(!A.postRender)return;if(Object.keys($.runFlags).length==0){A.postRender(E)}}function H(){const e=M.insert("div").attr("class","sja-gdcbam-tokendiv");e.insert("div").style("display","inline-block").style("width","15vw").text("GDC Token File");const t=e.insert("div").style("display","inline-block");const s=t.append("input").attr("type","file").attr("aria-label","GDC token file");const n=t.append("span").style("margin-left","20px").style("display","none");s.on("change",(e=>{const t=e.target.files[0];if(!t){s.property("value","");return}if(!t.size){s.property("value","");w(n,"Blank file "+t.name);return}const a=new FileReader;a.onload=e=>{const t=e.target.result.trim();if(t.length<100){s.property("value","");w(n,"Does not look like a toke file (content too short)");return}if(t.length>1e3){s.property("value","");w(n,"Does not look like a toke file (content too long)");return}$.gdc_token=t};a.onerror=function(){s.property("value","");w(n,"Error reading file "+t.name);return};w(n);a.readAsText(t,"utf8")}));setTimeout((()=>s.node().focus()),1100)}async function V(){const e=M.insert("div");e.append("div").style("display","inline-block").style("width","15vw").style("padding-top","5px").text("Enter Search String").style("vertical-align","top");const t=e.append("div").style("display","inline-block");const i=t.append("input").attr("type","search").attr("size",45).attr("aria-label","Specify File Name / File UUID / Case ID / Case UUID").style("padding","3px 10px").property("placeholder","File Name / File UUID / Case ID / Case UUID").attr("class","sja-gdcbam-input").on("search",y).on("keyup",(e=>{if(s(e)){y();return}l.style("display","").text("Press ENTER to search");o.style("display","none")}));const l=t.append("span").style("padding-left","10px").style("display","none");const o=t.append("span").attr("class","sja-gdcbam-gdcid_error_div").style("display","none").style("padding","2px 5px");t.append("br");const r=t.append("div").attr("class","sja-gdcbam-listCaseFileHandle").style("margin","5px").style("display","inline-block").text("Looking for BAM files from current cohort...");q(r);const c=t.append("div").style("display","none").style("width","500px").style("margin","20px 3px").html(k);const d=G.append("div").style("display","none").style("margin","20px 20px 20px 40px");const p=d.append("div").attr("class","sja-gdcbam-onefiletable").style("display","none");const u=d.append("div").attr("class","sja-gdcbam-multifiletable").style("display","none");E.update=e=>{y(null,e?.filter0||v);q(r,e?.filter0||v)};async function y(e,t){U.selectAll("*").remove();R.style("display","none");z.style("display","inline-block");o.style("display","none");l.style("display","none");try{await m(Object.keys(t||{}).length?t:v||null)}catch(e){w(o,e.message||e);d.style("display","none");O.style("display","none")}L()}async function m(e){const t=i.property("value").trim();if(!t.length){d.style("display","none");U.selectAll("*").remove();O.style("display","none");return}i.attr("disabled",1);l.style("display","").text("Loading...");$.runFlags.runflag_gdcInput=1;const s={gdc_id:t};if(e)s.filter0=e;let a;try{a=await n("gdcbam",{body:s})}catch(e){throw e}finally{delete $.runFlags.runflag_gdcInput}i.attr("disabled",null);l.style("display","none");$.bam_files=[];if(a.error)throw"Error: "+a.error;if(!Array.isArray(a.file_metadata))throw"Error: .file_metadata[] missing";if(a.file_metadata.length==0){if(a.numFilesSkippedByWorkflow){throw`File${a.numFilesSkippedByWorkflow>1?"s":""} not viewable due to workflow type.`}throw"No viewable BAM files found"}c.style("display",a.userHasNoAccess?"block":"none");$.case_id=a.file_metadata[0].case_id;if(a.file_metadata.length==1){h(a)}else{g(a.file_metadata)}w(o);$.runFlags.ssmSearch=1;try{await X()}catch(e){throw e}finally{delete $.runFlags.ssmSearch}}function h(e,t){d.style("display","block");p.style("display","block").selectAll("*").remove();u.style("display","none");const s=e.file_metadata[0];const n={file_id:s.file_uuid,track_name:s.entity_id,about:[]};$.bam_files.push(n);const i=a({holder:p});for(const e of b){const[t,a]=i.addRow();t.text(e.title);a.html(e.url?`<a href=${e.url}${s.file_uuid} target=_blank>${s[e.key]}</a>`:s[e.key]);n.about.push({k:e.title,v:s[e.key]})}p.select("input").node()?.focus()}function g(e){const t=b.map((e=>({label:e.title,width:e.width})));const s=[];for(const[t,n]of e.entries()){const e=[];for(const t of b){if(t.url){e.push({html:`<a href=${e.url}${n.file_uuid} target=_blank>${n[e.key]}</a>`})}else{e.push({value:n[t.key]})}}s.push(e)}d.style("display","block");u.style("display","block").selectAll("*").remove();p.style("display","none");f({rows:s,columns:t,div:u,singleMode:F?true:false,noButtonCallback:(t,s)=>{const n=e[t];if(F){$.bam_files=[{file_id:n.file_uuid,track_name:n.sample_type+", "+n.experimental_strategy+", "+n.entity_id,about:b.map((e=>({k:e.title,v:n[e.key]})))}]}else{if(s.checked){$.bam_files.push({file_id:n.file_uuid,track_name:n.sample_type+", "+n.experimental_strategy+", "+n.entity_id,about:b.map((e=>({k:e.title,v:n[e.key]})))})}else{$.bam_files=$.bam_files.filter((e=>e.file_id!=n.file_uuid))}}}})}return i}async function q(e,t){$.runFlags.runflag_caseFileList=1;try{await W(e,t)}catch(t){e.text(t.message||t)}finally{delete $.runFlags.runflag_caseFileList}L()}async function W(e,t){const s=Object.keys(t||{}).length?t:v||null;const a={};if(s)a.filter0=s;const i=await n("gdcbam",{body:a});if(i.error)throw i.error;if(typeof i.case2files!="object")throw"wrong return";if(!i.restapihost)throw"data.restapihost is missing";$.restapihost=i.restapihost;e.text(`Or, Browse ${i.total} Available BAM Files`);const l=new Map;for(const e in i.case2files){for(const t of i.case2files[e]){const e=t.experimental_strategy;if(!l.has(e)){l.set(e,{count:1,checked:true})}else{l.get(e).count+=1}}}e.classed("sja_clbtext",true).attr("tabindex",0).on("keyup",(e=>{if(e.key=="Enter"){e.target.click()}})).on("click",(e=>{y.clear().showunder(e.target);{const e=y.d.append("div").style("margin","10px");for(const[s,n]of l){u({holder:e,labeltext:`${s}, ${n.count}`,divstyle:{display:"inline","margin-right":"15px"},checked:n.checked,callback:()=>{n.checked=!n.checked;o(t)}})}}const t=y.d.append("div").style("margin","10px").attr("class","sjpp_show_scrollbar").style("height","300px").style("resize","vertical");o(t)}));function o(e){e.selectAll("*").remove();const t=e.append("table").style("border-spacing","0px");const s=t.append("tr").style("position","sticky").style("top","0px").style("background-color","white").style("color","#888");s.append("td").text("CASE");s.append("td").text("BAM FILES, SELECT ONE TO VIEW");for(const e in i.case2files){const s=t.append("tr").attr("class","sja_clb_gray");s.append("td").style("vertical-align","top").style("color","#888").text(e);const n=s.append("td");for(const t of i.case2files[e]){if(!l.get(t.experimental_strategy).checked)continue;n.append("div").attr("class","sja_clbtext").attr("tabindex",0).html(`${t.sample_type}, ${t.experimental_strategy} <span style="font-size:.8em">${t.file_size}</span>`).on("click",(()=>{y.hide();D.property("value",t.file_uuid).node().dispatchEvent(new Event("search"))})).on("keyup",(e=>{if(e.key=="Enter")e.target.click()}))}}t.select(".sja_clbtext")?.node()?.focus()}}async function X(){delete $.ssmInput;O.style("display","block").selectAll("*").remove();const e=O.append("p").text("Searching for mutations...");const t=await n("termdb/singleSampleMutation",{body:{sample:"___"+$.case_id,genome:m,dslabel:h}});if(t.error)throw t.error;const s=t.mlst.filter((e=>e.dt==1));if(s.length==0){e.text("No mutations from this case.");if(F){const e=[{label:"Gene or position",callback:()=>$.useSsmOrGene="gene"},{label:"Unmapped reads",callback:()=>$.useSsmOrGene="unmapped"}];new i({holder:O,tabs:e}).main();await J(e[0].contentHolder);e[1].contentHolder.append("p").text("Only download unmapped reads from this BAM file.")}else{await J(O.append("div"))}return}e.remove();const a=[{label:`${s.length} variants${t.dt2total?.[0]?" ("+t.dt2total[0].total+" total)":""}`,callback:()=>{$.useSsmOrGene="ssm"}},{label:"Gene or position",callback:()=>{$.useSsmOrGene="gene"}}];if(F){a.push({label:"Unmapped reads",callback:()=>$.useSsmOrGene="unmapped"})}new i({holder:O,tabs:a}).main();Y(a[0].contentHolder,s);await J(a[1].contentHolder);if(a[2])a[2].contentHolder.append("p").text("Only download unmapped reads from this BAM file.")}function Y(e,t){const s=[{label:"Gene",width:"10vw"},{label:"Mutation"},{label:"Consequence"},{label:"Position"}];const n=new Map;for(const e of t){if(!n.has(e.gene))n.set(e.gene,[]);n.get(e.gene).push(e)}const a=[];for(const[e,t]of n){for(const s of t){const t=[];t.push({value:e,data:s});t.push({value:s.mname});t.push({value:l[s.class]?.label||"Unknown"});t.push({value:s.chr+":"+s.pos+" "+s.ref+">"+s.alt});a.push(t)}}f({rows:a,columns:s,div:e,noButtonCallback:(e,t)=>{const s=a[e][0].data;$.ssmInput={chr:s.chr,pos:s.pos-1,ref:s.ref,alt:s.alt}},singleMode:true});if(j.has("gdc_ssm")){for(const[e,t]of n){for(const e of t){if(e.mname==j.get("gdc_ssm")){$.ssmInput={chr:e.chr,pos:e.pos-1,ref:e.ref,alt:e.alt}}}}}e.select("input").node().focus()}async function J(e){const t=e.append("div").style("display","grid").style("grid-template-columns","300px auto");t.append("div").text("Enter gene, position, SNP, or variant");$.coordInput=o(await K(t));_(e)}async function K(e){const t={genome:C,tip:y,row:e.append("div"),allowVariant:true};if(j.has("gdc_pos")){const e=j.get("gdc_pos").split(/[:\-]/);if(e.length==3){t.defaultCoord={chr:e[0],start:Number(e[1]),stop:Number(e[2])}}}else if(j.has("gdc_var")){const e=await r(j.get("gdc_var"),C);if(e){t.defaultCoord=e}}return t}function Q(){const e=G.append("div");const t=e.insert("div").style("display","inline-block").append("button").style("margin","20px 20px 20px 40px").style("padding","10px 25px").style("border-radius","35px").text("Submit").on("click",(async()=>{try{s.selectAll("*").remove();x($,C,S);t.text("Loading ...");t.property("disabled",true);await Z()}catch(e){if(e=="Permission denied"){n.style("display","inline-block");t.style("display","none")}else{s.selectAll("*").remove();c(s,e)}}t.text("Submit");t.property("disabled",false)}));const s=e.insert("div").style("display","inline-block");const n=e.insert("div").style("display","none").style("margin","20px");n.append("div").text("Access Alert").style("font-size","1.5em").style("opacity",.4);n.append("div").style("border-top","solid 1px #eee").style("border-bottom","solid 1px #eee").style("padding","20px 0px").style("margin-top","5px").html(k);return[t,s,n]}async function Z(){const e=$;const t={nobox:1,genome:C,holder:B,debugmode:T};if(e.useSsmOrGene=="unmapped"){t.unmapped=1}else{if(e.position){t.chr=e.position.chr;t.start=e.position.start;t.stop=e.position.stop}else if(e.variant){t.chr=e.variant.chr;t.start=e.variant.pos-g;t.stop=e.variant.pos+g}else{throw"SV_EXPAND here"}}const s={"Content-Type":"application/json",Accept:"application/json"};if(e.gdc_token){s["X-Auth-Token"]=e.gdc_token}for(const[a,i]of e.bam_files.entries()){z.text(`Slicing BAM File ${a+1} of ${e.bam_files.length}...`);const l={downloadgdc:1,gdcFileUUID:i.file_id};if(t.unmapped){l.gdcFilePosition="unmapped";l.unmapped=1}else{l.gdcFilePosition=t.chr+":"+t.start+"-"+t.stop;l.regions=[{chr:t.chr,start:t.start,stop:t.stop}]}if(F){s.compression=false;const e=`${$.restapihost}/slicing/view/${i.file_id}?region=${l.gdcFilePosition}`;const n=await fetch(e,{method:"GET",headers:s});const a=await n.blob();const o=document.createElement("a");o.href=URL.createObjectURL(a);if(t.unmapped){o.download=i.track_name+".unmapped.bam"}else{o.download=`${i.track_name}.${t.chr}.${t.start}.${t.stop}.bam`}o.style.display="none";document.body.appendChild(o);o.click();document.body.removeChild(o);return}const o=await n("tkbam",{headers:s,body:l});if(o.error)throw o.error;{const e=i.about.find((e=>e.k=="Slice file size"));if(e)e.v=o.size;else i.about.push({k:"Slice file size",v:o.size})}if(o.time){const e=i.about.find((e=>e.k=="Stream time"));if(e)e.v=Math.round(o.time)+" seconds";else i.about.push({k:"Stream time",v:Math.round(o.time)+" seconds"})}if(o.truncated){if(!i.about.find((e=>e.k=="Truncated")))i.about.push({k:"Truncated",v:"BAM slice size exceeds limit and is truncated"})}else{const e=i.about.findIndex((e=>e.k=="Truncated"));if(e>0)i.about.splice(e,1)}}G.style("display","none");N.style("display","block");B.style("display","block");t.tklst=[];for(const s of e.bam_files){const n={type:"bam",name:s.track_name||"Sample BAM slice",gdcToken:e.gdc_token,gdcFile:{uuid:s.file_id,position:t.chr+":"+t.start+"-"+t.stop},aboutThisFile:s.about};if(e.variant){n.variants=[e.variant]}t.tklst.push(n)}d(C,t.tklst);const a=await import("./block-4f585abe.js").then((function(e){return e.c}));new a.Block(t)}return E}function _(e){e.append("div").style("opacity",.6).html(`<ul>\n\t\t<li>Enter gene, position, SNP, or variant.\n\t\tThe BAM file will be sliced at the given position and visualized.</li>\n\t\t<li>Position</li>\n\t\t<ul><li>Example: chr17:7676339-7676767</li>\n\t\t <li>Coordinates are hg38 and 1-based.</li>\n\t\t</ul>\n\t\t<li>SNP example: rs28934574</li>\n\t\t<li>Variant:</li>\n\t\t<ul>\n\t\t <li>Example: chr2.208248388.C.T</li>\n\t\t <li>Fields are separated by periods. Coordinate is hg38 and 1-based. Reference and alternative alleles are on forward strand.</li>\n\t\t</ul>\n\t\t<li>Supported HGVS formats for variants:</li>\n\t\t<ul>\n\t\t <li>SNV: chr2:g.208248388C>T</li>\n\t\t <li>MNV: chr2:g.119955155_119955159delinsTTTTT</li>\n\t\t <li>Insertion: chr5:g.171410539_171410540insTCTG</li>\n\t\t <li>Deletion: chr10:g.8073734delTTTAGA</li>\n\t\t</ul>\n\t\t</ul>`)}function w(e,t){e.style("display","inline-block").style("color",t?"red":"green").html(t?"❌ "+t:"✓")}function x(e,t,s=false){if(!s){if(!e.gdc_token)throw"GDC token missing";if(typeof e.gdc_token!=="string")throw"GDC token is not string"}if(!e.bam_files.length)throw"No BAM file selected";for(const t of e.bam_files){if(!t.file_id)throw"file uuid is missing";if(typeof t.file_id!=="string")throw"file uuid is not string"}if(e.useSsmOrGene=="unmapped"){return}delete e.position;delete e.variant;if(e.useSsmOrGene=="ssm"){const t=e.ssmInput;if(!t)throw"No variant selected";if(!t.chr)throw"ssmInput.chr missing";if(!Number.isInteger(t.pos))throw"ssmInput.pos not integer";if(!t.ref)throw"ssmInput.ref missing";if(!t.alt)throw"ssmInput.alt missing";e.variant=t;return}const n=e.coordInput;if(!n.chr)throw"No valid position or variant was entered";const[a,i]=p(t,[n.chr]);if(a+i==0)throw"Invalid chromosome name: "+n.chr;const l=a?"chr"+n.chr:n.chr;if(Number.isInteger(n.pos)){if(!n.ref)throw"Reference allele missing from variant string";if(!n.alt)throw"Alternative allele missing from variant string";e.variant={chr:l,pos:n.pos-1,ref:n.ref,alt:n.alt}}else{if(!Number.isInteger(n.start)||!Number.isInteger(n.stop))throw"non-integer start/stop";e.position={chr:l,start:n.start,stop:n.stop}}}export{v as bamsliceui};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{az as t,aF as e,x as s,E as i,q as r,aU as a,aT as o,aS as n}from"./app-f91922b4.js";import l from"./bars.settings-64bb4642.js";import c from"./bars.renderer-f0e5af5a.js";import{h as d}from"./html.legend-3e428f9e.js";import{s as h}from"./svg.legend-c82b153f.js";import p from"./barchart.events-272fd122.js";import{controlsInit as m}from"./controls-8d4972c8.js";import{r as g}from"./table-d6c411fd.js";import{f}from"./termsetting-9a7511e6.js";import{i as u}from"./FilterRxComp-0e75dd8d.js";import"./axis-6cb4f314.js";import"./log-4d74231e.js";import"./controls.btns-bad9e4cf.js";import"./controls.config-e0f394cb.js";import"./controls.overlay-3ac8773d.js";import"./controls.term1-008f4be4.js";import"./controls.divide-d8ac5a9b.js";import"path";class b{constructor(t){this.type="barchart"}preApiFreeze(t){t.download=this.download}async init(t){const e=this.opts;const s=this.opts.controls?null:e.holder.append("div");const i=e.controls?e.holder:e.holder.append("div");this.dom={loadingDiv:i.append("div").style("position","absolute").style("display","none").style("padding","20px").html("Loading ..."),header:e.header,controls:s,holder:i,banner:i.append("div").style("display","none").style("text-align","center").style("padding","24px").style("font-size","16px").style("color","#aaa"),barDiv:i.append("div"),legendDiv:i.append("div").style("margin","5px 5px 15px 5px")};if(this.dom.header)this.dom.header.html("Barchart");this.settings=JSON.parse(l);x(this);D(this);this.renderers={};this.legendRenderer=d(this.dom.legendDiv,{settings:{legendOrientation:"vertical"},handlers:this.handlers},this.dom.barDiv);this.controls={};this.term2toColor={};await this.setControls(this.getState(t));if(this.opts.bar_click_override);else if(!this.opts.bar_click_opts){this.opts.bar_click_opts=["hide_bar"];if(this.app.getState().nav.header_mode==="with_tabs")this.opts.bar_click_opts.push("add_filter")}}async setControls(t){if(this.opts.controls){this.opts.controls.on("downloadClick.barchart",this.download)}else{this.dom.holder.attr("class","pp-termdb-plot-viz").style("display","inline-block").style("min-width","300px").style("margin-left","50px");const e=["term1",{type:"overlay",configKey:"term2",chartType:"barchart",usecase:{target:"barchart",detail:"term2",term1type:t.config.term.term.type},title:"Overlay data",label:"Overlay",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.opts.numericEditMenuVersion||["continuous","discrete"]},{type:"divideBy",configKey:"term0",chartType:"barchart",usecase:{target:"barchart",detail:"term0",term1type:t.config.term0?.term?.type},title:"Divide by data",label:"Divide by",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.opts.numericEditMenuVersion||["continuous","discrete"]},{label:"Orientation",type:"radio",chartType:"barchart",settingsKey:"orientation",options:[{label:"Vertical",value:"vertical"},{label:"Horizontal",value:"horizontal"}]},{label:"Scale",type:"radio",chartType:"barchart",settingsKey:"unit",options:[{label:"Linear",value:"abs"},{label:"Log",value:"log",getDisplayStyle:t=>t.term2?"none":"inline-block"},{label:"Proportion",value:"pct",getDisplayStyle:t=>t.term2?"inline-block":"none"}]},{label:"Multicolor bars",title:"Colors bars using the colors preassigned if available, otherwise generates a color",type:"checkbox",chartType:"barchart",settingsKey:"colorBars",boxLabel:"Yes",getDisplayStyle:t=>t.term2?"none":"table-row"},{label:"Deduplicate",title:"Use separate bars samples that has multiple values or belong to multiple groups",type:"checkbox",chartType:"barchart",settingsKey:"dedup",boxLabel:"Yes",getDisplayStyle:t=>this.chartsData.charts.find((t=>t.serieses.length!=t.dedupedSerieses.length))?"table-row":"none"},{label:"Default color",title:"Default color for bars when there is no overlay",type:"color",chartType:"barchart",settingsKey:"defaultColor"}];if(this.app.getState().termdbConfig.multipleTestingCorrection){e.push({label:"Asterisks",boxLabel:"Visible",type:"checkbox",chartType:"barchart",settingsKey:"asterisksVisible",title:"Display the asterisks"})}this.components={controls:await m({app:this.app,id:this.id,holder:this.dom.controls.attr("class","pp-termdb-plot-controls").style("display","inline-block"),inputs:e})};this.components.controls.on("downloadClick.barchart",this.download)}}reactsTo(t){if(t.type.startsWith("plot_")){return t.id===this.id&&(!t.config.childType||t.config.childType==this.type)}return true}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}return{nav:{header_mode:t.nav.header_mode},termfilter:t.termfilter,config:Object.assign({},e,{settings:{barchart:e.settings.barchart,common:e.settings.common},displaySampleIds:t.termdbConfig.displaySampleIds&&this.app.vocabApi.hasVerifiedToken()}),multipleTestingCorrection:t.termdbConfig.multipleTestingCorrection,bar_click_menu:t.bar_click_menu||{}}}async main(){const t=this.state.config;if(t.chartType!=this.type&&t.childType!=this.type)return;try{this.config=structuredClone(t);if(!this.currServerData)this.dom.barDiv.style("max-width",window.innerWidth+"px");this.prevConfig=this.config||{};if(this.dom.header)this.dom.header.html(this.config.term.term.name+` <span style="opacity:.6;font-size:.7em;margin-left:10px;">BARCHART</span>`);this.toggleLoadingDiv();const s=this.getDataRequestOpts();await this.getDescrStats();const i=await this.app.vocabApi.getNestedChartSeriesData(s);const r=i.data;this.bins=i.bins;this.toggleLoadingDiv("none");this.app.vocabApi.syncTermData(this.config,r,this.prevConfig);this.currServerData=r;if(this.currServerData.refs&&this.currServerData.refs.q){for(const t of this.currServerData.refs.q){if(t.error)throw t.error}}this.term1toColor={};this.term2toColor={};this.updateSettings(this.config);this.colorScale=e(this.config.term2?this.settings.rows.length:this.settings.cols.length);this.chartsData=this.processData(this.currServerData);this.render()}catch(t){throw t}}getDataRequestOpts(){const t=this.config;const e={term:t.term,filter:this.state.termfilter.filter};if(t.term2)e.term2=t.term2;if(t.term0)e.term0=t.term0;return e}async getDescrStats(){const t=[this.config.term];if(this.config.term2)t.push(this.config.term2);if(this.config.term0)t.push(this.config.term0);for(const e of t){if(u(e.term)){const t=await this.app.vocabApi.getDescrStats(e,this.state.termfilter.filter);if(t.error)throw t.error;e.q.descrStats=t.values}}}updateSettings(t){if(!t)return;this.state;const e={term0:t.term0?t.term0.term.id:"",term1:t.term.term.id,term2:t.term2?t.term2.term.id:"",unit:t.settings.barchart.unit,orientation:t.settings.barchart.orientation,asterisksVisible:t.settings.barchart.asterisksVisible,defaultColor:t.settings.barchart.defaultColor,colorBars:t.settings.barchart.colorBars,dedup:t.settings.barchart.dedup,colw:t.settings.common.barwidth,rowh:t.settings.common.barwidth,colspace:t.settings.common.barspace,rowspace:t.settings.common.barspace};this.setExclude(this.config.term,this.config.term2);Object.assign(this.settings,e,this.currServerData.refs||{},{exclude:this.settings.exclude});this.settings.cols=this.settings.dedup?this.currServerData.refs.dedupCols:this.currServerData.refs.cols;this.settings.numCharts=this.currServerData.charts?this.currServerData.charts.length:0;if(!t.term2&&this.settings.unit=="pct"){this.settings.unit="abs"}}mayResetHidden(t,e,s){const i=(t&&t.term.id)+";;"+(e&&e.term.id)+";;"+(s&&s.term.id);if(i===this.currCombinedTermIds)return;for(const s of this.currServerData.charts){if(t.q&&t.q.hiddenValues){this.mayEditHiddenValues(t,s.serieses.length,"term")}if(e&&e.q&&e.q.hiddenValues){for(const t of s.serieses){this.mayEditHiddenValues(e,t.data.length,"term2")}}}this.currCombinedTermIds=i}mayEditHiddenValues(t,e,s){const i=Object.keys(t.q.hiddenValues).filter((e=>t.q.hiddenValues[e])).length;if(i<e)return;for(const e in t.q.hiddenValues){if(!t.q.hiddenValues[e])return;delete t.q.hiddenValues[e]}this.app.save({type:"plot_edit",id:this.id,config:{[s]:t}})}setExclude(t,e){this.settings.exclude.cols=Object.keys(t.q?.hiddenValues||{}).filter((e=>t.q.hiddenValues[e])).map((e=>t.term.type=="categorical"?e:this.settings.cols?.includes(e)?e:t.term.values[e]?.label?t.term.values[e].label:e));this.settings.exclude.rows=!e?.q?.hiddenValues?[]:Object.keys(e.q.hiddenValues).filter((t=>e.q.hiddenValues[t])).map((t=>e.term.type=="categorical"?t:this.settings.rows?.includes(t)?t:e.term.values[t]?.label?e.term.values[t].label:t))}processData(t){this.seriesOrder=this.setMaxVisibleTotals(t);if(!t.charts.length){this.seriesOrder=[]}else if(t.refs.useColOrder){this.seriesOrder=this.settings.cols}const e=t.refs.rows;this.barSorter=(t,e)=>this.seriesOrder.indexOf(t)-this.seriesOrder.indexOf(e);this.overlaySorter=t.refs.useRowOrder?(t,s)=>e.indexOf(t.dataId)-e.indexOf(s.dataId):(t,e)=>this.totalsByDataId[e.dataId]>this.totalsByDataId[t.dataId]?1:this.totalsByDataId[e.dataId]<this.totalsByDataId[t.dataId]?-1:t.dataId<e.dataId?-1:1;this.visibleCharts=t.charts.filter((t=>t.visibleSerieses.length));const s=this.config.term;const i=this.config.term2;const r=t.tests;for(const t in r){const e=r[t];for(const t of e){const e=s.term.values&&t.term1comparison in s.term.values?s.term.values[t.term1comparison].label:t.term1comparison;t.term1Label=e;for(const e of t.term2tests){const t=i.term.values&&e.term2id in i.term.values?i.term.values[e.term2id].label:e.term2id;e.term2Label=t}}}return t}setMaxVisibleTotals(t){this.totalsByDataId={};const e=this.config.term;const s=this.config.term2;const i={};let r=0;for(const a of t.charts){if(!a.settings)a.settings=JSON.parse(l);Object.assign(a.settings,this.settings);a.visibleTotal=0;const t=this.settings.dedup?a.dedupedSerieses:a.serieses;a.visibleSerieses=t.filter((t=>{if(a.settings.exclude.cols.includes(t.seriesId))return false;t.visibleData=t.data.filter((t=>!a.settings.exclude.rows.includes(t.dataId)));t.visibleTotal=t.visibleData.reduce(((t,e)=>t+e.total),0);if(!t.visibleTotal)return false;a.visibleTotal+=t.visibleTotal;if(!(t.seriesId in i))i[t.seriesId]=t.visibleTotal;for(const i of t.data){i.seriesId=t.seriesId;if(e.term.type=="geneVariant"&&!e.q.groupsetting.inuse||s?.term.type=="geneVariant"&&!s?.q.groupsetting.inuse){if(!(i.dataId in this.totalsByDataId)){this.totalsByDataId[i.dataId]={}}this.totalsByDataId[i.dataId][a.chartId]=this.totalsByDataId[i.dataId][a.chartId]?this.totalsByDataId[i.dataId][a.chartId]+i.total:0+i.total}else{if(!(i.dataId in this.totalsByDataId)){this.totalsByDataId[i.dataId]=0}this.totalsByDataId[i.dataId]+=i.total}}return true}));a.settings.colLabels=a.visibleSerieses.map((t=>{const i=t.seriesId;const r=e.term.values&&i in e.term.values?e.term.values[i].label:i;const a=t&&"AF"in t?", AF="+t.AF:"";const o=s&&s.term.type=="condition"&&s.q.value_by_computable_grade?"":`, n=${t.visibleTotal}`;return{id:i,label:r+a+o}}));a.maxVisibleSeriesTotal=a.visibleSerieses.reduce(((t,e)=>e.visibleTotal>t?e.visibleTotal:t),0);if(a.maxVisibleSeriesTotal>r){r=a.maxVisibleSeriesTotal}}for(const e of t.charts){e.maxVisibleAcrossCharts=r}return Object.keys(i).sort(((t,e)=>i[e]-i[t]))}sortStacking(t,e,s){this.term1toColor[t.seriesId]=this.settings.colorBars?this.getColor(this.config.term.term,t.seriesId,this.bins?.[1]):this.settings.defaultColor;t.visibleData.sort(this.overlaySorter);let i=0;for(const r of t.visibleData){r.colgrp="-";r.rowgrp="-";r.chartId=e.chartId;r.seriesId=t.seriesId;if(s.tests){r.groupPvalues=s.tests[e.chartId].find((e=>e.term1comparison===t.seriesId))}r.seriesTotal=t.total;r.chartTotal=e.visibleTotal;r.logTotal=Math.log10(r.total);i+=r.logTotal;this.setTerm2Color(r);r.color=this.term2toColor[r.dataId]||this.term1toColor[t.seriesId]}if(i>e.maxSeriesLogTotal){e.maxSeriesLogTotal=i}for(const e of t.data){if(e.color)continue;this.setTerm2Color(e);e.color=this.term2toColor[e.dataId]||this.term1toColor[t.seriesId]}}setTerm2Color(t){if(!this.config.term2)return;this.term2toColor[t.dataId]=this.getColor(this.config.term2,t.dataId,this.bins?.[2])}getColor(t,e,i){if(!t.term)return;if(t.term.values){for(const[s,i]of Object.entries(t.term.values)){if(!i.color)continue;if(s===e)return i.color;if(i.label===e)return i.color}}const r=i?.find((t=>t.label==e));if(r?.color)return r.color;if(t.term.type=="geneVariant"&&!t.q.groupsetting.inuse)return this.getMutationColor(e);return s(this.colorScale(e)).toString()}getMutationColor(t){for(const e of Object.values(i))if(e.label===t&&e.color)return e.color;for(const e in i){if(i[e].label===t&&i[e].color)return i[e].color}}getLegendGrps(){const t=this.config.term;const e=this.config.term2;if(t.term.type=="geneVariant"&&!t.q.groupsetting.inuse||e?.term.type=="geneVariant"&&!e?.q.groupsetting.inuse){const t=[];for(const e of this.chartsData.charts){t.push(this.getOneLegendGrps(e))}return t}return this.getOneLegendGrps()}getOneLegendGrps(t){const e=[];const s=this.settings;const i=this.config.term;const r=this.config.term2;const a="color: #aaa; font-weight: 400";if(i.q.descrStats){const t=i.q.descrStats.map((t=>({text:`${t.label}: ${t.value}`,noIcon:true})));const s=r?`Descriptive statistics: ${i.term.name}`:"Descriptive statistics";const o=`<span style="${a}">${s}</span>`;e.push({name:o,items:t})}if(r?.q.descrStats){const t=r.q.descrStats.map((t=>({text:`${t.label}: ${t.value}`,noIcon:true})));const s=`Descriptive statistics: ${r.term.name}`;const i=`<span style="${a}">${s}</span>`;e.push({name:i,items:t})}if(s.cols&&s.exclude.cols.length){const o=(t,e)=>t+e.total;const n=s.exclude.cols.filter((t=>s.cols.includes(t))).flatMap((e=>{const s=t=>t.seriesId==e;const a=r?.term?.type=="condition"?0:i.term.type=="geneVariant"&&!i.q.groupsetting.inuse||r?.term.type=="geneVariant"&&!r?.q.groupsetting.inuse?t.serieses.filter(s).reduce(o,0):this.currServerData.charts.reduce(((t,e)=>t+e.serieses.filter(s).reduce(o,0)),0);if(!a&&!r?.term?.type)return[];const n=i.term.values&&e in i.term.values?i.term.values[e].label:e;const l=a?", n="+a:"";return[{id:e,text:n+l,color:"#fff",textColor:"#000",border:"1px solid #333",noIcon:true,type:"col",isHidden:true,hiddenOpacity:1}]})).sort(this.barSorter);if(n.length){const t=r?i.term.name:"Other categories";e.push({name:`<span style="${a}">${t}</span>`,items:n})}}if(s.rows&&!s.hidelegend&&r&&this.term2toColor){const i=r.term.type!="condition"||!r.q?"":r.q.value_by_max_grade?"max. grade":r.q.value_by_most_recent?"most recent":"";e.push({name:`<span style="${a}">`+r.term.name+(i?", "+i:"")+"</span>",items:s.rows.flatMap((e=>{const i=t?this.totalsByDataId[e]?.[t.chartId]:this.totalsByDataId[e];if(!i)return[];const a=i?", n="+i:"";const o=r.term.values&&e in r.term.values?r.term.values[e].label:e;return[{dataId:e,text:o+a,color:this.term2toColor[e],type:"row",isHidden:s.exclude.rows.includes(e)}]})).sort(this.overlaySorter)})}if(r&&this.state.multipleTestingCorrection){let t=0;for(const e in this.chartsData.tests){t+=this.chartsData.tests[e].reduce(((t,e)=>t+e.term2tests.filter((t=>!t.skipped)).length),0)}e.push({name:`<span style="${a}">Statistical Significance</span>`,items:[{text:`* p-value < (0.05 / ${t} tests)`,noEditColor:true}]})}return e}toggleLoadingDiv(t=""){if(t!="none"){this.dom.loadingDiv.style("opacity",0).style("display",t).transition().duration("loadingWait"in this?this.loadingWait:0).style("opacity",1)}else{this.dom.loadingDiv.style("display",t)}this.loadingWait=1e3}}const y=t(b);const v=y;function x(t){t.render=function(){const e=t.dom.barDiv.selectAll(".pp-sbar-div").data(t.visibleCharts,(t=>t.chartId));e.exit().each(t.exitChart);e.each(t.updateChart);e.enter().append("div").each(t.addChart);t.dom.holder.selectAll(".pp-chart-title").style("display",t.visibleCharts.length<2?"none":"block");const s=t.getLegendGrps();t.legendRenderer(s);if(!t.visibleCharts.length){const e=t.settings.exclude.cols.length||t.settings.exclude.rows.length?`<br/><span>click on a legend label below to display the barchart</span>`:"";t.dom.banner.html(`<span>No visible barchart data to render</span>${e}`).style("display","block");t.dom.legendDiv.selectAll("*").remove()}else{t.dom.banner.text("").style("display","none")}};t.exitChart=function(e){delete t.renderers[e.chartId];r(this).remove()};t.updateChart=function(s){s.settings.cols.sort(t.barSorter);s.maxAcrossCharts=t.chartsData.maxAcrossCharts;s.handlers=t.handlers;s.maxSeriesLogTotal=0;s.visibleSerieses.forEach((e=>t.sortStacking(e,s,t.chartsData)));t.renderers[s.chartId](s);const i=r(this);i.select(".pp-sbar-div-chartLengends").selectAll("*").remove();if(t.chartsData.tests&&t.chartsData.tests[s.chartId]){e(s,i)}};t.addChart=function(s,i){const a=r(this).attr("class","pp-sbar-div").style("display","inline-block").style("padding","20px").style("vertical-align","top");t.renderers[s.chartId]=c(t,r(this));s.settings.cols.sort(t.barSorter);s.maxAcrossCharts=t.chartsData.maxAcrossCharts;s.handlers=t.handlers;s.maxSeriesLogTotal=0;s.visibleSerieses.forEach((e=>t.sortStacking(e,s,t.chartsData)));t.renderers[s.chartId](s);a.append("div").attr("class","pp-sbar-div-chartLengends").attr("data-testid","sjpcb-bars-chartLengends").style("vertical-align","top").style("margin","10px 10px 10px 30px").style("display","none");if(t.chartsData.tests&&t.chartsData.tests[s.chartId]){e(s,a)}};function e(e,i){const r=i.select(".pp-sbar-div-chartLengends").style("display","inline-block").style("vertical-align","top").style("text-align","center").append("div");t.chartsData.tests[e.chartId].sort((function(e,s){return t.settings.cols.indexOf(e.term1comparison)-t.settings.cols.indexOf(s.term1comparison)}));for(const s of t.chartsData.tests[e.chartId]){s.term2tests.sort((function(e,s){return t.chartsData.refs.rows.indexOf(e.term2id)-t.chartsData.refs.rows.indexOf(s.term2id)}))}const a=[{label:"Row 1"},{label:"Row 2"},{label:"Column 1"},{label:"Column 2"},{label:"P-value"}];const o=t.chartsData.tests[e.chartId].every((t=>t.term2tests.every((t=>!t.skipped))));const n=[];const l=t.chartsData.tests[e.chartId].filter((t=>e.visibleSerieses.some((e=>e.seriesId===t.term1comparison))));for(const[t,i]of l.entries()){if(l.length==2&&t==1){break}const r=e.visibleSerieses.find((t=>t.seriesId===i.term1comparison));const a=i.term2tests.filter((t=>r.visibleData.some((e=>e.dataId===t.term2id))));for(const[t,e]of a.entries()){if(a.length==2&&t==1){break}n.push([{value:`${i.term1Label}`},{value:l.length==2?l[1].term1Label:s(i.term1Label)},{value:e.term2Label},{value:a.length==2?a[1].term2Label:s(e.term2Label)},{html:e.skipped?"N/A":e.pvalue>1e-4?Number(e.pvalue.toFixed(4)):Number(e.pvalue.toPrecision(4)).toExponential()}])}}r.append("div").style("font-weight","bold").style("padding-bottom","0.5em").html("2x2 Association test (Fisher's exact test)").style("font-size","0.9em");const c=r.append("div").style("font-size","0.9em");g({columns:a,rows:n,div:c,showLines:false,maxWidth:"70vw",maxHeight:`${e.svgh-100}px`,resize:true});c.append("div").style("margin-top","10px").style("text-align","left").style("font-size","10px").style("font-weight","normal").html(o?"":"N/A: association test skipped because of limited sample size <br>")}function s(t){if(t.toUpperCase().startsWith("NOT ")){return t.substring(4)}else{return"not "+t}}}function D(t){t.handlers=p(t);t.download=function(){if(!t.state)return;const e=[];const s={x:undefined,y:undefined};const i=[];let o=0,n=0,l=0;let c=0,d=0;t.dom.barDiv.selectAll(".sjpcb-bars-mainG").each((function(){e.push(this);const t=this.getBBox();if(t.width>o)o=t.width;if(t.height>n)n=t.height;const a=Math.round(this.parentNode.parentNode.getBoundingClientRect().y);if(!d){c=a;d++}else if(Math.abs(a-c)<5){d++}const h=r(this).attr("transform").split("translate(")[1].split(")")[0].split(",").map((t=>+t.trim()));if(s.x===undefined||h[0]>s.x)s.x=+h[0];if(s.y===undefined||h[1]>s.y)s.y=+h[1];const p=this.parentNode.parentNode.firstChild;const m=p.getBoundingClientRect();if(m.width>o)o=m.width;if(m.height>l)l=m.height;i.push({text:p.innerText,styles:window.getComputedStyle(p)})}));o+=30;n+=30;const p=document.createElementNS("http://www.w3.org/2000/svg","svg");const m=r(p).style("display","block").style("opacity",1).attr("width",d*o).attr("height",Math.floor(e.length/d)*n);const g=window.getComputedStyle(document.querySelector(".pp-bars-svg"));for(const t of g){if(t.startsWith("font"))m.style(t,g.getPropertyValue(t))}e.forEach(((t,e)=>{const a=t.cloneNode(true);const c=e%d;const h=Math.floor(e/d);const m={x:c*o+s.x,y:h*n+s.y};const g=r(p).append("text").attr("transform","translate("+m.x+","+m.y+")").text(i[e].text);for(const t of i[e].styles){if(t.startsWith("font"))g.style(t,i[e].styles.getPropertyValue(t))}r(a).attr("transform","translate("+m.x+","+(m.y+l)+")");p.appendChild(a)}));const f=r("body").append("div").style("opacity",0);f.node().appendChild(p);t.svgLegendRenderer=h({holder:m.append("g"),rectFillFxn:t=>t.color,iconStroke:"#aaa"});t.settings;const u=t.dom.barDiv.select("svg").node().getBoundingClientRect();let b=t.getLegendGrps();b.forEach((t=>{t.name=t.name.replace(/<[^>]*>?/gm,"");if(t.items)t.items=t.items.filter((t=>!t.isHidden))}));b=b.filter((t=>t.items.length&&!t.name.includes("tatistic")));const y=14;t.svgLegendRenderer(b,{settings:Object.assign({ontop:false,lineh:25,padx:5,padleft:0,padright:20,padbtm:30,fontsize:y,iconh:y-2,iconw:y-2,hangleft:1,linesep:false},{svgw:t.visibleCharts.length*u.width,svgh:u.height,dimensions:{xOffset:50},padleft:50})});const v=t.dom.legendDiv.node().getBoundingClientRect();r(p).attr("height",u.height+v.height+30);if(v.width>u.width)r(p).attr("width",v.width);f.remove();const x=t.config.term.term.name+" barchart";a(p,x,{apply_dom_styles:true})}}function w(t){return{orientation:"horizontal",unit:"abs",overlay:"none",divideBy:"none",rowlabelw:250,asterisksVisible:t?.getState()?.termdbConfig?.multipleTestingCorrection?true:false,defaultColor:o,colorBars:false,dedup:false}}async function C(t,e){if(!t.term)throw"barchart getPlotConfig: opts.term{} missing";try{await f(t.term,e.vocabApi);if(t.term2)await f(t.term2,e.vocabApi);if(t.term0)await f(t.term0,e.vocabApi)}catch(t){throw`${t} [barchart getPlotConfig()]`}const s={id:t.term.term.id,settings:{controls:{term2:null,term0:null},common:{use_logscale:false,use_percentage:false,barheight:300,barwidth:20,barspace:2},barchart:w(e)}};return n(s,t)}export{y as barInit,v as componentInit,w as getDefaultBarSettings,C as getPlotConfig};
|
|
1
|
+
import{az as t,aF as e,x as s,E as i,q as r,aU as a,aT as o,aS as n}from"./app-71453429.js";import l from"./bars.settings-64bb4642.js";import c from"./bars.renderer-c46d3f44.js";import{h as d}from"./html.legend-ef8066dd.js";import{s as h}from"./svg.legend-28652faa.js";import p from"./barchart.events-e24facf7.js";import{controlsInit as m}from"./controls-0467d2ec.js";import{r as g}from"./table-1dae543a.js";import{f}from"./termsetting-636d2271.js";import{i as u}from"./FilterRxComp-fc769f34.js";import"./axis-6cb4f314.js";import"./log-ca1e2a74.js";import"./controls.btns-ad7b28a2.js";import"./controls.config-6cf816fb.js";import"./controls.overlay-3a55c2ec.js";import"./controls.term1-59f4cd60.js";import"./controls.divide-3c0d52d7.js";import"path";class b{constructor(t){this.type="barchart"}preApiFreeze(t){t.download=this.download}async init(t){const e=this.opts;const s=this.opts.controls?null:e.holder.append("div");const i=e.controls?e.holder:e.holder.append("div");this.dom={loadingDiv:i.append("div").style("position","absolute").style("display","none").style("padding","20px").html("Loading ..."),header:e.header,controls:s,holder:i,banner:i.append("div").style("display","none").style("text-align","center").style("padding","24px").style("font-size","16px").style("color","#aaa"),barDiv:i.append("div"),legendDiv:i.append("div").style("margin","5px 5px 15px 5px")};if(this.dom.header)this.dom.header.html("Barchart");this.settings=JSON.parse(l);x(this);D(this);this.renderers={};this.legendRenderer=d(this.dom.legendDiv,{settings:{legendOrientation:"vertical"},handlers:this.handlers},this.dom.barDiv);this.controls={};this.term2toColor={};await this.setControls(this.getState(t));if(this.opts.bar_click_override);else if(!this.opts.bar_click_opts){this.opts.bar_click_opts=["hide_bar"];if(this.app.getState().nav.header_mode==="with_tabs")this.opts.bar_click_opts.push("add_filter")}}async setControls(t){if(this.opts.controls){this.opts.controls.on("downloadClick.barchart",this.download)}else{this.dom.holder.attr("class","pp-termdb-plot-viz").style("display","inline-block").style("min-width","300px").style("margin-left","50px");const e=["term1",{type:"overlay",configKey:"term2",chartType:"barchart",usecase:{target:"barchart",detail:"term2",term1type:t.config.term.term.type},title:"Overlay data",label:"Overlay",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.opts.numericEditMenuVersion||["continuous","discrete"]},{type:"divideBy",configKey:"term0",chartType:"barchart",usecase:{target:"barchart",detail:"term0",term1type:t.config.term0?.term?.type},title:"Divide by data",label:"Divide by",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.opts.numericEditMenuVersion||["continuous","discrete"]},{label:"Orientation",type:"radio",chartType:"barchart",settingsKey:"orientation",options:[{label:"Vertical",value:"vertical"},{label:"Horizontal",value:"horizontal"}]},{label:"Scale",type:"radio",chartType:"barchart",settingsKey:"unit",options:[{label:"Linear",value:"abs"},{label:"Log",value:"log",getDisplayStyle:t=>t.term2?"none":"inline-block"},{label:"Proportion",value:"pct",getDisplayStyle:t=>t.term2?"inline-block":"none"}]},{label:"Multicolor bars",title:"Colors bars using the colors preassigned if available, otherwise generates a color",type:"checkbox",chartType:"barchart",settingsKey:"colorBars",boxLabel:"Yes",getDisplayStyle:t=>t.term2?"none":"table-row"},{label:"Deduplicate",title:"Use separate bars samples that has multiple values or belong to multiple groups",type:"checkbox",chartType:"barchart",settingsKey:"dedup",boxLabel:"Yes",getDisplayStyle:t=>this.chartsData.charts.find((t=>t.serieses.length!=t.dedupedSerieses.length))?"table-row":"none"},{label:"Default color",title:"Default color for bars when there is no overlay",type:"color",chartType:"barchart",settingsKey:"defaultColor"}];if(this.app.getState().termdbConfig.multipleTestingCorrection){e.push({label:"Asterisks",boxLabel:"Visible",type:"checkbox",chartType:"barchart",settingsKey:"asterisksVisible",title:"Display the asterisks"})}this.components={controls:await m({app:this.app,id:this.id,holder:this.dom.controls.attr("class","pp-termdb-plot-controls").style("display","inline-block"),inputs:e})};this.components.controls.on("downloadClick.barchart",this.download)}}reactsTo(t){if(t.type.startsWith("plot_")){return t.id===this.id&&(!t.config.childType||t.config.childType==this.type)}return true}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}return{nav:{header_mode:t.nav.header_mode},termfilter:t.termfilter,config:Object.assign({},e,{settings:{barchart:e.settings.barchart,common:e.settings.common},displaySampleIds:t.termdbConfig.displaySampleIds&&this.app.vocabApi.hasVerifiedToken()}),multipleTestingCorrection:t.termdbConfig.multipleTestingCorrection,bar_click_menu:t.bar_click_menu||{}}}async main(){const t=this.state.config;if(t.chartType!=this.type&&t.childType!=this.type)return;try{this.config=structuredClone(t);if(!this.currServerData)this.dom.barDiv.style("max-width",window.innerWidth+"px");this.prevConfig=this.config||{};if(this.dom.header)this.dom.header.html(this.config.term.term.name+` <span style="opacity:.6;font-size:.7em;margin-left:10px;">BARCHART</span>`);this.toggleLoadingDiv();const s=this.getDataRequestOpts();await this.getDescrStats();const i=await this.app.vocabApi.getNestedChartSeriesData(s);const r=i.data;this.bins=i.bins;this.toggleLoadingDiv("none");this.app.vocabApi.syncTermData(this.config,r,this.prevConfig);this.currServerData=r;if(this.currServerData.refs&&this.currServerData.refs.q){for(const t of this.currServerData.refs.q){if(t.error)throw t.error}}this.term1toColor={};this.term2toColor={};this.updateSettings(this.config);this.colorScale=e(this.config.term2?this.settings.rows.length:this.settings.cols.length);this.chartsData=this.processData(this.currServerData);this.render()}catch(t){throw t}}getDataRequestOpts(){const t=this.config;const e={term:t.term,filter:this.state.termfilter.filter};if(t.term2)e.term2=t.term2;if(t.term0)e.term0=t.term0;return e}async getDescrStats(){const t=[this.config.term];if(this.config.term2)t.push(this.config.term2);if(this.config.term0)t.push(this.config.term0);for(const e of t){if(u(e.term)){const t=await this.app.vocabApi.getDescrStats(e,this.state.termfilter.filter);if(t.error)throw t.error;e.q.descrStats=t.values}}}updateSettings(t){if(!t)return;this.state;const e={term0:t.term0?t.term0.term.id:"",term1:t.term.term.id,term2:t.term2?t.term2.term.id:"",unit:t.settings.barchart.unit,orientation:t.settings.barchart.orientation,asterisksVisible:t.settings.barchart.asterisksVisible,defaultColor:t.settings.barchart.defaultColor,colorBars:t.settings.barchart.colorBars,dedup:t.settings.barchart.dedup,colw:t.settings.common.barwidth,rowh:t.settings.common.barwidth,colspace:t.settings.common.barspace,rowspace:t.settings.common.barspace};this.setExclude(this.config.term,this.config.term2);Object.assign(this.settings,e,this.currServerData.refs||{},{exclude:this.settings.exclude});this.settings.cols=this.settings.dedup?this.currServerData.refs.dedupCols:this.currServerData.refs.cols;this.settings.numCharts=this.currServerData.charts?this.currServerData.charts.length:0;if(!t.term2&&this.settings.unit=="pct"){this.settings.unit="abs"}}mayResetHidden(t,e,s){const i=(t&&t.term.id)+";;"+(e&&e.term.id)+";;"+(s&&s.term.id);if(i===this.currCombinedTermIds)return;for(const s of this.currServerData.charts){if(t.q&&t.q.hiddenValues){this.mayEditHiddenValues(t,s.serieses.length,"term")}if(e&&e.q&&e.q.hiddenValues){for(const t of s.serieses){this.mayEditHiddenValues(e,t.data.length,"term2")}}}this.currCombinedTermIds=i}mayEditHiddenValues(t,e,s){const i=Object.keys(t.q.hiddenValues).filter((e=>t.q.hiddenValues[e])).length;if(i<e)return;for(const e in t.q.hiddenValues){if(!t.q.hiddenValues[e])return;delete t.q.hiddenValues[e]}this.app.save({type:"plot_edit",id:this.id,config:{[s]:t}})}setExclude(t,e){this.settings.exclude.cols=Object.keys(t.q?.hiddenValues||{}).filter((e=>t.q.hiddenValues[e])).map((e=>t.term.type=="categorical"?e:this.settings.cols?.includes(e)?e:t.term.values[e]?.label?t.term.values[e].label:e));this.settings.exclude.rows=!e?.q?.hiddenValues?[]:Object.keys(e.q.hiddenValues).filter((t=>e.q.hiddenValues[t])).map((t=>e.term.type=="categorical"?t:this.settings.rows?.includes(t)?t:e.term.values[t]?.label?e.term.values[t].label:t))}processData(t){this.seriesOrder=this.setMaxVisibleTotals(t);if(!t.charts.length){this.seriesOrder=[]}else if(t.refs.useColOrder){this.seriesOrder=this.settings.cols}const e=t.refs.rows;this.barSorter=(t,e)=>this.seriesOrder.indexOf(t)-this.seriesOrder.indexOf(e);this.overlaySorter=t.refs.useRowOrder?(t,s)=>e.indexOf(t.dataId)-e.indexOf(s.dataId):(t,e)=>this.totalsByDataId[e.dataId]>this.totalsByDataId[t.dataId]?1:this.totalsByDataId[e.dataId]<this.totalsByDataId[t.dataId]?-1:t.dataId<e.dataId?-1:1;this.visibleCharts=t.charts.filter((t=>t.visibleSerieses.length));const s=this.config.term;const i=this.config.term2;const r=t.tests;for(const t in r){const e=r[t];for(const t of e){const e=s.term.values&&t.term1comparison in s.term.values?s.term.values[t.term1comparison].label:t.term1comparison;t.term1Label=e;for(const e of t.term2tests){const t=i.term.values&&e.term2id in i.term.values?i.term.values[e.term2id].label:e.term2id;e.term2Label=t}}}return t}setMaxVisibleTotals(t){this.totalsByDataId={};const e=this.config.term;const s=this.config.term2;const i={};let r=0;for(const a of t.charts){if(!a.settings)a.settings=JSON.parse(l);Object.assign(a.settings,this.settings);a.visibleTotal=0;const t=this.settings.dedup?a.dedupedSerieses:a.serieses;a.visibleSerieses=t.filter((t=>{if(a.settings.exclude.cols.includes(t.seriesId))return false;t.visibleData=t.data.filter((t=>!a.settings.exclude.rows.includes(t.dataId)));t.visibleTotal=t.visibleData.reduce(((t,e)=>t+e.total),0);if(!t.visibleTotal)return false;a.visibleTotal+=t.visibleTotal;if(!(t.seriesId in i))i[t.seriesId]=t.visibleTotal;for(const i of t.data){i.seriesId=t.seriesId;if(e.term.type=="geneVariant"&&!e.q.groupsetting.inuse||s?.term.type=="geneVariant"&&!s?.q.groupsetting.inuse){if(!(i.dataId in this.totalsByDataId)){this.totalsByDataId[i.dataId]={}}this.totalsByDataId[i.dataId][a.chartId]=this.totalsByDataId[i.dataId][a.chartId]?this.totalsByDataId[i.dataId][a.chartId]+i.total:0+i.total}else{if(!(i.dataId in this.totalsByDataId)){this.totalsByDataId[i.dataId]=0}this.totalsByDataId[i.dataId]+=i.total}}return true}));a.settings.colLabels=a.visibleSerieses.map((t=>{const i=t.seriesId;const r=e.term.values&&i in e.term.values?e.term.values[i].label:i;const a=t&&"AF"in t?", AF="+t.AF:"";const o=s&&s.term.type=="condition"&&s.q.value_by_computable_grade?"":`, n=${t.visibleTotal}`;return{id:i,label:r+a+o}}));a.maxVisibleSeriesTotal=a.visibleSerieses.reduce(((t,e)=>e.visibleTotal>t?e.visibleTotal:t),0);if(a.maxVisibleSeriesTotal>r){r=a.maxVisibleSeriesTotal}}for(const e of t.charts){e.maxVisibleAcrossCharts=r}return Object.keys(i).sort(((t,e)=>i[e]-i[t]))}sortStacking(t,e,s){this.term1toColor[t.seriesId]=this.settings.colorBars?this.getColor(this.config.term.term,t.seriesId,this.bins?.[1]):this.settings.defaultColor;t.visibleData.sort(this.overlaySorter);let i=0;for(const r of t.visibleData){r.colgrp="-";r.rowgrp="-";r.chartId=e.chartId;r.seriesId=t.seriesId;if(s.tests){r.groupPvalues=s.tests[e.chartId].find((e=>e.term1comparison===t.seriesId))}r.seriesTotal=t.total;r.chartTotal=e.visibleTotal;r.logTotal=Math.log10(r.total);i+=r.logTotal;this.setTerm2Color(r);r.color=this.term2toColor[r.dataId]||this.term1toColor[t.seriesId]}if(i>e.maxSeriesLogTotal){e.maxSeriesLogTotal=i}for(const e of t.data){if(e.color)continue;this.setTerm2Color(e);e.color=this.term2toColor[e.dataId]||this.term1toColor[t.seriesId]}}setTerm2Color(t){if(!this.config.term2)return;this.term2toColor[t.dataId]=this.getColor(this.config.term2,t.dataId,this.bins?.[2])}getColor(t,e,i){if(!t.term)return;if(t.term.values){for(const[s,i]of Object.entries(t.term.values)){if(!i.color)continue;if(s===e)return i.color;if(i.label===e)return i.color}}const r=i?.find((t=>t.label==e));if(r?.color)return r.color;if(t.term.type=="geneVariant"&&!t.q.groupsetting.inuse)return this.getMutationColor(e);return s(this.colorScale(e)).toString()}getMutationColor(t){for(const e of Object.values(i))if(e.label===t&&e.color)return e.color;for(const e in i){if(i[e].label===t&&i[e].color)return i[e].color}}getLegendGrps(){const t=this.config.term;const e=this.config.term2;if(t.term.type=="geneVariant"&&!t.q.groupsetting.inuse||e?.term.type=="geneVariant"&&!e?.q.groupsetting.inuse){const t=[];for(const e of this.chartsData.charts){t.push(this.getOneLegendGrps(e))}return t}return this.getOneLegendGrps()}getOneLegendGrps(t){const e=[];const s=this.settings;const i=this.config.term;const r=this.config.term2;const a="color: #aaa; font-weight: 400";if(i.q.descrStats){const t=i.q.descrStats.map((t=>({text:`${t.label}: ${t.value}`,noIcon:true})));const s=r?`Descriptive statistics: ${i.term.name}`:"Descriptive statistics";const o=`<span style="${a}">${s}</span>`;e.push({name:o,items:t})}if(r?.q.descrStats){const t=r.q.descrStats.map((t=>({text:`${t.label}: ${t.value}`,noIcon:true})));const s=`Descriptive statistics: ${r.term.name}`;const i=`<span style="${a}">${s}</span>`;e.push({name:i,items:t})}if(s.cols&&s.exclude.cols.length){const o=(t,e)=>t+e.total;const n=s.exclude.cols.filter((t=>s.cols.includes(t))).flatMap((e=>{const s=t=>t.seriesId==e;const a=r?.term?.type=="condition"?0:i.term.type=="geneVariant"&&!i.q.groupsetting.inuse||r?.term.type=="geneVariant"&&!r?.q.groupsetting.inuse?t.serieses.filter(s).reduce(o,0):this.currServerData.charts.reduce(((t,e)=>t+e.serieses.filter(s).reduce(o,0)),0);if(!a&&!r?.term?.type)return[];const n=i.term.values&&e in i.term.values?i.term.values[e].label:e;const l=a?", n="+a:"";return[{id:e,text:n+l,color:"#fff",textColor:"#000",border:"1px solid #333",noIcon:true,type:"col",isHidden:true,hiddenOpacity:1}]})).sort(this.barSorter);if(n.length){const t=r?i.term.name:"Other categories";e.push({name:`<span style="${a}">${t}</span>`,items:n})}}if(s.rows&&!s.hidelegend&&r&&this.term2toColor){const i=r.term.type!="condition"||!r.q?"":r.q.value_by_max_grade?"max. grade":r.q.value_by_most_recent?"most recent":"";e.push({name:`<span style="${a}">`+r.term.name+(i?", "+i:"")+"</span>",items:s.rows.flatMap((e=>{const i=t?this.totalsByDataId[e]?.[t.chartId]:this.totalsByDataId[e];if(!i)return[];const a=i?", n="+i:"";const o=r.term.values&&e in r.term.values?r.term.values[e].label:e;return[{dataId:e,text:o+a,color:this.term2toColor[e],type:"row",isHidden:s.exclude.rows.includes(e)}]})).sort(this.overlaySorter)})}if(r&&this.state.multipleTestingCorrection){let t=0;for(const e in this.chartsData.tests){t+=this.chartsData.tests[e].reduce(((t,e)=>t+e.term2tests.filter((t=>!t.skipped)).length),0)}e.push({name:`<span style="${a}">Statistical Significance</span>`,items:[{text:`* p-value < (0.05 / ${t} tests)`,noEditColor:true}]})}return e}toggleLoadingDiv(t=""){if(t!="none"){this.dom.loadingDiv.style("opacity",0).style("display",t).transition().duration("loadingWait"in this?this.loadingWait:0).style("opacity",1)}else{this.dom.loadingDiv.style("display",t)}this.loadingWait=1e3}}const y=t(b);const v=y;function x(t){t.render=function(){const e=t.dom.barDiv.selectAll(".pp-sbar-div").data(t.visibleCharts,(t=>t.chartId));e.exit().each(t.exitChart);e.each(t.updateChart);e.enter().append("div").each(t.addChart);t.dom.holder.selectAll(".pp-chart-title").style("display",t.visibleCharts.length<2?"none":"block");const s=t.getLegendGrps();t.legendRenderer(s);if(!t.visibleCharts.length){const e=t.settings.exclude.cols.length||t.settings.exclude.rows.length?`<br/><span>click on a legend label below to display the barchart</span>`:"";t.dom.banner.html(`<span>No visible barchart data to render</span>${e}`).style("display","block");t.dom.legendDiv.selectAll("*").remove()}else{t.dom.banner.text("").style("display","none")}};t.exitChart=function(e){delete t.renderers[e.chartId];r(this).remove()};t.updateChart=function(s){s.settings.cols.sort(t.barSorter);s.maxAcrossCharts=t.chartsData.maxAcrossCharts;s.handlers=t.handlers;s.maxSeriesLogTotal=0;s.visibleSerieses.forEach((e=>t.sortStacking(e,s,t.chartsData)));t.renderers[s.chartId](s);const i=r(this);i.select(".pp-sbar-div-chartLengends").selectAll("*").remove();if(t.chartsData.tests&&t.chartsData.tests[s.chartId]){e(s,i)}};t.addChart=function(s,i){const a=r(this).attr("class","pp-sbar-div").style("display","inline-block").style("padding","20px").style("vertical-align","top");t.renderers[s.chartId]=c(t,r(this));s.settings.cols.sort(t.barSorter);s.maxAcrossCharts=t.chartsData.maxAcrossCharts;s.handlers=t.handlers;s.maxSeriesLogTotal=0;s.visibleSerieses.forEach((e=>t.sortStacking(e,s,t.chartsData)));t.renderers[s.chartId](s);a.append("div").attr("class","pp-sbar-div-chartLengends").attr("data-testid","sjpcb-bars-chartLengends").style("vertical-align","top").style("margin","10px 10px 10px 30px").style("display","none");if(t.chartsData.tests&&t.chartsData.tests[s.chartId]){e(s,a)}};function e(e,i){const r=i.select(".pp-sbar-div-chartLengends").style("display","inline-block").style("vertical-align","top").style("text-align","center").append("div");t.chartsData.tests[e.chartId].sort((function(e,s){return t.settings.cols.indexOf(e.term1comparison)-t.settings.cols.indexOf(s.term1comparison)}));for(const s of t.chartsData.tests[e.chartId]){s.term2tests.sort((function(e,s){return t.chartsData.refs.rows.indexOf(e.term2id)-t.chartsData.refs.rows.indexOf(s.term2id)}))}const a=[{label:"Row 1"},{label:"Row 2"},{label:"Column 1"},{label:"Column 2"},{label:"P-value"}];const o=t.chartsData.tests[e.chartId].every((t=>t.term2tests.every((t=>!t.skipped))));const n=[];const l=t.chartsData.tests[e.chartId].filter((t=>e.visibleSerieses.some((e=>e.seriesId===t.term1comparison))));for(const[t,i]of l.entries()){if(l.length==2&&t==1){break}const r=e.visibleSerieses.find((t=>t.seriesId===i.term1comparison));const a=i.term2tests.filter((t=>r.visibleData.some((e=>e.dataId===t.term2id))));for(const[t,e]of a.entries()){if(a.length==2&&t==1){break}n.push([{value:`${i.term1Label}`},{value:l.length==2?l[1].term1Label:s(i.term1Label)},{value:e.term2Label},{value:a.length==2?a[1].term2Label:s(e.term2Label)},{html:e.skipped?"N/A":e.pvalue>1e-4?Number(e.pvalue.toFixed(4)):Number(e.pvalue.toPrecision(4)).toExponential()}])}}r.append("div").style("font-weight","bold").style("padding-bottom","0.5em").html("2x2 Association test (Fisher's exact test)").style("font-size","0.9em");const c=r.append("div").style("font-size","0.9em");g({columns:a,rows:n,div:c,showLines:false,maxWidth:"70vw",maxHeight:`${e.svgh-100}px`,resize:true});c.append("div").style("margin-top","10px").style("text-align","left").style("font-size","10px").style("font-weight","normal").html(o?"":"N/A: association test skipped because of limited sample size <br>")}function s(t){if(t.toUpperCase().startsWith("NOT ")){return t.substring(4)}else{return"not "+t}}}function D(t){t.handlers=p(t);t.download=function(){if(!t.state)return;const e=[];const s={x:undefined,y:undefined};const i=[];let o=0,n=0,l=0;let c=0,d=0;t.dom.barDiv.selectAll(".sjpcb-bars-mainG").each((function(){e.push(this);const t=this.getBBox();if(t.width>o)o=t.width;if(t.height>n)n=t.height;const a=Math.round(this.parentNode.parentNode.getBoundingClientRect().y);if(!d){c=a;d++}else if(Math.abs(a-c)<5){d++}const h=r(this).attr("transform").split("translate(")[1].split(")")[0].split(",").map((t=>+t.trim()));if(s.x===undefined||h[0]>s.x)s.x=+h[0];if(s.y===undefined||h[1]>s.y)s.y=+h[1];const p=this.parentNode.parentNode.firstChild;const m=p.getBoundingClientRect();if(m.width>o)o=m.width;if(m.height>l)l=m.height;i.push({text:p.innerText,styles:window.getComputedStyle(p)})}));o+=30;n+=30;const p=document.createElementNS("http://www.w3.org/2000/svg","svg");const m=r(p).style("display","block").style("opacity",1).attr("width",d*o).attr("height",Math.floor(e.length/d)*n);const g=window.getComputedStyle(document.querySelector(".pp-bars-svg"));for(const t of g){if(t.startsWith("font"))m.style(t,g.getPropertyValue(t))}e.forEach(((t,e)=>{const a=t.cloneNode(true);const c=e%d;const h=Math.floor(e/d);const m={x:c*o+s.x,y:h*n+s.y};const g=r(p).append("text").attr("transform","translate("+m.x+","+m.y+")").text(i[e].text);for(const t of i[e].styles){if(t.startsWith("font"))g.style(t,i[e].styles.getPropertyValue(t))}r(a).attr("transform","translate("+m.x+","+(m.y+l)+")");p.appendChild(a)}));const f=r("body").append("div").style("opacity",0);f.node().appendChild(p);t.svgLegendRenderer=h({holder:m.append("g"),rectFillFxn:t=>t.color,iconStroke:"#aaa"});t.settings;const u=t.dom.barDiv.select("svg").node().getBoundingClientRect();let b=t.getLegendGrps();b.forEach((t=>{t.name=t.name.replace(/<[^>]*>?/gm,"");if(t.items)t.items=t.items.filter((t=>!t.isHidden))}));b=b.filter((t=>t.items.length&&!t.name.includes("tatistic")));const y=14;t.svgLegendRenderer(b,{settings:Object.assign({ontop:false,lineh:25,padx:5,padleft:0,padright:20,padbtm:30,fontsize:y,iconh:y-2,iconw:y-2,hangleft:1,linesep:false},{svgw:t.visibleCharts.length*u.width,svgh:u.height,dimensions:{xOffset:50},padleft:50})});const v=t.dom.legendDiv.node().getBoundingClientRect();r(p).attr("height",u.height+v.height+30);if(v.width>u.width)r(p).attr("width",v.width);f.remove();const x=t.config.term.term.name+" barchart";a(p,x,{apply_dom_styles:true})}}function w(t){return{orientation:"horizontal",unit:"abs",overlay:"none",divideBy:"none",rowlabelw:250,asterisksVisible:t?.getState()?.termdbConfig?.multipleTestingCorrection?true:false,defaultColor:o,colorBars:false,dedup:false}}async function C(t,e){if(!t.term)throw"barchart getPlotConfig: opts.term{} missing";try{await f(t.term,e.vocabApi);if(t.term2)await f(t.term2,e.vocabApi);if(t.term0)await f(t.term0,e.vocabApi)}catch(t){throw`${t} [barchart getPlotConfig()]`}const s={id:t.term.term.id,settings:{controls:{term2:null,term0:null},common:{use_logscale:false,use_percentage:false,barheight:300,barwidth:20,barspace:2},barchart:w(e)}};return n(s,t)}export{y as barInit,v as componentInit,w as getDefaultBarSettings,C as getPlotConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as t,x as e,a0 as a}from"./app-f91922b4.js";import{r as i}from"./table-d6c411fd.js";import{l as s,c as n,a as r,g as o}from"./FilterRxComp-0e75dd8d.js";function l(a){const i=new t({padding:"5px"});a.dom.tip=i;const s=a.settings;function n(t){const e=t.target.__data__;if(e===undefined)return;e.type=="col"?"term":"term2";const i=a.config.term;a.app.dispatch({type:"plot_edit",id:a.id,config:{term:{isAtomic:true,term:i.term,q:u(e,i,true)}}})}return{chart:{title(t){if(!a.config.term0)return t.chartId;return a.config.term0.term.values&&t.chartId in a.config.term0.term.values?a.config.term0.term.values[t.chartId].label:t.chartId}},svg:{mouseout:()=>{i.hide()}},series:{mouseover(t,e){t.stopPropagation();const s=a.config.term.term;const n=a.config.term2&&a.config.term2.term;s.unit;const r=(s.values&&e.seriesId in s.values?s.values[e.seriesId].label:e.seriesId)+(s.unit?" "+s.unit:"");const o=(n&&n.values&&e.dataId in n.values?n.values[e.dataId].label:e.dataId)+(n&&n.unit?" "+n.unit:"");const l=!n?"":"<div style='display:inline-block; width:14px; height:14px; margin: 2px 3px; vertical-align:top; background:"+e.color+"'> </div>";const d=[`<tr><td colspan=2 style='padding:3px; text-align:center'>${r}</td></tr>`];if(n){d.push(`<tr><td colspan=2 style='padding:3px; text-align:center'>${l} <span>${o}</span></td></tr>`)}d.push(`<tr><td style='padding:3px; color:#aaa'>#Individuals</td><td style='padding:3px; text-align:center'>n=${e.total}</td></tr>`);if(n){const t=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).pvalue;const a=e.groupPvalues.term1Label;const i=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).term2Label;const s=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).tableValues;const n=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).skipped;d.push(`<tr>\n\t\t\t\t\t\t\t<td style='padding:3px; color:#aaa'>p-value</td>\n\t\t\t\t\t\t\t<td style='padding:3px; text-align:center'>${n?"N/A":t>1e-4?Number(t.toFixed(4)):Number(t.toPrecision(4)).toExponential()}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<table style="margin: 5px; text-align:left; font-size: 0.8em; border-spacing: 5px; border-collapse: separate;"\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'></td>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>${i}</td>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>not ${i}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>${a}</td>\n\t\t\t\t\t\t\t\t<td>${s.R1C1}</td>\n\t\t\t\t\t\t\t\t<td>${s.R1C2}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>not ${a}</td>\n\t\t\t\t\t\t\t\t<td>${s.R2C1}</td>\n\t\t\t\t\t\t\t\t<td>${s.R2C2}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>`)}if(!s.type=="condition"&&(!n||!n.type=="condition")){d.push(`<tr><td style='padding:3px; color:#aaa'>Percentage</td><td style='padding:3px; text-align:center'>${(100*e.total/(n?e.seriesTotal:e.chartTotal)).toFixed(1)}%</td></tr>`)}i.show(t.clientX,t.clientY).d.html(`<table class='sja_simpletable'>${d.join("\n")}</table>`)},mouseout:()=>{i.hide()},rectFill(t){return t.color},strokeFill(t){const a=e(t.color);const i=a.toString()==e("white").toString()?a.darker():a;return i},click:a.opts.bar_click_override?(t,e)=>a.opts.bar_click_override(v(e,a)):(t,e)=>m(t,a,e)},colLabel:{text:t=>"label"in t?t.label:a.config.term.values&&"id"in t&&t.id in a.config.term.values?a.config.term.values[t.id].label:t,click:n,mouseover:t=>{t.stopPropagation();i.show(t.clientX,t.clientY).d.html("Click to hide bar")},mouseout:()=>{i.hide()}},rowLabel:{text:t=>t.label?t.label:a.config.term.values&&"id"in t&&t.id in a.config.term.values?a.config.term.values[t.id].label:t,click:n,mouseover:t=>{t.stopPropagation();i.show(t.clientX,t.clientY).d.html("Click to hide bar")},mouseout:()=>{i.hide()}},legend:{onColorClick:t=>c(t.target,a),click:t=>c(t.target,a),mouseover:t=>{t.stopPropagation();const e=t.target.__data__;if(e===undefined)return;if(e.isHidden)i.show(t.clientX,t.clientY).d.html("Click to unhide bar")},mouseout:()=>{i.hide()}},yAxis:{text:t=>{const e=a.config.term;if(s.orientation=="vertical"){return s.unit=="pct"?"% of patients":"# of patients "+(e.q.bar_by_children||e.q.value_by_most_recent||e.q.value_by_computable_grade?"":`(n=${t})`)}else{return e.q.bar_by_children?"Sub-condition":e.q.value_by_max_grade?"Maximum grade":e.q.value_by_most_recent?"Most recent grade":e.q.value_by_computable_grade?"Any grade":e.type=="categorical"||!e.unit?"":e.unit}}},xAxis:{text:t=>{const e=a.config.term;if(s.orientation=="vertical"){return e.q.bar_by_children?"Sub-condition":e.q.value_by_max_grade?"Maximum grade":e.q.value_by_most_recent?"Most recent grade":e.q.value_by_computable_grade?"Any grade":e.type=="categorical"||!e.unit?"":e.unit}else{return s.unit=="pct"?"% of patients":"# of patients "+(e.q.bar_by_children||e.q.value_by_most_recent||e.q.value_by_computable_grade?"":`(n=${t})`)}}}}}function d(t,e,a){const i=t.type=="col"?"term":"term2";const s=e.config[i];let n=t.dataId;if(s.term.values&&!s.term.values?.[n])for(const[e,a]of Object.entries(s.term.values))if(a.label==t.dataId)n=e;if(s.term.values?.[n])s.term.values[n].color=a;if(s.term.type=="geneVariant"){if(!s.term.values)s.term.values={};s.term.values[t.dataId]={label:t.dataId,color:a}}let r=null;if(e.bins[2].length>0){r=e.bins[2].find((e=>e.label==t.dataId));r.color=a}e.app.dispatch({type:"plot_edit",id:e.id,config:{[i]:{isAtomic:true,term:s.term,q:u(t,s,t.isHidden,r)}}})}function c(t,a){const i=t.__data__;if(i===undefined)return;if(!("type"in i))return;const s=i.type=="col"?"term":"term2";const n=a.config[s];const r="isHidden"in i?!i.isHidden:!(n.q&&n.q.hiddenValues&&n.q.hiddenValues["dataId"in i?i.dataId:i.id]);const o=a.app.tip;const l=o.clear();l.showunder(t);const c=l.d.append("div");c.append("div").attr("class","sja_menuoption sja_sharp_border").text(!r?"Show":"Hide").on("click",(()=>{l.hide();p(i,a,r)}));if(n.q.hiddenValues&&Object.keys(n.q.hiddenValues).length>1)c.append("div").attr("class","sja_menuoption sja_sharp_border").text("Show all").on("click",(()=>{l.hide();const t=structuredClone(n);delete t.q.hiddenValues;a.app.dispatch({type:"plot_edit",id:a.id,config:{[s]:t}})}));const u=e(i.color).formatHex();if(u!="#ffffff"){const t=c.append("div").attr("class","sja_sharp_border").style("padding","0px 10px").text("Color:").append("input").attr("type","color").attr("value",u).on("change",(()=>{d(i,a,t.node().value);l.hide()}))}}function p(t,e,a){const i=t.type=="col"?"term":"term2";const s=e.config[i];e.app.dispatch({type:"plot_edit",id:e.id,config:{[i]:{isAtomic:true,term:s.term,q:u(t,s,a)}}})}function u(t,e,a=false,i=null){const s="id"in t?t.id:t.type=="col"?t.seriesId:t.dataId;const n=e.term.values&&Object.keys(e.term.values).find((t=>e.term.values[t].label===s));const r=!n?s:n;const o=JSON.parse(JSON.stringify(e.q));if(!o.hiddenValues)o.hiddenValues={};if(a)o.hiddenValues[r]=1;else delete o.hiddenValues[r];if(i)o.binColored=i;return o}function m(t,e,a){const i=t.target.__data__||t.target.parentNode.__data__;const n=e.config.term.term;const r=e.config.term2?e.config.term2.term:null;const o=n.values?Object.values(n.values).map((t=>t.label)):[];const l=r&&r.values?Object.values(r.values).map((t=>t.label)):[];const d=n.unit&&!o.includes(i.seriesId||i.id)?" "+n.unit:"";const c=r&&r.unit&&!l.includes(i.dataId||i.id)?" "+r.unit:"";const p=(n.values&&i.seriesId in n.values?n.values[i.seriesId].label:i.seriesId?i.seriesId:i.id)+d;const m=(r&&r.values&&i.dataId in r.values?r.values[i.dataId].label:i.dataId?i.dataId:i.id)+c;const b=!r?"":"<div style='display:inline-block; width:14px; height:14px; margin: 2px 3px; vertical-align:top; background:"+i.color+"'> </div>";const h=`<div style='padding:2px'><b>${n.name}</b>: ${p}</div>`+(i.seriesId&&r?`<div style='padding:2px'><b>${r.name}</b>: ${m} ${b}</div>`:"");const y=i.seriesId||i.seriesId===0?i:{seriesId:i.id,dataId:i.dataId};const x=[];if(e.opts.bar_click_opts.includes("hide_bar")){x.push({label:i.seriesId?'Hide "'+p+'"':"Hide",callback:()=>{const t=e.config.term;e.app.dispatch({type:"plot_edit",id:e.id,config:{term:{isAtomic:true,term:t.term,q:u({id:i.seriesId,type:"col"},t,true)}}})}});if(i.dataId||i.dataId===0){x.push({label:'Hide "'+m+'" '+b,callback:()=>{const t=e.config.term2;e.app.dispatch({isAtomic:true,type:"plot_edit",id:e.id,config:{term2:{isAtomic:true,term:t.term,q:u({id:i.dataId,type:"row"},t,true)}}})}})}}if(e.opts.bar_click_opts.includes("add_filter")&&(!r||!r.isgenotype)){const t=s(e.state.termfilter.filter,e.config.term.term.id);if(!t){x.push({label:"Add as filter",callback:g})}}if(e.config.displaySampleIds){x.push({label:"List samples",callback:async()=>await f(t,e,i.seriesId,i.dataId,a.chartId)})}if(e.opts.bar_click_opts.includes("select_to_gp")){x.push({label:"Select to GenomePaint",callback:_})}if(!x.length)return;e.app.tip.clear();if(h){e.app.tip.d.append("div").html(h)}const I=v(y,e);e.app.tip.d.append("div").selectAll("div").data(x).enter().append("div").attr("class","sja_menuoption").html((t=>t.label)).on("click",(async(t,a)=>{e.app.tip.hide();await a.callback(e,I)}));e.app.tip.show(t.clientX,t.clientY)}async function f(e,a,s,r,o){const l={type:"tvslst",in:true,join:"and",lst:[b(1,s)]};const d=[a.config.term];if(a.config.term2){d.push(a.config.term2);l.lst.push(b(2,r))}if(a.config.term0){d.push(a.config.term0);l.lst.push(b(0,o))}const c={terms:d,filter:n([a.state.termfilter.filter,l])};const p=await a.app.vocabApi.getAnnotatedSampleData(c);const u=[];for(const t of p.lst){const e=p.refs.bySampleId[Number(t.sample)].label;u.push([{value:e}])}const m=[{label:"Sample"}];const f=new t({padding:"5px"});const g=f.d.append("div");i({rows:u,columns:m,div:g,showLines:true,maxWidth:"27vw",maxHeight:"40vh",resize:true});f.show(e.clientX,e.clientY,false);function b(t,e){const i=t==0?a.config.term0:t==1?a.config.term:a.config.term2;const s={type:"tvs",tvs:{term:i.term,values:[{key:e}]}};if(i.term.type=="integer"||i.term.type=="float"){const i=a.bins[t];s.tvs.ranges=[i.find((t=>t.label==e))]}return s}}function g(t,e){if(!e)return;if(!t.state.termfilter||t.state.nav?.header_mode!=="with_tabs"){return}const a=r(t.state.termfilter.filter,"filterUiRoot");const i=n([a,{type:"tvslst",in:true,join:e.length>1?"and":"",lst:[...e.map(b)]}]);i.tag="filterUiRoot";t.app.dispatch({type:"filter_replace",filter:i})}function b(t){return t.type==="tvs"?t:{type:"tvs",tvs:t}}function _(t,e){const i=[];for(const a of e){b(a);const e=s(t.state.termfilter.filter,a.tvs.term.id);if(!e)i.push(b(a))}import("./block-ec76524e.js").then((function(t){return t.c})).then((async e=>{const s={genome:t.app.opts.genome,dslabel:t.state.dslabel};const n=a({x:100,y:100});const l=o(t.state.termfilter.filter);const d=r(l,d);if(d&&d!=l)delete d.tag;l.tag="filterUiRoot";if(i.length){l.join="and";l.lst.push(...i)}const c=r(l,"cohortFilter");if(c){c.renderAs="htmlSelect";c.selectOptionsFrom="selectCohort"}new e.Block({hostURL:sessionStorage.getItem("hostURL"),holder:n.body,genome:s.genome,nobox:true,chr:s.genome.defaultcoord.chr,start:s.genome.defaultcoord.start,stop:s.genome.defaultcoord.stop,nativetracks:[s.genome.tracks.find((t=>t.__isgene)).name.toLowerCase()],tklst:[{type:"mds2",dslabel:s.dslabel,vcf:{numerical_axis:{AFtest:{groups:[{is_termdb:true,filter:l},{is_population:true,key:"gnomAD",allowto_adjust_race:true,adjust_race:true}]}}}}]})}))}function v(t,e){const a=[];if(e.state.nav?.header_mode=="with_cohortHtmlSelect"){const t=r(e.state.termfilter.filter,"cohortFilter");if(t)a.push(JSON.parse(JSON.stringify(t)))}const i=e.config.term;const s=i.term.values&&Object.keys(i.term.values).filter((e=>i.term.values[e].label===t.seriesId))[0];const n=i.term.values&&s in i.term.values?s:t.seriesId;const o=e.config.term2;const l=o&&o.term.values&&Object.keys(o.term.values).filter((e=>o.term.values[e].label===t.dataId))[0];const d=o&&o.term.values&&l in o.term.values?l:t.dataId;for(const s of[i,o]){if(!s)continue;const r=s==i?1:2;const l=s==i?n:d;const c=s.q;const p=!s||!s.term.values?l:l in s.term.values?s.term.values[l].label:l;if(c.groupsetting&&c.groupsetting.inuse){const t="predefined_groupset_idx"in c.groupsetting?s.term.groupsetting.lst[c.groupsetting.predefined_groupset_idx]:c.groupsetting.customset;const e=t.groups.find((t=>t.name===l));const i={term:s.term,values:e.values,groupset_label:e.name};if(s.term.type=="condition"){i.bar_by_children=s.q.bar_by_children;i.bar_by_grade=s.q.bar_by_grade;i.value_by_most_recent=s.q.value_by_most_recent;i.value_by_max_grade=s.q.value_by_max_grade}a.push(i)}else if(s.term.type=="condition"){if(!o||i.term.id!=o.term.id){a.push(Object.assign({term:s.term,values:[{key:l,label:p}]},c))}if(s==i&&o&&s.term.id==o.term.id){const i=o.q;const n=o.term.values&&t.dataId in o.term.values?e.config.term2.values[t.dataId].label:t.dataId;a.push(Object.assign({term:s.term,grade_and_child:[{grade:i.bar_by_grade?t.dataId:l,grade_label:i.bar_by_grade?n:p,child_id:i.bar_by_children?t.dataId:l,child_label:i.bar_by_children?n:p}]},i))}}else{const t=e.currServerData.refs.bins[r];if(!t||!t.length){a.push({term:s.term,values:[{key:l,label:p}]})}else{const e=t.find((t=>t.label==p||t.name==p));if(e)a.push({term:s.term,ranges:[e]});else if(s==i){a.push({term:s.term,ranges:[{value:l}]})}else if(s==o){a.push({term:s.term,ranges:[{value:l}]})}else{throw"should not happen"}}}}return a.map((t=>b(t)))}export{l as default,p as hideCategory};
|
|
1
|
+
import{M as t,x as e,a0 as a}from"./app-71453429.js";import{r as i}from"./table-1dae543a.js";import{l as s,c as n,a as r,g as o}from"./FilterRxComp-fc769f34.js";function l(a){const i=new t({padding:"5px"});a.dom.tip=i;const s=a.settings;function n(t){const e=t.target.__data__;if(e===undefined)return;e.type=="col"?"term":"term2";const i=a.config.term;a.app.dispatch({type:"plot_edit",id:a.id,config:{term:{isAtomic:true,term:i.term,q:u(e,i,true)}}})}return{chart:{title(t){if(!a.config.term0)return t.chartId;return a.config.term0.term.values&&t.chartId in a.config.term0.term.values?a.config.term0.term.values[t.chartId].label:t.chartId}},svg:{mouseout:()=>{i.hide()}},series:{mouseover(t,e){t.stopPropagation();const s=a.config.term.term;const n=a.config.term2&&a.config.term2.term;s.unit;const r=(s.values&&e.seriesId in s.values?s.values[e.seriesId].label:e.seriesId)+(s.unit?" "+s.unit:"");const o=(n&&n.values&&e.dataId in n.values?n.values[e.dataId].label:e.dataId)+(n&&n.unit?" "+n.unit:"");const l=!n?"":"<div style='display:inline-block; width:14px; height:14px; margin: 2px 3px; vertical-align:top; background:"+e.color+"'> </div>";const d=[`<tr><td colspan=2 style='padding:3px; text-align:center'>${r}</td></tr>`];if(n){d.push(`<tr><td colspan=2 style='padding:3px; text-align:center'>${l} <span>${o}</span></td></tr>`)}d.push(`<tr><td style='padding:3px; color:#aaa'>#Individuals</td><td style='padding:3px; text-align:center'>n=${e.total}</td></tr>`);if(n){const t=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).pvalue;const a=e.groupPvalues.term1Label;const i=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).term2Label;const s=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).tableValues;const n=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).skipped;d.push(`<tr>\n\t\t\t\t\t\t\t<td style='padding:3px; color:#aaa'>p-value</td>\n\t\t\t\t\t\t\t<td style='padding:3px; text-align:center'>${n?"N/A":t>1e-4?Number(t.toFixed(4)):Number(t.toPrecision(4)).toExponential()}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<table style="margin: 5px; text-align:left; font-size: 0.8em; border-spacing: 5px; border-collapse: separate;"\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'></td>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>${i}</td>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>not ${i}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>${a}</td>\n\t\t\t\t\t\t\t\t<td>${s.R1C1}</td>\n\t\t\t\t\t\t\t\t<td>${s.R1C2}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>not ${a}</td>\n\t\t\t\t\t\t\t\t<td>${s.R2C1}</td>\n\t\t\t\t\t\t\t\t<td>${s.R2C2}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>`)}if(!s.type=="condition"&&(!n||!n.type=="condition")){d.push(`<tr><td style='padding:3px; color:#aaa'>Percentage</td><td style='padding:3px; text-align:center'>${(100*e.total/(n?e.seriesTotal:e.chartTotal)).toFixed(1)}%</td></tr>`)}i.show(t.clientX,t.clientY).d.html(`<table class='sja_simpletable'>${d.join("\n")}</table>`)},mouseout:()=>{i.hide()},rectFill(t){return t.color},strokeFill(t){const a=e(t.color);const i=a.toString()==e("white").toString()?a.darker():a;return i},click:a.opts.bar_click_override?(t,e)=>a.opts.bar_click_override(v(e,a)):(t,e)=>m(t,a,e)},colLabel:{text:t=>"label"in t?t.label:a.config.term.values&&"id"in t&&t.id in a.config.term.values?a.config.term.values[t.id].label:t,click:n,mouseover:t=>{t.stopPropagation();i.show(t.clientX,t.clientY).d.html("Click to hide bar")},mouseout:()=>{i.hide()}},rowLabel:{text:t=>t.label?t.label:a.config.term.values&&"id"in t&&t.id in a.config.term.values?a.config.term.values[t.id].label:t,click:n,mouseover:t=>{t.stopPropagation();i.show(t.clientX,t.clientY).d.html("Click to hide bar")},mouseout:()=>{i.hide()}},legend:{onColorClick:t=>c(t.target,a),click:t=>c(t.target,a),mouseover:t=>{t.stopPropagation();const e=t.target.__data__;if(e===undefined)return;if(e.isHidden)i.show(t.clientX,t.clientY).d.html("Click to unhide bar")},mouseout:()=>{i.hide()}},yAxis:{text:t=>{const e=a.config.term;if(s.orientation=="vertical"){return s.unit=="pct"?"% of patients":"# of patients "+(e.q.bar_by_children||e.q.value_by_most_recent||e.q.value_by_computable_grade?"":`(n=${t})`)}else{return e.q.bar_by_children?"Sub-condition":e.q.value_by_max_grade?"Maximum grade":e.q.value_by_most_recent?"Most recent grade":e.q.value_by_computable_grade?"Any grade":e.type=="categorical"||!e.unit?"":e.unit}}},xAxis:{text:t=>{const e=a.config.term;if(s.orientation=="vertical"){return e.q.bar_by_children?"Sub-condition":e.q.value_by_max_grade?"Maximum grade":e.q.value_by_most_recent?"Most recent grade":e.q.value_by_computable_grade?"Any grade":e.type=="categorical"||!e.unit?"":e.unit}else{return s.unit=="pct"?"% of patients":"# of patients "+(e.q.bar_by_children||e.q.value_by_most_recent||e.q.value_by_computable_grade?"":`(n=${t})`)}}}}}function d(t,e,a){const i=t.type=="col"?"term":"term2";const s=e.config[i];let n=t.dataId;if(s.term.values&&!s.term.values?.[n])for(const[e,a]of Object.entries(s.term.values))if(a.label==t.dataId)n=e;if(s.term.values?.[n])s.term.values[n].color=a;if(s.term.type=="geneVariant"){if(!s.term.values)s.term.values={};s.term.values[t.dataId]={label:t.dataId,color:a}}let r=null;if(e.bins[2].length>0){r=e.bins[2].find((e=>e.label==t.dataId));r.color=a}e.app.dispatch({type:"plot_edit",id:e.id,config:{[i]:{isAtomic:true,term:s.term,q:u(t,s,t.isHidden,r)}}})}function c(t,a){const i=t.__data__;if(i===undefined)return;if(!("type"in i))return;const s=i.type=="col"?"term":"term2";const n=a.config[s];const r="isHidden"in i?!i.isHidden:!(n.q&&n.q.hiddenValues&&n.q.hiddenValues["dataId"in i?i.dataId:i.id]);const o=a.app.tip;const l=o.clear();l.showunder(t);const c=l.d.append("div");c.append("div").attr("class","sja_menuoption sja_sharp_border").text(!r?"Show":"Hide").on("click",(()=>{l.hide();p(i,a,r)}));if(n.q.hiddenValues&&Object.keys(n.q.hiddenValues).length>1)c.append("div").attr("class","sja_menuoption sja_sharp_border").text("Show all").on("click",(()=>{l.hide();const t=structuredClone(n);delete t.q.hiddenValues;a.app.dispatch({type:"plot_edit",id:a.id,config:{[s]:t}})}));const u=e(i.color).formatHex();if(u!="#ffffff"){const t=c.append("div").attr("class","sja_sharp_border").style("padding","0px 10px").text("Color:").append("input").attr("type","color").attr("value",u).on("change",(()=>{d(i,a,t.node().value);l.hide()}))}}function p(t,e,a){const i=t.type=="col"?"term":"term2";const s=e.config[i];e.app.dispatch({type:"plot_edit",id:e.id,config:{[i]:{isAtomic:true,term:s.term,q:u(t,s,a)}}})}function u(t,e,a=false,i=null){const s="id"in t?t.id:t.type=="col"?t.seriesId:t.dataId;const n=e.term.values&&Object.keys(e.term.values).find((t=>e.term.values[t].label===s));const r=!n?s:n;const o=JSON.parse(JSON.stringify(e.q));if(!o.hiddenValues)o.hiddenValues={};if(a)o.hiddenValues[r]=1;else delete o.hiddenValues[r];if(i)o.binColored=i;return o}function m(t,e,a){const i=t.target.__data__||t.target.parentNode.__data__;const n=e.config.term.term;const r=e.config.term2?e.config.term2.term:null;const o=n.values?Object.values(n.values).map((t=>t.label)):[];const l=r&&r.values?Object.values(r.values).map((t=>t.label)):[];const d=n.unit&&!o.includes(i.seriesId||i.id)?" "+n.unit:"";const c=r&&r.unit&&!l.includes(i.dataId||i.id)?" "+r.unit:"";const p=(n.values&&i.seriesId in n.values?n.values[i.seriesId].label:i.seriesId?i.seriesId:i.id)+d;const m=(r&&r.values&&i.dataId in r.values?r.values[i.dataId].label:i.dataId?i.dataId:i.id)+c;const b=!r?"":"<div style='display:inline-block; width:14px; height:14px; margin: 2px 3px; vertical-align:top; background:"+i.color+"'> </div>";const h=`<div style='padding:2px'><b>${n.name}</b>: ${p}</div>`+(i.seriesId&&r?`<div style='padding:2px'><b>${r.name}</b>: ${m} ${b}</div>`:"");const y=i.seriesId||i.seriesId===0?i:{seriesId:i.id,dataId:i.dataId};const x=[];if(e.opts.bar_click_opts.includes("hide_bar")){x.push({label:i.seriesId?'Hide "'+p+'"':"Hide",callback:()=>{const t=e.config.term;e.app.dispatch({type:"plot_edit",id:e.id,config:{term:{isAtomic:true,term:t.term,q:u({id:i.seriesId,type:"col"},t,true)}}})}});if(i.dataId||i.dataId===0){x.push({label:'Hide "'+m+'" '+b,callback:()=>{const t=e.config.term2;e.app.dispatch({isAtomic:true,type:"plot_edit",id:e.id,config:{term2:{isAtomic:true,term:t.term,q:u({id:i.dataId,type:"row"},t,true)}}})}})}}if(e.opts.bar_click_opts.includes("add_filter")&&(!r||!r.isgenotype)){const t=s(e.state.termfilter.filter,e.config.term.term.id);if(!t){x.push({label:"Add as filter",callback:g})}}if(e.config.displaySampleIds){x.push({label:"List samples",callback:async()=>await f(t,e,i.seriesId,i.dataId,a.chartId)})}if(e.opts.bar_click_opts.includes("select_to_gp")){x.push({label:"Select to GenomePaint",callback:_})}if(!x.length)return;e.app.tip.clear();if(h){e.app.tip.d.append("div").html(h)}const I=v(y,e);e.app.tip.d.append("div").selectAll("div").data(x).enter().append("div").attr("class","sja_menuoption").html((t=>t.label)).on("click",(async(t,a)=>{e.app.tip.hide();await a.callback(e,I)}));e.app.tip.show(t.clientX,t.clientY)}async function f(e,a,s,r,o){const l={type:"tvslst",in:true,join:"and",lst:[b(1,s)]};const d=[a.config.term];if(a.config.term2){d.push(a.config.term2);l.lst.push(b(2,r))}if(a.config.term0){d.push(a.config.term0);l.lst.push(b(0,o))}const c={terms:d,filter:n([a.state.termfilter.filter,l])};const p=await a.app.vocabApi.getAnnotatedSampleData(c);const u=[];for(const t of p.lst){const e=p.refs.bySampleId[Number(t.sample)].label;u.push([{value:e}])}const m=[{label:"Sample"}];const f=new t({padding:"5px"});const g=f.d.append("div");i({rows:u,columns:m,div:g,showLines:true,maxWidth:"27vw",maxHeight:"40vh",resize:true});f.show(e.clientX,e.clientY,false);function b(t,e){const i=t==0?a.config.term0:t==1?a.config.term:a.config.term2;const s={type:"tvs",tvs:{term:i.term,values:[{key:e}]}};if(i.term.type=="integer"||i.term.type=="float"){const i=a.bins[t];s.tvs.ranges=[i.find((t=>t.label==e))]}return s}}function g(t,e){if(!e)return;if(!t.state.termfilter||t.state.nav?.header_mode!=="with_tabs"){return}const a=r(t.state.termfilter.filter,"filterUiRoot");const i=n([a,{type:"tvslst",in:true,join:e.length>1?"and":"",lst:[...e.map(b)]}]);i.tag="filterUiRoot";t.app.dispatch({type:"filter_replace",filter:i})}function b(t){return t.type==="tvs"?t:{type:"tvs",tvs:t}}function _(t,e){const i=[];for(const a of e){b(a);const e=s(t.state.termfilter.filter,a.tvs.term.id);if(!e)i.push(b(a))}import("./block-4f585abe.js").then((function(t){return t.c})).then((async e=>{const s={genome:t.app.opts.genome,dslabel:t.state.dslabel};const n=a({x:100,y:100});const l=o(t.state.termfilter.filter);const d=r(l,d);if(d&&d!=l)delete d.tag;l.tag="filterUiRoot";if(i.length){l.join="and";l.lst.push(...i)}const c=r(l,"cohortFilter");if(c){c.renderAs="htmlSelect";c.selectOptionsFrom="selectCohort"}new e.Block({hostURL:sessionStorage.getItem("hostURL"),holder:n.body,genome:s.genome,nobox:true,chr:s.genome.defaultcoord.chr,start:s.genome.defaultcoord.start,stop:s.genome.defaultcoord.stop,nativetracks:[s.genome.tracks.find((t=>t.__isgene)).name.toLowerCase()],tklst:[{type:"mds2",dslabel:s.dslabel,vcf:{numerical_axis:{AFtest:{groups:[{is_termdb:true,filter:l},{is_population:true,key:"gnomAD",allowto_adjust_race:true,adjust_race:true}]}}}}]})}))}function v(t,e){const a=[];if(e.state.nav?.header_mode=="with_cohortHtmlSelect"){const t=r(e.state.termfilter.filter,"cohortFilter");if(t)a.push(JSON.parse(JSON.stringify(t)))}const i=e.config.term;const s=i.term.values&&Object.keys(i.term.values).filter((e=>i.term.values[e].label===t.seriesId))[0];const n=i.term.values&&s in i.term.values?s:t.seriesId;const o=e.config.term2;const l=o&&o.term.values&&Object.keys(o.term.values).filter((e=>o.term.values[e].label===t.dataId))[0];const d=o&&o.term.values&&l in o.term.values?l:t.dataId;for(const s of[i,o]){if(!s)continue;const r=s==i?1:2;const l=s==i?n:d;const c=s.q;const p=!s||!s.term.values?l:l in s.term.values?s.term.values[l].label:l;if(c.groupsetting&&c.groupsetting.inuse){const t="predefined_groupset_idx"in c.groupsetting?s.term.groupsetting.lst[c.groupsetting.predefined_groupset_idx]:c.groupsetting.customset;const e=t.groups.find((t=>t.name===l));const i={term:s.term,values:e.values,groupset_label:e.name};if(s.term.type=="condition"){i.bar_by_children=s.q.bar_by_children;i.bar_by_grade=s.q.bar_by_grade;i.value_by_most_recent=s.q.value_by_most_recent;i.value_by_max_grade=s.q.value_by_max_grade}a.push(i)}else if(s.term.type=="condition"){if(!o||i.term.id!=o.term.id){a.push(Object.assign({term:s.term,values:[{key:l,label:p}]},c))}if(s==i&&o&&s.term.id==o.term.id){const i=o.q;const n=o.term.values&&t.dataId in o.term.values?e.config.term2.values[t.dataId].label:t.dataId;a.push(Object.assign({term:s.term,grade_and_child:[{grade:i.bar_by_grade?t.dataId:l,grade_label:i.bar_by_grade?n:p,child_id:i.bar_by_children?t.dataId:l,child_label:i.bar_by_children?n:p}]},i))}}else{const t=e.currServerData.refs.bins[r];if(!t||!t.length){a.push({term:s.term,values:[{key:l,label:p}]})}else{const e=t.find((t=>t.label==p||t.name==p));if(e)a.push({term:s.term,ranges:[e]});else if(s==i){a.push({term:s.term,ranges:[{value:l}]})}else if(s==o){a.push({term:s.term,ranges:[{value:l}]})}else{throw"should not happen"}}}}return a.map((t=>b(t)))}export{l as default,p as hideCategory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as t,q as e,f as o}from"./app-f91922b4.js";import{b as a,d as s}from"./axis-6cb4f314.js";import{l}from"./log-4d74231e.js";function n(n,r){const i={},c={};const d={};let h;let p;let g,f,u,m,w;let y,x,b,v,k,z,I;let S,B,M;let A;let T=[];let j;function L(t,e){let o=i.orientation;h=t;Object.assign(i,h.settings);i.handlers=h.handlers;i.cols=i.cols.filter((t=>i.colLabels.find((e=>e.id==t))));i.rows=i.rows?.filter((t=>!i.exclude.rows.includes(t)))||[];const a=!g;if(a)P();const s=i.colw;T=h.visibleSerieses;T.map(C);h.serieses.map(C);_();p.style("width",i.svgw+100+"px").style("font-weight",600).style("font-size","20px").style("margin-bottom","24px").html(i.handlers.chart.title(h));if(a){g.attr("height",0).attr("width",0).style("opacity",0);f.attr("transform","translate("+i.rowlabelw+",0)")}const l=u.attr("transform",E).selectAll(".bars-cell-grp").data(T,F);l.exit().each(O);l.each(N);l.enter().append("g").each(G);const n=m.attr("transform",Q).style("opacity",o!=i.orientation?1e-4:1).style("display",i.orientation!="vertical"?"none":"").selectAll("g").data(i.colLabels,(t=>t.id));n.exit().remove();n.each(Y);n.enter().append("g").each(X);const r=w.attr("transform",Z).style("opacity",o!=i.orientation?1e-4:1).style("display",i.orientation!="horizontal"?"none":"").selectAll("g").data(i.colLabels,(t=>t.id));r.exit().remove();r.each(et);r.enter().append("g").each(tt);u.selectAll("rect");M=m.selectAll("text");i.delay=.35*i.duration;it(i,o,h.visibleTotal);i.colw=s;if(o!=i.orientation){const t=i.orientation=="vertical"?m:w;t.transition().duration(1500).style("opacity",1)}if(a){g.transition().duration(100).attr("height",1).attr("width",1).style("opacity",1)}setTimeout((()=>{const t=20;const e=f.node().getBBox();const o=!j||e.width?e:j;j=o;g.transition().duration(e.width?100:0).attr("width",o.width+t).attr("height",o.height+t);if(i.orientation=="vertical"){const a=m.node().getBBox();const s=b.node().getBBox();const l=Math.max(-a.x,-s.x,-o.x);f.transition().duration(e.width?100:0).attr("transform","translate("+l+","+-t+")")}else{const t=w.node().getBBox();const o=b.node().getBBox();const a=z.node().getBBox();f.transition().duration(e.width?100:0).attr("transform","translate("+Math.max(-t.x,-o.x)+","+-a.y+")")}}),a?110:510)}function P(){A={geneonrow:i.geneonrow,nicenames:{},colw:i.geneonrow?Math.min(15,Math.max(1,Math.floor(document.body.clientWidth*.7/i.cols.length))):20,rowh:i.geneonrow?20:Math.min(18,Math.max(10,Math.floor(document.body.clientHeight*.7/i.rows.length))),rowspace:i.geneonrow?2:i.rows.length>100?0:1,colspace:!i.geneonrow?2:i.cols.length>100?0:1,rowtick:8,coltick:5,rowlabtickspace:4,collabtickspace:4,collabelh:150,rowlabelw:250,rowheadleft:true,colheadtop:false,samplecount4gene:true,samplecount4legend:false,showgrid:true,gridstroke:"#fff",showEmptyCells:false,cellbg:"#eeeeee",fontsizeratio:.9,rowlabelfontsizemax:16,collabelfontsizemax:12,crudefill:i.colw<=2,duration:1e3,delay:0};for(let t in A){if(!(t in i)||t=="cols"||t=="rows")i[t]=A[t]}if(!g){p=r.append("div").attr("class","pp-chart-title").style("text-align","center");g=r.append("svg").attr("class","pp-bars-svg").style("overflow","visible").on("mouseover.tphm2",i.handlers.svg.mouseover).on("mouseout.tphm2",i.handlers.svg.mouseout).on("click.tphm2",i.handlers.svg.click)}f=g.append("g").attr("class","sjpcb-bars-mainG").attr("data-testid","sjpcb-bars-mainG");i.h.svg=g;i.h.mainG=f;m=f.append("g").attr("class","bars-collabels").style("cursor",i.handlers.colLabel.click?"pointer":"").on("mouseover.tphm2",gt).on("mouseout.tphm2",ft).on("click.tphm2",i.handlers.colLabel.click);w=f.append("g").attr("class","bars-rowlabels").attr("data-testid","sjpcb-bars-rowlabels").style("cursor",i.handlers.rowLabel.click?"pointer":"").on("mouseover.tphm2",gt).on("mouseout.tphm2",ft).on("click.tphm2",i.handlers.rowLabel.click);u=f.append("g").attr("class","bars-series").attr("data-testid","sjpcb-bars-series").on("mouseover.tphm2",ht).on("mouseout.tphm2",pt).on("click",ut).style("cursor","pointer");y=f.append("g").attr("class","sjpcb-bar-chart-axis-g");x=y.append("g").attr("class","sjpcb-bar-chart-y-axis");v=y.append("line").attr("class","sjpcb-bar-chart-y-line").style("stroke","#000");b=y.append("g").attr("class","sjpcb-bar-chart-y-title").style("cursor","default");k=y.append("g").attr("class","sjpcb-bar-chart-x-axis");I=y.append("line").attr("class","sjpcb-bar-chart-x-line").style("stroke","#000");z=y.append("g").attr("class","sjpcb-bar-chart-x-title").style("cursor","default")}function _(){const e=i.numCharts<4?i.numCharts:i.numCharts%3==0?3:2;const o=i.cols.length*i.colspace+(i.colgrps.length-1)*i.colgspace+i.rowlabelw+i.rowgrplabelw;if(i.orientation=="horizontal"){i.svgw=Math.min(400,.92*window.innerWidth/e);i.rowh=Math.max(14,Math.min(22,.7*window.innerHeight/i.cols.length));i.svgh=i.cols.length*(i.rowh+i.colspace)-i.colspace+(i.colgrps.length-1)*i.colgspace+i.rowlabelw+i.rowgrplabelw}else{const t=window.innerWidth*.92/e;i.colw=Math.min(Math.max(16,Math.round((t-o)/i.cols.length)),30);i.svgw=i.cols.length*(i.colw+i.colspace)-i.colspace+(i.colgrps.length-1)*i.colgspace+i.rowlabelw+i.rowgrplabelw;const a=Math.ceil(i.numCharts/e);i.svgh=Math.max(350,Math.min(400,window.innerHeight*.5))/(a>3?2:1)}h.svgh=i.svgh;i.h.yScale={};i.h.xScale={};i.h.yPrevBySeries={};i.h.xPrevBySeries={};const a=i.scale=="byChart"?1:h.maxVisibleSeriesTotal/h.maxVisibleAcrossCharts;for(const e of T){if(e.visibleData[0]){const o=i.unit=="log"?1:0;const s=i.unit=="pct"?e.visibleTotal:i.unit=="log"?h.maxSeriesLogTotal:h.maxVisibleSeriesTotal;i.h.yScale[e.seriesId]=t().domain([o,s/a]).range([0,i.svgh-i.collabelh]);i.h.xScale[e.seriesId]=t().domain([o,s/a]).range([0,i.svgw-i.rowlabelw]);i.h.yPrevBySeries[e.seriesId]=0;i.h.xPrevBySeries[e.seriesId]=0;for(const t of e.visibleData){t.height=R(t);t.y=q(t);t.x=K(t);t.width=J(t)}}}c.colfontsize=Math.min(i.colw*i.fontsizeratio,i.collabelfontsizemax);c.rowfontsize=Math.min(i.rowh*i.fontsizeratio,i.rowlabelfontsizemax);c.rowtextyalign=Math.min(i.rowh,(i.rowh+c.rowfontsize)/2)+i.rowspace}function C(t){if(!("seriesId"in t)){t.data.map((e=>{if(e)t.seriesId=e[i.serieskey]}))}t.data.map((t=>{t.rowId=t[i.rowkey];t.colId=t[i.colkey]}))}function F(t){return t.seriesId}function V(t){return t.rowId+" "+t.colId}function O(){e(this).remove()}function N(t){const o=e(this).selectAll(".bars-cell").data(t.data.filter(H),V);o.exit().each((function(){e(this).remove()}));o.style("display",(t=>i.cols.includes(t.colId)?"block":"none"));o.select("rect").datum((t=>t)).transition().duration(i.duration).attr("x",(t=>t.x)).attr("y",(t=>t.y)).attr("width",(t=>t.width)).attr("height",(t=>t.height)).attr("fill",i.handlers.series.rectFill).attr("stroke",i.handlers.series.strokeFill);o.enter().append("g").each(W);o.selectAll("text").remove();D(o)}function G(t){if(!t||!t.data.length)return;e(this).attr("class","bars-cell-grp").selectAll("g").data(t.data.filter(H),V).enter().append("g").each(W)}function H(t){return i.rows.includes(t.dataId)}function W(t){const o=e(this).attr("class","bars-cell").datum(t);o.style("display",(t=>i.cols.includes(t.colId)?"block":"none"));o.append("rect").attr("x",(t=>t.x)).attr("y",(t=>t.y)).attr("width",(t=>t.width)).attr("height",(t=>t.height)).attr("fill",i.handlers.series.rectFill).attr("stroke",i.handlers.series.strokeFill).attr("shape-rendering","crispEdges").style("opacity",0).transition().delay(i.delay).duration(i.duration).style("opacity",1);D(o)}function D(t){if(!n.config.settings.barchart.asterisksVisible){return}t.append("text").text((t=>{const e=t.groupPvalues&&t.groupPvalues.term2tests.find((e=>e.term2id==t.dataId));if(!e||e.skipped||!e.adjusted_p_value)return"";return e.adjusted_p_value<.05?"*":""})).attr("x",(t=>t.x+t.width/2)).attr("y",(t=>t.y+t.height/2)).attr("dy","0.6em").style("text-anchor","middle").style("opacity",0).transition().delay(i.delay).duration(i.duration).style("opacity",1)}function E(){const t=i.colspace;let e=i.colheadtop?i.collabelh:i.colgrplabelh;if(i.legendontop)e+=i.legendh;return"translate("+t+","+e+")"}function R(t){const e=i.unit=="log"?t.logTotal:t.total;const o=i.orientation=="vertical"?i.h.yScale[t.seriesId](e):i.rowh;const a=0;i.h.yPrevBySeries[t.seriesId]+=o+a;return Math.max(1,o-a)}function q(t){const e=i.colgrps.indexOf(t[i.colgrpkey])*i.colgspace;const o=i.unit=="log"?Math.max(0,i.h.yPrevBySeries[t.seriesId]):i.h.yPrevBySeries[t.seriesId];return i.orientation=="vertical"?i.svgh-i.collabelh-o:i.cols.indexOf(t.colId)*(i.rowh+i.rowspace)+e}function J(t){const e=i.unit=="log"?t.logTotal:t.total;const o=i.orientation=="vertical"?i.colw:i.h.xScale[t.seriesId](e);const a=0;i.h.xPrevBySeries[t.seriesId];i.h.xPrevBySeries[t.seriesId]+=Math.max(1,o+a);return Math.max(1,o-a)}function K(t){const e=i.colgrps.indexOf(t[i.colgrpkey])*i.colgspace;return i.orientation=="vertical"?i.cols.indexOf(t.colId)*(i.colw+i.colspace)+e:i.h.xPrevBySeries[t.seriesId]}function Q(){let t=5+i.colspace;let e=i.colheadtop?i.borderwidth+1:i.svgh-i.collabelh+25;if(i.legendontop)e+=i.legendh;return"translate("+t+","+e+")"}function U(t){const e=i.col2name[t]?i.col2name[t].grp:"";const o=i.colgrps.indexOf(e)*i.colgspace+i.cols.indexOf("id"in t?t.id:t)*(i.colw+i.colspace)+i.colw/2;const a=i.colheadtop?-1*(i.coltick+i.collabtickspace):i.coltick+i.collabtickspace;return"translate("+o+","+a+")"}function X(t){if(!this||t===undefined)return;const o=e(this).attr("transform",U).style("opacity",0);o.append("text").attr("transform","rotate(-40)").attr("y",2).attr("text-anchor","end").attr("font-size",c.colfontsize+"px").html(i.handlers.colLabel.text);o.transition().delay(i.delay).duration(i.duration).style("opacity",1)}function Y(t){const o=e(this).datum(t);o.attr("transform",U);o.selectAll("text").datum(t).attr("y",2).attr("text-anchor","end").attr("font-size",c.colfontsize+"px").html(i.handlers.colLabel.text)}function Z(){const t=i.colheadtop?i.collabelh:i.colgrplabelh;const e=i.rowheadleft?i.borderwidth+1:i.svgw-i.rowlabelw+20;return"translate("+e+","+t+")"}function $(t){const e=i.row2name[t]?i.row2name[t].grp:"";const o=i.colgrps.indexOf(e)*i.rowgspace+i.cols.indexOf("id"in t?t.id:t)*(i.rowh+i.rowspace)+c.rowtextyalign;const a=i.rowheadleft?-1*(i.rowtick+i.rowlabtickspace):i.rowtick+i.rowlabtickspace;return"translate("+a+","+o+")"}function tt(t){if(!this||t===undefined)return;const o=e(this).attr("transform",$).style("opacity",0);o.append("text").attr("x",2).attr("text-anchor","end").attr("font-size",c.rowfontsize+"px").html(i.handlers.rowLabel.text);o.transition().delay(i.delay).duration(i.duration).style("opacity",1)}function et(t){const o=e(this).datum(t);o.attr("transform",$);o.selectAll("text").datum(t).attr("x",2).attr("text-anchor","end").attr("font-size",c.rowfontsize+"px").html(i.handlers.rowLabel.text)}function ot(t){return t==S.rowId?700:""}function at(t){return t==S.rowId?Math.max(12,c.rowfontsize):c.rowfontsize}function st(t){return t==S.rowId?"#00f":""}function lt(t){return t==S.colId?700:""}function nt(t){return t==S.colId?12:c.colfontsize}function rt(t){return t==S.colId?"#00f":""}function it(t,e,o){y.style("opacity",e!=t.orientation?0:1).transition().duration(1500).style("opacity",1);if(t.orientation=="vertical"){ct(t,o)}else{dt(t,o)}}function ct(e,s){k.style("display","none");v.style("display","none");const n=m.node().getBBox();e.svgh-e.collabelh+24;z.selectAll("*").remove();const r=i.handlers.xAxis.text(s);z.append("text").style("text-anchor","middle").style("font-size",e.axisTitleFontSize+"px").style("font-weight",600).text(r);setTimeout((()=>{z.attr("transform","translate("+(e.svgw-e.svgPadding.left-e.svgPadding.right-e.rowlabelw)/2+","+(n.height+i.svgh-i.collabelh+20+e.axisTitleFontSize)+")")}),0);const c=i.scale=="byChart"||i.clickedAge?1:h.maxVisibleSeriesTotal/h.maxVisibleAcrossCharts;const d=i.unit=="log"?1:0;const p=i.unit=="pct"?100:h.maxVisibleSeriesTotal;x.style("display","block").call(a((i.unit=="log"?l():t()).domain([p/c,d]).range([e.colgrplabelh,e.svgh-e.collabelh+e.colgrplabelh-e.borderwidth+1])).ticks(4,o("d")));b.selectAll("*").remove();const g=e.svgh-e.collabelh;b.style("font-weight",600).attr("transform","translate("+(-e.svgPadding.left-e.axisTitleFontSize)+","+g/2+")rotate(-90)").append("text").style("text-anchor","middle").style("font-size",e.axisTitleFontSize+"px").text(i.handlers.yAxis.text(s))}function dt(e,a){x.style("display","none");I.style("display","none");b.selectAll("*").remove();const n=i.handlers.yAxis.text(a);b.append("text").style("text-anchor","end").style("font-size",e.axisTitleFontSize+"px").style("font-weight",600).text(n);w.node().getBBox();setTimeout((()=>{b.style("text-anchor","end").attr("transform","translate("+0+",0)")}),0);const r=i.scale=="byChart"||i.clickedAge?1:h.maxVisibleSeriesTotal/h.maxVisibleAcrossCharts;const c=i.unit=="log"?1:0;const d=i.unit=="pct"?100:h.maxVisibleSeriesTotal;let p=e.colheadtop?e.collabelh-2:e.colgrplabelh-2;if(e.legendontop)p+=e.legendh;k.style("display","block").attr("transform","translate(2.5,"+p+")").call(s((i.unit=="log"?l():t()).domain([c,d/r]).range([0,e.svgw-e.rowlabelw])).ticks(4,o("d")));z.selectAll("*").remove();const g=e.svgw-e.rowlabelw;z.attr("transform","translate("+g/2+",0)").append("text").style("text-anchor","middle").style("font-size",e.axisTitleFontSize+"px").style("font-weight",600).text(i.handlers.xAxis.text(a))}function ht(t){const e=t.target.tagName=="tspan"?t.target.parentNode:t.target;const o=e.__data__;if(o&&(e.tagName=="rect"||e.nodeName=="text")){S=o;o.x;q(o.cellmates?o.cellmates[0]:o);M.attr("font-weight",lt).attr("font-size",nt).style("fill",rt)}else{S=d;B.attr("font-weight",ot).attr("font-size",at).style("fill",st);M.attr("font-weight",lt).attr("font-size",nt).style("fill",rt)}i.handlers.series.mouseover(t,o)}function pt(t){t.stopPropagation();M.attr("font-weight","").attr("font-size",c.colfontsize).style("fill","");S=d;if(i.handlers.series.mouseout)i.handlers.series.mouseout(t)}function gt(t){const e=t.target.__data__;if(!e)return;const o=i.col2name["id"in e?e.id:e];const a={colId:o.name};a[i.colkey]=o.name;a[i.colgrpkey]=o.grp;if(i.handlers.colLabel.mouseover)i.handlers.colLabel.mouseover(t)}function ft(t){S=d;if(i.handlers.colLabel.mouseout)i.handlers.colLabel.mouseout(t)}function ut(t){const e=t.target.__data__;n.handlers.series.click(t,e)}L.hm=i;L.styles=()=>{const t={};for(const e in A){t[e]=i[e]}if(legendRenderer){for(const e in legendRenderer.defaults)t[e]=i[e]}return t};return L}export{n as default};
|
|
1
|
+
import{l as t,q as e,f as o}from"./app-71453429.js";import{b as a,d as s}from"./axis-6cb4f314.js";import{l}from"./log-ca1e2a74.js";function n(n,r){const i={},c={};const d={};let h;let p;let g,f,u,m,w;let y,x,b,v,k,z,I;let S,B,M;let A;let T=[];let j;function L(t,e){let o=i.orientation;h=t;Object.assign(i,h.settings);i.handlers=h.handlers;i.cols=i.cols.filter((t=>i.colLabels.find((e=>e.id==t))));i.rows=i.rows?.filter((t=>!i.exclude.rows.includes(t)))||[];const a=!g;if(a)P();const s=i.colw;T=h.visibleSerieses;T.map(C);h.serieses.map(C);_();p.style("width",i.svgw+100+"px").style("font-weight",600).style("font-size","20px").style("margin-bottom","24px").html(i.handlers.chart.title(h));if(a){g.attr("height",0).attr("width",0).style("opacity",0);f.attr("transform","translate("+i.rowlabelw+",0)")}const l=u.attr("transform",E).selectAll(".bars-cell-grp").data(T,F);l.exit().each(O);l.each(N);l.enter().append("g").each(G);const n=m.attr("transform",Q).style("opacity",o!=i.orientation?1e-4:1).style("display",i.orientation!="vertical"?"none":"").selectAll("g").data(i.colLabels,(t=>t.id));n.exit().remove();n.each(Y);n.enter().append("g").each(X);const r=w.attr("transform",Z).style("opacity",o!=i.orientation?1e-4:1).style("display",i.orientation!="horizontal"?"none":"").selectAll("g").data(i.colLabels,(t=>t.id));r.exit().remove();r.each(et);r.enter().append("g").each(tt);u.selectAll("rect");M=m.selectAll("text");i.delay=.35*i.duration;it(i,o,h.visibleTotal);i.colw=s;if(o!=i.orientation){const t=i.orientation=="vertical"?m:w;t.transition().duration(1500).style("opacity",1)}if(a){g.transition().duration(100).attr("height",1).attr("width",1).style("opacity",1)}setTimeout((()=>{const t=20;const e=f.node().getBBox();const o=!j||e.width?e:j;j=o;g.transition().duration(e.width?100:0).attr("width",o.width+t).attr("height",o.height+t);if(i.orientation=="vertical"){const a=m.node().getBBox();const s=b.node().getBBox();const l=Math.max(-a.x,-s.x,-o.x);f.transition().duration(e.width?100:0).attr("transform","translate("+l+","+-t+")")}else{const t=w.node().getBBox();const o=b.node().getBBox();const a=z.node().getBBox();f.transition().duration(e.width?100:0).attr("transform","translate("+Math.max(-t.x,-o.x)+","+-a.y+")")}}),a?110:510)}function P(){A={geneonrow:i.geneonrow,nicenames:{},colw:i.geneonrow?Math.min(15,Math.max(1,Math.floor(document.body.clientWidth*.7/i.cols.length))):20,rowh:i.geneonrow?20:Math.min(18,Math.max(10,Math.floor(document.body.clientHeight*.7/i.rows.length))),rowspace:i.geneonrow?2:i.rows.length>100?0:1,colspace:!i.geneonrow?2:i.cols.length>100?0:1,rowtick:8,coltick:5,rowlabtickspace:4,collabtickspace:4,collabelh:150,rowlabelw:250,rowheadleft:true,colheadtop:false,samplecount4gene:true,samplecount4legend:false,showgrid:true,gridstroke:"#fff",showEmptyCells:false,cellbg:"#eeeeee",fontsizeratio:.9,rowlabelfontsizemax:16,collabelfontsizemax:12,crudefill:i.colw<=2,duration:1e3,delay:0};for(let t in A){if(!(t in i)||t=="cols"||t=="rows")i[t]=A[t]}if(!g){p=r.append("div").attr("class","pp-chart-title").style("text-align","center");g=r.append("svg").attr("class","pp-bars-svg").style("overflow","visible").on("mouseover.tphm2",i.handlers.svg.mouseover).on("mouseout.tphm2",i.handlers.svg.mouseout).on("click.tphm2",i.handlers.svg.click)}f=g.append("g").attr("class","sjpcb-bars-mainG").attr("data-testid","sjpcb-bars-mainG");i.h.svg=g;i.h.mainG=f;m=f.append("g").attr("class","bars-collabels").style("cursor",i.handlers.colLabel.click?"pointer":"").on("mouseover.tphm2",gt).on("mouseout.tphm2",ft).on("click.tphm2",i.handlers.colLabel.click);w=f.append("g").attr("class","bars-rowlabels").attr("data-testid","sjpcb-bars-rowlabels").style("cursor",i.handlers.rowLabel.click?"pointer":"").on("mouseover.tphm2",gt).on("mouseout.tphm2",ft).on("click.tphm2",i.handlers.rowLabel.click);u=f.append("g").attr("class","bars-series").attr("data-testid","sjpcb-bars-series").on("mouseover.tphm2",ht).on("mouseout.tphm2",pt).on("click",ut).style("cursor","pointer");y=f.append("g").attr("class","sjpcb-bar-chart-axis-g");x=y.append("g").attr("class","sjpcb-bar-chart-y-axis");v=y.append("line").attr("class","sjpcb-bar-chart-y-line").style("stroke","#000");b=y.append("g").attr("class","sjpcb-bar-chart-y-title").style("cursor","default");k=y.append("g").attr("class","sjpcb-bar-chart-x-axis");I=y.append("line").attr("class","sjpcb-bar-chart-x-line").style("stroke","#000");z=y.append("g").attr("class","sjpcb-bar-chart-x-title").style("cursor","default")}function _(){const e=i.numCharts<4?i.numCharts:i.numCharts%3==0?3:2;const o=i.cols.length*i.colspace+(i.colgrps.length-1)*i.colgspace+i.rowlabelw+i.rowgrplabelw;if(i.orientation=="horizontal"){i.svgw=Math.min(400,.92*window.innerWidth/e);i.rowh=Math.max(14,Math.min(22,.7*window.innerHeight/i.cols.length));i.svgh=i.cols.length*(i.rowh+i.colspace)-i.colspace+(i.colgrps.length-1)*i.colgspace+i.rowlabelw+i.rowgrplabelw}else{const t=window.innerWidth*.92/e;i.colw=Math.min(Math.max(16,Math.round((t-o)/i.cols.length)),30);i.svgw=i.cols.length*(i.colw+i.colspace)-i.colspace+(i.colgrps.length-1)*i.colgspace+i.rowlabelw+i.rowgrplabelw;const a=Math.ceil(i.numCharts/e);i.svgh=Math.max(350,Math.min(400,window.innerHeight*.5))/(a>3?2:1)}h.svgh=i.svgh;i.h.yScale={};i.h.xScale={};i.h.yPrevBySeries={};i.h.xPrevBySeries={};const a=i.scale=="byChart"?1:h.maxVisibleSeriesTotal/h.maxVisibleAcrossCharts;for(const e of T){if(e.visibleData[0]){const o=i.unit=="log"?1:0;const s=i.unit=="pct"?e.visibleTotal:i.unit=="log"?h.maxSeriesLogTotal:h.maxVisibleSeriesTotal;i.h.yScale[e.seriesId]=t().domain([o,s/a]).range([0,i.svgh-i.collabelh]);i.h.xScale[e.seriesId]=t().domain([o,s/a]).range([0,i.svgw-i.rowlabelw]);i.h.yPrevBySeries[e.seriesId]=0;i.h.xPrevBySeries[e.seriesId]=0;for(const t of e.visibleData){t.height=R(t);t.y=q(t);t.x=K(t);t.width=J(t)}}}c.colfontsize=Math.min(i.colw*i.fontsizeratio,i.collabelfontsizemax);c.rowfontsize=Math.min(i.rowh*i.fontsizeratio,i.rowlabelfontsizemax);c.rowtextyalign=Math.min(i.rowh,(i.rowh+c.rowfontsize)/2)+i.rowspace}function C(t){if(!("seriesId"in t)){t.data.map((e=>{if(e)t.seriesId=e[i.serieskey]}))}t.data.map((t=>{t.rowId=t[i.rowkey];t.colId=t[i.colkey]}))}function F(t){return t.seriesId}function V(t){return t.rowId+" "+t.colId}function O(){e(this).remove()}function N(t){const o=e(this).selectAll(".bars-cell").data(t.data.filter(H),V);o.exit().each((function(){e(this).remove()}));o.style("display",(t=>i.cols.includes(t.colId)?"block":"none"));o.select("rect").datum((t=>t)).transition().duration(i.duration).attr("x",(t=>t.x)).attr("y",(t=>t.y)).attr("width",(t=>t.width)).attr("height",(t=>t.height)).attr("fill",i.handlers.series.rectFill).attr("stroke",i.handlers.series.strokeFill);o.enter().append("g").each(W);o.selectAll("text").remove();D(o)}function G(t){if(!t||!t.data.length)return;e(this).attr("class","bars-cell-grp").selectAll("g").data(t.data.filter(H),V).enter().append("g").each(W)}function H(t){return i.rows.includes(t.dataId)}function W(t){const o=e(this).attr("class","bars-cell").datum(t);o.style("display",(t=>i.cols.includes(t.colId)?"block":"none"));o.append("rect").attr("x",(t=>t.x)).attr("y",(t=>t.y)).attr("width",(t=>t.width)).attr("height",(t=>t.height)).attr("fill",i.handlers.series.rectFill).attr("stroke",i.handlers.series.strokeFill).attr("shape-rendering","crispEdges").style("opacity",0).transition().delay(i.delay).duration(i.duration).style("opacity",1);D(o)}function D(t){if(!n.config.settings.barchart.asterisksVisible){return}t.append("text").text((t=>{const e=t.groupPvalues&&t.groupPvalues.term2tests.find((e=>e.term2id==t.dataId));if(!e||e.skipped||!e.adjusted_p_value)return"";return e.adjusted_p_value<.05?"*":""})).attr("x",(t=>t.x+t.width/2)).attr("y",(t=>t.y+t.height/2)).attr("dy","0.6em").style("text-anchor","middle").style("opacity",0).transition().delay(i.delay).duration(i.duration).style("opacity",1)}function E(){const t=i.colspace;let e=i.colheadtop?i.collabelh:i.colgrplabelh;if(i.legendontop)e+=i.legendh;return"translate("+t+","+e+")"}function R(t){const e=i.unit=="log"?t.logTotal:t.total;const o=i.orientation=="vertical"?i.h.yScale[t.seriesId](e):i.rowh;const a=0;i.h.yPrevBySeries[t.seriesId]+=o+a;return Math.max(1,o-a)}function q(t){const e=i.colgrps.indexOf(t[i.colgrpkey])*i.colgspace;const o=i.unit=="log"?Math.max(0,i.h.yPrevBySeries[t.seriesId]):i.h.yPrevBySeries[t.seriesId];return i.orientation=="vertical"?i.svgh-i.collabelh-o:i.cols.indexOf(t.colId)*(i.rowh+i.rowspace)+e}function J(t){const e=i.unit=="log"?t.logTotal:t.total;const o=i.orientation=="vertical"?i.colw:i.h.xScale[t.seriesId](e);const a=0;i.h.xPrevBySeries[t.seriesId];i.h.xPrevBySeries[t.seriesId]+=Math.max(1,o+a);return Math.max(1,o-a)}function K(t){const e=i.colgrps.indexOf(t[i.colgrpkey])*i.colgspace;return i.orientation=="vertical"?i.cols.indexOf(t.colId)*(i.colw+i.colspace)+e:i.h.xPrevBySeries[t.seriesId]}function Q(){let t=5+i.colspace;let e=i.colheadtop?i.borderwidth+1:i.svgh-i.collabelh+25;if(i.legendontop)e+=i.legendh;return"translate("+t+","+e+")"}function U(t){const e=i.col2name[t]?i.col2name[t].grp:"";const o=i.colgrps.indexOf(e)*i.colgspace+i.cols.indexOf("id"in t?t.id:t)*(i.colw+i.colspace)+i.colw/2;const a=i.colheadtop?-1*(i.coltick+i.collabtickspace):i.coltick+i.collabtickspace;return"translate("+o+","+a+")"}function X(t){if(!this||t===undefined)return;const o=e(this).attr("transform",U).style("opacity",0);o.append("text").attr("transform","rotate(-40)").attr("y",2).attr("text-anchor","end").attr("font-size",c.colfontsize+"px").html(i.handlers.colLabel.text);o.transition().delay(i.delay).duration(i.duration).style("opacity",1)}function Y(t){const o=e(this).datum(t);o.attr("transform",U);o.selectAll("text").datum(t).attr("y",2).attr("text-anchor","end").attr("font-size",c.colfontsize+"px").html(i.handlers.colLabel.text)}function Z(){const t=i.colheadtop?i.collabelh:i.colgrplabelh;const e=i.rowheadleft?i.borderwidth+1:i.svgw-i.rowlabelw+20;return"translate("+e+","+t+")"}function $(t){const e=i.row2name[t]?i.row2name[t].grp:"";const o=i.colgrps.indexOf(e)*i.rowgspace+i.cols.indexOf("id"in t?t.id:t)*(i.rowh+i.rowspace)+c.rowtextyalign;const a=i.rowheadleft?-1*(i.rowtick+i.rowlabtickspace):i.rowtick+i.rowlabtickspace;return"translate("+a+","+o+")"}function tt(t){if(!this||t===undefined)return;const o=e(this).attr("transform",$).style("opacity",0);o.append("text").attr("x",2).attr("text-anchor","end").attr("font-size",c.rowfontsize+"px").html(i.handlers.rowLabel.text);o.transition().delay(i.delay).duration(i.duration).style("opacity",1)}function et(t){const o=e(this).datum(t);o.attr("transform",$);o.selectAll("text").datum(t).attr("x",2).attr("text-anchor","end").attr("font-size",c.rowfontsize+"px").html(i.handlers.rowLabel.text)}function ot(t){return t==S.rowId?700:""}function at(t){return t==S.rowId?Math.max(12,c.rowfontsize):c.rowfontsize}function st(t){return t==S.rowId?"#00f":""}function lt(t){return t==S.colId?700:""}function nt(t){return t==S.colId?12:c.colfontsize}function rt(t){return t==S.colId?"#00f":""}function it(t,e,o){y.style("opacity",e!=t.orientation?0:1).transition().duration(1500).style("opacity",1);if(t.orientation=="vertical"){ct(t,o)}else{dt(t,o)}}function ct(e,s){k.style("display","none");v.style("display","none");const n=m.node().getBBox();e.svgh-e.collabelh+24;z.selectAll("*").remove();const r=i.handlers.xAxis.text(s);z.append("text").style("text-anchor","middle").style("font-size",e.axisTitleFontSize+"px").style("font-weight",600).text(r);setTimeout((()=>{z.attr("transform","translate("+(e.svgw-e.svgPadding.left-e.svgPadding.right-e.rowlabelw)/2+","+(n.height+i.svgh-i.collabelh+20+e.axisTitleFontSize)+")")}),0);const c=i.scale=="byChart"||i.clickedAge?1:h.maxVisibleSeriesTotal/h.maxVisibleAcrossCharts;const d=i.unit=="log"?1:0;const p=i.unit=="pct"?100:h.maxVisibleSeriesTotal;x.style("display","block").call(a((i.unit=="log"?l():t()).domain([p/c,d]).range([e.colgrplabelh,e.svgh-e.collabelh+e.colgrplabelh-e.borderwidth+1])).ticks(4,o("d")));b.selectAll("*").remove();const g=e.svgh-e.collabelh;b.style("font-weight",600).attr("transform","translate("+(-e.svgPadding.left-e.axisTitleFontSize)+","+g/2+")rotate(-90)").append("text").style("text-anchor","middle").style("font-size",e.axisTitleFontSize+"px").text(i.handlers.yAxis.text(s))}function dt(e,a){x.style("display","none");I.style("display","none");b.selectAll("*").remove();const n=i.handlers.yAxis.text(a);b.append("text").style("text-anchor","end").style("font-size",e.axisTitleFontSize+"px").style("font-weight",600).text(n);w.node().getBBox();setTimeout((()=>{b.style("text-anchor","end").attr("transform","translate("+0+",0)")}),0);const r=i.scale=="byChart"||i.clickedAge?1:h.maxVisibleSeriesTotal/h.maxVisibleAcrossCharts;const c=i.unit=="log"?1:0;const d=i.unit=="pct"?100:h.maxVisibleSeriesTotal;let p=e.colheadtop?e.collabelh-2:e.colgrplabelh-2;if(e.legendontop)p+=e.legendh;k.style("display","block").attr("transform","translate(2.5,"+p+")").call(s((i.unit=="log"?l():t()).domain([c,d/r]).range([0,e.svgw-e.rowlabelw])).ticks(4,o("d")));z.selectAll("*").remove();const g=e.svgw-e.rowlabelw;z.attr("transform","translate("+g/2+",0)").append("text").style("text-anchor","middle").style("font-size",e.axisTitleFontSize+"px").style("font-weight",600).text(i.handlers.xAxis.text(a))}function ht(t){const e=t.target.tagName=="tspan"?t.target.parentNode:t.target;const o=e.__data__;if(o&&(e.tagName=="rect"||e.nodeName=="text")){S=o;o.x;q(o.cellmates?o.cellmates[0]:o);M.attr("font-weight",lt).attr("font-size",nt).style("fill",rt)}else{S=d;B.attr("font-weight",ot).attr("font-size",at).style("fill",st);M.attr("font-weight",lt).attr("font-size",nt).style("fill",rt)}i.handlers.series.mouseover(t,o)}function pt(t){t.stopPropagation();M.attr("font-weight","").attr("font-size",c.colfontsize).style("fill","");S=d;if(i.handlers.series.mouseout)i.handlers.series.mouseout(t)}function gt(t){const e=t.target.__data__;if(!e)return;const o=i.col2name["id"in e?e.id:e];const a={colId:o.name};a[i.colkey]=o.name;a[i.colgrpkey]=o.grp;if(i.handlers.colLabel.mouseover)i.handlers.colLabel.mouseover(t)}function ft(t){S=d;if(i.handlers.colLabel.mouseout)i.handlers.colLabel.mouseout(t)}function ut(t){const e=t.target.__data__;n.handlers.series.click(t,e)}L.hm=i;L.styles=()=>{const t={};for(const e in A){t[e]=i[e]}if(legendRenderer){for(const e in legendRenderer.defaults)t[e]=i[e]}return t};return L}export{n as default};
|