@platforma-open/milaboratories.humanization-score.model 0.3.0 → 0.3.2

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/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@platforma-open/milaboratories.humanization-score.model",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Block model",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "dependencies": {
9
- "@platforma-sdk/model": "1.77.15",
9
+ "@platforma-sdk/model": "1.77.17",
10
10
  "@milaboratories/helpers": "1.14.2",
11
- "@milaboratories/graph-maker": "1.4.3"
11
+ "@milaboratories/graph-maker": "1.4.4"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@milaboratories/ts-builder": "1.5.0",
15
15
  "@milaboratories/ts-configs": "1.2.3",
16
- "@platforma-sdk/block-tools": "2.9.3",
16
+ "@platforma-sdk/block-tools": "2.10.0",
17
17
  "@platforma-sdk/eslint-config": "1.2.0",
18
18
  "eslint": "^9.25.1",
19
19
  "vitest": "^4.0.7",
package/src/index.ts CHANGED
@@ -6,10 +6,8 @@ import type {
6
6
  PlRef,
7
7
  } from '@platforma-sdk/model';
8
8
  import {
9
- ArrayColumnProvider,
10
9
  BlockModelV3,
11
- DataModelBuilder,
12
- createPFrameForGraphs,
10
+ DataModelBuilder, createPFrameForGraphs,
13
11
  createPlDataTableStateV2,
14
12
  createPlDataTableV3,
15
13
  } from '@platforma-sdk/model';
@@ -24,7 +22,6 @@ type OldArgs = {
24
22
  type OldUiState = {
25
23
  tableState: PlDataTableStateV2;
26
24
  graphStateHistogram?: GraphMakerState;
27
- graphStateBoxplot?: GraphMakerState;
28
25
  };
29
26
 
30
27
  export type BlockData = {
@@ -34,8 +31,6 @@ export type BlockData = {
34
31
  tableState: PlDataTableStateV2;
35
32
  // Distribution of the per-clonotype humanness score across the whole dataset.
36
33
  graphStateHistogram: GraphMakerState;
37
- // Per-sample distribution of humanness (box/violin), grouped by sampleId.
38
- graphStateBoxplot: GraphMakerState;
39
34
  };
40
35
 
41
36
  // Humanness score column name emitted by `clonotype-process.tpl.tengo`.
@@ -48,12 +43,11 @@ export const defaultGraphStateHistogram = (): GraphMakerState => ({
48
43
  axesSettings: {
49
44
  other: { binsCount: 20 },
50
45
  },
51
- });
52
-
53
- export const defaultGraphStateBoxplot = (): GraphMakerState => ({
54
- title: 'Humanness by Sample',
55
- template: 'box',
56
- currentTab: null,
46
+ // Give the bars a solid fill instead of the default white — colour values
47
+ // taken from graph-maker's fixed palette ("Blue").
48
+ layersSettings: {
49
+ bins: { fillColor: '#2D93FA' },
50
+ },
57
51
  });
58
52
 
59
53
  // Selectors for the input dataset anchor — shared between `inputOptions`
@@ -78,13 +72,11 @@ const dataModel = new DataModelBuilder()
78
72
  ...args,
79
73
  tableState: uiState.tableState,
80
74
  graphStateHistogram: uiState.graphStateHistogram ?? defaultGraphStateHistogram(),
81
- graphStateBoxplot: uiState.graphStateBoxplot ?? defaultGraphStateBoxplot(),
82
75
  }))
83
76
  .init(() => ({
84
77
  customBlockLabel: '',
85
78
  tableState: createPlDataTableStateV2(),
86
79
  graphStateHistogram: defaultGraphStateHistogram(),
87
- graphStateBoxplot: defaultGraphStateBoxplot(),
88
80
  }));
89
81
 
90
82
  export const platforma = BlockModelV3.create(dataModel)
@@ -110,21 +102,21 @@ export const platforma = BlockModelV3.create(dataModel)
110
102
  if (pCols === undefined) {
111
103
  return undefined;
112
104
  }
105
+
106
+ const anchorCol = pCols[0];
107
+ if (anchorCol === undefined) {
108
+ return undefined;
109
+ }
110
+
113
111
  return createPlDataTableV3(ctx, {
114
112
  tableState: ctx.data.tableState,
115
- columns: new ArrayColumnProvider(pCols)
116
- .getAllColumns()
117
- .map((column) => ({ column, isPrimary: true })),
113
+ columns: {
114
+ anchors: { main: anchorCol.spec },
115
+ selector: { mode: 'enrichment' },
116
+ },
118
117
  });
119
118
  })
120
119
 
121
- // --- Score distribution (histogram) ---------------------------------------
122
- // One row per clonotype, so the histogram counts UNIQUE clonotypes by humanness
123
- // score — it is deliberately NOT weighted by clonotype abundance. The question it
124
- // answers is "how many distinct candidates sit below/above a humanness level"
125
- // (i.e. how much humanization work is there), not "how human is the repertoire by
126
- // read mass". No human-like threshold line is drawn: this score is a 9-mer
127
- // fraction rescaled to 0..100, not a cutoff validated against therapeutic mAbs.
128
120
  .outputWithStatus('histogramPf', (ctx): PFrameHandle | undefined => {
129
121
  const pCols = ctx.outputs?.resolve('outputHumanness')?.getPColumns();
130
122
  if (pCols === undefined) return undefined;
@@ -137,55 +129,6 @@ export const platforma = BlockModelV3.create(dataModel)
137
129
  return pCols.map((c) => ({ columnId: c.id, spec: c.spec }));
138
130
  })
139
131
 
140
- // --- Per-sample distribution (box / violin) --------------------------------
141
- // The humanness column is keyed by clonotypeKey only (sample-agnostic). To get
142
- // a per-sample view we join it with the input dataset's primary abundance
143
- // column, which carries the [sampleId, clonotypeKey] axes. graph-maker joins on
144
- // the shared clonotypeKey axis, so each (sample, clonotype) pair contributes the
145
- // clonotype's score — grouping by sampleId then yields a distribution per sample.
146
- // This is a box/violin (median + spread + tails) on purpose, not a per-sample
147
- // mean: the spread is exactly what a single mean would hide.
148
- // Degrades gracefully: if the dataset has no primary-abundance column the join
149
- // adds nothing, the sampleId axis is absent, and the page simply can't preselect
150
- // a grouping (the chart still opens). VDJ datasets almost always carry abundance.
151
- .outputWithStatus('perSamplePf', (ctx): PFrameHandle | undefined => {
152
- const humanness = ctx.outputs?.resolve('outputHumanness')?.getPColumns();
153
- if (humanness === undefined) return undefined;
154
-
155
- const ref = ctx.data.inputAnchor;
156
- if (ref === undefined) return undefined;
157
-
158
- const abundance = ctx.resultPool.getAnchoredPColumns({ main: ref }, [{
159
- axes: [{ anchor: 'main', idx: 0 }, { anchor: 'main', idx: 1 }],
160
- annotations: {
161
- 'pl7.app/isAbundance': 'true',
162
- 'pl7.app/abundance/normalized': 'false',
163
- 'pl7.app/abundance/isPrimary': 'true',
164
- },
165
- }]);
166
-
167
- return createPFrameForGraphs(ctx, [...humanness, ...(abundance ?? [])]);
168
- })
169
-
170
- .output('perSamplePfPcols', (ctx): PColumnIdAndSpec[] | undefined => {
171
- const humanness = ctx.outputs?.resolve('outputHumanness')?.getPColumns();
172
- if (humanness === undefined || humanness.length === 0) return undefined;
173
-
174
- const ref = ctx.data.inputAnchor;
175
- if (ref === undefined) return undefined;
176
-
177
- const abundance = ctx.resultPool.getAnchoredPColumns({ main: ref }, [{
178
- axes: [{ anchor: 'main', idx: 0 }, { anchor: 'main', idx: 1 }],
179
- annotations: {
180
- 'pl7.app/isAbundance': 'true',
181
- 'pl7.app/abundance/normalized': 'false',
182
- 'pl7.app/abundance/isPrimary': 'true',
183
- },
184
- }]);
185
-
186
- return [...humanness, ...(abundance ?? [])].map((c) => ({ columnId: c.id, spec: c.spec }));
187
- })
188
-
189
132
  .output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)
190
133
 
191
134
  .title(() => 'Humanization Score')
@@ -198,7 +141,6 @@ export const platforma = BlockModelV3.create(dataModel)
198
141
  .sections((_) => [
199
142
  { type: 'link', href: '/', label: 'Table' },
200
143
  { type: 'link', href: '/histogram', label: 'Score Distribution' },
201
- { type: 'link', href: '/by-sample', label: 'By Sample' },
202
144
  ])
203
145
 
204
146
  .done();