@milaboratories/miplots4 1.0.145 → 1.0.147
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/heatmap/ChartRenderer.d.ts +1 -1
- package/dist/heatmap/ChartRenderer.d.ts.map +1 -1
- package/dist/heatmap/ChartRenderer.js +110 -109
- package/dist/heatmap/ChartRenderer.js.map +1 -1
- package/dist/heatmap/HeatmapSettingsImpl.d.ts +1 -0
- package/dist/heatmap/HeatmapSettingsImpl.d.ts.map +1 -1
- package/dist/heatmap/HeatmapSettingsImpl.js +7 -6
- package/dist/heatmap/HeatmapSettingsImpl.js.map +1 -1
- package/dist/heatmap/components/Annotations/Annotation.d.ts +2 -2
- package/dist/heatmap/components/Annotations/Annotation.d.ts.map +1 -1
- package/dist/heatmap/components/Annotations/Annotation.js +106 -98
- package/dist/heatmap/components/Annotations/Annotation.js.map +1 -1
- package/dist/heatmap/components/Annotations/AnnotationCellsCanvas.d.ts +23 -0
- package/dist/heatmap/components/Annotations/AnnotationCellsCanvas.d.ts.map +1 -0
- package/dist/heatmap/components/Annotations/AnnotationCellsCanvas.js +99 -0
- package/dist/heatmap/components/Annotations/AnnotationCellsCanvas.js.map +1 -0
- package/dist/heatmap/components/Annotations/AnnotationCellsSvg.d.ts +23 -0
- package/dist/heatmap/components/Annotations/AnnotationCellsSvg.d.ts.map +1 -0
- package/dist/heatmap/components/Annotations/AnnotationCellsSvg.js +57 -0
- package/dist/heatmap/components/Annotations/AnnotationCellsSvg.js.map +1 -0
- package/dist/heatmap/components/Annotations/index.d.ts +2 -2
- package/dist/heatmap/components/Annotations/index.d.ts.map +1 -1
- package/dist/heatmap/components/Annotations/index.js +2 -2
- package/dist/heatmap/components/Annotations/index.js.map +1 -1
- package/dist/heatmap/components/CanvasCells.d.ts +21 -0
- package/dist/heatmap/components/CanvasCells.d.ts.map +1 -0
- package/dist/heatmap/components/CanvasCells.js +85 -0
- package/dist/heatmap/components/CanvasCells.js.map +1 -0
- package/dist/heatmap/components/Chart.d.ts +2 -1
- package/dist/heatmap/components/Chart.d.ts.map +1 -1
- package/dist/heatmap/components/Chart.js +180 -186
- package/dist/heatmap/components/Chart.js.map +1 -1
- package/dist/heatmap/components/ChartsGroup.d.ts +2 -1
- package/dist/heatmap/components/ChartsGroup.d.ts.map +1 -1
- package/dist/heatmap/components/ChartsGroup.js +27 -25
- package/dist/heatmap/components/ChartsGroup.js.map +1 -1
- package/dist/heatmap/components/Dendrograms.d.ts.map +1 -1
- package/dist/heatmap/components/Dendrograms.js +51 -51
- package/dist/heatmap/components/Dendrograms.js.map +1 -1
- package/dist/heatmap/components/SvgCells.d.ts +19 -0
- package/dist/heatmap/components/SvgCells.d.ts.map +1 -0
- package/dist/heatmap/components/SvgCells.js +38 -0
- package/dist/heatmap/components/SvgCells.js.map +1 -0
- package/dist/heatmap/components/tooltipUtils.d.ts +10 -0
- package/dist/heatmap/components/tooltipUtils.d.ts.map +1 -0
- package/dist/heatmap/components/tooltipUtils.js +44 -0
- package/dist/heatmap/components/tooltipUtils.js.map +1 -0
- package/dist/heatmap/components/types.d.ts +8 -1
- package/dist/heatmap/components/types.d.ts.map +1 -1
- package/dist/heatmap/constants.d.ts +1 -0
- package/dist/heatmap/constants.d.ts.map +1 -1
- package/dist/heatmap/constants.js +13 -12
- package/dist/heatmap/constants.js.map +1 -1
- package/dist/heatmap/getCells.d.ts.map +1 -1
- package/dist/heatmap/getCells.js +65 -68
- package/dist/heatmap/getCells.js.map +1 -1
- package/dist/heatmap/getClusters.d.ts +81 -4
- package/dist/heatmap/getClusters.d.ts.map +1 -1
- package/dist/heatmap/getClusters.js +137 -48
- package/dist/heatmap/getClusters.js.map +1 -1
- package/dist/heatmap/getDendrograms.d.ts.map +1 -1
- package/dist/heatmap/getDendrograms.js +33 -35
- package/dist/heatmap/getDendrograms.js.map +1 -1
- package/dist/heatmap/index.d.ts.map +1 -1
- package/dist/heatmap/index.js +89 -87
- package/dist/heatmap/index.js.map +1 -1
- package/dist/node_modules/react/index.js +1 -1
- package/dist/node_modules/react-dom/index.js +1 -1
- package/dist/types/heatmap.d.ts +3 -0
- package/dist/types/heatmap.d.ts.map +1 -1
- package/dist/types/heatmap.js +5 -4
- package/dist/types/heatmap.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { format as s } from "../../node_modules/d3-format/src/defaultLocale.js";
|
|
2
|
+
function l(n, o) {
|
|
3
|
+
if (n === null)
|
|
4
|
+
return "null";
|
|
5
|
+
if (typeof n == "number") {
|
|
6
|
+
if (o)
|
|
7
|
+
return s(o)(n);
|
|
8
|
+
const e = n > 0 ? Math.floor(n) : Math.ceil(n), t = n - e;
|
|
9
|
+
return e + Number(t.toPrecision(2));
|
|
10
|
+
}
|
|
11
|
+
return n;
|
|
12
|
+
}
|
|
13
|
+
function c(n, o, e, t = []) {
|
|
14
|
+
const i = `${l(o.value)}${o.value !== o.normalizedValue ? ` (${l(o.normalizedValue)})` : ""}`;
|
|
15
|
+
if (t.length) {
|
|
16
|
+
const r = [
|
|
17
|
+
`Value: ${i}`
|
|
18
|
+
];
|
|
19
|
+
for (const u of t) {
|
|
20
|
+
const f = n.getColumnValue(u.value, o.idx);
|
|
21
|
+
r.push(`${u.label}: ${l(f, u.format)}`);
|
|
22
|
+
}
|
|
23
|
+
return r;
|
|
24
|
+
}
|
|
25
|
+
return [i];
|
|
26
|
+
}
|
|
27
|
+
function m(n, o) {
|
|
28
|
+
const e = [];
|
|
29
|
+
return n.xKey && e.push(`X: ${o.xLabels[n.xKey]}`), n.yKey && e.push(`Y: ${o.yLabels[n.yKey]}`), e.push(`${n.title}: ${l(n.value, n.column.format)}`), e;
|
|
30
|
+
}
|
|
31
|
+
function p(n) {
|
|
32
|
+
return n !== null && "isAnnotation" in n;
|
|
33
|
+
}
|
|
34
|
+
function $(n) {
|
|
35
|
+
return n !== null && "isCell" in n;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
l as formatCellValue,
|
|
39
|
+
m as getAnnotationTooltipContent,
|
|
40
|
+
c as getTooltipContent,
|
|
41
|
+
p as isAnnotationTooltip,
|
|
42
|
+
$ as isCellTooltip
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=tooltipUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltipUtils.js","sources":["../../../src/heatmap/components/tooltipUtils.ts"],"sourcesContent":["import { format as d3format } from 'd3-format';\nimport type { DataFrame } from '../../DataFrame';\nimport type { ColumnName, DataValue } from '../../types';\nimport type { Cell, GroupedCellsData } from '../getCells';\nimport type { AnnotationTooltipData } from './types';\n\nexport function formatCellValue(v: DataValue, format?: string): number | string {\n if (v === null) {\n return 'null';\n }\n if (typeof v === 'number') {\n if (format) {\n return d3format(format)(v);\n }\n const whole = v > 0 ? Math.floor(v) : Math.ceil(v);\n const decimal = v - whole;\n return whole + Number(decimal.toPrecision(2));\n }\n return v;\n}\nexport function getTooltipContent(\n dataFrame: DataFrame,\n cell: Cell,\n cellsMeta: GroupedCellsData['meta'],\n columnsList: ColumnName[] = []\n) {\n const value = `${formatCellValue(cell.value)}${cell.value !== cell.normalizedValue ? ` (${formatCellValue(cell.normalizedValue)})` : ''}`;\n if (columnsList.length) {\n const lines = [\n `Value: ${value}`,\n ];\n for (const column of columnsList) {\n const value = dataFrame.getColumnValue(column.value, cell.idx);\n lines.push(`${column.label}: ${formatCellValue(value, column.format)}`);\n }\n return lines;\n }\n\n return [value];\n}\nexport function getAnnotationTooltipContent(data: AnnotationTooltipData, cellsMeta: GroupedCellsData['meta']) {\n const lines: string[] = [];\n if (data.xKey) {\n lines.push(`X: ${cellsMeta.xLabels[data.xKey as string]}`);\n }\n if (data.yKey) {\n lines.push(`Y: ${cellsMeta.yLabels[data.yKey as string]}`);\n }\n lines.push(`${data.title}: ${formatCellValue(data.value, data.column.format)}`);\n return lines;\n}\n\nexport function isAnnotationTooltip(d: Cell | AnnotationTooltipData | null): d is AnnotationTooltipData {\n return d !== null && 'isAnnotation' in d;\n}\n\nexport function isCellTooltip(d: Cell | AnnotationTooltipData | null): d is Cell {\n return d !== null && 'isCell' in d;\n}\n"],"names":["formatCellValue","v","format","d3format","whole","decimal","getTooltipContent","dataFrame","cell","cellsMeta","columnsList","value","lines","column","getAnnotationTooltipContent","data","isAnnotationTooltip","d","isCellTooltip"],"mappings":";AAMO,SAASA,EAAgBC,GAAcC,GAAkC;AAC5E,MAAID,MAAM;AACN,WAAO;AAEX,MAAI,OAAOA,KAAM,UAAU;AACvB,QAAIC;AACA,aAAOC,EAASD,CAAM,EAAED,CAAC;AAE7B,UAAMG,IAAQH,IAAI,IAAI,KAAK,MAAMA,CAAC,IAAI,KAAK,KAAKA,CAAC,GAC3CI,IAAUJ,IAAIG;AACpB,WAAOA,IAAQ,OAAOC,EAAQ,YAAY,CAAC,CAAC;AAAA,EAChD;AACA,SAAOJ;AACX;AACO,SAASK,EACZC,GACAC,GACAC,GACAC,IAA4B,CAAA,GAC9B;AACE,QAAMC,IAAQ,GAAGX,EAAgBQ,EAAK,KAAK,CAAC,GAAGA,EAAK,UAAUA,EAAK,kBAAkB,KAAKR,EAAgBQ,EAAK,eAAe,CAAC,MAAM,EAAE;AACvI,MAAIE,EAAY,QAAQ;AACpB,UAAME,IAAQ;AAAA,MACV,UAAUD,CAAK;AAAA,IAAA;AAEnB,eAAWE,KAAUH,GAAa;AAC9B,YAAMC,IAAQJ,EAAU,eAAeM,EAAO,OAAOL,EAAK,GAAG;AAC7D,MAAAI,EAAM,KAAK,GAAGC,EAAO,KAAK,KAAKb,EAAgBW,GAAOE,EAAO,MAAM,CAAC,EAAE;AAAA,IAC1E;AACA,WAAOD;AAAA,EACX;AAEA,SAAO,CAACD,CAAK;AACjB;AACO,SAASG,EAA4BC,GAA6BN,GAAqC;AAC1G,QAAMG,IAAkB,CAAA;AACxB,SAAIG,EAAK,QACLH,EAAM,KAAK,MAAMH,EAAU,QAAQM,EAAK,IAAc,CAAC,EAAE,GAEzDA,EAAK,QACLH,EAAM,KAAK,MAAMH,EAAU,QAAQM,EAAK,IAAc,CAAC,EAAE,GAE7DH,EAAM,KAAK,GAAGG,EAAK,KAAK,KAAKf,EAAgBe,EAAK,OAAOA,EAAK,OAAO,MAAM,CAAC,EAAE,GACvEH;AACX;AAEO,SAASI,EAAoBC,GAAoE;AACpG,SAAOA,MAAM,QAAQ,kBAAkBA;AAC3C;AAEO,SAASC,EAAcD,GAAmD;AAC7E,SAAOA,MAAM,QAAQ,YAAYA;AACrC;"}
|
|
@@ -69,7 +69,6 @@ export interface ChartDimensionsData {
|
|
|
69
69
|
export type Cluster = {
|
|
70
70
|
height: number;
|
|
71
71
|
indexes: number[];
|
|
72
|
-
keys: string[];
|
|
73
72
|
children: Cluster[];
|
|
74
73
|
};
|
|
75
74
|
export type ChartDendrograms = {
|
|
@@ -103,6 +102,14 @@ export type AnnotationTooltipData = {
|
|
|
103
102
|
yKey: DataValue | null;
|
|
104
103
|
value: DataValue;
|
|
105
104
|
title: string;
|
|
105
|
+
cell: {
|
|
106
|
+
x: number;
|
|
107
|
+
y: number;
|
|
108
|
+
width: number;
|
|
109
|
+
height: number;
|
|
110
|
+
fill: string;
|
|
111
|
+
stroke: string;
|
|
112
|
+
};
|
|
106
113
|
column: ColumnName;
|
|
107
114
|
};
|
|
108
115
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/heatmap/components/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,KAAK,EAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE,MAAM,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2
|
-
const n = 15, s = 8, T = 30,
|
|
2
|
+
const n = 15, s = 8, T = 30, E = 48, i = 24, _ = 16, e = 4, I = 4, a = 20, S = 16, N = 16, c = 8, l = {
|
|
3
3
|
left: ["annotations", "axis", "groups", "axisTitle", "dendro"],
|
|
4
4
|
right: ["annotations", "axis", "groups", "axisTitle", "dendro"],
|
|
5
5
|
top: ["annotations", "axis", "groups", "axisTitle", "dendro", "facetTitle"],
|
|
6
6
|
bottom: ["annotations", "axis", "groups", "axisTitle", "dendro"]
|
|
7
|
-
},
|
|
7
|
+
}, A = {
|
|
8
8
|
fillColor: "white",
|
|
9
9
|
lineColor: o,
|
|
10
10
|
lineWidth: 1,
|
|
@@ -12,21 +12,22 @@ const n = 15, s = 8, T = 30, i = 48, E = 24, _ = 16, I = 4, a = 4, e = 20, S = 1
|
|
|
12
12
|
dotSize: 3,
|
|
13
13
|
dotFill: o,
|
|
14
14
|
dotShape: "21"
|
|
15
|
-
};
|
|
15
|
+
}, F = 5e5;
|
|
16
16
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
c as ANNOTATIONS_OFFSET,
|
|
18
|
+
N as ANNOTATION_WIDTH,
|
|
19
|
+
l as CHART_SIDE_ELEMENTS,
|
|
20
|
+
A as DEFAULT_AES,
|
|
21
|
+
I as DEFAULT_TICKS_SIZE,
|
|
22
|
+
E as FACET_TITLE_LINE,
|
|
23
|
+
i as FACET_TITLE_OFFSET,
|
|
24
24
|
S as FONT_SIZE,
|
|
25
|
-
|
|
25
|
+
a as LEGEND_OFFSET,
|
|
26
|
+
F as MAX_SVG_RENDERED_CELLS_COUNT,
|
|
26
27
|
s as MIN_MARGIN,
|
|
27
28
|
n as MIN_PADDING,
|
|
28
29
|
_ as MIN_STEP_FOR_VISIBLE_LABELS,
|
|
29
|
-
|
|
30
|
+
e as TICK_OFFSET,
|
|
30
31
|
T as TITLE_LINE
|
|
31
32
|
};
|
|
32
33
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../src/heatmap/constants.ts"],"sourcesContent":["import {BLACK} from '../constants';\nimport type {AesItem} from '../types';\n\nexport const MIN_PADDING = 15;\nexport const MIN_MARGIN = 8;\n\nexport const TITLE_LINE = 30;\nexport const FACET_TITLE_LINE = 48;\nexport const FACET_TITLE_OFFSET = 24;\n\nexport const MIN_STEP_FOR_VISIBLE_LABELS = 16;\n\nexport const TICK_OFFSET = 4;\nexport const DEFAULT_TICKS_SIZE = 4;\n\nexport const LEGEND_OFFSET = 20;\nexport const FONT_SIZE = 16;\n\nexport const ANNOTATION_WIDTH = 16;\nexport const ANNOTATIONS_OFFSET = 8;\n\nexport const CHART_SIDE_ELEMENTS = {\n left: ['annotations', 'axis', 'groups', 'axisTitle', 'dendro'],\n right: ['annotations', 'axis', 'groups', 'axisTitle', 'dendro'],\n top: ['annotations', 'axis', 'groups', 'axisTitle', 'dendro', 'facetTitle'],\n bottom: ['annotations', 'axis', 'groups', 'axisTitle', 'dendro']\n};\n\nexport const DEFAULT_AES:AesItem = {\n fillColor: 'white',\n lineColor: BLACK,\n lineWidth: 1,\n lineShape: 'solid',\n dotSize: 3,\n dotFill: BLACK,\n dotShape: '21',\n};\n"],"names":["MIN_PADDING","MIN_MARGIN","TITLE_LINE","FACET_TITLE_LINE","FACET_TITLE_OFFSET","MIN_STEP_FOR_VISIBLE_LABELS","TICK_OFFSET","DEFAULT_TICKS_SIZE","LEGEND_OFFSET","FONT_SIZE","ANNOTATION_WIDTH","ANNOTATIONS_OFFSET","CHART_SIDE_ELEMENTS","DEFAULT_AES","BLACK"],"mappings":";AAGO,MAAMA,IAAc,IACdC,IAAa,GAEbC,IAAa,IACbC,IAAmB,IACnBC,IAAqB,IAErBC,IAA8B,IAE9BC,IAAc,GACdC,IAAqB,GAErBC,IAAgB,IAChBC,IAAY,IAEZC,IAAmB,IACnBC,IAAqB,GAErBC,IAAsB;AAAA,EAC/B,MAAM,CAAC,eAAe,QAAQ,UAAU,aAAa,QAAQ;AAAA,EAC7D,OAAO,CAAC,eAAe,QAAQ,UAAU,aAAa,QAAQ;AAAA,EAC9D,KAAK,CAAC,eAAe,QAAQ,UAAU,aAAa,UAAU,YAAY;AAAA,EAC1E,QAAQ,CAAC,eAAe,QAAQ,UAAU,aAAa,QAAQ;AACnE,GAEaC,IAAsB;AAAA,EAC/B,WAAW;AAAA,EACX,WAAWC;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,SAAS;AAAA,EACT,SAASA;AAAA,EACT,UAAU;AACd;"}
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../src/heatmap/constants.ts"],"sourcesContent":["import {BLACK} from '../constants';\nimport type {AesItem} from '../types';\n\nexport const MIN_PADDING = 15;\nexport const MIN_MARGIN = 8;\n\nexport const TITLE_LINE = 30;\nexport const FACET_TITLE_LINE = 48;\nexport const FACET_TITLE_OFFSET = 24;\n\nexport const MIN_STEP_FOR_VISIBLE_LABELS = 16;\n\nexport const TICK_OFFSET = 4;\nexport const DEFAULT_TICKS_SIZE = 4;\n\nexport const LEGEND_OFFSET = 20;\nexport const FONT_SIZE = 16;\n\nexport const ANNOTATION_WIDTH = 16;\nexport const ANNOTATIONS_OFFSET = 8;\n\nexport const CHART_SIDE_ELEMENTS = {\n left: ['annotations', 'axis', 'groups', 'axisTitle', 'dendro'],\n right: ['annotations', 'axis', 'groups', 'axisTitle', 'dendro'],\n top: ['annotations', 'axis', 'groups', 'axisTitle', 'dendro', 'facetTitle'],\n bottom: ['annotations', 'axis', 'groups', 'axisTitle', 'dendro']\n};\n\nexport const DEFAULT_AES:AesItem = {\n fillColor: 'white',\n lineColor: BLACK,\n lineWidth: 1,\n lineShape: 'solid',\n dotSize: 3,\n dotFill: BLACK,\n dotShape: '21',\n};\n\nexport const MAX_SVG_RENDERED_CELLS_COUNT = 500000;\n\n"],"names":["MIN_PADDING","MIN_MARGIN","TITLE_LINE","FACET_TITLE_LINE","FACET_TITLE_OFFSET","MIN_STEP_FOR_VISIBLE_LABELS","TICK_OFFSET","DEFAULT_TICKS_SIZE","LEGEND_OFFSET","FONT_SIZE","ANNOTATION_WIDTH","ANNOTATIONS_OFFSET","CHART_SIDE_ELEMENTS","DEFAULT_AES","BLACK","MAX_SVG_RENDERED_CELLS_COUNT"],"mappings":";AAGO,MAAMA,IAAc,IACdC,IAAa,GAEbC,IAAa,IACbC,IAAmB,IACnBC,IAAqB,IAErBC,IAA8B,IAE9BC,IAAc,GACdC,IAAqB,GAErBC,IAAgB,IAChBC,IAAY,IAEZC,IAAmB,IACnBC,IAAqB,GAErBC,IAAsB;AAAA,EAC/B,MAAM,CAAC,eAAe,QAAQ,UAAU,aAAa,QAAQ;AAAA,EAC7D,OAAO,CAAC,eAAe,QAAQ,UAAU,aAAa,QAAQ;AAAA,EAC9D,KAAK,CAAC,eAAe,QAAQ,UAAU,aAAa,UAAU,YAAY;AAAA,EAC1E,QAAQ,CAAC,eAAe,QAAQ,UAAU,aAAa,QAAQ;AACnE,GAEaC,IAAsB;AAAA,EAC/B,WAAW;AAAA,EACX,WAAWC;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,SAAS;AAAA,EACT,SAASA;AAAA,EACT,UAAU;AACd,GAEaC,IAA+B;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCells.d.ts","sourceRoot":"","sources":["../../src/heatmap/getCells.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAuB,MAAM,UAAU,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"getCells.d.ts","sourceRoot":"","sources":["../../src/heatmap/getCells.ts"],"names":[],"mappings":"AAEA,OAAO,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1
|
import v from "../node_modules/lodash/lodash.js";
|
|
2
|
-
import
|
|
2
|
+
import Z from "../node_modules/d3-array/src/deviation.js";
|
|
3
3
|
import I from "../node_modules/d3-array/src/mean.js";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const o = O(s), l = I(s);
|
|
4
|
+
import O from "../node_modules/d3-array/src/extent.js";
|
|
5
|
+
function k(n) {
|
|
6
|
+
const o = Z(n), l = I(n);
|
|
8
7
|
return o === void 0 || l === void 0 || o === 0 ? (c) => c : (c) => (c - l) / o;
|
|
9
8
|
}
|
|
10
|
-
function
|
|
11
|
-
const o = I(
|
|
9
|
+
function ee(n) {
|
|
10
|
+
const o = I(n), [l, c] = O(n);
|
|
12
11
|
return o === void 0 || l === void 0 || c === void 0 || c === l ? (f) => f : (f) => (f - o) / (c - l);
|
|
13
12
|
}
|
|
14
|
-
function
|
|
15
|
-
return
|
|
13
|
+
function te(n, o) {
|
|
14
|
+
return n === "standardScaling" ? k(o) : n === "meanNormalization" ? ee(o) : (l) => l;
|
|
16
15
|
}
|
|
17
|
-
function B(
|
|
18
|
-
if (!
|
|
16
|
+
function B(n) {
|
|
17
|
+
if (!n.length)
|
|
19
18
|
return [];
|
|
20
19
|
let o = [[]];
|
|
21
|
-
return
|
|
20
|
+
return n.forEach((l) => {
|
|
22
21
|
const c = [];
|
|
23
22
|
l.forEach((f) => {
|
|
24
|
-
c.push(...o.map((
|
|
23
|
+
c.push(...o.map((d) => [...d, f]));
|
|
25
24
|
}), o = c;
|
|
26
25
|
}), o;
|
|
27
26
|
}
|
|
28
|
-
const
|
|
27
|
+
const _ = (n, o, l = {}) => n.sort(
|
|
29
28
|
(c, f) => o === "asc" ? (l[c] ?? c).localeCompare(l[f] ?? f, "en", { numeric: !0 }) : (l[f] ?? f).localeCompare(l[c] ?? c, "en", { numeric: !0 })
|
|
30
29
|
);
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
S > ee && console.error(`Too many cells for graph rendering (${S})`);
|
|
34
|
-
const T = f.length ? f.map((e) => x[e.value] ?? s.getColumnCategories(e.value)) : [["null"]], F = E.length ? E.map((e) => x[e.value] ?? s.getColumnCategories(e.value)) : [["null"]], U = d.length ? d.map((e) => x[e.value] ?? s.getColumnCategories(e.value)) : [["null"]], M = B(T), $ = B(F), j = B(U), _ = M.map((e) => e.join("_")), V = $.map((e) => e.join("_")), b = j.map((e) => e.join("_")), t = {
|
|
30
|
+
function le(n, o, l, c, f, d, b, D, z, X, C, Y, x, A, N) {
|
|
31
|
+
const F = f.length ? f.map((e) => x[e.value] ?? n.getColumnCategories(e.value)) : [["null"]], R = d.length ? d.map((e) => x[e.value] ?? n.getColumnCategories(e.value)) : [["null"]], H = b.length ? b.map((e) => x[e.value] ?? n.getColumnCategories(e.value)) : [["null"]], S = B(F), M = B(R), j = B(H), $ = S.map((e) => e.join("_")), E = M.map((e) => e.join("_")), L = j.map((e) => e.join("_")), t = {
|
|
35
32
|
meta: {
|
|
36
|
-
facetKeys:
|
|
37
|
-
xGroupKeys:
|
|
38
|
-
yGroupKeys:
|
|
33
|
+
facetKeys: $,
|
|
34
|
+
xGroupKeys: E,
|
|
35
|
+
yGroupKeys: L,
|
|
39
36
|
xKeysByGroups: {},
|
|
40
37
|
yKeysByGroups: {},
|
|
41
38
|
xLabels: {},
|
|
@@ -44,17 +41,17 @@ function ie(s, o, l, c, f, E, d, D, N, X, L, A, x, Y, R) {
|
|
|
44
41
|
yGroupLabels: {},
|
|
45
42
|
xDataByKeys: {},
|
|
46
43
|
yDataByKeys: {},
|
|
47
|
-
facetKeyValues:
|
|
48
|
-
xGroupKeyValues:
|
|
49
|
-
yGroupKeyValues:
|
|
44
|
+
facetKeyValues: $.reduce((e, a, u) => (e[a] = S[u], e), {}),
|
|
45
|
+
xGroupKeyValues: E.reduce((e, a, u) => (e[a] = M[u], e), {}),
|
|
46
|
+
yGroupKeyValues: L.reduce((e, a, u) => (e[a] = j[u], e), {}),
|
|
50
47
|
valueExtent: [1 / 0, -1 / 0]
|
|
51
48
|
},
|
|
52
49
|
facets: {}
|
|
53
|
-
}, w = o.valueLabels ?? o.value, q = l.valueLabels ?? l.value,
|
|
54
|
-
for (let e = 0; e <
|
|
55
|
-
const a = f.length ? f.map((
|
|
56
|
-
t.meta.xGroupLabels[u] =
|
|
57
|
-
const i = String(
|
|
50
|
+
}, w = o.valueLabels ?? o.value, q = l.valueLabels ?? l.value, J = D.filter((e) => e.axis === "x").map((e) => e.valueColumn.value), P = D.filter((e) => e.axis === "y").map((e) => e.valueColumn.value), Q = Object.values(z ?? {}).map((e) => e.value), T = Object.values(X ?? {}).map((e) => e.value), U = v.uniq([...J, ...Q, w]), W = v.uniq([...P, ...T, q]);
|
|
51
|
+
for (let e = 0; e < n.rowsCount; e++) {
|
|
52
|
+
const a = f.length ? f.map((s) => n.getColumnValue(s.value, e)).join("_") : "null", u = d.length ? d.map((s) => n.getColumnValue(s.value, e)).join("_") : "null", y = b.length ? b.map((s) => n.getColumnValue(s.value, e)).join("_") : "null", K = d.length ? d.map((s) => n.getColumnValue(s.valueLabels ?? s.value, e)).join(", ") : "", G = b.length ? b.map((s) => n.getColumnValue(s.valueLabels ?? s.value, e)).join(", ") : "";
|
|
53
|
+
t.meta.xGroupLabels[u] = K, t.meta.yGroupLabels[y] = G;
|
|
54
|
+
const i = String(n.getColumnValue(o.value, e)), r = String(n.getColumnValue(l.value, e)), p = n.getColumnValue(c.value, e) ?? Y;
|
|
58
55
|
if (i === "null" || r === "null" || p === null)
|
|
59
56
|
continue;
|
|
60
57
|
if (t.facets[a] || (t.facets[a] = {
|
|
@@ -65,22 +62,22 @@ function ie(s, o, l, c, f, E, d, D, N, X, L, A, x, Y, R) {
|
|
|
65
62
|
cells: {}
|
|
66
63
|
}), t.facets[a].xKeysByGroups[u] || (t.facets[a].xKeysByGroups[u] = []), t.facets[a].yKeysByGroups[y] || (t.facets[a].yKeysByGroups[y] = []), t.facets[a].xKeys.push(i), t.facets[a].yKeys.push(r), t.facets[a].xKeysByGroups[u].push(i), t.facets[a].yKeysByGroups[y].push(r), t.facets[a].cells[i] || (t.facets[a].cells[i] = {}), t.meta.valueExtent[0] = Math.min(p, t.meta.valueExtent[0]), t.meta.valueExtent[1] = Math.max(p, t.meta.valueExtent[1]), t.facets[a].cells[i][r] && t.facets[a].cells[i][r].value !== p)
|
|
67
64
|
throw Error(`More than 1 value for x=${i}, y=${r}`);
|
|
68
|
-
const h =
|
|
65
|
+
const h = n.getColumnValue(w, e);
|
|
69
66
|
if (t.meta.xLabels[i] && String(h) !== t.meta.xLabels[i])
|
|
70
67
|
throw Error(`More than 1 x-label value for x=${i}`);
|
|
71
|
-
const
|
|
72
|
-
if (t.meta.yLabels[r] && String(
|
|
68
|
+
const g = n.getColumnValue(q, e);
|
|
69
|
+
if (t.meta.yLabels[r] && String(g) !== t.meta.yLabels[r])
|
|
73
70
|
throw Error(`More than 1 y-label value for y=${r}`);
|
|
74
|
-
t.meta.xLabels[i] = String(h), t.meta.yLabels[r] = String(
|
|
75
|
-
const m = typeof t.meta.xDataByKeys[
|
|
76
|
-
if (m || (t.meta.xDataByKeys[
|
|
77
|
-
throw Error(`More than 1 value for x = ${i} and column = ${
|
|
78
|
-
|
|
79
|
-
}),
|
|
80
|
-
const m = typeof t.meta.yDataByKeys[
|
|
81
|
-
if (m || (t.meta.yDataByKeys[
|
|
82
|
-
throw Error(`More than 1 value for y = ${r} and column = ${
|
|
83
|
-
|
|
71
|
+
t.meta.xLabels[i] = String(h), t.meta.yLabels[r] = String(g), U.forEach((s) => {
|
|
72
|
+
const m = typeof t.meta.xDataByKeys[s] < "u", V = m && typeof t.meta.xDataByKeys[s][i] < "u";
|
|
73
|
+
if (m || (t.meta.xDataByKeys[s] = {}), V && t.meta.xDataByKeys[s][i] !== n.getColumnValue(s, e))
|
|
74
|
+
throw Error(`More than 1 value for x = ${i} and column = ${s}`);
|
|
75
|
+
V || (t.meta.xDataByKeys[s][i] = n.getColumnValue(s, e));
|
|
76
|
+
}), W.forEach((s) => {
|
|
77
|
+
const m = typeof t.meta.yDataByKeys[s] < "u", V = m && typeof t.meta.yDataByKeys[s][r] < "u";
|
|
78
|
+
if (m || (t.meta.yDataByKeys[s] = {}), V && t.meta.yDataByKeys[s][r] !== n.getColumnValue(s, e))
|
|
79
|
+
throw Error(`More than 1 value for y = ${r} and column = ${s}`);
|
|
80
|
+
V || (t.meta.yDataByKeys[s][r] = n.getColumnValue(s, e));
|
|
84
81
|
}), t.facets[a].cells[i][r] = {
|
|
85
82
|
isCell: !0,
|
|
86
83
|
idx: e,
|
|
@@ -93,55 +90,55 @@ function ie(s, o, l, c, f, E, d, D, N, X, L, A, x, Y, R) {
|
|
|
93
90
|
}
|
|
94
91
|
if (t.meta.facetKeys = t.meta.facetKeys.filter((e) => t.facets[e]), t.meta.facetKeys.forEach((e) => {
|
|
95
92
|
const a = t.facets[e], u = v.uniq(a.xKeys), y = v.uniq(a.yKeys);
|
|
96
|
-
a.xKeys = x[o.value] ? v.intersection(x[o.value], u) : u, a.yKeys = x[l.value] ? v.intersection(x[l.value], y) : y,
|
|
97
|
-
t.facets[e].xKeysByGroups[
|
|
93
|
+
a.xKeys = x[o.value] ? v.intersection(x[o.value], u) : u, a.yKeys = x[l.value] ? v.intersection(x[l.value], y) : y, E.forEach((K) => {
|
|
94
|
+
t.facets[e].xKeysByGroups[K] = v.intersection(
|
|
98
95
|
a.xKeys,
|
|
99
|
-
t.facets[e].xKeysByGroups[
|
|
96
|
+
t.facets[e].xKeysByGroups[K]
|
|
100
97
|
);
|
|
101
|
-
}),
|
|
102
|
-
t.facets[e].yKeysByGroups[
|
|
98
|
+
}), L.forEach((K) => {
|
|
99
|
+
t.facets[e].yKeysByGroups[K] = v.intersection(
|
|
103
100
|
a.yKeys,
|
|
104
|
-
t.facets[e].yKeysByGroups[
|
|
101
|
+
t.facets[e].yKeysByGroups[K]
|
|
105
102
|
);
|
|
106
103
|
});
|
|
107
|
-
}),
|
|
104
|
+
}), C) {
|
|
108
105
|
const e = [1 / 0, -1 / 0];
|
|
109
106
|
t.meta.facetKeys.forEach((a) => {
|
|
110
|
-
const { xKeys: u, yKeys: y, cells:
|
|
111
|
-
var
|
|
112
|
-
return (
|
|
107
|
+
const { xKeys: u, yKeys: y, cells: K } = t.facets[a], G = C.direction === "row" ? u : y, i = C.direction === "row" ? y : u, r = C.direction === "row" ? (p, h) => {
|
|
108
|
+
var g;
|
|
109
|
+
return (g = K[p]) == null ? void 0 : g[h];
|
|
113
110
|
} : (p, h) => {
|
|
114
|
-
var
|
|
115
|
-
return (
|
|
111
|
+
var g;
|
|
112
|
+
return (g = K[h]) == null ? void 0 : g[p];
|
|
116
113
|
};
|
|
117
114
|
i.forEach((p) => {
|
|
118
115
|
const h = [];
|
|
119
|
-
G.forEach((
|
|
120
|
-
var
|
|
121
|
-
const m = (
|
|
116
|
+
G.forEach((s) => {
|
|
117
|
+
var V;
|
|
118
|
+
const m = (V = r(s, p)) == null ? void 0 : V.value;
|
|
122
119
|
m !== void 0 && h.push(m);
|
|
123
120
|
});
|
|
124
|
-
const
|
|
125
|
-
G.forEach((
|
|
126
|
-
const m = r(
|
|
127
|
-
m !== void 0 && (m.normalizedValue =
|
|
121
|
+
const g = te(C.method, h);
|
|
122
|
+
G.forEach((s) => {
|
|
123
|
+
const m = r(s, p);
|
|
124
|
+
m !== void 0 && (m.normalizedValue = g(m.value), e[0] = Math.min(m.normalizedValue, e[0]), e[1] = Math.max(m.normalizedValue, e[1]));
|
|
128
125
|
});
|
|
129
126
|
});
|
|
130
127
|
}), t.meta.valueExtent = e;
|
|
131
128
|
}
|
|
132
|
-
return t.meta.xKeysByGroups =
|
|
133
|
-
const u =
|
|
129
|
+
return t.meta.xKeysByGroups = E.reduce((e, a) => {
|
|
130
|
+
const u = _(v.uniq(
|
|
134
131
|
v.flatten(t.meta.facetKeys.map((y) => t.facets[y].xKeysByGroups[a]))
|
|
135
|
-
),
|
|
132
|
+
), A.sorting, t.meta.xLabels);
|
|
136
133
|
return e[a] = x[o.value] ? v.intersection(x[o.value], u) : u, e;
|
|
137
|
-
}, {}), t.meta.yKeysByGroups =
|
|
138
|
-
const u =
|
|
134
|
+
}, {}), t.meta.yKeysByGroups = L.reduce((e, a) => {
|
|
135
|
+
const u = _(v.uniq(
|
|
139
136
|
v.flatten(t.meta.facetKeys.map((y) => t.facets[y].yKeysByGroups[a]))
|
|
140
|
-
),
|
|
137
|
+
), N.sorting, t.meta.yLabels);
|
|
141
138
|
return e[a] = x[l.value] ? v.intersection(x[l.value], u) : u, e;
|
|
142
139
|
}, {}), t.meta.valueExtent[0] === 1 / 0 && (t.meta.valueExtent[0] = 0), t.meta.valueExtent[1] === -1 / 0 && (t.meta.valueExtent[1] = 0), t;
|
|
143
140
|
}
|
|
144
141
|
export {
|
|
145
|
-
|
|
142
|
+
le as getCells
|
|
146
143
|
};
|
|
147
144
|
//# sourceMappingURL=getCells.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCells.js","sources":["../../src/heatmap/getCells.ts"],"sourcesContent":["import { deviation, extent, mean } from 'd3-array';\nimport lodash from 'lodash';\nimport type { DataFrame } from '../DataFrame';\nimport type { ColumnName, DataValue, NormalizationMethod } from '../types';\nimport type { HeatmapSettingsImpl } from './HeatmapSettingsImpl';\n\nconst MAX_RENDERED_CELLS_COUNT = 500000;\nfunction normalizeByStd(values:number[]) {\n const stdValue = deviation(values);\n const meanValue = mean(values);\n\n if (stdValue === undefined || meanValue === undefined || stdValue === 0) {\n return (v:number) => v;\n }\n return (v:number) => (v - meanValue) / stdValue;\n}\nfunction normalizeByMinMax(values:number[]) {\n const meanValue = mean(values);\n const [min, max] = extent(values);\n if (meanValue === undefined || min === undefined || max === undefined || max === min) {\n return (v:number) => v;\n }\n return (v:number) => (v - meanValue) / (max - min);\n}\n\nfunction getNormalizationFn(method:NormalizationMethod, values:number[]) {\n if (method === 'standardScaling') {\n return normalizeByStd(values);\n }\n if (method === 'meanNormalization') {\n return normalizeByMinMax(values);\n }\n return (v:number) => v;\n}\n\nexport type Cell = {\n isCell: true;\n idx: number;\n id: string;\n value: DataValue;\n normalizedValue: DataValue;\n x: DataValue;\n y: DataValue;\n};\n\nexport type GroupedCellsData = {\n meta: {\n facetKeys: string[];\n xGroupKeys: string[];\n yGroupKeys: string[];\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n // for titles, if facet by more 1 columns title has several values separated by commas\n facetKeyValues: Record<string, string[]>;\n xGroupKeyValues: Record<string, string[]>;\n yGroupKeyValues: Record<string, string[]>;\n xLabels: Record<string, string>;\n yLabels: Record<string, string>;\n xGroupLabels: Record<string, string>;\n yGroupLabels: Record<string, string>;\n valueExtent: [number, number]; // for color scales\n // data for labels, annotations and dendrograms\n xDataByKeys: Record<string, Record<string, DataValue>>;\n yDataByKeys: Record<string, Record<string, DataValue>>;\n };\n //facet groups\n facets: Record<\n string,\n {\n // axis keys\n xKeys: string[];\n yKeys: string[];\n // axis keys grouped by group keys from meta\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n // cells grouped by X, then by Y\n cells: Record<string, Record<string, Cell>>;\n }\n >;\n};\n\n// all combinations with 1 key from each list\nfunction getKeysCombinations(keysLists: string[][]) {\n if (!keysLists.length) {\n return [];\n }\n let result: string[][] = [[]];\n keysLists.forEach(keys => {\n const nextResult: string[][] = [];\n keys.forEach(key => {\n nextResult.push(...result.map(resultItem => [...resultItem, key]));\n });\n result = nextResult;\n });\n return result;\n}\nconst sortByLabels = (arr: string[], direction: 'asc' | 'desc', labels: Record<string, string> = {}) => {\n return arr.sort((a, b) => direction === 'asc'\n ? (labels[a] ?? a).localeCompare((labels[b] ?? b), 'en', { numeric: true })\n : (labels[b] ?? b).localeCompare((labels[a] ?? a), 'en', { numeric: true })\n );\n};\n\nexport function getCells(\n data: DataFrame,\n xColumn: ColumnName,\n yColumn: ColumnName,\n valueColumn: ColumnName,\n facetBy: ColumnName[],\n xGroupBy: ColumnName[],\n yGroupBy: ColumnName[],\n annotations: HeatmapSettingsImpl['annotations'],\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY'],\n normalization: HeatmapSettingsImpl['normalization'],\n NAValueAs: HeatmapSettingsImpl['NAValueAs'],\n keysOrder: HeatmapSettingsImpl['keysOrder'],\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n): GroupedCellsData {\n const dataSize = data.columnNames.length ? data.getColumn(data.columnNames[0]).length : 0;\n if (dataSize > MAX_RENDERED_CELLS_COUNT) {\n console.error(`Too many cells for graph rendering (${dataSize})`);\n }\n const facetKeysLists = facetBy.length\n ? facetBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const xGroupKeysLists = xGroupBy.length\n ? xGroupBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const yGroupKeysLists = yGroupBy.length\n ? yGroupBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const facetKeysCombinations = getKeysCombinations(facetKeysLists);\n const xGroupKeysCombinations = getKeysCombinations(xGroupKeysLists);\n const yGroupKeysCombinations = getKeysCombinations(yGroupKeysLists);\n\n const facetKeys = facetKeysCombinations.map(keys => keys.join('_'));\n const xGroupKeys = xGroupKeysCombinations.map(keys => keys.join('_'));\n const yGroupKeys = yGroupKeysCombinations.map(keys => keys.join('_'));\n\n const result: GroupedCellsData = {\n meta: {\n facetKeys,\n xGroupKeys,\n yGroupKeys,\n xKeysByGroups: {},\n yKeysByGroups: {},\n xLabels: {},\n yLabels: {},\n xGroupLabels: {},\n yGroupLabels: {},\n xDataByKeys: {},\n yDataByKeys: {},\n facetKeyValues: facetKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = facetKeysCombinations[index];\n return res;\n }, {}),\n xGroupKeyValues: xGroupKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = xGroupKeysCombinations[index];\n return res;\n }, {}),\n yGroupKeyValues: yGroupKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = yGroupKeysCombinations[index];\n return res;\n }, {}),\n valueExtent: [Infinity, -Infinity],\n },\n facets: {},\n };\n\n const xLabelsSource = xColumn.valueLabels ?? xColumn.value;\n const yLabelsSource = yColumn.valueLabels ?? yColumn.value;\n const annotationColumnsX = annotations.filter(item => item.axis === 'x').map(item => item.valueColumn.value);\n const annotationColumnsY = annotations.filter(item => item.axis === 'y').map(item => item.valueColumn.value);\n const dendrogramXColumns = Object.values(dendrogramX ?? {}).map(column => column.value);\n const dendrogramYColumns = Object.values(dendrogramY ?? {}).map(column => column.value);\n const additionalDataColumnsX = lodash.uniq([...annotationColumnsX, ...dendrogramXColumns, xLabelsSource]);\n const additionalDataColumnsY = lodash.uniq([...annotationColumnsY, ...dendrogramYColumns, yLabelsSource]);\n\n for (let i = 0; i < data.rowsCount; i++) {\n const facetKey = facetBy.length ? facetBy.map(column => data.getColumnValue(column.value, i)).join('_') : 'null';\n const xGroupKey = xGroupBy.length ? xGroupBy.map(column => data.getColumnValue(column.value, i)).join('_') : 'null';\n const yGroupKey = yGroupBy.length ? yGroupBy.map(column => data.getColumnValue(column.value, i)).join('_') : 'null';\n const xGroupLabel = xGroupBy.length ? xGroupBy.map(column => data.getColumnValue(column.valueLabels ?? column.value, i)).join(', ') : '';\n const yGroupLabel = yGroupBy.length ? yGroupBy.map(column => data.getColumnValue(column.valueLabels ?? column.value, i)).join(', ') : '';\n result.meta.xGroupLabels[xGroupKey] = xGroupLabel;\n result.meta.yGroupLabels[yGroupKey] = yGroupLabel;\n const x = String(data.getColumnValue(xColumn.value, i));\n const y = String(data.getColumnValue(yColumn.value, i));\n const value = (data.getColumnValue(valueColumn.value, i) ?? NAValueAs) as number | null;\n \n if (x === 'null' || y === 'null' || value === null) {\n continue;\n }\n\n if (!result.facets[facetKey]) {\n result.facets[facetKey] = {\n xKeys: [],\n yKeys: [],\n xKeysByGroups: {},\n yKeysByGroups: {},\n cells: {},\n };\n }\n if (!result.facets[facetKey].xKeysByGroups[xGroupKey]) {\n result.facets[facetKey].xKeysByGroups[xGroupKey] = [];\n }\n if (!result.facets[facetKey].yKeysByGroups[yGroupKey]) {\n result.facets[facetKey].yKeysByGroups[yGroupKey] = [];\n }\n result.facets[facetKey].xKeys.push(x);\n result.facets[facetKey].yKeys.push(y);\n result.facets[facetKey].xKeysByGroups[xGroupKey].push(x);\n result.facets[facetKey].yKeysByGroups[yGroupKey].push(y);\n\n if (!result.facets[facetKey].cells[x]) {\n result.facets[facetKey].cells[x] = {};\n }\n result.meta.valueExtent[0] = Math.min(value, result.meta.valueExtent[0]);\n result.meta.valueExtent[1] = Math.max(value, result.meta.valueExtent[1]);\n if (result.facets[facetKey].cells[x][y] && result.facets[facetKey].cells[x][y].value !== value) {\n throw Error(`More than 1 value for x=${x}, y=${y}`);\n }\n const xLabelsSourceValue = data.getColumnValue(xLabelsSource, i);\n if (result.meta.xLabels[x] && String(xLabelsSourceValue) !== result.meta.xLabels[x]) {\n throw Error(`More than 1 x-label value for x=${x}`);\n }\n const yLabelsSourceValue = data.getColumnValue(yLabelsSource, i);\n if (result.meta.yLabels[y] && String(yLabelsSourceValue) !== result.meta.yLabels[y]) {\n throw Error(`More than 1 y-label value for y=${y}`);\n }\n result.meta.xLabels[x] = String(xLabelsSourceValue);\n result.meta.yLabels[y] = String(yLabelsSourceValue);\n // data for labels, annotations and dendrograms by X\n additionalDataColumnsX.forEach(columnKey => {\n const isAddedColumn = typeof result.meta.xDataByKeys[columnKey] !== 'undefined';\n const isAddedValue = isAddedColumn && typeof result.meta.xDataByKeys[columnKey][x] !== 'undefined';\n if (!isAddedColumn) {\n result.meta.xDataByKeys[columnKey] = {};\n }\n if (isAddedValue && result.meta.xDataByKeys[columnKey][x] !== data.getColumnValue(columnKey, i)) {\n throw Error(`More than 1 value for x = ${x} and column = ${columnKey}`);\n }\n if (!isAddedValue) {\n result.meta.xDataByKeys[columnKey][x] = data.getColumnValue(columnKey, i);\n }\n });\n // data for labels, annotations and dendrograms by Y\n additionalDataColumnsY.forEach(columnKey => {\n const isAddedColumn = typeof result.meta.yDataByKeys[columnKey] !== 'undefined';\n const isAddedValue = isAddedColumn && typeof result.meta.yDataByKeys[columnKey][y] !== 'undefined';\n if (!isAddedColumn) {\n result.meta.yDataByKeys[columnKey] = {};\n }\n if (isAddedValue && result.meta.yDataByKeys[columnKey][y] !== data.getColumnValue(columnKey, i)) {\n throw Error(`More than 1 value for y = ${y} and column = ${columnKey}`);\n }\n if (!isAddedValue) {\n result.meta.yDataByKeys[columnKey][y] = data.getColumnValue(columnKey, i);\n }\n });\n result.facets[facetKey].cells[x][y] = {\n isCell: true,\n idx: i,\n id: `${x}_${y}`,\n x,\n y,\n value,\n normalizedValue: value,\n };\n }\n\n result.meta.facetKeys = result.meta.facetKeys.filter((key) => result.facets[key]); // filter only used;\n\n // make uniq x, y, x-group and y-group keys\n result.meta.facetKeys.forEach(facetKey => {\n const facet = result.facets[facetKey];\n const uniqueXKeys = lodash.uniq(facet.xKeys);\n const uniqueYKeys = lodash.uniq(facet.yKeys);\n facet.xKeys = keysOrder[xColumn.value] ? lodash.intersection(keysOrder[xColumn.value], uniqueXKeys) : uniqueXKeys;\n facet.yKeys = keysOrder[yColumn.value] ? lodash.intersection(keysOrder[yColumn.value], uniqueYKeys) : uniqueYKeys;\n xGroupKeys.forEach(xGroupKey => {\n result.facets[facetKey].xKeysByGroups[xGroupKey] = lodash.intersection(\n facet.xKeys,\n result.facets[facetKey].xKeysByGroups[xGroupKey]\n );\n });\n yGroupKeys.forEach(yGroupKey => {\n result.facets[facetKey].yKeysByGroups[yGroupKey] = lodash.intersection(\n facet.yKeys,\n result.facets[facetKey].yKeysByGroups[yGroupKey]\n );\n });\n });\n\n if (normalization) {\n const valueExtent = [Infinity, -Infinity] as [number, number];\n result.meta.facetKeys.forEach(facetKey => {\n const {xKeys, yKeys, cells} = result.facets[facetKey];\n const cellKeys = normalization.direction === 'row' ? xKeys : yKeys;\n const groupKeys = normalization.direction === 'row' ? yKeys : xKeys;\n const cellGetter = normalization.direction === 'row'\n ? (cellKey:string, groupKey:string) => cells[cellKey]?.[groupKey]\n : (cellKey:string, groupKey:string) => cells[groupKey]?.[cellKey];\n groupKeys.forEach((groupKey) => {\n const values:number[] = [];\n cellKeys.forEach((cellKey) => {\n const v = cellGetter(cellKey, groupKey)?.value;\n if (v !== undefined) {\n values.push(v as number);\n }\n });\n const normalize = getNormalizationFn(normalization.method, values);\n cellKeys.forEach((cellKey) => {\n const cell = cellGetter(cellKey, groupKey);\n if (cell !== undefined) {\n cell.normalizedValue = normalize(cell.value as number);\n valueExtent[0] = Math.min(cell.normalizedValue, valueExtent[0]);\n valueExtent[1] = Math.max(cell.normalizedValue, valueExtent[1]);\n }\n });\n });\n });\n result.meta.valueExtent = valueExtent;\n }\n\n // every facet may contain not all of available keys, but for shared axes it is necessary to have all of them\n result.meta.xKeysByGroups = xGroupKeys.reduce((res: Record<string, string[]>, xGroupKey) => {\n const existingXKeys = sortByLabels(lodash.uniq(\n lodash.flatten(result.meta.facetKeys.map(facetKey => result.facets[facetKey].xKeysByGroups[xGroupKey]))\n ), xAxis.sorting, result.meta.xLabels);\n res[xGroupKey] = keysOrder[xColumn.value] ? lodash.intersection(keysOrder[xColumn.value], existingXKeys) : existingXKeys;\n return res;\n }, {});\n result.meta.yKeysByGroups = yGroupKeys.reduce((res: Record<string, string[]>, yGroupKey) => {\n const existingYKeys = sortByLabels(lodash.uniq(\n lodash.flatten(result.meta.facetKeys.map(facetKey => result.facets[facetKey].yKeysByGroups[yGroupKey]))\n ), yAxis.sorting, result.meta.yLabels);\n res[yGroupKey] = keysOrder[yColumn.value] ? lodash.intersection(keysOrder[yColumn.value], existingYKeys) : existingYKeys;\n return res;\n }, {});\n\n // avoid render errors on empty data\n if (result.meta.valueExtent[0] === Infinity) {\n result.meta.valueExtent[0] = 0;\n }\n if (result.meta.valueExtent[1] === -Infinity) {\n result.meta.valueExtent[1] = 0;\n }\n\n return result;\n}\n"],"names":["MAX_RENDERED_CELLS_COUNT","normalizeByStd","values","stdValue","deviation","meanValue","mean","v","normalizeByMinMax","min","max","extent","getNormalizationFn","method","getKeysCombinations","keysLists","result","keys","nextResult","key","resultItem","sortByLabels","arr","direction","labels","a","b","getCells","data","xColumn","yColumn","valueColumn","facetBy","xGroupBy","yGroupBy","annotations","dendrogramX","dendrogramY","normalization","NAValueAs","keysOrder","xAxis","yAxis","dataSize","facetKeysLists","column","xGroupKeysLists","yGroupKeysLists","facetKeysCombinations","xGroupKeysCombinations","yGroupKeysCombinations","facetKeys","xGroupKeys","yGroupKeys","res","index","xLabelsSource","yLabelsSource","annotationColumnsX","item","annotationColumnsY","dendrogramXColumns","dendrogramYColumns","additionalDataColumnsX","lodash","additionalDataColumnsY","i","facetKey","xGroupKey","yGroupKey","xGroupLabel","yGroupLabel","x","y","value","xLabelsSourceValue","yLabelsSourceValue","columnKey","isAddedColumn","isAddedValue","facet","uniqueXKeys","uniqueYKeys","valueExtent","xKeys","yKeys","cells","cellKeys","groupKeys","cellGetter","cellKey","groupKey","_a","normalize","cell","existingXKeys","existingYKeys"],"mappings":";;;;AAMA,MAAMA,KAA2B;AACjC,SAASC,GAAeC,GAAiB;AACrC,QAAMC,IAAWC,EAAUF,CAAM,GAC3BG,IAAYC,EAAKJ,CAAM;AAE7B,SAAIC,MAAa,UAAaE,MAAc,UAAaF,MAAa,IAC3D,CAACI,MAAaA,IAElB,CAACA,OAAcA,IAAIF,KAAaF;AAC3C;AACA,SAASK,GAAkBN,GAAiB;AACxC,QAAMG,IAAYC,EAAKJ,CAAM,GACvB,CAACO,GAAKC,CAAG,IAAIC,EAAOT,CAAM;AAChC,SAAIG,MAAc,UAAaI,MAAQ,UAAaC,MAAQ,UAAaA,MAAQD,IACtE,CAACF,MAAaA,IAElB,CAACA,OAAcA,IAAIF,MAAcK,IAAMD;AAClD;AAEA,SAASG,GA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,KAAK,OAAO;AACrC,WAAAsC,EAAIe,CAAS,IAAI7B,EAAUV,EAAQ,KAAK,IAAIkC,EAAO,aAAaxB,EAAUV,EAAQ,KAAK,GAAGkE,CAAa,IAAIA,GACpG1C;AAAA,EACX,GAAG,CAAA,CAAE,GAGDtC,EAAO,KAAK,YAAY,CAAC,MAAM,UAC/BA,EAAO,KAAK,YAAY,CAAC,IAAI,IAE7BA,EAAO,KAAK,YAAY,CAAC,MAAM,WAC/BA,EAAO,KAAK,YAAY,CAAC,IAAI,IAG1BA;AACX;"}
|
|
1
|
+
{"version":3,"file":"getCells.js","sources":["../../src/heatmap/getCells.ts"],"sourcesContent":["import { deviation, extent, mean } from 'd3-array';\nimport lodash from 'lodash';\nimport type { DataFrame } from '../DataFrame';\nimport type { ColumnName, DataValue, NormalizationMethod } from '../types';\nimport type { HeatmapSettingsImpl } from './HeatmapSettingsImpl';\n\nfunction normalizeByStd(values:number[]) {\n const stdValue = deviation(values);\n const meanValue = mean(values);\n\n if (stdValue === undefined || meanValue === undefined || stdValue === 0) {\n return (v:number) => v;\n }\n return (v:number) => (v - meanValue) / stdValue;\n}\nfunction normalizeByMinMax(values:number[]) {\n const meanValue = mean(values);\n const [min, max] = extent(values);\n if (meanValue === undefined || min === undefined || max === undefined || max === min) {\n return (v:number) => v;\n }\n return (v:number) => (v - meanValue) / (max - min);\n}\n\nfunction getNormalizationFn(method:NormalizationMethod, values:number[]) {\n if (method === 'standardScaling') {\n return normalizeByStd(values);\n }\n if (method === 'meanNormalization') {\n return normalizeByMinMax(values);\n }\n return (v:number) => v;\n}\n\nexport type Cell = {\n isCell: true;\n idx: number;\n id: string;\n value: DataValue;\n normalizedValue: DataValue;\n x: DataValue;\n y: DataValue;\n};\n\nexport type GroupedCellsData = {\n meta: {\n facetKeys: string[];\n xGroupKeys: string[];\n yGroupKeys: string[];\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n // for titles, if facet by more 1 columns title has several values separated by commas\n facetKeyValues: Record<string, string[]>;\n xGroupKeyValues: Record<string, string[]>;\n yGroupKeyValues: Record<string, string[]>;\n xLabels: Record<string, string>;\n yLabels: Record<string, string>;\n xGroupLabels: Record<string, string>;\n yGroupLabels: Record<string, string>;\n valueExtent: [number, number]; // for color scales\n // data for labels, annotations and dendrograms\n xDataByKeys: Record<string, Record<string, DataValue>>;\n yDataByKeys: Record<string, Record<string, DataValue>>;\n };\n //facet groups\n facets: Record<\n string,\n {\n // axis keys\n xKeys: string[];\n yKeys: string[];\n // axis keys grouped by group keys from meta\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n // cells grouped by X, then by Y\n cells: Record<string, Record<string, Cell>>;\n }\n >;\n};\n\n// all combinations with 1 key from each list\nfunction getKeysCombinations(keysLists: string[][]) {\n if (!keysLists.length) {\n return [];\n }\n let result: string[][] = [[]];\n keysLists.forEach(keys => {\n const nextResult: string[][] = [];\n keys.forEach(key => {\n nextResult.push(...result.map(resultItem => [...resultItem, key]));\n });\n result = nextResult;\n });\n return result;\n}\nconst sortByLabels = (arr: string[], direction: 'asc' | 'desc', labels: Record<string, string> = {}) => {\n return arr.sort((a, b) => direction === 'asc'\n ? (labels[a] ?? a).localeCompare((labels[b] ?? b), 'en', { numeric: true })\n : (labels[b] ?? b).localeCompare((labels[a] ?? a), 'en', { numeric: true })\n );\n};\n\nexport function getCells(\n data: DataFrame,\n xColumn: ColumnName,\n yColumn: ColumnName,\n valueColumn: ColumnName,\n facetBy: ColumnName[],\n xGroupBy: ColumnName[],\n yGroupBy: ColumnName[],\n annotations: HeatmapSettingsImpl['annotations'],\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY'],\n normalization: HeatmapSettingsImpl['normalization'],\n NAValueAs: HeatmapSettingsImpl['NAValueAs'],\n keysOrder: HeatmapSettingsImpl['keysOrder'],\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n): GroupedCellsData {\n const facetKeysLists = facetBy.length\n ? facetBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const xGroupKeysLists = xGroupBy.length\n ? xGroupBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const yGroupKeysLists = yGroupBy.length\n ? yGroupBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const facetKeysCombinations = getKeysCombinations(facetKeysLists);\n const xGroupKeysCombinations = getKeysCombinations(xGroupKeysLists);\n const yGroupKeysCombinations = getKeysCombinations(yGroupKeysLists);\n\n const facetKeys = facetKeysCombinations.map(keys => keys.join('_'));\n const xGroupKeys = xGroupKeysCombinations.map(keys => keys.join('_'));\n const yGroupKeys = yGroupKeysCombinations.map(keys => keys.join('_'));\n\n const result: GroupedCellsData = {\n meta: {\n facetKeys,\n xGroupKeys,\n yGroupKeys,\n xKeysByGroups: {},\n yKeysByGroups: {},\n xLabels: {},\n yLabels: {},\n xGroupLabels: {},\n yGroupLabels: {},\n xDataByKeys: {},\n yDataByKeys: {},\n facetKeyValues: facetKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = facetKeysCombinations[index];\n return res;\n }, {}),\n xGroupKeyValues: xGroupKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = xGroupKeysCombinations[index];\n return res;\n }, {}),\n yGroupKeyValues: yGroupKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = yGroupKeysCombinations[index];\n return res;\n }, {}),\n valueExtent: [Infinity, -Infinity],\n },\n facets: {},\n };\n\n const xLabelsSource = xColumn.valueLabels ?? xColumn.value;\n const yLabelsSource = yColumn.valueLabels ?? yColumn.value;\n const annotationColumnsX = annotations.filter(item => item.axis === 'x').map(item => item.valueColumn.value);\n const annotationColumnsY = annotations.filter(item => item.axis === 'y').map(item => item.valueColumn.value);\n const dendrogramXColumns = Object.values(dendrogramX ?? {}).map(column => column.value);\n const dendrogramYColumns = Object.values(dendrogramY ?? {}).map(column => column.value);\n const additionalDataColumnsX = lodash.uniq([...annotationColumnsX, ...dendrogramXColumns, xLabelsSource]);\n const additionalDataColumnsY = lodash.uniq([...annotationColumnsY, ...dendrogramYColumns, yLabelsSource]);\n\n for (let i = 0; i < data.rowsCount; i++) {\n const facetKey = facetBy.length ? facetBy.map(column => data.getColumnValue(column.value, i)).join('_') : 'null';\n const xGroupKey = xGroupBy.length ? xGroupBy.map(column => data.getColumnValue(column.value, i)).join('_') : 'null';\n const yGroupKey = yGroupBy.length ? yGroupBy.map(column => data.getColumnValue(column.value, i)).join('_') : 'null';\n const xGroupLabel = xGroupBy.length ? xGroupBy.map(column => data.getColumnValue(column.valueLabels ?? column.value, i)).join(', ') : '';\n const yGroupLabel = yGroupBy.length ? yGroupBy.map(column => data.getColumnValue(column.valueLabels ?? column.value, i)).join(', ') : '';\n result.meta.xGroupLabels[xGroupKey] = xGroupLabel;\n result.meta.yGroupLabels[yGroupKey] = yGroupLabel;\n const x = String(data.getColumnValue(xColumn.value, i));\n const y = String(data.getColumnValue(yColumn.value, i));\n const value = (data.getColumnValue(valueColumn.value, i) ?? NAValueAs) as number | null;\n \n if (x === 'null' || y === 'null' || value === null) {\n continue;\n }\n\n if (!result.facets[facetKey]) {\n result.facets[facetKey] = {\n xKeys: [],\n yKeys: [],\n xKeysByGroups: {},\n yKeysByGroups: {},\n cells: {},\n };\n }\n if (!result.facets[facetKey].xKeysByGroups[xGroupKey]) {\n result.facets[facetKey].xKeysByGroups[xGroupKey] = [];\n }\n if (!result.facets[facetKey].yKeysByGroups[yGroupKey]) {\n result.facets[facetKey].yKeysByGroups[yGroupKey] = [];\n }\n result.facets[facetKey].xKeys.push(x);\n result.facets[facetKey].yKeys.push(y);\n result.facets[facetKey].xKeysByGroups[xGroupKey].push(x);\n result.facets[facetKey].yKeysByGroups[yGroupKey].push(y);\n\n if (!result.facets[facetKey].cells[x]) {\n result.facets[facetKey].cells[x] = {};\n }\n result.meta.valueExtent[0] = Math.min(value, result.meta.valueExtent[0]);\n result.meta.valueExtent[1] = Math.max(value, result.meta.valueExtent[1]);\n if (result.facets[facetKey].cells[x][y] && result.facets[facetKey].cells[x][y].value !== value) {\n throw Error(`More than 1 value for x=${x}, y=${y}`);\n }\n const xLabelsSourceValue = data.getColumnValue(xLabelsSource, i);\n if (result.meta.xLabels[x] && String(xLabelsSourceValue) !== result.meta.xLabels[x]) {\n throw Error(`More than 1 x-label value for x=${x}`);\n }\n const yLabelsSourceValue = data.getColumnValue(yLabelsSource, i);\n if (result.meta.yLabels[y] && String(yLabelsSourceValue) !== result.meta.yLabels[y]) {\n throw Error(`More than 1 y-label value for y=${y}`);\n }\n result.meta.xLabels[x] = String(xLabelsSourceValue);\n result.meta.yLabels[y] = String(yLabelsSourceValue);\n // data for labels, annotations and dendrograms by X\n additionalDataColumnsX.forEach(columnKey => {\n const isAddedColumn = typeof result.meta.xDataByKeys[columnKey] !== 'undefined';\n const isAddedValue = isAddedColumn && typeof result.meta.xDataByKeys[columnKey][x] !== 'undefined';\n if (!isAddedColumn) {\n result.meta.xDataByKeys[columnKey] = {};\n }\n if (isAddedValue && result.meta.xDataByKeys[columnKey][x] !== data.getColumnValue(columnKey, i)) {\n throw Error(`More than 1 value for x = ${x} and column = ${columnKey}`);\n }\n if (!isAddedValue) {\n result.meta.xDataByKeys[columnKey][x] = data.getColumnValue(columnKey, i);\n }\n });\n // data for labels, annotations and dendrograms by Y\n additionalDataColumnsY.forEach(columnKey => {\n const isAddedColumn = typeof result.meta.yDataByKeys[columnKey] !== 'undefined';\n const isAddedValue = isAddedColumn && typeof result.meta.yDataByKeys[columnKey][y] !== 'undefined';\n if (!isAddedColumn) {\n result.meta.yDataByKeys[columnKey] = {};\n }\n if (isAddedValue && result.meta.yDataByKeys[columnKey][y] !== data.getColumnValue(columnKey, i)) {\n throw Error(`More than 1 value for y = ${y} and column = ${columnKey}`);\n }\n if (!isAddedValue) {\n result.meta.yDataByKeys[columnKey][y] = data.getColumnValue(columnKey, i);\n }\n });\n result.facets[facetKey].cells[x][y] = {\n isCell: true,\n idx: i,\n id: `${x}_${y}`,\n x,\n y,\n value,\n normalizedValue: value,\n };\n }\n\n result.meta.facetKeys = result.meta.facetKeys.filter((key) => result.facets[key]); // filter only used;\n\n // make uniq x, y, x-group and y-group keys\n result.meta.facetKeys.forEach(facetKey => {\n const facet = result.facets[facetKey];\n const uniqueXKeys = lodash.uniq(facet.xKeys);\n const uniqueYKeys = lodash.uniq(facet.yKeys);\n facet.xKeys = keysOrder[xColumn.value] ? lodash.intersection(keysOrder[xColumn.value], uniqueXKeys) : uniqueXKeys;\n facet.yKeys = keysOrder[yColumn.value] ? lodash.intersection(keysOrder[yColumn.value], uniqueYKeys) : uniqueYKeys;\n xGroupKeys.forEach(xGroupKey => {\n result.facets[facetKey].xKeysByGroups[xGroupKey] = lodash.intersection(\n facet.xKeys,\n result.facets[facetKey].xKeysByGroups[xGroupKey]\n );\n });\n yGroupKeys.forEach(yGroupKey => {\n result.facets[facetKey].yKeysByGroups[yGroupKey] = lodash.intersection(\n facet.yKeys,\n result.facets[facetKey].yKeysByGroups[yGroupKey]\n );\n });\n });\n\n if (normalization) {\n const valueExtent = [Infinity, -Infinity] as [number, number];\n result.meta.facetKeys.forEach(facetKey => {\n const {xKeys, yKeys, cells} = result.facets[facetKey];\n const cellKeys = normalization.direction === 'row' ? xKeys : yKeys;\n const groupKeys = normalization.direction === 'row' ? yKeys : xKeys;\n const cellGetter = normalization.direction === 'row'\n ? (cellKey:string, groupKey:string) => cells[cellKey]?.[groupKey]\n : (cellKey:string, groupKey:string) => cells[groupKey]?.[cellKey];\n groupKeys.forEach((groupKey) => {\n const values:number[] = [];\n cellKeys.forEach((cellKey) => {\n const v = cellGetter(cellKey, groupKey)?.value;\n if (v !== undefined) {\n values.push(v as number);\n }\n });\n const normalize = getNormalizationFn(normalization.method, values);\n cellKeys.forEach((cellKey) => {\n const cell = cellGetter(cellKey, groupKey);\n if (cell !== undefined) {\n cell.normalizedValue = normalize(cell.value as number);\n valueExtent[0] = Math.min(cell.normalizedValue, valueExtent[0]);\n valueExtent[1] = Math.max(cell.normalizedValue, valueExtent[1]);\n }\n });\n });\n });\n result.meta.valueExtent = valueExtent;\n }\n\n // every facet may contain not all of available keys, but for shared axes it is necessary to have all of them\n result.meta.xKeysByGroups = xGroupKeys.reduce((res: Record<string, string[]>, xGroupKey) => {\n const existingXKeys = sortByLabels(lodash.uniq(\n lodash.flatten(result.meta.facetKeys.map(facetKey => result.facets[facetKey].xKeysByGroups[xGroupKey]))\n ), xAxis.sorting, result.meta.xLabels);\n res[xGroupKey] = keysOrder[xColumn.value] ? lodash.intersection(keysOrder[xColumn.value], existingXKeys) : existingXKeys;\n return res;\n }, {});\n result.meta.yKeysByGroups = yGroupKeys.reduce((res: Record<string, string[]>, yGroupKey) => {\n const existingYKeys = sortByLabels(lodash.uniq(\n lodash.flatten(result.meta.facetKeys.map(facetKey => result.facets[facetKey].yKeysByGroups[yGroupKey]))\n ), yAxis.sorting, result.meta.yLabels);\n res[yGroupKey] = keysOrder[yColumn.value] ? lodash.intersection(keysOrder[yColumn.value], existingYKeys) : existingYKeys;\n return res;\n }, {});\n\n // avoid render errors on empty data\n if (result.meta.valueExtent[0] === Infinity) {\n result.meta.valueExtent[0] = 0;\n }\n if (result.meta.valueExtent[1] === -Infinity) {\n result.meta.valueExtent[1] = 0;\n }\n\n return result;\n}\n"],"names":["normalizeByStd","values","stdValue","deviation","meanValue","mean","v","normalizeByMinMax","min","max","extent","getNormalizationFn","method","getKeysCombinations","keysLists","result","keys","nextResult","key","resultItem","sortByLabels","arr","direction","labels","a","b","getCells","data","xColumn","yColumn","valueColumn","facetBy","xGroupBy","yGroupBy","annotations","dendrogramX","dendrogramY","normalization","NAValueAs","keysOrder","xAxis","yAxis","facetKeysLists","column","xGroupKeysLists","yGroupKeysLists","facetKeysCombinations","xGroupKeysCombinations","yGroupKeysCombinations","facetKeys","xGroupKeys","yGroupKeys","res","index","xLabelsSource","yLabelsSource","annotationColumnsX","item","annotationColumnsY","dendrogramXColumns","dendrogramYColumns","additionalDataColumnsX","lodash","additionalDataColumnsY","i","facetKey","xGroupKey","yGroupKey","xGroupLabel","yGroupLabel","x","y","value","xLabelsSourceValue","yLabelsSourceValue","columnKey","isAddedColumn","isAddedValue","facet","uniqueXKeys","uniqueYKeys","valueExtent","xKeys","yKeys","cells","cellKeys","groupKeys","cellGetter","cellKey","groupKey","_a","normalize","cell","existingXKeys","existingYKeys"],"mappings":";;;;AAMA,SAASA,EAAeC,GAAiB;AACrC,QAAMC,IAAWC,EAAUF,CAAM,GAC3BG,IAAYC,EAAKJ,CAAM;AAE7B,SAAIC,MAAa,UAAaE,MAAc,UAAaF,MAAa,IAC3D,CAACI,MAAaA,IAElB,CAACA,OAAcA,IAAIF,KAAaF;AAC3C;AACA,SAASK,GAAkBN,GAAiB;AACxC,QAAMG,IAAYC,EAAKJ,CAAM,GACvB,CAACO,GAAKC,CAAG,IAAIC,EAAOT,CAAM;AAChC,SAAIG,MAAc,UAAaI,MAAQ,UAAaC,MAAQ,UAAaA,MAAQD,IACtE,CAACF,MAAaA,IAElB,CAACA,OAAcA,IAAIF,MAAcK,IAAMD;AAClD;AAEA,SAASG,GAAmBC,GAA4BX,GAAiB;AACrE,SAAIW,MAAW,oBACJZ,EAAeC,CAAM,IAE5BW,MAAW,sBACJL,GAAkBN,CAAM,IAE5B,CAACK,MAAaA;AACzB;AAiDA,SAASO,EAAoBC,GAAuB;AAChD,MAAI,CAACA,EAAU;AACX,WAAO,CAAA;AAEX,MAAIC,IAAqB,CAAC,EAAE;AAC5B,SAAAD,EAAU,QAAQ,CAAAE,MAAQ;AACtB,UAAMC,IAAyB,CAAA;AAC/B,IAAAD,EAAK,QAAQ,CAAAE,MAAO;AAChB,MAAAD,EAAW,KAAK,GAAGF,EAAO,IAAI,CAAAI,MAAc,CAAC,GAAGA,GAAYD,CAAG,CAAC,CAAC;AAAA,IACrE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c;AACxF,UAAM2B,IAAgBzE,EAAa0C,EAAO;AAAA,MACtCA,EAAO,QAAQ/C,EAAO,KAAK,UAAU,IAAI,CAAAkD,MAAYlD,EAAO,OAAOkD,CAAQ,EAAE,cAAcC,CAAS,CAAC,CAAC;AAAA,IAAA,GACvG1B,EAAM,SAASzB,EAAO,KAAK,OAAO;AACrC,WAAAqC,EAAIc,CAAS,IAAI3B,EAAUX,EAAQ,KAAK,IAAIkC,EAAO,aAAavB,EAAUX,EAAQ,KAAK,GAAGiE,CAAa,IAAIA,GACpGzC;AAAA,EACX,GAAG,CAAA,CAAE,GACLrC,EAAO,KAAK,gBAAgBoC,EAAW,OAAO,CAACC,GAA+Be,MAAc;AACxF,UAAM2B,IAAgB1E,EAAa0C,EAAO;AAAA,MACtCA,EAAO,QAAQ/C,EAAO,KAAK,UAAU,IAAI,CAAAkD,MAAYlD,EAAO,OAAOkD,CAAQ,EAAE,cAAcE,CAAS,CAAC,CAAC;AAAA,IAAA,GACvG1B,EAAM,SAAS1B,EAAO,KAAK,OAAO;AACrC,WAAAqC,EAAIe,CAAS,IAAI5B,EAAUV,EAAQ,KAAK,IAAIiC,EAAO,aAAavB,EAAUV,EAAQ,KAAK,GAAGiE,CAAa,IAAIA,GACpG1C;AAAA,EACX,GAAG,CAAA,CAAE,GAGDrC,EAAO,KAAK,YAAY,CAAC,MAAM,UAC/BA,EAAO,KAAK,YAAY,CAAC,IAAI,IAE7BA,EAAO,KAAK,YAAY,CAAC,MAAM,WAC/BA,EAAO,KAAK,YAAY,CAAC,IAAI,IAG1BA;AACX;"}
|
|
@@ -1,9 +1,86 @@
|
|
|
1
1
|
import { Cluster } from './components/types';
|
|
2
2
|
import { DendrogramDistance, DendrogramLinkage } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Calculate squared Euclidean distance between two vectors
|
|
5
|
+
* This is faster than regular Euclidean distance since it avoids the square root
|
|
6
|
+
* Formula: Σ(p[i] - q[i])²
|
|
7
|
+
* @param p First vector
|
|
8
|
+
* @param q Second vector
|
|
9
|
+
* @returns Squared distance (always positive)
|
|
10
|
+
*/
|
|
3
11
|
export declare function squaredEuclidean(p: number[], q: number[]): number;
|
|
12
|
+
/**
|
|
13
|
+
* Calculate Euclidean distance between two vectors
|
|
14
|
+
* This is the standard geometric distance in n-dimensional space
|
|
15
|
+
* Formula: √(Σ(p[i] - q[i])²)
|
|
16
|
+
* @param p First vector
|
|
17
|
+
* @param q Second vector
|
|
18
|
+
* @returns Euclidean distance
|
|
19
|
+
*/
|
|
4
20
|
export declare function euclidean(p: number[], q: number[]): number;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Average Linkage
|
|
23
|
+
* Calculates the average distance between all pairs of points in the two clusters
|
|
24
|
+
* This is the most commonly used linkage method as it balances between single and complete linkage
|
|
25
|
+
* @param setA Indexes of points in first cluster
|
|
26
|
+
* @param setB Indexes of points in second cluster
|
|
27
|
+
* @param getDistance Function to get distance between two point indexes
|
|
28
|
+
* @returns Average distance between clusters
|
|
29
|
+
*/
|
|
30
|
+
export declare const averageLinkage: (setA: number[], setB: number[], getDistance: (i: number, j: number) => number) => number;
|
|
31
|
+
/**
|
|
32
|
+
* Complete Linkage (Maximum Linkage)
|
|
33
|
+
* Uses the maximum distance between any pair of points in the two clusters
|
|
34
|
+
* Tends to create compact, well-separated clusters
|
|
35
|
+
* Formula: max{d(a,b)} for all a in A, b in B
|
|
36
|
+
* @param setA Indexes of points in first cluster
|
|
37
|
+
* @param setB Indexes of points in second cluster
|
|
38
|
+
* @param getDistance Function to get distance between two point indexes
|
|
39
|
+
* @returns Maximum distance between clusters
|
|
40
|
+
*/
|
|
41
|
+
export declare const completeLinkage: (setA: number[], setB: number[], getDistance: (i: number, j: number) => number) => number;
|
|
42
|
+
/**
|
|
43
|
+
* Single Linkage (Minimum Linkage)
|
|
44
|
+
* Uses the minimum distance between any pair of points in the two clusters
|
|
45
|
+
* Tends to create elongated, chain-like clusters
|
|
46
|
+
* Formula: min{d(a,b)} for all a in A, b in B
|
|
47
|
+
* @param setA Indexes of points in first cluster
|
|
48
|
+
* @param setB Indexes of points in second cluster
|
|
49
|
+
* @param getDistance Function to get distance between two point indexes
|
|
50
|
+
* @returns Minimum distance between clusters
|
|
51
|
+
*/
|
|
52
|
+
export declare const singleLinkage: (setA: number[], setB: number[], getDistance: (i: number, j: number) => number) => number;
|
|
53
|
+
/**
|
|
54
|
+
* Extract indexes from a cluster hierarchy in the correct hierarchical order
|
|
55
|
+
* This function traverses the cluster tree and collects all indexes in the order
|
|
56
|
+
* they appear in the dendrogram (left-to-right traversal)
|
|
57
|
+
* @param cluster The root cluster to extract indexes from
|
|
58
|
+
* @returns Array of indexes in hierarchical order
|
|
59
|
+
*/
|
|
60
|
+
export declare function extractOrderedIndexes(cluster: Cluster): number[];
|
|
61
|
+
export declare function getClustersApproximate(dataValues: number[][], distanceType?: DendrogramDistance, linkageType?: DendrogramLinkage): Cluster;
|
|
62
|
+
/**
|
|
63
|
+
* Main hierarchical clustering function using agglomerative approach
|
|
64
|
+
*
|
|
65
|
+
* This implements the standard agglomerative hierarchical clustering algorithm:
|
|
66
|
+
* 1. Start with each point as its own cluster
|
|
67
|
+
* 2. Compute pairwise distances between all points
|
|
68
|
+
* 3. Iteratively merge the two closest clusters
|
|
69
|
+
* 4. Continue until only one cluster remains
|
|
70
|
+
*
|
|
71
|
+
* Algorithm complexity:
|
|
72
|
+
* - Time: O(n³) - for each of n-1 iterations, scan all n² cluster pairs
|
|
73
|
+
* - Space: O(n²) - store upper triangular distance matrix
|
|
74
|
+
*
|
|
75
|
+
* Memory optimization:
|
|
76
|
+
* - Uses upper triangular matrix storage (50% memory reduction)
|
|
77
|
+
* - Only stores distances where i < j since distance matrix is symmetric
|
|
78
|
+
*
|
|
79
|
+
* @param dataKeys Labels for each data point
|
|
80
|
+
* @param dataValues Feature vectors for each data point (n×d matrix)
|
|
81
|
+
* @param distanceType Distance metric to use between points
|
|
82
|
+
* @param linkageType Linkage method to use between clusters
|
|
83
|
+
* @returns Root cluster containing the complete hierarchy
|
|
84
|
+
*/
|
|
85
|
+
export declare function getClusters(dataValues: number[][], distanceType?: DendrogramDistance, linkageType?: DendrogramLinkage): Cluster;
|
|
9
86
|
//# sourceMappingURL=getClusters.d.ts.map
|