import {
  detectOne
} from "./chunk-DJQTUDJM.js";
import {
  getRunPp
} from "./chunk-W55XSG6K.js";
import {
  require_tape
} from "./chunk-QWOE5YTB.js";
import {
  runproteinpaint
} from "./chunk-74ZU4BT6.js";
import "./chunk-IW57W7EQ.js";
import "./chunk-ZTYNN6G5.js";
import "./chunk-DKVUOBIE.js";
import "./chunk-PRZWSBMA.js";
import "./chunk-LTOBEUM2.js";
import "./chunk-MKAF2BHB.js";
import "./chunk-WKNI3HRQ.js";
import "./chunk-VGYTAYFK.js";
import "./chunk-67DBIM6H.js";
import "./chunk-SA7APTJR.js";
import "./chunk-HJ6L54YS.js";
import "./chunk-LSEFWW72.js";
import "./chunk-SKREEF3H.js";
import "./chunk-HYOEWQ5P.js";
import "./chunk-HBW42TDT.js";
import "./chunk-G6O3URDN.js";
import "./chunk-FN5XPUPH.js";
import "./chunk-IIT367QZ.js";
import "./chunk-RZGEKL77.js";
import "./chunk-UI7OCM2A.js";
import "./chunk-YZK37YCC.js";
import "./chunk-7EMWHCVW.js";
import "./chunk-7IYJZZQI.js";
import "./chunk-M3J4MINX.js";
import "./chunk-PF4DSFDR.js";
import "./chunk-QH6W3NVF.js";
import "./chunk-NOEAT6CX.js";
import "./chunk-4UWS5Y3N.js";
import "./chunk-DD4R5P6W.js";
import "./chunk-JNITUVXP.js";
import "./chunk-KSGA62R2.js";
import "./chunk-LOZEKOES.js";
import "./chunk-TOU7EVFQ.js";
import "./chunk-OAWQ6LOO.js";
import "./chunk-TLT4YIG3.js";
import "./chunk-KYBIQBXE.js";
import {
  select_default
} from "./chunk-I6Y4O3RR.js";
import "./chunk-OMR2DT66.js";
import "./chunk-DQC5FFGV.js";
import {
  __toESM
} from "./chunk-HFNDKYVF.js";

// plots/test/expclust.gdc.spec.js
var import_tape = __toESM(require_tape(), 1);
(0, import_tape.default)("\n", function(test) {
  test.comment("-***- plots/hierCluster.gdc -***-");
  test.end();
});
(0, import_tape.default)("TME genes and dictionary variables, survival", function(test) {
  test.timeoutAfter(6e4);
  runpp({
    state: {
      nav: { header_mode: "hidden" },
      // must set to hidden for gdc, since it lacks termdb method to get cohort size..
      plots: [
        {
          chartType: "hierCluster",
          dataType: "geneExpression",
          /* not needed, reenable to add other customizations
          settings: {
          	hierCluster: {
          		termGroupName: 'Gene Expression (CGC genes only)'
          	}
          },
          */
          terms: TMEgenes,
          termgroups: [{ name: "Variables", lst: dictTerms }]
        }
      ]
    },
    hierCluster: {
      callbacks: {
        "postRender.test": runTests
      }
    }
  });
  async function runTests(hierCluster) {
    hierCluster.on("postRender.test", null);
    await testhierClusterrendering(hierCluster);
    await testLegendRendering(hierCluster);
    await testBtnRendering(hierCluster);
    await testZoom(hierCluster);
    await testCaseLabelCharLimit(hierCluster);
    await testClusteringMethod(hierCluster);
    await testRowColumnDendrograms(hierCluster);
    await testzScoreCap(hierCluster);
    if (test._ok) hierCluster.Inner.app.destroy();
    test.end();
  }
  async function testhierClusterrendering(hierCluster) {
    await detectOne({ elem: hierCluster.Inner.dom.seriesesG.node(), selector: "image" });
    test.equal(hierCluster.Inner.dom.seriesesG.selectAll("image").size(), 1, `should render 1 <image> element`);
    test.equal(
      hierCluster.Inner.dom.svg.selectAll(".sjpp-matrix-term-label-g").node().querySelectorAll("text").length,
      TMEgenes.length + dictTerms.length,
      `should render ${TMEgenes.length + dictTerms.length} <series> elements`
    );
    test.pass("hierCluster rendered");
  }
  async function testLegendRendering(hierCluster) {
    test.true(hierCluster.Inner.dom.legendG.nodes().length > 0, `should render legend`);
    test.true(hierCluster.Inner.dom.legendG.selectAll("rect").size() > 0, `should render legend rects`);
    test.true(hierCluster.Inner.dom.legendG.selectAll("text").size() > 0, `should render legend text`);
  }
  async function testBtnRendering(hierCluster) {
    test.equal(hierCluster.Inner.dom.controls.node().querySelectorAll("button").length, 9, `should render buttons`);
  }
  async function testZoom(hierCluster) {
    await hierCluster.Inner.app.dispatch({
      type: "plot_edit",
      id: hierCluster.Inner.id,
      config: {
        settings: {
          hierCluster: {
            zoomLevel: 10
          },
          //note zoom works via matrix settings, not hierCluster
          matrix: {
            zoomLevel: 10
          }
        }
      }
    });
    test.equal(
      hierCluster.Inner.config.settings.hierCluster.zoomLevel,
      10,
      `config.settings.hiercluster.zoomlevel does not allow zoom in on the UI`
    );
    test.equal(
      hierCluster.Inner.config.settings.matrix.zoomLevel,
      10,
      `config.settings.matrix.zoomlevel allows zoom in on the UI`
    );
  }
  async function testCaseLabelCharLimit(hierCluster) {
    await hierCluster.Inner.app.dispatch({
      type: "plot_edit",
      id: hierCluster.Inner.id,
      config: {
        settings: {
          matrix: {
            collabelmaxchars: 10
          }
        }
      }
    });
    test.equal(
      hierCluster.Inner.config.settings.matrix.collabelmaxchars,
      10,
      `should limit case label characters to ${hierCluster.Inner.config.settings.matrix.collabelmaxchars}`
    );
  }
  async function testClusteringMethod(hierCluster) {
    await hierCluster.Inner.app.dispatch({
      type: "plot_edit",
      id: hierCluster.Inner.id,
      config: {
        settings: {
          hierCluster: {
            clusterMethod: "complete",
            distanceMethod: "euclidean"
          }
        }
      }
    });
    test.equal(
      hierCluster.Inner.config.settings.hierCluster.clusterMethod,
      "complete",
      `should change clustering method to ${hierCluster.Inner.config.settings.hierCluster.clusterMethod}`
    );
    test.equal(
      hierCluster.Inner.config.settings.hierCluster.distanceMethod,
      "euclidean",
      `should change clustering method to ${hierCluster.Inner.config.settings.hierCluster.distanceMethod}`
    );
  }
  async function testRowColumnDendrograms(hierCluster) {
    await hierCluster.Inner.app.dispatch({
      type: "plot_edit",
      id: hierCluster.Inner.id,
      config: {
        settings: {
          hierCluster: {
            colDendrogramHeight: 100,
            rowDendrogramWidth: 200
          }
        }
      }
    });
    test.equal(
      hierCluster.Inner.config.settings.hierCluster.colDendrogramHeight,
      100,
      `should change column dendrogram height to ${hierCluster.Inner.config.settings.hierCluster.colDendrogramHeight}`
    );
    test.equal(
      hierCluster.Inner.config.settings.hierCluster.rowDendrogramWidth,
      200,
      `should change row dendrogram width to ${hierCluster.Inner.config.settings.hierCluster.rowDendrogramWidth}`
    );
  }
  async function testzScoreCap(hierCluster) {
    await hierCluster.Inner.app.dispatch({
      type: "plot_edit",
      id: hierCluster.Inner.id,
      config: {
        settings: {
          hierCluster: {
            zScoreCap: 10
          }
        }
      }
    });
    test.equal(
      hierCluster.Inner.config.settings.hierCluster.zScoreCap,
      10,
      `should cap zscore at ${hierCluster.Inner.config.settings.hierCluster.zScoreCap}`
    );
  }
});
(0, import_tape.default)("gdc laucher with top variably expressed genes, for gliomas", function(test) {
  const maxGeneCount = 5;
  runproteinpaint({
    debug: true,
    holder: select_default("body").append("div").node(),
    noheader: 1,
    launchGdcHierCluster: true,
    filter0: {
      op: "and",
      content: [{ op: "in", content: { field: "cases.disease_type", value: ["Gliomas"] } }]
    },
    settings: {
      hierCluster: {
        maxGenes: maxGeneCount
      }
    },
    termgroups: [
      {
        name: "Variables",
        lst: dictTerms
      }
    ],
    opts: {
      hierCluster: {
        callbacks: {
          "postRender.test": runTests
        }
      }
    }
  });
  async function runTests(hierCluster) {
    hierCluster.on("postRender.test", null);
    await detectOne({ elem: hierCluster.Inner.dom.seriesesG.node(), selector: "image" });
    test.equal(hierCluster.Inner.dom.seriesesG.selectAll("image").size(), 1, `should render 1 <image> element`);
    test.equal(
      hierCluster.Inner.dom.svg.selectAll(".sjpp-matrix-term-label-g").node().querySelectorAll("text").length,
      maxGeneCount + dictTerms.length,
      `should render ${maxGeneCount + dictTerms.length} <series> elements`
    );
    if (test._ok) hierCluster.Inner.app.destroy();
    test.end();
  }
});
var runpp = getRunPp("mass", {
  state: {
    dslabel: "GDC",
    genome: "hg38"
  },
  debug: 1
});
var TMEgenes = [
  { gene: "KIF11" },
  { gene: "BUB1B" },
  { gene: "BUB1" },
  { gene: "CDK1" },
  { gene: "CDC20" },
  { gene: "AURKB" },
  { gene: "TPX2" },
  { gene: "CCNB2" },
  { gene: "CCNA2" },
  { gene: "TOP2A" },
  { gene: "AURKA" },
  { gene: "KIF20A" },
  { gene: "KIF2C" },
  { gene: "CDCA8" }
];
var dictTerms = [
  { id: "case.disease_type" },
  { id: "case.primary_site" },
  { id: "case.demographic.gender" },
  { id: "Overall Survival" }
];
//# sourceMappingURL=expclust.gdc.spec-UJO2R3CW.js.map
