@platforma-open/milaboratories.repertoire-mutation-heatmap.block 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8905,6 +8905,8 @@ const dataModel = new DataModelBuilder().from("v1").init(() => ({
8905
8905
  valueMode: "abundance",
8906
8906
  normalize: true,
8907
8907
  filter: { membership: "all" },
8908
+ roundFrequencyRefs: [],
8909
+ compositionEpsilon: 1e-6,
8908
8910
  stateHeatmapState: {
8909
8911
  title: "Deep Mutational Scanning",
8910
8912
  template: "heatmap",
@@ -8930,6 +8932,19 @@ const dataModel = new DataModelBuilder().from("v1").init(() => ({
8930
8932
  hideAxisLabels: false,
8931
8933
  cellSize: 20
8932
8934
  } }
8935
+ },
8936
+ compositionHeatmapState: {
8937
+ title: "Composition Enrichment",
8938
+ template: "heatmap",
8939
+ currentTab: null,
8940
+ layersSettings: { heatmap: {
8941
+ normalizationDirection: null,
8942
+ transform: null
8943
+ } },
8944
+ axesSettings: { axisY: {
8945
+ hideAxisLabels: false,
8946
+ cellSize: 20
8947
+ } }
8933
8948
  }
8934
8949
  }));
8935
8950
  const platforma$1 = BlockModelV3.create(dataModel).args((data) => {
@@ -8944,18 +8959,63 @@ const platforma$1 = BlockModelV3.create(dataModel).args((data) => {
8944
8959
  level: data.level,
8945
8960
  valueMode: data.valueMode,
8946
8961
  normalize: data.valueMode === "abundance" ? data.normalize : false,
8947
- filter: canonicalizeFilter(data.filter)
8962
+ filter: canonicalizeFilter(data.filter),
8963
+ roundFrequencyRefs: data.roundFrequencyRefs ?? [],
8964
+ compositionEpsilon: data.compositionEpsilon ?? 1e-6
8948
8965
  };
8949
8966
  }).output("stateMatrixOptions", (ctx) => ctx.resultPool.getOptions([{ name: STATE_MATRIX }], { label: { includeNativeLabel: true } })).output("abundanceOptions", (ctx) => ctx.resultPool.getOptions([{
8950
8967
  axes: [{ name: SAMPLE_ID_AXIS }, { name: VARIANT_KEY_AXIS }],
8951
8968
  annotations: { "pl7.app/isAbundance": "true" }
8952
8969
  }], { label: { includeNativeLabel: true } })).output("propertyOptions", (ctx) => {
8953
- const anchor = ctx.data.stateMatrixRef;
8954
- if (anchor === void 0) return void 0;
8955
- return ctx.resultPool.getCanonicalOptions({ main: anchor }, [{ axes: [{
8956
- anchor: "main",
8957
- idx: 0
8958
- }] }]);
8970
+ const stateMatrixRef = ctx.data.stateMatrixRef;
8971
+ if (stateMatrixRef === void 0) return void 0;
8972
+ const stateSpec = ctx.resultPool.getPColumnSpecByRef(stateMatrixRef);
8973
+ if (!stateSpec) return void 0;
8974
+ const anchors = { main: stateSpec };
8975
+ const abundanceRef = ctx.data.abundanceRef;
8976
+ const abundanceSpec = abundanceRef ? ctx.resultPool.getPColumnSpecByRef(abundanceRef) : void 0;
8977
+ if (abundanceSpec) anchors.freqAnchor = abundanceSpec;
8978
+ const sourceColumns = ctx.resultPool.selectColumns((spec) => spec.valueType !== "File" && !(spec.annotations?.["pl7.app/isLinkerColumn"] === "true" && spec.axesSpec.length > 2));
8979
+ const collection = new ColumnCollectionBuilder(ctx.getService("pframeSpec")).addSource(sourceColumns).build({ anchors });
8980
+ if (!collection) return void 0;
8981
+ const numeric = /* @__PURE__ */ new Set([
8982
+ "Int",
8983
+ "Long",
8984
+ "Float",
8985
+ "Double"
8986
+ ]);
8987
+ const seen = /* @__PURE__ */ new Set();
8988
+ const options = [];
8989
+ for (const m of collection.findColumns({
8990
+ mode: "enrichment",
8991
+ maxHops: 0
8992
+ })) {
8993
+ if (!numeric.has(m.column.spec.valueType)) continue;
8994
+ const dedupKey = m.column.spec.name + "|" + JSON.stringify(m.column.spec.domain ?? {});
8995
+ if (seen.has(dedupKey)) continue;
8996
+ seen.add(dedupKey);
8997
+ options.push({
8998
+ label: m.column.spec.annotations?.["pl7.app/label"] ?? m.column.id,
8999
+ value: m.column.id
9000
+ });
9001
+ }
9002
+ return options;
9003
+ }).output("roundFrequencyOptions", (ctx) => {
9004
+ const abundanceRef = ctx.data.abundanceRef;
9005
+ if (abundanceRef === void 0) return void 0;
9006
+ const anchorSpec = ctx.resultPool.getPColumnSpecByRef(abundanceRef);
9007
+ if (!anchorSpec) return void 0;
9008
+ const sourceColumns = ctx.resultPool.selectColumns((spec) => spec.valueType !== "File" && !(spec.annotations?.["pl7.app/isLinkerColumn"] === "true" && spec.axesSpec.length > 2));
9009
+ const collection = new ColumnCollectionBuilder(ctx.getService("pframeSpec")).addSource(sourceColumns).build({ anchors: { freqAnchor: anchorSpec } });
9010
+ if (!collection) return void 0;
9011
+ return collection.findColumns({
9012
+ include: { name: "pl7.app/frequency" },
9013
+ mode: "enrichment",
9014
+ maxHops: 0
9015
+ }).map((m) => ({
9016
+ label: m.column.spec.annotations?.["pl7.app/label"] ?? m.column.id,
9017
+ value: m.column.id
9018
+ }));
8959
9019
  }).output("knownAbundanceOptions", (ctx) => ctx.resultPool.getOptions([{
8960
9020
  axes: [{ name: SAMPLE_ID_AXIS }, { name: KNOWN_VARIANT_KEY_AXIS }],
8961
9021
  annotations: {
@@ -8998,6 +9058,20 @@ const platforma$1 = BlockModelV3.create(dataModel).args((data) => {
8998
9058
  } catch {
8999
9059
  return;
9000
9060
  }
9061
+ }).outputWithStatus("compositionHeatmapPf", (ctx) => {
9062
+ try {
9063
+ const pCols = ctx.outputs?.resolve("compositionHeatmapPf")?.getPColumns();
9064
+ if (pCols === void 0) return void 0;
9065
+ return createPFrameForGraphs(ctx, pCols);
9066
+ } catch {
9067
+ return;
9068
+ }
9069
+ }).output("compositionHeatmapPCols", (ctx) => {
9070
+ try {
9071
+ return ctx.outputs?.resolve("compositionHeatmapPf")?.getPColumns();
9072
+ } catch {
9073
+ return;
9074
+ }
9001
9075
  }).outputWithStatus("knownHeatmapPf", (ctx) => {
9002
9076
  const { knownAbundanceRef } = ctx.data;
9003
9077
  if (knownAbundanceRef === void 0) return void 0;
@@ -9046,6 +9120,11 @@ const platforma$1 = BlockModelV3.create(dataModel).args((data) => {
9046
9120
  href: "/",
9047
9121
  label: "Mutation Heatmap"
9048
9122
  }];
9123
+ if (ctx.data.roundFrequencyRefs.length >= 2) sections.push({
9124
+ type: "link",
9125
+ href: "/composition",
9126
+ label: "Composition Enrichment"
9127
+ });
9049
9128
  if (ctx.data.knownAbundanceRef !== void 0) sections.push({
9050
9129
  type: "link",
9051
9130
  href: "/known-heatmap",