@inflexa-ai/harness 0.42.1 → 0.43.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/README.md +2 -2
- package/dist/agents/conversation-agent.js +5 -1
- package/dist/agents/sandbox/drug-repurposing-agent.js +1 -0
- package/dist/agents/sandbox/shared.d.ts +1 -6
- package/dist/agents/sandbox/shared.js +3 -16
- package/dist/agents/sandbox/types.d.ts +1 -1
- package/dist/app/chat-turn.js +13 -1
- package/dist/config/environment-stores.d.ts +4 -2
- package/dist/contracts/chat-events.d.ts +9 -1
- package/dist/contracts/chat-frame.d.ts +3 -3
- package/dist/contracts/chat-frame.js +8 -3
- package/dist/contracts/chat-parts.d.ts +4 -1
- package/dist/contracts/data-profile.d.ts +4 -6
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/report-blocks.d.ts +1364 -75
- package/dist/contracts/report-blocks.js +221 -29
- package/dist/contracts/report-reference.js +1 -1
- package/dist/contracts/schemas/chat-events.d.ts +13 -0
- package/dist/contracts/schemas/chat-events.js +5 -0
- package/dist/contracts/schemas/chat-parts.d.ts +2 -2
- package/dist/contracts/schemas/index.d.ts +1 -1
- package/dist/contracts/schemas/index.js +1 -1
- package/dist/execution/input-signature.d.ts +7 -13
- package/dist/execution/input-signature.js +0 -0
- package/dist/execution/run-canceler.d.ts +3 -2
- package/dist/execution/run-canceler.js +3 -2
- package/dist/execution/run-event-stream.d.ts +16 -2
- package/dist/execution/run-event-stream.js +54 -3
- package/dist/index.d.ts +1 -8
- package/dist/index.js +5 -16
- package/dist/input-scan/enrich.d.ts +0 -2
- package/dist/input-scan/enrich.js +0 -1
- package/dist/lib/metrics.js +6 -7
- package/dist/lib/otel-spans.d.ts +4 -9
- package/dist/lib/otel-spans.js +3 -8
- package/dist/loop/run-agent.d.ts +4 -2
- package/dist/loop/run-agent.js +38 -23
- package/dist/memory/thread-history.d.ts +1 -1
- package/dist/prompts/report-session.d.ts +1 -1
- package/dist/prompts/report-session.js +17 -0
- package/dist/prompts/sandbox/drug-repurposing-agent.d.ts +1 -1
- package/dist/prompts/sandbox/drug-repurposing-agent.js +7 -0
- package/dist/provenance/exec-frame.d.ts +1 -1
- package/dist/report-model/authoring-grammar.d.ts +416 -17
- package/dist/report-model/authoring-grammar.js +25 -4
- package/dist/report-model/block-walk.d.ts +20 -4
- package/dist/report-model/block-walk.js +64 -7
- package/dist/report-model/draft-finish.d.ts +6 -2
- package/dist/report-model/draft-finish.js +6 -1
- package/dist/report-model/production-resolver.d.ts +8 -0
- package/dist/report-model/production-resolver.js +1 -1
- package/dist/report-model/validate.d.ts +20 -10
- package/dist/report-model/validate.js +29 -13
- package/dist/report-render/chart-export.d.ts +52 -0
- package/dist/report-render/chart-export.js +192 -0
- package/dist/report-render/chart-presets.d.ts +46 -47
- package/dist/report-render/chart-presets.js +31 -101
- package/dist/report-render/chart-renderers.d.ts +163 -0
- package/dist/report-render/chart-renderers.js +1055 -0
- package/dist/report-render/chart-toolbox.d.ts +124 -0
- package/dist/report-render/chart-toolbox.js +595 -0
- package/dist/report-render/chart.d.ts +60 -27
- package/dist/report-render/chart.js +2323 -524
- package/dist/report-render/design.d.ts +476 -16
- package/dist/report-render/design.js +390 -56
- package/dist/report-render/figures/common.d.ts +321 -0
- package/dist/report-render/figures/common.js +759 -0
- package/dist/report-render/figures/dendrogram.d.ts +36 -0
- package/dist/report-render/figures/dendrogram.js +130 -0
- package/dist/report-render/figures/dense.d.ts +111 -0
- package/dist/report-render/figures/dense.js +204 -0
- package/dist/report-render/figures/dotplot.d.ts +28 -0
- package/dist/report-render/figures/dotplot.js +234 -0
- package/dist/report-render/figures/embedding.d.ts +43 -0
- package/dist/report-render/figures/embedding.js +360 -0
- package/dist/report-render/figures/equal-units.d.ts +101 -0
- package/dist/report-render/figures/equal-units.js +215 -0
- package/dist/report-render/figures/forest.d.ts +20 -0
- package/dist/report-render/figures/forest.js +398 -0
- package/dist/report-render/figures/gsea.d.ts +30 -0
- package/dist/report-render/figures/gsea.js +391 -0
- package/dist/report-render/figures/heatmap.d.ts +40 -0
- package/dist/report-render/figures/heatmap.js +395 -0
- package/dist/report-render/figures/index.d.ts +135 -0
- package/dist/report-render/figures/index.js +100 -0
- package/dist/report-render/figures/km.d.ts +16 -0
- package/dist/report-render/figures/km.js +406 -0
- package/dist/report-render/figures/label-room.d.ts +130 -0
- package/dist/report-render/figures/label-room.js +341 -0
- package/dist/report-render/figures/locuszoom.d.ts +50 -0
- package/dist/report-render/figures/locuszoom.js +675 -0
- package/dist/report-render/figures/lollipop.d.ts +16 -0
- package/dist/report-render/figures/lollipop.js +247 -0
- package/dist/report-render/figures/ma.d.ts +20 -0
- package/dist/report-render/figures/ma.js +114 -0
- package/dist/report-render/figures/manhattan.d.ts +60 -0
- package/dist/report-render/figures/manhattan.js +343 -0
- package/dist/report-render/figures/oncoprint.d.ts +41 -0
- package/dist/report-render/figures/oncoprint.js +420 -0
- package/dist/report-render/figures/pca.d.ts +37 -0
- package/dist/report-render/figures/pca.js +241 -0
- package/dist/report-render/figures/qq.d.ts +30 -0
- package/dist/report-render/figures/qq.js +182 -0
- package/dist/report-render/figures/roc.d.ts +17 -0
- package/dist/report-render/figures/roc.js +116 -0
- package/dist/report-render/figures/sankey.d.ts +48 -0
- package/dist/report-render/figures/sankey.js +353 -0
- package/dist/report-render/figures/upset.d.ts +60 -0
- package/dist/report-render/figures/upset.js +316 -0
- package/dist/report-render/figures/volcano.d.ts +25 -0
- package/dist/report-render/figures/volcano.js +166 -0
- package/dist/report-render/hybrid-svg.d.ts +75 -0
- package/dist/report-render/hybrid-svg.js +504 -0
- package/dist/report-render/number-format.d.ts +19 -0
- package/dist/report-render/number-format.js +25 -1
- package/dist/report-render/page.d.ts +41 -4
- package/dist/report-render/page.js +247 -12
- package/dist/report-render/render.d.ts +13 -4
- package/dist/report-render/render.js +37 -6
- package/dist/report-render/types.d.ts +23 -2
- package/dist/report-render/value-bridge.d.ts +38 -3
- package/dist/report-render/value-bridge.js +137 -6
- package/dist/report-render/views/chart-view.d.ts +42 -6
- package/dist/report-render/views/chart-view.js +70 -9
- package/dist/report-render/views/page-view.js +9 -10
- package/dist/runtime/assemble.js +2 -2
- package/dist/sandbox/client.d.ts +23 -32
- package/dist/sandbox/client.js +3 -11
- package/dist/sandbox/create-sandbox.d.ts +9 -24
- package/dist/sandbox/create-sandbox.js +15 -30
- package/dist/sandbox/docker-client.d.ts +12 -22
- package/dist/sandbox/docker-client.js +29 -43
- package/dist/sandbox/exec.d.ts +58 -0
- package/dist/sandbox/exec.js +197 -0
- package/dist/sandbox/identity.d.ts +5 -5
- package/dist/sandbox/identity.js +7 -10
- package/dist/sandbox/k8s-client.d.ts +4 -10
- package/dist/sandbox/k8s-client.js +5 -12
- package/dist/sandbox/liveness.d.ts +5 -12
- package/dist/sandbox/liveness.js +5 -12
- package/dist/sandbox/notification-sweep.d.ts +4 -7
- package/dist/sandbox/notification-sweep.js +4 -7
- package/dist/sandbox/reaper.d.ts +3 -3
- package/dist/sandbox/reaper.js +3 -3
- package/dist/sandbox/sandbox-error.d.ts +10 -11
- package/dist/sandbox/sandbox-error.js +10 -11
- package/dist/sandbox/sandbox-step-translate.d.ts +1 -1
- package/dist/sandbox/sandbox-step-translate.js +1 -1
- package/dist/sandbox/types.d.ts +31 -99
- package/dist/sandbox/types.js +17 -84
- package/dist/state/active-sandboxes.d.ts +7 -32
- package/dist/state/active-sandboxes.js +11 -46
- package/dist/state/index.d.ts +1 -2
- package/dist/state/index.js +1 -1
- package/dist/state/migrations/20261005120000_drop_the_active_exec_tracking.d.ts +7 -0
- package/dist/state/migrations/20261005120000_drop_the_active_exec_tracking.js +12 -0
- package/dist/state/migrations/index.js +2 -0
- package/dist/state/schema.d.ts +1 -5
- package/dist/state/schema.js +1 -6
- package/dist/state/step-executions.js +1 -2
- package/dist/tasks/data-profile.js +7 -20
- package/dist/tasks/derive-table-exec.d.ts +4 -14
- package/dist/tasks/derive-table-exec.js +9 -24
- package/dist/tasks/extract-values.d.ts +2 -2
- package/dist/tasks/extract-values.js +4 -7
- package/dist/tools/bio/index.d.ts +2 -0
- package/dist/tools/bio/index.js +3 -0
- package/dist/tools/bio/keys.d.ts +11 -0
- package/dist/tools/bio/keys.js +15 -0
- package/dist/tools/bio/search-clinical-trials.d.ts +1 -1
- package/dist/tools/bio/search-patents.d.ts +46 -0
- package/dist/tools/bio/search-patents.js +134 -0
- package/dist/tools/bio/search-regulatory-approvals.d.ts +49 -0
- package/dist/tools/bio/search-regulatory-approvals.js +158 -0
- package/dist/tools/define-tool.d.ts +56 -13
- package/dist/tools/define-tool.js +28 -1
- package/dist/tools/execute-analysis.js +3 -3
- package/dist/tools/lib/amass-client.d.ts +586 -0
- package/dist/tools/lib/amass-client.js +492 -0
- package/dist/tools/lib/amass-config.d.ts +2 -0
- package/dist/tools/lib/amass-config.js +10 -0
- package/dist/tools/report-session/derive-table.d.ts +8 -9
- package/dist/tools/report-session/derive-table.js +3 -4
- package/dist/tools/report-session/preview-report.js +4 -49
- package/dist/tools/sandbox/list-available-packages.d.ts +1 -1
- package/dist/tools/sandbox/list-available-packages.js +5 -4
- package/dist/tools/workspace/edit-file.d.ts +5 -4
- package/dist/tools/workspace/edit-file.js +10 -13
- package/dist/tools/workspace/execute-command.d.ts +27 -42
- package/dist/tools/workspace/execute-command.js +42 -38
- package/dist/tools/workspace/index.d.ts +5 -6
- package/dist/tools/workspace/index.js +5 -6
- package/dist/tools/workspace/mutator.d.ts +43 -8
- package/dist/tools/workspace/mutator.js +45 -34
- package/dist/tools/workspace/run-exec.d.ts +3 -12
- package/dist/tools/workspace/run-exec.js +7 -24
- package/dist/tools/workspace/scan-inputs.d.ts +0 -3
- package/dist/tools/workspace/scan-inputs.js +0 -1
- package/dist/tools/workspace/write-file.d.ts +12 -3
- package/dist/tools/workspace/write-file.js +17 -13
- package/dist/workflows/sandbox-step.d.ts +7 -11
- package/dist/workflows/sandbox-step.js +24 -27
- package/package.json +3 -1
- package/dist/sandbox/await-exec.d.ts +0 -143
- package/dist/sandbox/await-exec.js +0 -417
- package/dist/sandbox/deliver-exec-event.d.ts +0 -25
- package/dist/sandbox/deliver-exec-event.js +0 -29
- package/dist/sandbox/digest.d.ts +0 -14
- package/dist/sandbox/digest.js +0 -17
- package/dist/sandbox/exec-id.d.ts +0 -12
- package/dist/sandbox/exec-id.js +0 -20
- package/dist/sandbox/hmac.d.ts +0 -62
- package/dist/sandbox/hmac.js +0 -72
- package/dist/sandbox/submit-exec.d.ts +0 -38
- package/dist/sandbox/submit-exec.js +0 -80
- package/dist/sandbox/watchdog.d.ts +0 -71
- package/dist/sandbox/watchdog.js +0 -161
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
2
|
+
* The constants, the classification, and the volcano expansion that the dense figure modules read.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Each default of a figure is a declared constant of this module, and a declared threshold pair replaces
|
|
5
|
+
* one. A guide line carries such a value, and a guide is never a plotted value.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* A figure can carry a classification. The classification reads the plotted pair of one row against the
|
|
8
|
+
* same values that the guides carry, thus the color split lands on the drawn lines. It reads one row at a
|
|
9
|
+
* time, and it computes no aggregate. The page builds the series of a dense figure from the rule of the
|
|
10
|
+
* classification, thus the rule is plain data.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* at a time, and it computes no aggregate.
|
|
14
|
-
*
|
|
15
|
-
* A preset declares its own transform on the channel that it transforms. Thus it reads the column of that
|
|
16
|
-
* channel and it drops an authored transform there, and no value takes the transform two times.
|
|
12
|
+
* The volcano declares its own transform on the p channel. Thus it reads the column of that channel and it
|
|
13
|
+
* drops an authored transform there, and no value takes the transform two times.
|
|
17
14
|
*/
|
|
18
|
-
import { type ChartChannel, type ChartComposition, type ChartEncoding, type ChartThresholds
|
|
19
|
-
/** The four chart types that expand into a composition. */
|
|
20
|
-
export declare const PRESET_CHART_TYPES: readonly ["volcano", "manhattan", "ma", "km"];
|
|
21
|
-
/** One chart type that expands into a composition. */
|
|
22
|
-
export type PresetChartType = (typeof PRESET_CHART_TYPES)[number];
|
|
15
|
+
import { type ChartChannel, type ChartComposition, type ChartEncoding, type ChartThresholds } from "../contracts/report-blocks.js";
|
|
23
16
|
/** The default p-value threshold of a volcano. The guide line sits at the transformed value of it. */
|
|
24
17
|
export declare const VOLCANO_P_THRESHOLD = 0.05;
|
|
25
18
|
/** The default effect threshold of a volcano. One guide line sits at each side of zero. */
|
|
@@ -45,58 +38,64 @@ export interface PresetCategory {
|
|
|
45
38
|
* series in the browser, and this shape is what such a build takes. The two forms answer alike, and the
|
|
46
39
|
* shared test vector holds them together.
|
|
47
40
|
*
|
|
48
|
-
* `cut` sits on the plotted y value, which is the transformed
|
|
49
|
-
* value
|
|
50
|
-
* up side, and 2 for the null category.
|
|
41
|
+
* The volcano rule reads the plotted pair. `cut` sits on the plotted y value, which is the transformed
|
|
42
|
+
* p-value, and `effect` sits on the plotted x value. It gives the place of the category in `categories`: 0
|
|
43
|
+
* for the down side, 1 for the up side, and 2 for the null category.
|
|
44
|
+
*
|
|
45
|
+
* The MA rule reads a third column, the p-value `column`, against `cut` on its untransformed scale. It gives
|
|
46
|
+
* 0 for a row under the cut and 1 for every other row, a row with no p included. The x axis of an MA is
|
|
47
|
+
* logarithmic, thus a row whose x is not positive belongs to no category.
|
|
51
48
|
*/
|
|
52
|
-
export
|
|
49
|
+
export type PresetRule = {
|
|
53
50
|
readonly kind: "volcano";
|
|
54
51
|
readonly cut: number;
|
|
55
52
|
readonly effect: number;
|
|
56
|
-
}
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: "ma";
|
|
55
|
+
readonly column: string;
|
|
56
|
+
readonly cut: number;
|
|
57
|
+
};
|
|
57
58
|
/**
|
|
58
59
|
* The per-row classification of one preset.
|
|
59
60
|
*
|
|
60
|
-
* `categoryOf` reads the plotted pair of one row and
|
|
61
|
-
* compares each point against the same numbers that the
|
|
62
|
-
* the drawn lines. A row that gives no pair belongs to no
|
|
61
|
+
* `categoryOf` reads the plotted pair of one row, and the row index where the rule reads a third column of
|
|
62
|
+
* that row. Thus it computes no aggregate, and it compares each point against the same numbers that the
|
|
63
|
+
* guide lines carry. The color split then lands on the drawn lines. A row that gives no pair belongs to no
|
|
64
|
+
* category, and its point drops.
|
|
63
65
|
*/
|
|
64
66
|
export interface PresetClassification {
|
|
65
67
|
readonly categories: readonly PresetCategory[];
|
|
66
|
-
readonly categoryOf: (x: number | null, y: number | null) => string | undefined;
|
|
68
|
+
readonly categoryOf: (x: number | null, y: number | null, index: number) => string | undefined;
|
|
67
69
|
readonly rule: PresetRule;
|
|
68
70
|
}
|
|
69
|
-
/** The expansion of
|
|
71
|
+
/** The expansion of the volcano: the composition of its points and its guides, and its classification. */
|
|
70
72
|
export interface PresetExpansion {
|
|
71
73
|
readonly composition: ChartComposition;
|
|
72
|
-
readonly classification
|
|
74
|
+
readonly classification: PresetClassification;
|
|
73
75
|
}
|
|
74
|
-
/** True when the chart type expands into a composition. */
|
|
75
|
-
export declare function isPresetChartType(chartType: ChartType): chartType is PresetChartType;
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
77
|
+
* The composition of a volcano: the effect on x, the transformed p-value on y, three guide lines, and the
|
|
78
|
+
* three-way classification.
|
|
78
79
|
*
|
|
79
|
-
* `x` and `y` are the two channels that
|
|
80
|
-
*
|
|
81
|
-
*
|
|
80
|
+
* `x` and `y` are the two channels that the volcano demands, and the caller refuses an absent one. `encoding`
|
|
81
|
+
* supplies the optional `label` channel. `thresholds` carries the pair that the author declared, and an absent
|
|
82
|
+
* pair gives the two constants of this module.
|
|
82
83
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
84
|
+
* The two effect guides sit at each side of zero, and the p guide sits at the transformed significance. The
|
|
85
|
+
* expression of the guide is the expression of the `neg_log10` transform, thus the guide and the points
|
|
86
|
+
* share one scale. The classification reads the same two numbers, thus the color split lands on the lines.
|
|
87
|
+
* The label of the p guide prints the cut as a p-value column prints it, with the power of ten of a figure.
|
|
85
88
|
*/
|
|
86
|
-
export declare function
|
|
89
|
+
export declare function expandVolcano(x: ChartChannel, y: ChartChannel, encoding: ChartEncoding, thresholds: ChartThresholds | undefined): PresetExpansion;
|
|
87
90
|
/**
|
|
88
|
-
* The semantic axis titles
|
|
89
|
-
*
|
|
90
|
-
* A preset knows its own quantities, thus it names them in words. A volcano plots a log2 effect against the
|
|
91
|
-
* transformed p, and a manhattan plots a genome position against the same transformed p. The `ma` and the
|
|
92
|
-
* `km` presets name nothing, because neither axis of them carries a fixed quantity.
|
|
91
|
+
* The semantic axis titles of a volcano. It plots a log2 effect against the transformed p, thus it names them
|
|
92
|
+
* in words.
|
|
93
93
|
*
|
|
94
|
-
* A channel that carries an authored transform plots a derived quantity, thus the semantic title would
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* its title is exact.
|
|
94
|
+
* A channel that carries an authored transform plots a derived quantity, thus the semantic title would state
|
|
95
|
+
* the wrong one. Such a channel takes no title, and the derived name of the renderer states the true quantity.
|
|
96
|
+
* The y channel takes the transform of the volcano itself, thus its title is exact.
|
|
98
97
|
*
|
|
99
98
|
* The titles rank under a declared column label. Thus they ride beside the composition and never inside its
|
|
100
99
|
* `axes` field, where an agent title sits and where they would outrank the label.
|
|
101
100
|
*/
|
|
102
|
-
export declare function
|
|
101
|
+
export declare function volcanoAxisTitles(x: ChartChannel): PresetAxisTitles;
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
2
|
+
* The constants, the classification, and the volcano expansion that the dense figure modules read.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Each default of a figure is a declared constant of this module, and a declared threshold pair replaces
|
|
5
|
+
* one. A guide line carries such a value, and a guide is never a plotted value.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* A figure can carry a classification. The classification reads the plotted pair of one row against the
|
|
8
|
+
* same values that the guides carry, thus the color split lands on the drawn lines. It reads one row at a
|
|
9
|
+
* time, and it computes no aggregate. The page builds the series of a dense figure from the rule of the
|
|
10
|
+
* classification, thus the rule is plain data.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* at a time, and it computes no aggregate.
|
|
14
|
-
*
|
|
15
|
-
* A preset declares its own transform on the channel that it transforms. Thus it reads the column of that
|
|
16
|
-
* channel and it drops an authored transform there, and no value takes the transform two times.
|
|
12
|
+
* The volcano declares its own transform on the p channel. Thus it reads the column of that channel and it
|
|
13
|
+
* drops an authored transform there, and no value takes the transform two times.
|
|
17
14
|
*/
|
|
18
15
|
import { channelColumn, channelTransform, } from "../contracts/report-blocks.js";
|
|
19
|
-
|
|
20
|
-
export const PRESET_CHART_TYPES = ["volcano", "manhattan", "ma", "km"];
|
|
16
|
+
import { formatTableCell, typographicExponent } from "./number-format.js";
|
|
21
17
|
/** The default p-value threshold of a volcano. The guide line sits at the transformed value of it. */
|
|
22
18
|
export const VOLCANO_P_THRESHOLD = 0.05;
|
|
23
19
|
/** The default effect threshold of a volcano. One guide line sits at each side of zero. */
|
|
@@ -42,41 +38,20 @@ const NEG_LOG10_P_TITLE = "−log10(p)";
|
|
|
42
38
|
const VOLCANO_DOWN = "Down";
|
|
43
39
|
const VOLCANO_UP = "Up";
|
|
44
40
|
const VOLCANO_NULL = "Not significant";
|
|
45
|
-
/** True when the chart type expands into a composition. */
|
|
46
|
-
export function isPresetChartType(chartType) {
|
|
47
|
-
// The array holds the four preset members, thus the test never reads a base type as a preset.
|
|
48
|
-
return PRESET_CHART_TYPES.includes(chartType);
|
|
49
|
-
}
|
|
50
41
|
/**
|
|
51
|
-
*
|
|
42
|
+
* The composition of a volcano: the effect on x, the transformed p-value on y, three guide lines, and the
|
|
43
|
+
* three-way classification.
|
|
52
44
|
*
|
|
53
|
-
* `x` and `y` are the two channels that
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* `thresholds` carries the pair that the author declared. The volcano is the one preset that reads it, and
|
|
58
|
-
* an absent pair gives the two constants of this module.
|
|
59
|
-
*/
|
|
60
|
-
export function expandPreset(preset, x, y, encoding, thresholds) {
|
|
61
|
-
switch (preset) {
|
|
62
|
-
case "volcano":
|
|
63
|
-
return volcano(x, y, encoding, thresholds);
|
|
64
|
-
case "manhattan":
|
|
65
|
-
return manhattan(x, y, encoding);
|
|
66
|
-
case "ma":
|
|
67
|
-
return ma(x, y, encoding);
|
|
68
|
-
case "km":
|
|
69
|
-
return km(x, y, encoding);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* The effect on x, the transformed p-value on y, three guide lines, and the three-way classification.
|
|
45
|
+
* `x` and `y` are the two channels that the volcano demands, and the caller refuses an absent one. `encoding`
|
|
46
|
+
* supplies the optional `label` channel. `thresholds` carries the pair that the author declared, and an absent
|
|
47
|
+
* pair gives the two constants of this module.
|
|
74
48
|
*
|
|
75
49
|
* The two effect guides sit at each side of zero, and the p guide sits at the transformed significance. The
|
|
76
50
|
* expression of the guide is the expression of the `neg_log10` transform, thus the guide and the points
|
|
77
51
|
* share one scale. The classification reads the same two numbers, thus the color split lands on the lines.
|
|
52
|
+
* The label of the p guide prints the cut as a p-value column prints it, with the power of ten of a figure.
|
|
78
53
|
*/
|
|
79
|
-
function
|
|
54
|
+
export function expandVolcano(x, y, encoding, thresholds) {
|
|
80
55
|
const pColumn = channelColumn(y);
|
|
81
56
|
const significance = thresholds?.significance ?? VOLCANO_P_THRESHOLD;
|
|
82
57
|
const effect = thresholds?.effect ?? VOLCANO_EFFECT_THRESHOLD;
|
|
@@ -89,7 +64,12 @@ function volcano(x, y, encoding, thresholds) {
|
|
|
89
64
|
},
|
|
90
65
|
],
|
|
91
66
|
annotations: [
|
|
92
|
-
{
|
|
67
|
+
{
|
|
68
|
+
kind: "reference-line",
|
|
69
|
+
axis: "y",
|
|
70
|
+
value: -Math.log10(significance),
|
|
71
|
+
label: `p ${typographicExponent(formatTableCell(significance, "scientific"))}`,
|
|
72
|
+
},
|
|
93
73
|
{ kind: "reference-line", axis: "x", value: -effect },
|
|
94
74
|
{ kind: "reference-line", axis: "x", value: effect },
|
|
95
75
|
],
|
|
@@ -132,71 +112,21 @@ function volcanoClassification(significance, effect) {
|
|
|
132
112
|
},
|
|
133
113
|
};
|
|
134
114
|
}
|
|
135
|
-
/** The genome position on x, the transformed p-value on y, and the genome-wide guide line. */
|
|
136
|
-
function manhattan(x, y, encoding) {
|
|
137
|
-
const pColumn = channelColumn(y);
|
|
138
|
-
return {
|
|
139
|
-
composition: {
|
|
140
|
-
series: [
|
|
141
|
-
{
|
|
142
|
-
form: "scatter",
|
|
143
|
-
encoding: { x, y: { column: pColumn, transform: "neg_log10" }, ...optionalChannels(encoding) },
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
annotations: [{ kind: "reference-line", axis: "y", value: -Math.log10(MANHATTAN_P_THRESHOLD), label: `p ${MANHATTAN_P_THRESHOLD}` }],
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
/** The mean level on x, the effect on y, and the baseline guide line. */
|
|
151
|
-
function ma(x, y, encoding) {
|
|
152
|
-
return {
|
|
153
|
-
composition: {
|
|
154
|
-
series: [{ form: "scatter", encoding: { x, y, ...optionalChannels(encoding) } }],
|
|
155
|
-
annotations: [{ kind: "reference-line", axis: "y", value: MA_BASELINE }],
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
115
|
/**
|
|
160
|
-
* The
|
|
161
|
-
*
|
|
162
|
-
* A survival curve holds its value between two events, thus the step form is the honest one. The quick
|
|
163
|
-
* path carries two channels for the two axes and no channel for a confidence bound. Thus a band around a
|
|
164
|
-
* curve is a composition, where an `area` series names the upper bound on `y` and the lower bound on `y0`.
|
|
165
|
-
*/
|
|
166
|
-
function km(x, y, encoding) {
|
|
167
|
-
return {
|
|
168
|
-
composition: {
|
|
169
|
-
series: [{ form: "step", encoding: { x, y, ...optionalChannels(encoding) } }],
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* The semantic axis titles that one preset states.
|
|
175
|
-
*
|
|
176
|
-
* A preset knows its own quantities, thus it names them in words. A volcano plots a log2 effect against the
|
|
177
|
-
* transformed p, and a manhattan plots a genome position against the same transformed p. The `ma` and the
|
|
178
|
-
* `km` presets name nothing, because neither axis of them carries a fixed quantity.
|
|
116
|
+
* The semantic axis titles of a volcano. It plots a log2 effect against the transformed p, thus it names them
|
|
117
|
+
* in words.
|
|
179
118
|
*
|
|
180
|
-
* A channel that carries an authored transform plots a derived quantity, thus the semantic title would
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* its title is exact.
|
|
119
|
+
* A channel that carries an authored transform plots a derived quantity, thus the semantic title would state
|
|
120
|
+
* the wrong one. Such a channel takes no title, and the derived name of the renderer states the true quantity.
|
|
121
|
+
* The y channel takes the transform of the volcano itself, thus its title is exact.
|
|
184
122
|
*
|
|
185
123
|
* The titles rank under a declared column label. Thus they ride beside the composition and never inside its
|
|
186
124
|
* `axes` field, where an agent title sits and where they would outrank the label.
|
|
187
125
|
*/
|
|
188
|
-
export function
|
|
189
|
-
|
|
190
|
-
case "volcano":
|
|
191
|
-
return { ...(channelTransform(x) === undefined ? { x: LOG2_EFFECT_TITLE } : {}), y: NEG_LOG10_P_TITLE };
|
|
192
|
-
case "manhattan":
|
|
193
|
-
return { y: NEG_LOG10_P_TITLE };
|
|
194
|
-
case "ma":
|
|
195
|
-
case "km":
|
|
196
|
-
return {};
|
|
197
|
-
}
|
|
126
|
+
export function volcanoAxisTitles(x) {
|
|
127
|
+
return { ...(channelTransform(x) === undefined ? { x: LOG2_EFFECT_TITLE } : {}), y: NEG_LOG10_P_TITLE };
|
|
198
128
|
}
|
|
199
|
-
/** The two optional channels that
|
|
129
|
+
/** The two optional channels that the volcano carries through from the quick-path encoding. */
|
|
200
130
|
function optionalChannels(encoding) {
|
|
201
131
|
return {
|
|
202
132
|
...(encoding.group !== undefined ? { group: encoding.group } : {}),
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The named renderers of a custom series, in two twins.
|
|
3
|
+
*
|
|
4
|
+
* The chart runtime draws an interval, a violin outline, an oncoprint cell, and a lollipop stem through a
|
|
5
|
+
* `custom` series. The option rides to the page as inline JSON, thus it holds no function. The derivation
|
|
6
|
+
* writes the name of a renderer as the `renderItem` string, and the chart runtime finds the function under
|
|
7
|
+
* that name in its own registry. Each consumer registers each renderer with `registerCustomSeries` before it
|
|
8
|
+
* draws: the page bootstrap through the source text below, and the server export through the TypeScript
|
|
9
|
+
* functions. A series that needs parameters beyond its items carries them as JSON in `itemPayload`, and the
|
|
10
|
+
* renderer reads them from its first argument.
|
|
11
|
+
*
|
|
12
|
+
* The two twins hold one rule each. A shared test vector runs both over one set of items with a stub of the
|
|
13
|
+
* runtime, and it compares the elements that they give. Thus the two cannot drift in silence.
|
|
14
|
+
*
|
|
15
|
+
* A category axis rounds a data coordinate to its category, thus a renderer never adds a fraction of a
|
|
16
|
+
* category to a coordinate. It takes the band of one category in pixels from the runtime, and it shifts the
|
|
17
|
+
* pixel position by a fraction of that band.
|
|
18
|
+
*
|
|
19
|
+
* The export option lives here too, in the same two twins: the server draws the SVG through it, and the page
|
|
20
|
+
* draws each PNG through it.
|
|
21
|
+
*/
|
|
22
|
+
/** The renderer name of an interval: an error bar, a confidence interval, or the inner mark of a violin. */
|
|
23
|
+
export declare const INTERVAL_RENDERER = "interval";
|
|
24
|
+
/** The renderer name of a violin outline. */
|
|
25
|
+
export declare const OUTLINE_RENDERER = "outline";
|
|
26
|
+
/** The renderer name of one oncoprint cell: the gray ground and the glyph of its alteration class. */
|
|
27
|
+
export declare const CELL_GLYPH_RENDERER = "cell-glyph";
|
|
28
|
+
/** The renderer name of one lollipop mutation: a stem from zero and a head at its count. */
|
|
29
|
+
export declare const STEM_RENDERER = "stem";
|
|
30
|
+
/** The gap between two oncoprint cells, in pixels. */
|
|
31
|
+
export declare const CELL_GAP_PX = 1;
|
|
32
|
+
/** The share of the ground height that the glyph of a class covers. The gray ground shows above and below it. */
|
|
33
|
+
export declare const CELL_GLYPH_SHARE = 0.6;
|
|
34
|
+
/** The radius of the head of a lollipop stem, in pixels. */
|
|
35
|
+
export declare const STEM_HEAD_RADIUS_PX = 3.5;
|
|
36
|
+
/** The count of grid points of one violin outline. Each item of an outline holds one pair for each point. */
|
|
37
|
+
export declare const VIOLIN_GRID_POINTS = 64;
|
|
38
|
+
/** The half length of the cap at each bound of an error bar, in pixels. It is the half width of an arrow too. */
|
|
39
|
+
export declare const INTERVAL_CAP_PX = 4;
|
|
40
|
+
/** The length of the arrow at a clipped end of an interval, in pixels. */
|
|
41
|
+
export declare const INTERVAL_ARROW_PX = 6;
|
|
42
|
+
/** The first argument of a renderer: the JSON parameters that the series carries in `itemPayload`. */
|
|
43
|
+
export interface RenderParams {
|
|
44
|
+
readonly itemPayload?: Readonly<Record<string, unknown>>;
|
|
45
|
+
}
|
|
46
|
+
/** The part of the chart runtime that a renderer reads. */
|
|
47
|
+
export interface RenderApi {
|
|
48
|
+
value(dimension: number): number;
|
|
49
|
+
coord(point: number[]): number[];
|
|
50
|
+
size(delta: number[]): number[];
|
|
51
|
+
visual(name: "color"): string;
|
|
52
|
+
}
|
|
53
|
+
/** One graphic element that a renderer gives back to the chart runtime. */
|
|
54
|
+
export interface RenderedElement {
|
|
55
|
+
type: string;
|
|
56
|
+
shape?: Record<string, unknown>;
|
|
57
|
+
style?: Record<string, unknown>;
|
|
58
|
+
children?: RenderedElement[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Draw one interval.
|
|
62
|
+
*
|
|
63
|
+
* An item is `[x, y, low, high, axis, offset, mark, clipped]`. `axis` is `0` for an interval along x and `1`
|
|
64
|
+
* for one along y. `offset` is a fraction of one category band, and it moves the interval over its own bar in a
|
|
65
|
+
* grouped chart. `mark` is `0` for an error bar with two caps, and `1` for the inner mark of a violin: a
|
|
66
|
+
* thick quartile line and one point at the median, which is the anchor `y`. `clipped` is optional: its bit `1`
|
|
67
|
+
* marks a `low` that the axis clipped and its bit `2` a clipped `high`, and a clipped end draws an arrow in
|
|
68
|
+
* place of its cap, as `forestplot` draws it.
|
|
69
|
+
*/
|
|
70
|
+
export declare function intervalRenderer(_params: RenderParams, api: RenderApi): RenderedElement;
|
|
71
|
+
/**
|
|
72
|
+
* Draw one violin outline.
|
|
73
|
+
*
|
|
74
|
+
* An item is `[c, yMin, yMax, offset, w1, y1, w2, y2, ...]` with one pair for each grid point. `c` is the
|
|
75
|
+
* category index, `yMin` and `yMax` are the extent of the grid, and `offset` is a fraction of one band that
|
|
76
|
+
* moves a grouped violin inside its band. Each pair is a half-width in band fractions and its grid value.
|
|
77
|
+
* The outline runs up the right side and down the left side, thus the polygon closes on itself.
|
|
78
|
+
*/
|
|
79
|
+
export declare function outlineRenderer(_params: RenderParams, api: RenderApi): RenderedElement;
|
|
80
|
+
/**
|
|
81
|
+
* Draw one oncoprint cell.
|
|
82
|
+
*
|
|
83
|
+
* An item is `[x, y, class]`. `x` and `y` are the places of the sample and the gene on the two category axes,
|
|
84
|
+
* and `class` is the place of the alteration class in the `colors` list of the payload, or `-1` for a cell
|
|
85
|
+
* with no alteration. Each cell draws the `ground` color of the payload over its band less one gap. An altered
|
|
86
|
+
* cell adds one glyph in the color of its class: the width of the ground and a share of its height, centered.
|
|
87
|
+
*/
|
|
88
|
+
export declare function cellGlyphRenderer(params: RenderParams, api: RenderApi): RenderedElement;
|
|
89
|
+
/**
|
|
90
|
+
* Draw one lollipop mutation.
|
|
91
|
+
*
|
|
92
|
+
* An item is `[x, y]`: the amino-acid position and the count. The stem is a thin gray line from the value `0`
|
|
93
|
+
* to the count, and the head is one circle at the count in the color of the series.
|
|
94
|
+
*/
|
|
95
|
+
export declare function stemRenderer(_params: RenderParams, api: RenderApi): RenderedElement;
|
|
96
|
+
/** One renderer function: the parameters of its series and the part of the runtime that it reads. */
|
|
97
|
+
export type ChartRenderer = (params: RenderParams, api: RenderApi) => RenderedElement;
|
|
98
|
+
/**
|
|
99
|
+
* One registered renderer: the name that a derived series states, the TypeScript function that the export
|
|
100
|
+
* registers, and the name of the page twin in `CHART_RENDERERS_SOURCE` that the bootstrap registers.
|
|
101
|
+
*/
|
|
102
|
+
export interface ChartRendererEntry {
|
|
103
|
+
readonly name: string;
|
|
104
|
+
readonly render: ChartRenderer;
|
|
105
|
+
readonly pageFunction: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The registered renderers. A renderer joins by one entry here, beside its TypeScript function and its page
|
|
109
|
+
* twin, and each consumer registers it under the same name.
|
|
110
|
+
*/
|
|
111
|
+
export declare const CHART_RENDERERS: readonly ChartRendererEntry[];
|
|
112
|
+
/** The part of the chart runtime that holds the registry of the named renderers. */
|
|
113
|
+
export interface RendererRegistry {
|
|
114
|
+
registerCustomSeries(name: string, render: ChartRenderer): void;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Register each renderer with the chart runtime. A second registration of one name replaces the first with
|
|
118
|
+
* the same function, thus a caller registers before each draw and the runtime holds one function per name.
|
|
119
|
+
*/
|
|
120
|
+
export declare function registerChartRenderers(runtime: RendererRegistry): void;
|
|
121
|
+
/**
|
|
122
|
+
* The member of an option that holds the series of each export width, for a figure whose text the derivation
|
|
123
|
+
* places itself.
|
|
124
|
+
*
|
|
125
|
+
* A name that the derivation places clears its neighbors at one plot size and one text size alone. Thus the
|
|
126
|
+
* figure places its names again for the plot of each export, and the export takes the series of its width in
|
|
127
|
+
* place of the page series of the same names. The member is no field of the chart runtime, and the runtime
|
|
128
|
+
* keeps an unknown member without a draw.
|
|
129
|
+
*/
|
|
130
|
+
export declare const SIZED_SERIES_MEMBER = "sizedSeries";
|
|
131
|
+
/** The series of each export width: the names of the page series that they replace, and the series of each width. */
|
|
132
|
+
export interface SizedSeries {
|
|
133
|
+
readonly names: readonly string[];
|
|
134
|
+
readonly widths: Readonly<Record<string, readonly unknown[]>>;
|
|
135
|
+
}
|
|
136
|
+
/** The height of one line of the chart text, as a share of the text size. An upright category label takes one line along its axis. */
|
|
137
|
+
export declare const LABEL_LINE_SHARE = 1.3;
|
|
138
|
+
/**
|
|
139
|
+
* The label interval of an axis of upright category labels at one width and one text size: the count of labels that
|
|
140
|
+
* the chart runtime skips after each label that it prints. The width holds one upright label for each line of text.
|
|
141
|
+
* An axis of more categories prints the first label of each run that the width gives, and an axis that fits skips none.
|
|
142
|
+
*/
|
|
143
|
+
export declare function categoryInterval(count: number, textPx: number, widthPx: number): number;
|
|
144
|
+
/**
|
|
145
|
+
* The option of one export at one text size.
|
|
146
|
+
*
|
|
147
|
+
* An export is a still figure. Thus it carries no tooltip, no toolbox, and no animation. The theme of the
|
|
148
|
+
* export sets the text size, and the gap between an axis and its name, and the label of a facet panel, scale
|
|
149
|
+
* with the text. The copy leaves the input as it is, thus the page keeps its own option.
|
|
150
|
+
*
|
|
151
|
+
* A column export is short and narrow. Thus the grid of a chart with a bottom legend holds its labels and its
|
|
152
|
+
* names above a band of the legend height, and the panels of a facet end over the band of the legend lines
|
|
153
|
+
* that the export width gives. The category labels turn where they do not fit the width, and a color scale
|
|
154
|
+
* prints its ends as static text. A grid that contains its labels contains its names too.
|
|
155
|
+
*/
|
|
156
|
+
export declare function exportOption(option: Record<string, unknown>, textPx: number, widthPx: number, heightPx: number): Record<string, unknown>;
|
|
157
|
+
/**
|
|
158
|
+
* The page twin of each renderer, of the bind step, and of the export option, as browser source text.
|
|
159
|
+
*
|
|
160
|
+
* Each function holds the rule of its TypeScript twin in the same order of operations. Thus the two give
|
|
161
|
+
* the same numbers for one item, and the shared test vector compares them exactly.
|
|
162
|
+
*/
|
|
163
|
+
export declare const CHART_RENDERERS_SOURCE: string;
|