@platforma-open/milaboratories.humanization-score.model 0.2.0 → 0.3.1
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/.turbo/turbo-build.log +12 -10
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +28 -0
- package/dist/bundle.js +279 -52
- package/dist/bundle.js.map +1 -1
- package/dist/index.cjs +43 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +45 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -14
- package/dist/index.js.map +1 -1
- package/dist/model.json +1 -1
- package/package.json +5 -4
- package/src/index.ts +72 -17
package/dist/index.cjs
CHANGED
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _platforma_sdk_model = require("@platforma-sdk/model");
|
|
3
3
|
//#region src/index.ts
|
|
4
|
+
const HUMANNESS_SCORE_COLUMN = "pl7.app/humannessScore";
|
|
5
|
+
const defaultGraphStateHistogram = () => ({
|
|
6
|
+
title: "Humanness Score Distribution",
|
|
7
|
+
template: "bins",
|
|
8
|
+
currentTab: null,
|
|
9
|
+
axesSettings: { other: { binsCount: 20 } },
|
|
10
|
+
layersSettings: { bins: { fillColor: "#2D93FA" } }
|
|
11
|
+
});
|
|
12
|
+
const inputSelectors = [{
|
|
13
|
+
axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/clonotypeKey" }],
|
|
14
|
+
annotations: { "pl7.app/isAnchor": "true" }
|
|
15
|
+
}, {
|
|
16
|
+
axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/scClonotypeKey" }],
|
|
17
|
+
annotations: { "pl7.app/isAnchor": "true" }
|
|
18
|
+
}];
|
|
4
19
|
const dataModel = new _platforma_sdk_model.DataModelBuilder().from("v1").upgradeLegacy(({ args, uiState }) => ({
|
|
5
20
|
...args,
|
|
6
|
-
tableState: uiState.tableState
|
|
21
|
+
tableState: uiState.tableState,
|
|
22
|
+
graphStateHistogram: uiState.graphStateHistogram ?? defaultGraphStateHistogram()
|
|
7
23
|
})).init(() => ({
|
|
8
24
|
customBlockLabel: "",
|
|
9
|
-
tableState: (0, _platforma_sdk_model.createPlDataTableStateV2)()
|
|
25
|
+
tableState: (0, _platforma_sdk_model.createPlDataTableStateV2)(),
|
|
26
|
+
graphStateHistogram: defaultGraphStateHistogram()
|
|
10
27
|
}));
|
|
11
28
|
const platforma = _platforma_sdk_model.BlockModelV3.create(dataModel).args((data) => {
|
|
12
29
|
if (!data.inputAnchor) throw new Error("Input anchor is required");
|
|
13
30
|
return {
|
|
14
|
-
customBlockLabel: data.customBlockLabel || "
|
|
31
|
+
customBlockLabel: data.customBlockLabel || "",
|
|
15
32
|
inputAnchor: data.inputAnchor,
|
|
16
33
|
mem: data.mem
|
|
17
34
|
};
|
|
18
|
-
}).output("inputOptions", (ctx) => ctx.resultPool.getOptions(
|
|
19
|
-
|
|
20
|
-
annotations: { "pl7.app/isAnchor": "true" }
|
|
21
|
-
}, {
|
|
22
|
-
axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/scClonotypeKey" }],
|
|
23
|
-
annotations: { "pl7.app/isAnchor": "true" }
|
|
24
|
-
}])).outputWithStatus("pt", (ctx) => {
|
|
25
|
-
const pCols = ctx.outputs?.resolve("outputLiabilities")?.getPColumns();
|
|
35
|
+
}).output("inputOptions", (ctx) => ctx.resultPool.getOptions(inputSelectors)).outputWithStatus("pt", (ctx) => {
|
|
36
|
+
const pCols = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
26
37
|
if (pCols === void 0) return;
|
|
27
38
|
return (0, _platforma_sdk_model.createPlDataTableV3)(ctx, {
|
|
28
39
|
tableState: ctx.data.tableState,
|
|
@@ -31,12 +42,32 @@ const platforma = _platforma_sdk_model.BlockModelV3.create(dataModel).args((data
|
|
|
31
42
|
isPrimary: true
|
|
32
43
|
}))
|
|
33
44
|
});
|
|
34
|
-
}).
|
|
45
|
+
}).outputWithStatus("histogramPf", (ctx) => {
|
|
46
|
+
const pCols = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
47
|
+
if (pCols === void 0) return void 0;
|
|
48
|
+
return (0, _platforma_sdk_model.createPFrameForGraphs)(ctx, pCols);
|
|
49
|
+
}).output("histogramPfPcols", (ctx) => {
|
|
50
|
+
const pCols = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
51
|
+
if (pCols === void 0 || pCols.length === 0) return void 0;
|
|
52
|
+
return pCols.map((c) => ({
|
|
53
|
+
columnId: c.id,
|
|
54
|
+
spec: c.spec
|
|
55
|
+
}));
|
|
56
|
+
}).output("isRunning", (ctx) => ctx.outputs?.getIsReadyOrError() === false).title(() => "Humanization Score").subtitle((ctx) => {
|
|
57
|
+
if (ctx.data.customBlockLabel) return ctx.data.customBlockLabel;
|
|
58
|
+
return "Humanization Score";
|
|
59
|
+
}).sections((_) => [{
|
|
35
60
|
type: "link",
|
|
36
61
|
href: "/",
|
|
37
62
|
label: "Table"
|
|
63
|
+
}, {
|
|
64
|
+
type: "link",
|
|
65
|
+
href: "/histogram",
|
|
66
|
+
label: "Score Distribution"
|
|
38
67
|
}]).done();
|
|
39
68
|
//#endregion
|
|
69
|
+
exports.HUMANNESS_SCORE_COLUMN = HUMANNESS_SCORE_COLUMN;
|
|
70
|
+
exports.defaultGraphStateHistogram = defaultGraphStateHistogram;
|
|
40
71
|
exports.platforma = platforma;
|
|
41
72
|
|
|
42
73
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["DataModelBuilder","BlockModelV3","ArrayColumnProvider"],"sources":["../src/index.ts"],"sourcesContent":["import type {\n PlDataTableStateV2,\n PlRef,\n} from '@platforma-sdk/model';\nimport {\n ArrayColumnProvider,\n BlockModelV3,\n DataModelBuilder,\n createPlDataTableStateV2,\n createPlDataTableV3,\n} from '@platforma-sdk/model';\nexport type * from '@milaboratories/helpers';\n\ntype OldArgs = {\n customBlockLabel: string;\n inputAnchor?: PlRef;\n mem?: number;\n};\n\ntype OldUiState = {\n tableState: PlDataTableStateV2;\n};\n\nexport type BlockData = {\n customBlockLabel: string;\n inputAnchor?: PlRef;\n mem?: number;\n tableState: PlDataTableStateV2;\n};\n\nconst dataModel = new DataModelBuilder()\n .from<BlockData>('v1')\n .upgradeLegacy<OldArgs, OldUiState>(({ args, uiState }) => ({\n ...args,\n tableState: uiState.tableState,\n }))\n .init(() => ({\n customBlockLabel: '',\n tableState: createPlDataTableStateV2(),\n }));\n\nexport const platforma = BlockModelV3.create(dataModel)\n\n .args((data) => {\n if (!data.inputAnchor) throw new Error('Input anchor is required');\n\n return {\n customBlockLabel: data.customBlockLabel || '
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["DataModelBuilder","BlockModelV3","ArrayColumnProvider"],"sources":["../src/index.ts"],"sourcesContent":["import type { GraphMakerState } from '@milaboratories/graph-maker';\nimport type {\n PColumnIdAndSpec,\n PFrameHandle,\n PlDataTableStateV2,\n PlRef,\n} from '@platforma-sdk/model';\nimport {\n ArrayColumnProvider,\n BlockModelV3,\n DataModelBuilder,\n createPFrameForGraphs,\n createPlDataTableStateV2,\n createPlDataTableV3,\n} from '@platforma-sdk/model';\nexport type * from '@milaboratories/helpers';\n\ntype OldArgs = {\n customBlockLabel: string;\n inputAnchor?: PlRef;\n mem?: number;\n};\n\ntype OldUiState = {\n tableState: PlDataTableStateV2;\n graphStateHistogram?: GraphMakerState;\n};\n\nexport type BlockData = {\n customBlockLabel: string;\n inputAnchor?: PlRef;\n mem?: number;\n tableState: PlDataTableStateV2;\n // Distribution of the per-clonotype humanness score across the whole dataset.\n graphStateHistogram: GraphMakerState;\n};\n\n// Humanness score column name emitted by `clonotype-process.tpl.tengo`.\nexport const HUMANNESS_SCORE_COLUMN = 'pl7.app/humannessScore';\n\nexport const defaultGraphStateHistogram = (): GraphMakerState => ({\n title: 'Humanness Score Distribution',\n template: 'bins',\n currentTab: null,\n axesSettings: {\n other: { binsCount: 20 },\n },\n // Give the bars a solid fill instead of the default white — colour values\n // taken from graph-maker's fixed palette (\"Blue\").\n layersSettings: {\n bins: { fillColor: '#2D93FA' },\n },\n});\n\n// Selectors for the input dataset anchor — shared between `inputOptions`\n// (the dropdown) and `subtitle` (so the default label matches the dataset name).\nconst inputSelectors = [{\n axes: [\n { name: 'pl7.app/sampleId' },\n { name: 'pl7.app/vdj/clonotypeKey' },\n ],\n annotations: { 'pl7.app/isAnchor': 'true' },\n}, {\n axes: [\n { name: 'pl7.app/sampleId' },\n { name: 'pl7.app/vdj/scClonotypeKey' },\n ],\n annotations: { 'pl7.app/isAnchor': 'true' },\n}];\n\nconst dataModel = new DataModelBuilder()\n .from<BlockData>('v1')\n .upgradeLegacy<OldArgs, OldUiState>(({ args, uiState }) => ({\n ...args,\n tableState: uiState.tableState,\n graphStateHistogram: uiState.graphStateHistogram ?? defaultGraphStateHistogram(),\n }))\n .init(() => ({\n customBlockLabel: '',\n tableState: createPlDataTableStateV2(),\n graphStateHistogram: defaultGraphStateHistogram(),\n }));\n\nexport const platforma = BlockModelV3.create(dataModel)\n\n .args((data) => {\n if (!data.inputAnchor) throw new Error('Input anchor is required');\n\n return {\n // Empty when unset; the workflow falls back to the input dataset name so\n // the provenance trace label matches the block subtitle.\n customBlockLabel: data.customBlockLabel || '',\n inputAnchor: data.inputAnchor,\n mem: data.mem,\n };\n })\n\n .output('inputOptions', (ctx) =>\n ctx.resultPool.getOptions(inputSelectors),\n )\n\n .outputWithStatus('pt', (ctx) => {\n const pCols = ctx.outputs?.resolve('outputHumanness')?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n return createPlDataTableV3(ctx, {\n tableState: ctx.data.tableState,\n columns: new ArrayColumnProvider(pCols)\n .getAllColumns()\n .map((column) => ({ column, isPrimary: true })),\n });\n })\n\n // --- Score distribution (histogram) ---------------------------------------\n // One row per clonotype, so the histogram counts UNIQUE clonotypes by humanness\n // score — it is deliberately NOT weighted by clonotype abundance. The question it\n // answers is \"how many distinct candidates sit below/above a humanness level\"\n // (i.e. how much humanization work is there), not \"how human is the repertoire by\n // read mass\". No human-like threshold line is drawn: this score is a 9-mer\n // fraction rescaled to 0..100, not a cutoff validated against therapeutic mAbs.\n .outputWithStatus('histogramPf', (ctx): PFrameHandle | undefined => {\n const pCols = ctx.outputs?.resolve('outputHumanness')?.getPColumns();\n if (pCols === undefined) return undefined;\n return createPFrameForGraphs(ctx, pCols);\n })\n\n .output('histogramPfPcols', (ctx): PColumnIdAndSpec[] | undefined => {\n const pCols = ctx.outputs?.resolve('outputHumanness')?.getPColumns();\n if (pCols === undefined || pCols.length === 0) return undefined;\n return pCols.map((c) => ({ columnId: c.id, spec: c.spec }));\n })\n\n .output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)\n\n .title(() => 'Humanization Score')\n\n .subtitle((ctx) => {\n if (ctx.data.customBlockLabel) return ctx.data.customBlockLabel;\n return 'Humanization Score';\n })\n\n .sections((_) => [\n { type: 'link', href: '/', label: 'Table' },\n { type: 'link', href: '/histogram', label: 'Score Distribution' },\n ])\n\n .done();\n"],"mappings":";;;AAsCA,MAAa,yBAAyB;AAEtC,MAAa,oCAAqD;CAChE,OAAO;CACP,UAAU;CACV,YAAY;CACZ,cAAc,EACZ,OAAO,EAAE,WAAW,IAAI,EACzB;CAGD,gBAAgB,EACd,MAAM,EAAE,WAAW,WAAW,EAC/B;CACF;AAID,MAAM,iBAAiB,CAAC;CACtB,MAAM,CACJ,EAAE,MAAM,oBAAoB,EAC5B,EAAE,MAAM,4BAA4B,CACrC;CACD,aAAa,EAAE,oBAAoB,QAAQ;CAC5C,EAAE;CACD,MAAM,CACJ,EAAE,MAAM,oBAAoB,EAC5B,EAAE,MAAM,8BAA8B,CACvC;CACD,aAAa,EAAE,oBAAoB,QAAQ;CAC5C,CAAC;A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EAAE;EAC3D,CAED,OAAO,cAAc,QAAQ,IAAI,SAAS,mBAAmB,KAAK,MAAM,CAExE,YAAY,qBAAqB,CAEjC,UAAU,QAAQ;CACjB,IAAI,IAAI,KAAK,kBAAkB,OAAO,IAAI,KAAK;CAC/C,OAAO;EACP,CAED,UAAU,MAAM,CACf;CAAE,MAAM;CAAQ,MAAM;CAAK,OAAO;CAAS,EAC3C;CAAE,MAAM;CAAQ,MAAM;CAAc,OAAO;CAAsB,CAClE,CAAC,CAED,MAAM"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _$_platforma_sdk_model0 from "@platforma-sdk/model";
|
|
2
|
-
import { PlDataTableStateV2, PlRef } from "@platforma-sdk/model";
|
|
2
|
+
import { PFrameHandle, PlDataTableStateV2, PlRef } from "@platforma-sdk/model";
|
|
3
3
|
import * as _$_milaboratories_helpers0 from "@milaboratories/helpers";
|
|
4
|
+
import { GraphMakerState } from "@milaboratories/graph-maker";
|
|
4
5
|
export * from "@milaboratories/helpers";
|
|
5
6
|
|
|
6
7
|
//#region src/index.d.ts
|
|
@@ -9,7 +10,10 @@ type BlockData = {
|
|
|
9
10
|
inputAnchor?: PlRef;
|
|
10
11
|
mem?: number;
|
|
11
12
|
tableState: PlDataTableStateV2;
|
|
13
|
+
graphStateHistogram: GraphMakerState;
|
|
12
14
|
};
|
|
15
|
+
declare const HUMANNESS_SCORE_COLUMN = "pl7.app/humannessScore";
|
|
16
|
+
declare const defaultGraphStateHistogram: () => GraphMakerState;
|
|
13
17
|
declare const platforma: _$_platforma_sdk_model0.PlatformaExtended<_$_platforma_sdk_model0.PlatformaV3<BlockData, {
|
|
14
18
|
customBlockLabel: string;
|
|
15
19
|
inputAnchor: Readonly<{
|
|
@@ -33,7 +37,7 @@ declare const platforma: _$_platforma_sdk_model0.PlatformaExtended<_$_platforma_
|
|
|
33
37
|
pt: _$_platforma_sdk_model0.ConfigRenderLambda<{
|
|
34
38
|
sourceId: null | string;
|
|
35
39
|
fullTableHandle?: _$_platforma_sdk_model0.PTableHandle | undefined;
|
|
36
|
-
fullPframeHandle?:
|
|
40
|
+
fullPframeHandle?: PFrameHandle | undefined;
|
|
37
41
|
visibleTableHandle?: _$_platforma_sdk_model0.PTableHandle | undefined;
|
|
38
42
|
defaultFilters?: _$_milaboratories_helpers0.Nil | {
|
|
39
43
|
type: "or";
|
|
@@ -1679,9 +1683,46 @@ declare const platforma: _$_platforma_sdk_model0.PlatformaExtended<_$_platforma_
|
|
|
1679
1683
|
} | undefined> & {
|
|
1680
1684
|
withStatus: true;
|
|
1681
1685
|
};
|
|
1686
|
+
} & {
|
|
1687
|
+
histogramPf: _$_platforma_sdk_model0.ConfigRenderLambda<PFrameHandle | undefined> & {
|
|
1688
|
+
withStatus: true;
|
|
1689
|
+
};
|
|
1690
|
+
} & {
|
|
1691
|
+
histogramPfPcols: _$_platforma_sdk_model0.ConfigRenderLambda<{
|
|
1692
|
+
readonly columnId: _$_platforma_sdk_model0.PObjectId;
|
|
1693
|
+
readonly spec: {
|
|
1694
|
+
readonly kind: "PColumn";
|
|
1695
|
+
readonly name: string;
|
|
1696
|
+
readonly domain?: {
|
|
1697
|
+
[x: string]: string;
|
|
1698
|
+
} | undefined;
|
|
1699
|
+
readonly contextDomain?: {
|
|
1700
|
+
[x: string]: string;
|
|
1701
|
+
} | undefined;
|
|
1702
|
+
readonly annotations?: {
|
|
1703
|
+
[x: string]: string;
|
|
1704
|
+
} | undefined;
|
|
1705
|
+
readonly valueType: "Int" | "Long" | "Float" | "Double" | "String" | "Bytes";
|
|
1706
|
+
readonly parentAxes?: number[] | undefined;
|
|
1707
|
+
readonly axesSpec: {
|
|
1708
|
+
readonly type: _$_platforma_sdk_model0.AxisValueType;
|
|
1709
|
+
readonly name: string;
|
|
1710
|
+
readonly domain?: {
|
|
1711
|
+
[x: string]: string;
|
|
1712
|
+
} | undefined;
|
|
1713
|
+
readonly contextDomain?: {
|
|
1714
|
+
[x: string]: string;
|
|
1715
|
+
} | undefined;
|
|
1716
|
+
readonly annotations?: {
|
|
1717
|
+
[x: string]: string;
|
|
1718
|
+
} | undefined;
|
|
1719
|
+
readonly parentAxes?: number[] | undefined;
|
|
1720
|
+
}[];
|
|
1721
|
+
};
|
|
1722
|
+
}[] | undefined>;
|
|
1682
1723
|
} & {
|
|
1683
1724
|
isRunning: _$_platforma_sdk_model0.ConfigRenderLambda<boolean>;
|
|
1684
|
-
}>, "/", {}, _$_platforma_sdk_model0.BlockDefaultUiServices>>;
|
|
1725
|
+
}>, "/" | "/histogram", {}, _$_platforma_sdk_model0.BlockDefaultUiServices>>;
|
|
1685
1726
|
//#endregion
|
|
1686
|
-
export { BlockData, platforma };
|
|
1727
|
+
export { BlockData, HUMANNESS_SCORE_COLUMN, defaultGraphStateHistogram, platforma };
|
|
1687
1728
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;KA4BY,SAAA;EACV,gBAAA;EACA,WAAA,GAAc,KAAA;EACd,GAAA;EACA,UAAA,EAAY,kBAAA;EAEZ,mBAAA,EAAqB,eAAA;AAAA;AAAA,cAIV,sBAAA;AAAA,cAEA,0BAAA,QAAiC,eAAA;AAAA,cA2CjC,SAAA,EAAS,uBAAA,CAAA,iBAAA,yBAAA,WAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
|
-
import { ArrayColumnProvider, BlockModelV3, DataModelBuilder, createPlDataTableStateV2, createPlDataTableV3 } from "@platforma-sdk/model";
|
|
1
|
+
import { ArrayColumnProvider, BlockModelV3, DataModelBuilder, createPFrameForGraphs, createPlDataTableStateV2, createPlDataTableV3 } from "@platforma-sdk/model";
|
|
2
2
|
//#region src/index.ts
|
|
3
|
+
const HUMANNESS_SCORE_COLUMN = "pl7.app/humannessScore";
|
|
4
|
+
const defaultGraphStateHistogram = () => ({
|
|
5
|
+
title: "Humanness Score Distribution",
|
|
6
|
+
template: "bins",
|
|
7
|
+
currentTab: null,
|
|
8
|
+
axesSettings: { other: { binsCount: 20 } },
|
|
9
|
+
layersSettings: { bins: { fillColor: "#2D93FA" } }
|
|
10
|
+
});
|
|
11
|
+
const inputSelectors = [{
|
|
12
|
+
axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/clonotypeKey" }],
|
|
13
|
+
annotations: { "pl7.app/isAnchor": "true" }
|
|
14
|
+
}, {
|
|
15
|
+
axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/scClonotypeKey" }],
|
|
16
|
+
annotations: { "pl7.app/isAnchor": "true" }
|
|
17
|
+
}];
|
|
3
18
|
const dataModel = new DataModelBuilder().from("v1").upgradeLegacy(({ args, uiState }) => ({
|
|
4
19
|
...args,
|
|
5
|
-
tableState: uiState.tableState
|
|
20
|
+
tableState: uiState.tableState,
|
|
21
|
+
graphStateHistogram: uiState.graphStateHistogram ?? defaultGraphStateHistogram()
|
|
6
22
|
})).init(() => ({
|
|
7
23
|
customBlockLabel: "",
|
|
8
|
-
tableState: createPlDataTableStateV2()
|
|
24
|
+
tableState: createPlDataTableStateV2(),
|
|
25
|
+
graphStateHistogram: defaultGraphStateHistogram()
|
|
9
26
|
}));
|
|
10
27
|
const platforma = BlockModelV3.create(dataModel).args((data) => {
|
|
11
28
|
if (!data.inputAnchor) throw new Error("Input anchor is required");
|
|
12
29
|
return {
|
|
13
|
-
customBlockLabel: data.customBlockLabel || "
|
|
30
|
+
customBlockLabel: data.customBlockLabel || "",
|
|
14
31
|
inputAnchor: data.inputAnchor,
|
|
15
32
|
mem: data.mem
|
|
16
33
|
};
|
|
17
|
-
}).output("inputOptions", (ctx) => ctx.resultPool.getOptions(
|
|
18
|
-
|
|
19
|
-
annotations: { "pl7.app/isAnchor": "true" }
|
|
20
|
-
}, {
|
|
21
|
-
axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/scClonotypeKey" }],
|
|
22
|
-
annotations: { "pl7.app/isAnchor": "true" }
|
|
23
|
-
}])).outputWithStatus("pt", (ctx) => {
|
|
24
|
-
const pCols = ctx.outputs?.resolve("outputLiabilities")?.getPColumns();
|
|
34
|
+
}).output("inputOptions", (ctx) => ctx.resultPool.getOptions(inputSelectors)).outputWithStatus("pt", (ctx) => {
|
|
35
|
+
const pCols = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
25
36
|
if (pCols === void 0) return;
|
|
26
37
|
return createPlDataTableV3(ctx, {
|
|
27
38
|
tableState: ctx.data.tableState,
|
|
@@ -30,12 +41,30 @@ const platforma = BlockModelV3.create(dataModel).args((data) => {
|
|
|
30
41
|
isPrimary: true
|
|
31
42
|
}))
|
|
32
43
|
});
|
|
33
|
-
}).
|
|
44
|
+
}).outputWithStatus("histogramPf", (ctx) => {
|
|
45
|
+
const pCols = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
46
|
+
if (pCols === void 0) return void 0;
|
|
47
|
+
return createPFrameForGraphs(ctx, pCols);
|
|
48
|
+
}).output("histogramPfPcols", (ctx) => {
|
|
49
|
+
const pCols = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
50
|
+
if (pCols === void 0 || pCols.length === 0) return void 0;
|
|
51
|
+
return pCols.map((c) => ({
|
|
52
|
+
columnId: c.id,
|
|
53
|
+
spec: c.spec
|
|
54
|
+
}));
|
|
55
|
+
}).output("isRunning", (ctx) => ctx.outputs?.getIsReadyOrError() === false).title(() => "Humanization Score").subtitle((ctx) => {
|
|
56
|
+
if (ctx.data.customBlockLabel) return ctx.data.customBlockLabel;
|
|
57
|
+
return "Humanization Score";
|
|
58
|
+
}).sections((_) => [{
|
|
34
59
|
type: "link",
|
|
35
60
|
href: "/",
|
|
36
61
|
label: "Table"
|
|
62
|
+
}, {
|
|
63
|
+
type: "link",
|
|
64
|
+
href: "/histogram",
|
|
65
|
+
label: "Score Distribution"
|
|
37
66
|
}]).done();
|
|
38
67
|
//#endregion
|
|
39
|
-
export { platforma };
|
|
68
|
+
export { HUMANNESS_SCORE_COLUMN, defaultGraphStateHistogram, platforma };
|
|
40
69
|
|
|
41
70
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type {\n PlDataTableStateV2,\n PlRef,\n} from '@platforma-sdk/model';\nimport {\n ArrayColumnProvider,\n BlockModelV3,\n DataModelBuilder,\n createPlDataTableStateV2,\n createPlDataTableV3,\n} from '@platforma-sdk/model';\nexport type * from '@milaboratories/helpers';\n\ntype OldArgs = {\n customBlockLabel: string;\n inputAnchor?: PlRef;\n mem?: number;\n};\n\ntype OldUiState = {\n tableState: PlDataTableStateV2;\n};\n\nexport type BlockData = {\n customBlockLabel: string;\n inputAnchor?: PlRef;\n mem?: number;\n tableState: PlDataTableStateV2;\n};\n\nconst dataModel = new DataModelBuilder()\n .from<BlockData>('v1')\n .upgradeLegacy<OldArgs, OldUiState>(({ args, uiState }) => ({\n ...args,\n tableState: uiState.tableState,\n }))\n .init(() => ({\n customBlockLabel: '',\n tableState: createPlDataTableStateV2(),\n }));\n\nexport const platforma = BlockModelV3.create(dataModel)\n\n .args((data) => {\n if (!data.inputAnchor) throw new Error('Input anchor is required');\n\n return {\n customBlockLabel: data.customBlockLabel || '
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { GraphMakerState } from '@milaboratories/graph-maker';\nimport type {\n PColumnIdAndSpec,\n PFrameHandle,\n PlDataTableStateV2,\n PlRef,\n} from '@platforma-sdk/model';\nimport {\n ArrayColumnProvider,\n BlockModelV3,\n DataModelBuilder,\n createPFrameForGraphs,\n createPlDataTableStateV2,\n createPlDataTableV3,\n} from '@platforma-sdk/model';\nexport type * from '@milaboratories/helpers';\n\ntype OldArgs = {\n customBlockLabel: string;\n inputAnchor?: PlRef;\n mem?: number;\n};\n\ntype OldUiState = {\n tableState: PlDataTableStateV2;\n graphStateHistogram?: GraphMakerState;\n};\n\nexport type BlockData = {\n customBlockLabel: string;\n inputAnchor?: PlRef;\n mem?: number;\n tableState: PlDataTableStateV2;\n // Distribution of the per-clonotype humanness score across the whole dataset.\n graphStateHistogram: GraphMakerState;\n};\n\n// Humanness score column name emitted by `clonotype-process.tpl.tengo`.\nexport const HUMANNESS_SCORE_COLUMN = 'pl7.app/humannessScore';\n\nexport const defaultGraphStateHistogram = (): GraphMakerState => ({\n title: 'Humanness Score Distribution',\n template: 'bins',\n currentTab: null,\n axesSettings: {\n other: { binsCount: 20 },\n },\n // Give the bars a solid fill instead of the default white — colour values\n // taken from graph-maker's fixed palette (\"Blue\").\n layersSettings: {\n bins: { fillColor: '#2D93FA' },\n },\n});\n\n// Selectors for the input dataset anchor — shared between `inputOptions`\n// (the dropdown) and `subtitle` (so the default label matches the dataset name).\nconst inputSelectors = [{\n axes: [\n { name: 'pl7.app/sampleId' },\n { name: 'pl7.app/vdj/clonotypeKey' },\n ],\n annotations: { 'pl7.app/isAnchor': 'true' },\n}, {\n axes: [\n { name: 'pl7.app/sampleId' },\n { name: 'pl7.app/vdj/scClonotypeKey' },\n ],\n annotations: { 'pl7.app/isAnchor': 'true' },\n}];\n\nconst dataModel = new DataModelBuilder()\n .from<BlockData>('v1')\n .upgradeLegacy<OldArgs, OldUiState>(({ args, uiState }) => ({\n ...args,\n tableState: uiState.tableState,\n graphStateHistogram: uiState.graphStateHistogram ?? defaultGraphStateHistogram(),\n }))\n .init(() => ({\n customBlockLabel: '',\n tableState: createPlDataTableStateV2(),\n graphStateHistogram: defaultGraphStateHistogram(),\n }));\n\nexport const platforma = BlockModelV3.create(dataModel)\n\n .args((data) => {\n if (!data.inputAnchor) throw new Error('Input anchor is required');\n\n return {\n // Empty when unset; the workflow falls back to the input dataset name so\n // the provenance trace label matches the block subtitle.\n customBlockLabel: data.customBlockLabel || '',\n inputAnchor: data.inputAnchor,\n mem: data.mem,\n };\n })\n\n .output('inputOptions', (ctx) =>\n ctx.resultPool.getOptions(inputSelectors),\n )\n\n .outputWithStatus('pt', (ctx) => {\n const pCols = ctx.outputs?.resolve('outputHumanness')?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n return createPlDataTableV3(ctx, {\n tableState: ctx.data.tableState,\n columns: new ArrayColumnProvider(pCols)\n .getAllColumns()\n .map((column) => ({ column, isPrimary: true })),\n });\n })\n\n // --- Score distribution (histogram) ---------------------------------------\n // One row per clonotype, so the histogram counts UNIQUE clonotypes by humanness\n // score — it is deliberately NOT weighted by clonotype abundance. The question it\n // answers is \"how many distinct candidates sit below/above a humanness level\"\n // (i.e. how much humanization work is there), not \"how human is the repertoire by\n // read mass\". No human-like threshold line is drawn: this score is a 9-mer\n // fraction rescaled to 0..100, not a cutoff validated against therapeutic mAbs.\n .outputWithStatus('histogramPf', (ctx): PFrameHandle | undefined => {\n const pCols = ctx.outputs?.resolve('outputHumanness')?.getPColumns();\n if (pCols === undefined) return undefined;\n return createPFrameForGraphs(ctx, pCols);\n })\n\n .output('histogramPfPcols', (ctx): PColumnIdAndSpec[] | undefined => {\n const pCols = ctx.outputs?.resolve('outputHumanness')?.getPColumns();\n if (pCols === undefined || pCols.length === 0) return undefined;\n return pCols.map((c) => ({ columnId: c.id, spec: c.spec }));\n })\n\n .output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)\n\n .title(() => 'Humanization Score')\n\n .subtitle((ctx) => {\n if (ctx.data.customBlockLabel) return ctx.data.customBlockLabel;\n return 'Humanization Score';\n })\n\n .sections((_) => [\n { type: 'link', href: '/', label: 'Table' },\n { type: 'link', href: '/histogram', label: 'Score Distribution' },\n ])\n\n .done();\n"],"mappings":";;AAsCA,MAAa,yBAAyB;AA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