@platforma-open/milaboratories.humanization-score.model 0.2.0 → 0.3.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/.turbo/turbo-build.log +10 -10
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +17 -0
- package/dist/bundle.js +303 -18
- package/dist/bundle.js.map +1 -1
- package/dist/index.cjs +105 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +84 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +104 -18
- package/dist/index.js.map +1 -1
- package/dist/model.json +1 -1
- package/package.json +3 -2
- package/src/index.ts +128 -17
package/dist/index.cjs
CHANGED
|
@@ -1,28 +1,45 @@
|
|
|
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
|
+
});
|
|
11
|
+
const defaultGraphStateBoxplot = () => ({
|
|
12
|
+
title: "Humanness by Sample",
|
|
13
|
+
template: "box",
|
|
14
|
+
currentTab: null
|
|
15
|
+
});
|
|
16
|
+
const inputSelectors = [{
|
|
17
|
+
axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/clonotypeKey" }],
|
|
18
|
+
annotations: { "pl7.app/isAnchor": "true" }
|
|
19
|
+
}, {
|
|
20
|
+
axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/scClonotypeKey" }],
|
|
21
|
+
annotations: { "pl7.app/isAnchor": "true" }
|
|
22
|
+
}];
|
|
4
23
|
const dataModel = new _platforma_sdk_model.DataModelBuilder().from("v1").upgradeLegacy(({ args, uiState }) => ({
|
|
5
24
|
...args,
|
|
6
|
-
tableState: uiState.tableState
|
|
25
|
+
tableState: uiState.tableState,
|
|
26
|
+
graphStateHistogram: uiState.graphStateHistogram ?? defaultGraphStateHistogram(),
|
|
27
|
+
graphStateBoxplot: uiState.graphStateBoxplot ?? defaultGraphStateBoxplot()
|
|
7
28
|
})).init(() => ({
|
|
8
29
|
customBlockLabel: "",
|
|
9
|
-
tableState: (0, _platforma_sdk_model.createPlDataTableStateV2)()
|
|
30
|
+
tableState: (0, _platforma_sdk_model.createPlDataTableStateV2)(),
|
|
31
|
+
graphStateHistogram: defaultGraphStateHistogram(),
|
|
32
|
+
graphStateBoxplot: defaultGraphStateBoxplot()
|
|
10
33
|
}));
|
|
11
34
|
const platforma = _platforma_sdk_model.BlockModelV3.create(dataModel).args((data) => {
|
|
12
35
|
if (!data.inputAnchor) throw new Error("Input anchor is required");
|
|
13
36
|
return {
|
|
14
|
-
customBlockLabel: data.customBlockLabel || "
|
|
37
|
+
customBlockLabel: data.customBlockLabel || "",
|
|
15
38
|
inputAnchor: data.inputAnchor,
|
|
16
39
|
mem: data.mem
|
|
17
40
|
};
|
|
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();
|
|
41
|
+
}).output("inputOptions", (ctx) => ctx.resultPool.getOptions(inputSelectors)).outputWithStatus("pt", (ctx) => {
|
|
42
|
+
const pCols = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
26
43
|
if (pCols === void 0) return;
|
|
27
44
|
return (0, _platforma_sdk_model.createPlDataTableV3)(ctx, {
|
|
28
45
|
tableState: ctx.data.tableState,
|
|
@@ -31,12 +48,84 @@ const platforma = _platforma_sdk_model.BlockModelV3.create(dataModel).args((data
|
|
|
31
48
|
isPrimary: true
|
|
32
49
|
}))
|
|
33
50
|
});
|
|
34
|
-
}).
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
51
|
+
}).outputWithStatus("histogramPf", (ctx) => {
|
|
52
|
+
const pCols = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
53
|
+
if (pCols === void 0) return void 0;
|
|
54
|
+
return (0, _platforma_sdk_model.createPFrameForGraphs)(ctx, pCols);
|
|
55
|
+
}).output("histogramPfPcols", (ctx) => {
|
|
56
|
+
const pCols = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
57
|
+
if (pCols === void 0 || pCols.length === 0) return void 0;
|
|
58
|
+
return pCols.map((c) => ({
|
|
59
|
+
columnId: c.id,
|
|
60
|
+
spec: c.spec
|
|
61
|
+
}));
|
|
62
|
+
}).outputWithStatus("perSamplePf", (ctx) => {
|
|
63
|
+
const humanness = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
64
|
+
if (humanness === void 0) return void 0;
|
|
65
|
+
const ref = ctx.data.inputAnchor;
|
|
66
|
+
if (ref === void 0) return void 0;
|
|
67
|
+
const abundance = ctx.resultPool.getAnchoredPColumns({ main: ref }, [{
|
|
68
|
+
axes: [{
|
|
69
|
+
anchor: "main",
|
|
70
|
+
idx: 0
|
|
71
|
+
}, {
|
|
72
|
+
anchor: "main",
|
|
73
|
+
idx: 1
|
|
74
|
+
}],
|
|
75
|
+
annotations: {
|
|
76
|
+
"pl7.app/isAbundance": "true",
|
|
77
|
+
"pl7.app/abundance/normalized": "false",
|
|
78
|
+
"pl7.app/abundance/isPrimary": "true"
|
|
79
|
+
}
|
|
80
|
+
}]);
|
|
81
|
+
return (0, _platforma_sdk_model.createPFrameForGraphs)(ctx, [...humanness, ...abundance ?? []]);
|
|
82
|
+
}).output("perSamplePfPcols", (ctx) => {
|
|
83
|
+
const humanness = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
84
|
+
if (humanness === void 0 || humanness.length === 0) return void 0;
|
|
85
|
+
const ref = ctx.data.inputAnchor;
|
|
86
|
+
if (ref === void 0) return void 0;
|
|
87
|
+
const abundance = ctx.resultPool.getAnchoredPColumns({ main: ref }, [{
|
|
88
|
+
axes: [{
|
|
89
|
+
anchor: "main",
|
|
90
|
+
idx: 0
|
|
91
|
+
}, {
|
|
92
|
+
anchor: "main",
|
|
93
|
+
idx: 1
|
|
94
|
+
}],
|
|
95
|
+
annotations: {
|
|
96
|
+
"pl7.app/isAbundance": "true",
|
|
97
|
+
"pl7.app/abundance/normalized": "false",
|
|
98
|
+
"pl7.app/abundance/isPrimary": "true"
|
|
99
|
+
}
|
|
100
|
+
}]);
|
|
101
|
+
return [...humanness, ...abundance ?? []].map((c) => ({
|
|
102
|
+
columnId: c.id,
|
|
103
|
+
spec: c.spec
|
|
104
|
+
}));
|
|
105
|
+
}).output("isRunning", (ctx) => ctx.outputs?.getIsReadyOrError() === false).title(() => "Humanization Score").subtitle((ctx) => {
|
|
106
|
+
if (ctx.data.customBlockLabel) return ctx.data.customBlockLabel;
|
|
107
|
+
return "Humanization Score";
|
|
108
|
+
}).sections((_) => [
|
|
109
|
+
{
|
|
110
|
+
type: "link",
|
|
111
|
+
href: "/",
|
|
112
|
+
label: "Table"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
type: "link",
|
|
116
|
+
href: "/histogram",
|
|
117
|
+
label: "Score Distribution"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: "link",
|
|
121
|
+
href: "/by-sample",
|
|
122
|
+
label: "By Sample"
|
|
123
|
+
}
|
|
124
|
+
]).done();
|
|
39
125
|
//#endregion
|
|
126
|
+
exports.HUMANNESS_SCORE_COLUMN = HUMANNESS_SCORE_COLUMN;
|
|
127
|
+
exports.defaultGraphStateBoxplot = defaultGraphStateBoxplot;
|
|
128
|
+
exports.defaultGraphStateHistogram = defaultGraphStateHistogram;
|
|
40
129
|
exports.platforma = platforma;
|
|
41
130
|
|
|
42
131
|
//# 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 || 'Humanness Score',\n inputAnchor: data.inputAnchor,\n mem: data.mem,\n };\n })\n\n .output('inputOptions', (ctx) =>\n ctx.resultPool.getOptions([{\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 )\n\n .outputWithStatus('pt', (ctx) => {\n const pCols = ctx.outputs?.resolve('outputLiabilities')?.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 .output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)\n\n .title(() => 'Humanness Score')\n\n .subtitle((ctx) => ctx.data.customBlockLabel || 'Humanness Score')\n\n .sections((_) => [\n { type: 'link', href: '/', label: 'Table' },\n ])\n\n .done();\n"],"mappings":";;;AA8BA,MAAM,YAAY,IAAIA,qBAAAA,kBAAkB,CACrC,KAAgB,KAAK,CACrB,eAAoC,EAAE,MAAM,eAAe;CAC1D,GAAG;CACH,YAAY,QAAQ;CACrB,EAAE,CACF,YAAY;CACX,kBAAkB;CAClB,aAAA,GAAA,qBAAA,2BAAsC;CACvC,EAAE;AAEL,MAAa,YAAYC,qBAAAA,aAAa,OAAO,UAAU,CAEpD,MAAM,SAAS;CACd,IAAI,CAAC,KAAK,aAAa,MAAM,IAAI,MAAM,2BAA2B;CAElE,OAAO;EACL,kBAAkB,KAAK,oBAAoB;EAC3C,aAAa,KAAK;EAClB,KAAK,KAAK;EACX;EACD,CAED,OAAO,iBAAiB,QACvB,IAAI,WAAW,WAAW,CAAC;CACzB,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,CAAC,CACJ,CAEA,iBAAiB,OAAO,QAAQ;CAC/B,MAAM,QAAQ,IAAI,SAAS,QAAQ,oBAAoB,EAAE,aAAa;CACtE,IAAI,UAAU,KAAA,GACZ;CAEF,QAAA,GAAA,qBAAA,qBAA2B,KAAK;EAC9B,YAAY,IAAI,KAAK;EACrB,SAAS,IAAIC,qBAAAA,oBAAoB,MAAM,CACpC,eAAe,CACf,KAAK,YAAY;GAAE;GAAQ,WAAW;GAAM,EAAE;EAClD,CAAC;EACF,CAED,OAAO,cAAc,QAAQ,IAAI,SAAS,mBAAmB,KAAK,MAAM,CAExE,YAAY,kBAAkB,CAE9B,UAAU,QAAQ,IAAI,KAAK,oBAAoB,kBAAkB,CAEjE,UAAU,MAAM,CACf;CAAE,MAAM;CAAQ,MAAM;CAAK,OAAO;CAAS,CAC5C,CAAC,CAED,MAAM"}
|
|
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 graphStateBoxplot?: 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 // Per-sample distribution of humanness (box/violin), grouped by sampleId.\n graphStateBoxplot: 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});\n\nexport const defaultGraphStateBoxplot = (): GraphMakerState => ({\n title: 'Humanness by Sample',\n template: 'box',\n currentTab: null,\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 graphStateBoxplot: uiState.graphStateBoxplot ?? defaultGraphStateBoxplot(),\n }))\n .init(() => ({\n customBlockLabel: '',\n tableState: createPlDataTableStateV2(),\n graphStateHistogram: defaultGraphStateHistogram(),\n graphStateBoxplot: defaultGraphStateBoxplot(),\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 // --- Per-sample distribution (box / violin) --------------------------------\n // The humanness column is keyed by clonotypeKey only (sample-agnostic). To get\n // a per-sample view we join it with the input dataset's primary abundance\n // column, which carries the [sampleId, clonotypeKey] axes. graph-maker joins on\n // the shared clonotypeKey axis, so each (sample, clonotype) pair contributes the\n // clonotype's score — grouping by sampleId then yields a distribution per sample.\n // This is a box/violin (median + spread + tails) on purpose, not a per-sample\n // mean: the spread is exactly what a single mean would hide.\n // Degrades gracefully: if the dataset has no primary-abundance column the join\n // adds nothing, the sampleId axis is absent, and the page simply can't preselect\n // a grouping (the chart still opens). VDJ datasets almost always carry abundance.\n .outputWithStatus('perSamplePf', (ctx): PFrameHandle | undefined => {\n const humanness = ctx.outputs?.resolve('outputHumanness')?.getPColumns();\n if (humanness === undefined) return undefined;\n\n const ref = ctx.data.inputAnchor;\n if (ref === undefined) return undefined;\n\n const abundance = ctx.resultPool.getAnchoredPColumns({ main: ref }, [{\n axes: [{ anchor: 'main', idx: 0 }, { anchor: 'main', idx: 1 }],\n annotations: {\n 'pl7.app/isAbundance': 'true',\n 'pl7.app/abundance/normalized': 'false',\n 'pl7.app/abundance/isPrimary': 'true',\n },\n }]);\n\n return createPFrameForGraphs(ctx, [...humanness, ...(abundance ?? [])]);\n })\n\n .output('perSamplePfPcols', (ctx): PColumnIdAndSpec[] | undefined => {\n const humanness = ctx.outputs?.resolve('outputHumanness')?.getPColumns();\n if (humanness === undefined || humanness.length === 0) return undefined;\n\n const ref = ctx.data.inputAnchor;\n if (ref === undefined) return undefined;\n\n const abundance = ctx.resultPool.getAnchoredPColumns({ main: ref }, [{\n axes: [{ anchor: 'main', idx: 0 }, { anchor: 'main', idx: 1 }],\n annotations: {\n 'pl7.app/isAbundance': 'true',\n 'pl7.app/abundance/normalized': 'false',\n 'pl7.app/abundance/isPrimary': 'true',\n },\n }]);\n\n return [...humanness, ...(abundance ?? [])].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 { type: 'link', href: '/by-sample', label: 'By Sample' },\n ])\n\n .done();\n"],"mappings":";;;AAyCA,MAAa,yBAAyB;AAEtC,MAAa,oCAAqD;CAChE,OAAO;CACP,UAAU;CACV,YAAY;CACZ,cAAc,EACZ,OAAO,EAAE,WAAW,IAAI,EACzB;CACF;AAED,MAAa,kCAAmD;CAC9D,OAAO;CACP,UAAU;CACV,YAAY;CACb;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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;EAAI,MAAM,EAAE;EAAM,EAAE;EAC1F,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;EAAE,MAAM;EAAQ,MAAM;EAAK,OAAO;EAAS;CAC3C;EAAE,MAAM;EAAQ,MAAM;EAAc,OAAO;EAAsB;CACjE;EAAE,MAAM;EAAQ,MAAM;EAAc,OAAO;EAAa;CACzD,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,12 @@ type BlockData = {
|
|
|
9
10
|
inputAnchor?: PlRef;
|
|
10
11
|
mem?: number;
|
|
11
12
|
tableState: PlDataTableStateV2;
|
|
13
|
+
graphStateHistogram: GraphMakerState;
|
|
14
|
+
graphStateBoxplot: GraphMakerState;
|
|
12
15
|
};
|
|
16
|
+
declare const HUMANNESS_SCORE_COLUMN = "pl7.app/humannessScore";
|
|
17
|
+
declare const defaultGraphStateHistogram: () => GraphMakerState;
|
|
18
|
+
declare const defaultGraphStateBoxplot: () => GraphMakerState;
|
|
13
19
|
declare const platforma: _$_platforma_sdk_model0.PlatformaExtended<_$_platforma_sdk_model0.PlatformaV3<BlockData, {
|
|
14
20
|
customBlockLabel: string;
|
|
15
21
|
inputAnchor: Readonly<{
|
|
@@ -33,7 +39,7 @@ declare const platforma: _$_platforma_sdk_model0.PlatformaExtended<_$_platforma_
|
|
|
33
39
|
pt: _$_platforma_sdk_model0.ConfigRenderLambda<{
|
|
34
40
|
sourceId: null | string;
|
|
35
41
|
fullTableHandle?: _$_platforma_sdk_model0.PTableHandle | undefined;
|
|
36
|
-
fullPframeHandle?:
|
|
42
|
+
fullPframeHandle?: PFrameHandle | undefined;
|
|
37
43
|
visibleTableHandle?: _$_platforma_sdk_model0.PTableHandle | undefined;
|
|
38
44
|
defaultFilters?: _$_milaboratories_helpers0.Nil | {
|
|
39
45
|
type: "or";
|
|
@@ -1679,9 +1685,83 @@ declare const platforma: _$_platforma_sdk_model0.PlatformaExtended<_$_platforma_
|
|
|
1679
1685
|
} | undefined> & {
|
|
1680
1686
|
withStatus: true;
|
|
1681
1687
|
};
|
|
1688
|
+
} & {
|
|
1689
|
+
histogramPf: _$_platforma_sdk_model0.ConfigRenderLambda<PFrameHandle | undefined> & {
|
|
1690
|
+
withStatus: true;
|
|
1691
|
+
};
|
|
1692
|
+
} & {
|
|
1693
|
+
histogramPfPcols: _$_platforma_sdk_model0.ConfigRenderLambda<{
|
|
1694
|
+
readonly columnId: _$_platforma_sdk_model0.PObjectId;
|
|
1695
|
+
readonly spec: {
|
|
1696
|
+
readonly kind: "PColumn";
|
|
1697
|
+
readonly name: string;
|
|
1698
|
+
readonly domain?: {
|
|
1699
|
+
[x: string]: string;
|
|
1700
|
+
} | undefined;
|
|
1701
|
+
readonly contextDomain?: {
|
|
1702
|
+
[x: string]: string;
|
|
1703
|
+
} | undefined;
|
|
1704
|
+
readonly annotations?: {
|
|
1705
|
+
[x: string]: string;
|
|
1706
|
+
} | undefined;
|
|
1707
|
+
readonly valueType: "Int" | "Long" | "Float" | "Double" | "String" | "Bytes";
|
|
1708
|
+
readonly parentAxes?: number[] | undefined;
|
|
1709
|
+
readonly axesSpec: {
|
|
1710
|
+
readonly type: _$_platforma_sdk_model0.AxisValueType;
|
|
1711
|
+
readonly name: string;
|
|
1712
|
+
readonly domain?: {
|
|
1713
|
+
[x: string]: string;
|
|
1714
|
+
} | undefined;
|
|
1715
|
+
readonly contextDomain?: {
|
|
1716
|
+
[x: string]: string;
|
|
1717
|
+
} | undefined;
|
|
1718
|
+
readonly annotations?: {
|
|
1719
|
+
[x: string]: string;
|
|
1720
|
+
} | undefined;
|
|
1721
|
+
readonly parentAxes?: number[] | undefined;
|
|
1722
|
+
}[];
|
|
1723
|
+
};
|
|
1724
|
+
}[] | undefined>;
|
|
1725
|
+
} & {
|
|
1726
|
+
perSamplePf: _$_platforma_sdk_model0.ConfigRenderLambda<PFrameHandle | undefined> & {
|
|
1727
|
+
withStatus: true;
|
|
1728
|
+
};
|
|
1729
|
+
} & {
|
|
1730
|
+
perSamplePfPcols: _$_platforma_sdk_model0.ConfigRenderLambda<{
|
|
1731
|
+
readonly columnId: _$_platforma_sdk_model0.PObjectId;
|
|
1732
|
+
readonly spec: {
|
|
1733
|
+
readonly kind: "PColumn";
|
|
1734
|
+
readonly name: string;
|
|
1735
|
+
readonly domain?: {
|
|
1736
|
+
[x: string]: string;
|
|
1737
|
+
} | undefined;
|
|
1738
|
+
readonly contextDomain?: {
|
|
1739
|
+
[x: string]: string;
|
|
1740
|
+
} | undefined;
|
|
1741
|
+
readonly annotations?: {
|
|
1742
|
+
[x: string]: string;
|
|
1743
|
+
} | undefined;
|
|
1744
|
+
readonly valueType: "Int" | "Long" | "Float" | "Double" | "String" | "Bytes";
|
|
1745
|
+
readonly parentAxes?: number[] | undefined;
|
|
1746
|
+
readonly axesSpec: {
|
|
1747
|
+
readonly type: _$_platforma_sdk_model0.AxisValueType;
|
|
1748
|
+
readonly name: string;
|
|
1749
|
+
readonly domain?: {
|
|
1750
|
+
[x: string]: string;
|
|
1751
|
+
} | undefined;
|
|
1752
|
+
readonly contextDomain?: {
|
|
1753
|
+
[x: string]: string;
|
|
1754
|
+
} | undefined;
|
|
1755
|
+
readonly annotations?: {
|
|
1756
|
+
[x: string]: string;
|
|
1757
|
+
} | undefined;
|
|
1758
|
+
readonly parentAxes?: number[] | undefined;
|
|
1759
|
+
}[];
|
|
1760
|
+
};
|
|
1761
|
+
}[] | undefined>;
|
|
1682
1762
|
} & {
|
|
1683
1763
|
isRunning: _$_platforma_sdk_model0.ConfigRenderLambda<boolean>;
|
|
1684
|
-
}>, "/", {}, _$_platforma_sdk_model0.BlockDefaultUiServices>>;
|
|
1764
|
+
}>, "/" | "/histogram" | "/by-sample", {}, _$_platforma_sdk_model0.BlockDefaultUiServices>>;
|
|
1685
1765
|
//#endregion
|
|
1686
|
-
export { BlockData, platforma };
|
|
1766
|
+
export { BlockData, HUMANNESS_SCORE_COLUMN, defaultGraphStateBoxplot, defaultGraphStateHistogram, platforma };
|
|
1687
1767
|
//# 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":";;;;;;;KA6BY,SAAA;EACV,gBAAA;EACA,WAAA,GAAc,KAAA;EACd,GAAA;EACA,UAAA,EAAY,kBAAA;EAEZ,mBAAA,EAAqB,eAAA;EAErB,iBAAA,EAAmB,eAAA;AAAA;AAAA,cAIR,sBAAA;AAAA,cAEA,0BAAA,QAAiC,eAAA;AAAA,cASjC,wBAAA,QAA+B,eAAA;AAAA,cAqC/B,SAAA,EAAS,uBAAA,CAAA,iBAAA,yBAAA,WAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;gBArCsB;;kBAI1C,gBAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,44 @@
|
|
|
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
|
+
});
|
|
10
|
+
const defaultGraphStateBoxplot = () => ({
|
|
11
|
+
title: "Humanness by Sample",
|
|
12
|
+
template: "box",
|
|
13
|
+
currentTab: null
|
|
14
|
+
});
|
|
15
|
+
const inputSelectors = [{
|
|
16
|
+
axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/clonotypeKey" }],
|
|
17
|
+
annotations: { "pl7.app/isAnchor": "true" }
|
|
18
|
+
}, {
|
|
19
|
+
axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/scClonotypeKey" }],
|
|
20
|
+
annotations: { "pl7.app/isAnchor": "true" }
|
|
21
|
+
}];
|
|
3
22
|
const dataModel = new DataModelBuilder().from("v1").upgradeLegacy(({ args, uiState }) => ({
|
|
4
23
|
...args,
|
|
5
|
-
tableState: uiState.tableState
|
|
24
|
+
tableState: uiState.tableState,
|
|
25
|
+
graphStateHistogram: uiState.graphStateHistogram ?? defaultGraphStateHistogram(),
|
|
26
|
+
graphStateBoxplot: uiState.graphStateBoxplot ?? defaultGraphStateBoxplot()
|
|
6
27
|
})).init(() => ({
|
|
7
28
|
customBlockLabel: "",
|
|
8
|
-
tableState: createPlDataTableStateV2()
|
|
29
|
+
tableState: createPlDataTableStateV2(),
|
|
30
|
+
graphStateHistogram: defaultGraphStateHistogram(),
|
|
31
|
+
graphStateBoxplot: defaultGraphStateBoxplot()
|
|
9
32
|
}));
|
|
10
33
|
const platforma = BlockModelV3.create(dataModel).args((data) => {
|
|
11
34
|
if (!data.inputAnchor) throw new Error("Input anchor is required");
|
|
12
35
|
return {
|
|
13
|
-
customBlockLabel: data.customBlockLabel || "
|
|
36
|
+
customBlockLabel: data.customBlockLabel || "",
|
|
14
37
|
inputAnchor: data.inputAnchor,
|
|
15
38
|
mem: data.mem
|
|
16
39
|
};
|
|
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();
|
|
40
|
+
}).output("inputOptions", (ctx) => ctx.resultPool.getOptions(inputSelectors)).outputWithStatus("pt", (ctx) => {
|
|
41
|
+
const pCols = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
25
42
|
if (pCols === void 0) return;
|
|
26
43
|
return createPlDataTableV3(ctx, {
|
|
27
44
|
tableState: ctx.data.tableState,
|
|
@@ -30,12 +47,81 @@ const platforma = BlockModelV3.create(dataModel).args((data) => {
|
|
|
30
47
|
isPrimary: true
|
|
31
48
|
}))
|
|
32
49
|
});
|
|
33
|
-
}).
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
50
|
+
}).outputWithStatus("histogramPf", (ctx) => {
|
|
51
|
+
const pCols = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
52
|
+
if (pCols === void 0) return void 0;
|
|
53
|
+
return createPFrameForGraphs(ctx, pCols);
|
|
54
|
+
}).output("histogramPfPcols", (ctx) => {
|
|
55
|
+
const pCols = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
56
|
+
if (pCols === void 0 || pCols.length === 0) return void 0;
|
|
57
|
+
return pCols.map((c) => ({
|
|
58
|
+
columnId: c.id,
|
|
59
|
+
spec: c.spec
|
|
60
|
+
}));
|
|
61
|
+
}).outputWithStatus("perSamplePf", (ctx) => {
|
|
62
|
+
const humanness = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
63
|
+
if (humanness === void 0) return void 0;
|
|
64
|
+
const ref = ctx.data.inputAnchor;
|
|
65
|
+
if (ref === void 0) return void 0;
|
|
66
|
+
const abundance = ctx.resultPool.getAnchoredPColumns({ main: ref }, [{
|
|
67
|
+
axes: [{
|
|
68
|
+
anchor: "main",
|
|
69
|
+
idx: 0
|
|
70
|
+
}, {
|
|
71
|
+
anchor: "main",
|
|
72
|
+
idx: 1
|
|
73
|
+
}],
|
|
74
|
+
annotations: {
|
|
75
|
+
"pl7.app/isAbundance": "true",
|
|
76
|
+
"pl7.app/abundance/normalized": "false",
|
|
77
|
+
"pl7.app/abundance/isPrimary": "true"
|
|
78
|
+
}
|
|
79
|
+
}]);
|
|
80
|
+
return createPFrameForGraphs(ctx, [...humanness, ...abundance ?? []]);
|
|
81
|
+
}).output("perSamplePfPcols", (ctx) => {
|
|
82
|
+
const humanness = ctx.outputs?.resolve("outputHumanness")?.getPColumns();
|
|
83
|
+
if (humanness === void 0 || humanness.length === 0) return void 0;
|
|
84
|
+
const ref = ctx.data.inputAnchor;
|
|
85
|
+
if (ref === void 0) return void 0;
|
|
86
|
+
const abundance = ctx.resultPool.getAnchoredPColumns({ main: ref }, [{
|
|
87
|
+
axes: [{
|
|
88
|
+
anchor: "main",
|
|
89
|
+
idx: 0
|
|
90
|
+
}, {
|
|
91
|
+
anchor: "main",
|
|
92
|
+
idx: 1
|
|
93
|
+
}],
|
|
94
|
+
annotations: {
|
|
95
|
+
"pl7.app/isAbundance": "true",
|
|
96
|
+
"pl7.app/abundance/normalized": "false",
|
|
97
|
+
"pl7.app/abundance/isPrimary": "true"
|
|
98
|
+
}
|
|
99
|
+
}]);
|
|
100
|
+
return [...humanness, ...abundance ?? []].map((c) => ({
|
|
101
|
+
columnId: c.id,
|
|
102
|
+
spec: c.spec
|
|
103
|
+
}));
|
|
104
|
+
}).output("isRunning", (ctx) => ctx.outputs?.getIsReadyOrError() === false).title(() => "Humanization Score").subtitle((ctx) => {
|
|
105
|
+
if (ctx.data.customBlockLabel) return ctx.data.customBlockLabel;
|
|
106
|
+
return "Humanization Score";
|
|
107
|
+
}).sections((_) => [
|
|
108
|
+
{
|
|
109
|
+
type: "link",
|
|
110
|
+
href: "/",
|
|
111
|
+
label: "Table"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: "link",
|
|
115
|
+
href: "/histogram",
|
|
116
|
+
label: "Score Distribution"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: "link",
|
|
120
|
+
href: "/by-sample",
|
|
121
|
+
label: "By Sample"
|
|
122
|
+
}
|
|
123
|
+
]).done();
|
|
38
124
|
//#endregion
|
|
39
|
-
export { platforma };
|
|
125
|
+
export { HUMANNESS_SCORE_COLUMN, defaultGraphStateBoxplot, defaultGraphStateHistogram, platforma };
|
|
40
126
|
|
|
41
127
|
//# 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 || 'Humanness Score',\n inputAnchor: data.inputAnchor,\n mem: data.mem,\n };\n })\n\n .output('inputOptions', (ctx) =>\n ctx.resultPool.getOptions([{\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 )\n\n .outputWithStatus('pt', (ctx) => {\n const pCols = ctx.outputs?.resolve('outputLiabilities')?.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 .output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)\n\n .title(() => 'Humanness Score')\n\n .subtitle((ctx) => ctx.data.customBlockLabel || 'Humanness Score')\n\n .sections((_) => [\n { type: 'link', href: '/', label: 'Table' },\n ])\n\n .done();\n"],"mappings":";;AA8BA,MAAM,YAAY,IAAI,kBAAkB,CACrC,KAAgB,KAAK,CACrB,eAAoC,EAAE,MAAM,eAAe;CAC1D,GAAG;CACH,YAAY,QAAQ;CACrB,EAAE,CACF,YAAY;CACX,kBAAkB;CAClB,YAAY,0BAA0B;CACvC,EAAE;AAEL,MAAa,YAAY,aAAa,OAAO,UAAU,CAEpD,MAAM,SAAS;CACd,IAAI,CAAC,KAAK,aAAa,MAAM,IAAI,MAAM,2BAA2B;CAElE,OAAO;EACL,kBAAkB,KAAK,oBAAoB;EAC3C,aAAa,KAAK;EAClB,KAAK,KAAK;EACX;EACD,CAED,OAAO,iBAAiB,QACvB,IAAI,WAAW,WAAW,CAAC;CACzB,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,CAAC,CACJ,CAEA,iBAAiB,OAAO,QAAQ;CAC/B,MAAM,QAAQ,IAAI,SAAS,QAAQ,oBAAoB,EAAE,aAAa;CACtE,IAAI,UAAU,KAAA,GACZ;CAEF,OAAO,oBAAoB,KAAK;EAC9B,YAAY,IAAI,KAAK;EACrB,SAAS,IAAI,oBAAoB,MAAM,CACpC,eAAe,CACf,KAAK,YAAY;GAAE;GAAQ,WAAW;GAAM,EAAE;EAClD,CAAC;EACF,CAED,OAAO,cAAc,QAAQ,IAAI,SAAS,mBAAmB,KAAK,MAAM,CAExE,YAAY,kBAAkB,CAE9B,UAAU,QAAQ,IAAI,KAAK,oBAAoB,kBAAkB,CAEjE,UAAU,MAAM,CACf;CAAE,MAAM;CAAQ,MAAM;CAAK,OAAO;CAAS,CAC5C,CAAC,CAED,MAAM"}
|
|
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 graphStateBoxplot?: 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 // Per-sample distribution of humanness (box/violin), grouped by sampleId.\n graphStateBoxplot: 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});\n\nexport const defaultGraphStateBoxplot = (): GraphMakerState => ({\n title: 'Humanness by Sample',\n template: 'box',\n currentTab: null,\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 graphStateBoxplot: uiState.graphStateBoxplot ?? defaultGraphStateBoxplot(),\n }))\n .init(() => ({\n customBlockLabel: '',\n tableState: createPlDataTableStateV2(),\n graphStateHistogram: defaultGraphStateHistogram(),\n graphStateBoxplot: defaultGraphStateBoxplot(),\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 // --- Per-sample distribution (box / violin) --------------------------------\n // The humanness column is keyed by clonotypeKey only (sample-agnostic). To get\n // a per-sample view we join it with the input dataset's primary abundance\n // column, which carries the [sampleId, clonotypeKey] axes. graph-maker joins on\n // the shared clonotypeKey axis, so each (sample, clonotype) pair contributes the\n // clonotype's score — grouping by sampleId then yields a distribution per sample.\n // This is a box/violin (median + spread + tails) on purpose, not a per-sample\n // mean: the spread is exactly what a single mean would hide.\n // Degrades gracefully: if the dataset has no primary-abundance column the join\n // adds nothing, the sampleId axis is absent, and the page simply can't preselect\n // a grouping (the chart still opens). VDJ datasets almost always carry abundance.\n .outputWithStatus('perSamplePf', (ctx): PFrameHandle | undefined => {\n const humanness = ctx.outputs?.resolve('outputHumanness')?.getPColumns();\n if (humanness === undefined) return undefined;\n\n const ref = ctx.data.inputAnchor;\n if (ref === undefined) return undefined;\n\n const abundance = ctx.resultPool.getAnchoredPColumns({ main: ref }, [{\n axes: [{ anchor: 'main', idx: 0 }, { anchor: 'main', idx: 1 }],\n annotations: {\n 'pl7.app/isAbundance': 'true',\n 'pl7.app/abundance/normalized': 'false',\n 'pl7.app/abundance/isPrimary': 'true',\n },\n }]);\n\n return createPFrameForGraphs(ctx, [...humanness, ...(abundance ?? [])]);\n })\n\n .output('perSamplePfPcols', (ctx): PColumnIdAndSpec[] | undefined => {\n const humanness = ctx.outputs?.resolve('outputHumanness')?.getPColumns();\n if (humanness === undefined || humanness.length === 0) return undefined;\n\n const ref = ctx.data.inputAnchor;\n if (ref === undefined) return undefined;\n\n const abundance = ctx.resultPool.getAnchoredPColumns({ main: ref }, [{\n axes: [{ anchor: 'main', idx: 0 }, { anchor: 'main', idx: 1 }],\n annotations: {\n 'pl7.app/isAbundance': 'true',\n 'pl7.app/abundance/normalized': 'false',\n 'pl7.app/abundance/isPrimary': 'true',\n },\n }]);\n\n return [...humanness, ...(abundance ?? [])].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 { type: 'link', href: '/by-sample', label: 'By Sample' },\n ])\n\n .done();\n"],"mappings":";;AAyCA,MAAa,y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