@platforma-open/milaboratories.tcrdisco-enrichment.model 1.1.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/dist/index.js ADDED
@@ -0,0 +1,306 @@
1
+ import { BlockModel, createPlDataTableStateV2, isPColumnSpec, createPlDataTableV2, getUniquePartitionKeys, createPlDataTableSheet, createPFrameForGraphs } from "@platforma-sdk/model";
2
+ function filterPCols(pCols) {
3
+ pCols = pCols.filter(
4
+ (col) => col.spec.name === "pl7.app/differentialTCRAbundance/log2foldchange" || col.spec.name === "pl7.app/differentialTCRAbundance/minlog10padj" || col.spec.name === "pl7.app/differentialTCRAbundance/regulationDirection" || col.spec.name === "pl7.app/differentialTCRAbundance/contrastGroup" || col.spec.name === "pl7.app/differentialTCRAbundance/chain" || col.spec.name === "pl7.app/differentialTCRAbundance/cdsubset" || col.spec.name === "pl7.app/differentialTCRAbundance/robustEnrichment"
5
+ );
6
+ return pCols;
7
+ }
8
+ const model = BlockModel.create().withArgs({
9
+ covariateRefs: [],
10
+ numerators: [],
11
+ denominators: [],
12
+ findTcrAbPairs: false,
13
+ thresholdCounts: 10,
14
+ thresholdSamples: 3,
15
+ log2FcThreshold: 0,
16
+ pAdjThreshold: 0.05
17
+ }).withUiState({
18
+ title: "TCR Disco",
19
+ tableState: createPlDataTableStateV2(),
20
+ pairsTableState: createPlDataTableStateV2(),
21
+ selectedChain: "alpha",
22
+ cdSubsetColValid: false,
23
+ graphState: {
24
+ title: "Volcano plot",
25
+ template: "dots",
26
+ currentTab: null
27
+ },
28
+ pairsHeatmapState: {
29
+ title: "TCR A/B pairs correlation heatmap",
30
+ template: "heatmapClustered",
31
+ layersSettings: {
32
+ heatmapClustered: {
33
+ dendrogramX: false,
34
+ dendrogramY: false
35
+ }
36
+ },
37
+ axesSettings: {
38
+ axisX: {
39
+ cellSize: 20
40
+ },
41
+ axisY: {
42
+ cellSize: 20
43
+ }
44
+ }
45
+ },
46
+ frequenciesHeatmapState: {
47
+ title: "Enriched clonotypes heatmap",
48
+ template: "heatmapClustered",
49
+ layersSettings: {
50
+ heatmapClustered: {
51
+ normalizationDirection: "row",
52
+ normalizationMethod: "standardScaling",
53
+ dendrogramX: false,
54
+ dendrogramY: false
55
+ }
56
+ },
57
+ axesSettings: {
58
+ axisX: {
59
+ cellSize: 20
60
+ },
61
+ axisY: {
62
+ cellSize: 20
63
+ }
64
+ }
65
+ },
66
+ alignmentModel: {}
67
+ }).argsValid((ctx) => {
68
+ var _a;
69
+ return ctx.args.mainRef !== void 0 && ctx.args.covariateRefs !== void 0 && ctx.args.contrastFactor !== void 0 && ctx.args.numerators.length > 0 && ctx.args.denominators.length > 0 && ctx.args.log2FcThreshold !== void 0 && ctx.args.pAdjThreshold !== void 0 && ctx.args.thresholdCounts !== void 0 && ctx.args.thresholdSamples !== void 0 && (!ctx.args.cdRef || ctx.args.cdSubsetCol !== void 0 && ((_a = ctx.uiState) == null ? void 0 : _a.cdSubsetColValid));
70
+ }).output("inputOptions", (ctx) => {
71
+ return ctx.resultPool.getOptions([
72
+ {
73
+ axes: [
74
+ { name: "pl7.app/sampleId" },
75
+ {
76
+ domain: {
77
+ "pl7.app/vdj/chain": "TCRAlpha"
78
+ }
79
+ }
80
+ ],
81
+ annotations: {
82
+ "pl7.app/isAbundance": "true",
83
+ "pl7.app/abundance/normalized": "false",
84
+ "pl7.app/abundance/isPrimary": "true"
85
+ }
86
+ }
87
+ ], {
88
+ label: {
89
+ includeNativeLabel: false,
90
+ addLabelAsSuffix: true,
91
+ forceTraceElements: []
92
+ },
93
+ refsWithEnrichments: false
94
+ });
95
+ }).output(
96
+ "metadataOptions",
97
+ (ctx) => ctx.resultPool.getOptions((spec) => isPColumnSpec(spec) && spec.name === "pl7.app/metadata")
98
+ ).output("denominatorOptions", (ctx) => {
99
+ if (!ctx.args.contrastFactor) return void 0;
100
+ const pColumn = ctx.resultPool.getPColumnByRef(ctx.args.contrastFactor);
101
+ if (!pColumn) return void 0;
102
+ return ctx.createPFrame([pColumn]);
103
+ }).output("cdSubsetOptions", (ctx) => {
104
+ if (!ctx.args.cdSubsetCol) return void 0;
105
+ const pColumn = ctx.resultPool.getPColumnByRef(ctx.args.cdSubsetCol);
106
+ if (!pColumn) return void 0;
107
+ return ctx.createPFrame([pColumn]);
108
+ }).output("barcodeColPresent", (ctx) => {
109
+ const metadataCols = ctx.resultPool.selectColumns(
110
+ (spec) => spec.name === "pl7.app/metadata"
111
+ );
112
+ if (metadataCols === void 0) {
113
+ return false;
114
+ }
115
+ return metadataCols.some((col) => {
116
+ var _a;
117
+ return ((_a = col.spec.annotations) == null ? void 0 : _a["pl7.app/label"]) === "Barcode ID";
118
+ });
119
+ }).output("pt", (ctx) => {
120
+ var _a, _b, _c, _d;
121
+ const selectedChain = ((_a = ctx.uiState) == null ? void 0 : _a.selectedChain) ?? "alpha";
122
+ const outputName = selectedChain === "alpha" ? "topDegPFAlpha" : "topDegPFBeta";
123
+ const pCols = (_c = (_b = ctx.outputs) == null ? void 0 : _b.resolve(outputName)) == null ? void 0 : _c.getPColumns();
124
+ if (pCols === void 0) {
125
+ return void 0;
126
+ }
127
+ return createPlDataTableV2(ctx, pCols, (_d = ctx.uiState) == null ? void 0 : _d.tableState);
128
+ }).output("sheets", (ctx) => {
129
+ var _a, _b, _c, _d;
130
+ const selectedChain = ((_a = ctx.uiState) == null ? void 0 : _a.selectedChain) ?? "alpha";
131
+ const outputName = selectedChain === "alpha" ? "topDegPFAlpha" : "topDegPFBeta";
132
+ const pCols = (_c = (_b = ctx.outputs) == null ? void 0 : _b.resolve(outputName)) == null ? void 0 : _c.getPColumns();
133
+ if (pCols === void 0 || pCols.length === 0) {
134
+ return void 0;
135
+ }
136
+ const partitionKeys = (_d = getUniquePartitionKeys(pCols[0].data)) == null ? void 0 : _d[0];
137
+ if (!partitionKeys) return void 0;
138
+ return [createPlDataTableSheet(ctx, pCols[0].spec.axesSpec[0], partitionKeys)];
139
+ }).output("pairsPt", (ctx) => {
140
+ var _a, _b, _c;
141
+ const pCols = (_b = (_a = ctx.outputs) == null ? void 0 : _a.resolve({ field: "pairsPF", allowPermanentAbsence: true })) == null ? void 0 : _b.getPColumns();
142
+ if (pCols === void 0) {
143
+ return void 0;
144
+ }
145
+ return createPlDataTableV2(ctx, pCols, (_c = ctx.uiState) == null ? void 0 : _c.pairsTableState);
146
+ }).output("pairsSheets", (ctx) => {
147
+ var _a, _b, _c;
148
+ const pCols = (_b = (_a = ctx.outputs) == null ? void 0 : _a.resolve({ field: "pairsPF", allowPermanentAbsence: true })) == null ? void 0 : _b.getPColumns();
149
+ if (pCols === void 0 || pCols.length === 0) {
150
+ return void 0;
151
+ }
152
+ const partitionKeys = (_c = getUniquePartitionKeys(pCols[0].data)) == null ? void 0 : _c[0];
153
+ if (!partitionKeys) return void 0;
154
+ return [createPlDataTableSheet(ctx, pCols[0].spec.axesSpec[0], partitionKeys)];
155
+ }).output("topTablePf", (ctx) => {
156
+ var _a, _b, _c;
157
+ const selectedChain = ((_a = ctx.uiState) == null ? void 0 : _a.selectedChain) ?? "alpha";
158
+ const outputName = selectedChain === "alpha" ? "topDegPFAlpha" : "topDegPFBeta";
159
+ let pCols = (_c = (_b = ctx.outputs) == null ? void 0 : _b.resolve(outputName)) == null ? void 0 : _c.getPColumns();
160
+ if (pCols === void 0) {
161
+ return void 0;
162
+ }
163
+ pCols = filterPCols(pCols);
164
+ return createPFrameForGraphs(ctx, pCols);
165
+ }).output("topTablePcols", (ctx) => {
166
+ var _a, _b, _c;
167
+ const selectedChain = ((_a = ctx.uiState) == null ? void 0 : _a.selectedChain) ?? "alpha";
168
+ const outputName = selectedChain === "alpha" ? "topDegPFAlpha" : "topDegPFBeta";
169
+ const pCols = (_c = (_b = ctx.outputs) == null ? void 0 : _b.resolve(outputName)) == null ? void 0 : _c.getPColumns();
170
+ if (pCols === void 0) {
171
+ return void 0;
172
+ }
173
+ return pCols.map(
174
+ (c) => ({
175
+ columnId: c.id,
176
+ spec: c.spec
177
+ })
178
+ );
179
+ }).output("pairsHeatmapPf", (ctx) => {
180
+ var _a, _b;
181
+ const pCols = (_b = (_a = ctx.outputs) == null ? void 0 : _a.resolve({ field: "pairsPF", allowPermanentAbsence: true })) == null ? void 0 : _b.getPColumns();
182
+ if (pCols === void 0) {
183
+ return void 0;
184
+ }
185
+ let filteredPcols = pCols.filter((col) => col.spec.name !== "pl7.app/differentialTCRAbundance/tra_CDR3aa" && col.spec.name !== "pl7.app/differentialTCRAbundance/trb_CDR3aa" && col.spec.name !== "pl7.app/differentialTCRAbundance/tra_VGene" && col.spec.name !== "pl7.app/differentialTCRAbundance/trb_VGene");
186
+ const cdr3Pcols = ctx.resultPool.selectColumns(
187
+ (spec) => {
188
+ var _a2, _b2;
189
+ return spec.name === "pl7.app/vdj/sequence" && ((_a2 = spec.domain) == null ? void 0 : _a2["pl7.app/alphabet"]) === "aminoacid" && ((_b2 = spec.domain) == null ? void 0 : _b2["pl7.app/vdj/feature"]) === "CDR3";
190
+ }
191
+ );
192
+ const vGenePcols = ctx.resultPool.selectColumns(
193
+ (spec) => {
194
+ var _a2, _b2;
195
+ return spec.name === "pl7.app/vdj/sequence" && ((_a2 = spec.domain) == null ? void 0 : _a2["pl7.app/alphabet"]) === "aminoacid" && ((_b2 = spec.domain) == null ? void 0 : _b2["pl7.app/vdj/feature"]) === "VGene";
196
+ }
197
+ );
198
+ if (cdr3Pcols !== void 0 && vGenePcols !== void 0) {
199
+ filteredPcols = [...filteredPcols, ...cdr3Pcols, ...vGenePcols];
200
+ }
201
+ const clonotypeIds = ctx.resultPool.selectColumns(
202
+ (spec) => {
203
+ var _a2;
204
+ return spec.name === "pl7.app/label" && ((_a2 = spec.axesSpec) == null ? void 0 : _a2.some((axis) => axis.name === "pl7.app/vdj/clonotypeKey" || axis.name === "pl7.app/vdj/scClonotypeKey"));
205
+ }
206
+ );
207
+ const allPcols = [...filteredPcols, ...clonotypeIds];
208
+ return ctx.createPFrame(allPcols);
209
+ }).output("pairsHeatmapPcols", (ctx) => {
210
+ var _a, _b;
211
+ const pCols = (_b = (_a = ctx.outputs) == null ? void 0 : _a.resolve({ field: "pairsPF", allowPermanentAbsence: true })) == null ? void 0 : _b.getPColumns();
212
+ if (pCols === void 0) {
213
+ return void 0;
214
+ }
215
+ let filteredPcols = pCols.filter((col) => col.spec.name !== "pl7.app/differentialTCRAbundance/tra_CDR3aa" && col.spec.name !== "pl7.app/differentialTCRAbundance/trb_CDR3aa" && col.spec.name !== "pl7.app/differentialTCRAbundance/tra_VGene" && col.spec.name !== "pl7.app/differentialTCRAbundance/trb_VGene");
216
+ const cdr3Pcols = ctx.resultPool.selectColumns(
217
+ (spec) => {
218
+ var _a2, _b2;
219
+ return spec.name === "pl7.app/vdj/sequence" && ((_a2 = spec.domain) == null ? void 0 : _a2["pl7.app/alphabet"]) === "aminoacid" && ((_b2 = spec.domain) == null ? void 0 : _b2["pl7.app/vdj/feature"]) === "CDR3";
220
+ }
221
+ );
222
+ if (cdr3Pcols !== void 0) {
223
+ filteredPcols = [...filteredPcols, ...cdr3Pcols];
224
+ }
225
+ return filteredPcols.map(
226
+ (c) => ({
227
+ columnId: c.id,
228
+ spec: c.spec
229
+ })
230
+ );
231
+ }).output("frequenciesHeatmapPf", (ctx) => {
232
+ var _a, _b, _c, _d, _e;
233
+ const selectedChain = ((_a = ctx.uiState) == null ? void 0 : _a.selectedChain) ?? "alpha";
234
+ const outputName = selectedChain === "alpha" ? "mainAlphaFrequenciesPF" : "mainBetaFrequenciesPF";
235
+ let allPcols = (_c = (_b = ctx.outputs) == null ? void 0 : _b.resolve(outputName)) == null ? void 0 : _c.getPColumns();
236
+ if (allPcols === void 0) {
237
+ return void 0;
238
+ }
239
+ const subtypeLabel = selectedChain === "alpha" ? "clonotypeToSubsetAlpha" : "clonotypeToSubsetBeta";
240
+ const clonotypeToSubsetPcols = (_e = (_d = ctx.outputs) == null ? void 0 : _d.resolve({ field: subtypeLabel, allowPermanentAbsence: true })) == null ? void 0 : _e.getPColumns();
241
+ if (clonotypeToSubsetPcols !== void 0) {
242
+ allPcols = [...allPcols, ...clonotypeToSubsetPcols];
243
+ }
244
+ return createPFrameForGraphs(ctx, allPcols);
245
+ }).output("frequenciesHeatmapPcols", (ctx) => {
246
+ var _a, _b, _c, _d, _e;
247
+ const selectedChain = ((_a = ctx.uiState) == null ? void 0 : _a.selectedChain) ?? "alpha";
248
+ const outputName = selectedChain === "alpha" ? "mainAlphaFrequenciesPF" : "mainBetaFrequenciesPF";
249
+ const pCols = (_c = (_b = ctx.outputs) == null ? void 0 : _b.resolve(outputName)) == null ? void 0 : _c.getPColumns();
250
+ if (pCols === void 0) {
251
+ return void 0;
252
+ }
253
+ const subtypeLabel = selectedChain === "alpha" ? "clonotypeToSubsetAlpha" : "clonotypeToSubsetBeta";
254
+ const clonotypeToSubsetPcols = (_e = (_d = ctx.outputs) == null ? void 0 : _d.resolve({ field: subtypeLabel, allowPermanentAbsence: true })) == null ? void 0 : _e.getPColumns();
255
+ const metadataCols = ctx.resultPool.selectColumns(
256
+ (spec) => spec.name === "pl7.app/metadata"
257
+ );
258
+ const chain = selectedChain === "alpha" ? "TCRAlpha" : "TCRBeta";
259
+ const sequenceCol = ctx.resultPool.selectColumns(
260
+ (spec) => {
261
+ var _a2, _b2, _c2;
262
+ return spec.name === "pl7.app/vdj/sequence" && ((_a2 = spec.domain) == null ? void 0 : _a2["pl7.app/alphabet"]) === "aminoacid" && ((_b2 = spec.domain) == null ? void 0 : _b2["pl7.app/vdj/feature"]) === "CDR3" && ((_c2 = spec.axesSpec[0].domain) == null ? void 0 : _c2["pl7.app/vdj/chain"]) === chain;
263
+ }
264
+ );
265
+ let allCols = [...pCols, ...metadataCols];
266
+ if (clonotypeToSubsetPcols !== void 0) {
267
+ allCols = [...allCols, ...clonotypeToSubsetPcols];
268
+ }
269
+ if (sequenceCol !== void 0) {
270
+ allCols = [...allCols, ...sequenceCol];
271
+ }
272
+ return allCols.map(
273
+ (c) => ({
274
+ columnId: c.id,
275
+ spec: c.spec
276
+ })
277
+ );
278
+ }).output("msaPf", (ctx) => {
279
+ var _a, _b, _c;
280
+ const selectedChain = ((_a = ctx.uiState) == null ? void 0 : _a.selectedChain) ?? "alpha";
281
+ const outputName = selectedChain === "alpha" ? "topDegPFAlpha" : "topDegPFBeta";
282
+ const msaCols = (_c = (_b = ctx.outputs) == null ? void 0 : _b.resolve(outputName)) == null ? void 0 : _c.getPColumns();
283
+ if (!msaCols) return void 0;
284
+ const datasetRef = ctx.args.mainRef;
285
+ if (datasetRef === void 0)
286
+ return void 0;
287
+ return createPFrameForGraphs(ctx, msaCols);
288
+ }).title((ctx) => {
289
+ var _a;
290
+ return ((_a = ctx.uiState) == null ? void 0 : _a.title) ?? "TCR Disco";
291
+ }).sections((ctx) => {
292
+ const sections = [
293
+ { type: "link", href: "/", label: "Main" },
294
+ { type: "link", href: "/graph", label: "Volcano plot" },
295
+ { type: "link", href: "/freq-heatmap", label: "Enriched clonotypes heatmap" }
296
+ ];
297
+ if (ctx.args.findTcrAbPairs) {
298
+ sections.push({ type: "link", href: "/pairs", label: "TCR AB Pairs" });
299
+ sections.push({ type: "link", href: "/pairs-heatmap", label: "Pairs correlation heatmap" });
300
+ }
301
+ return sections;
302
+ }).done(2);
303
+ export {
304
+ model
305
+ };
306
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { GraphMakerState } from '@milaboratories/graph-maker';\nimport type {\n InferOutputsType,\n PColumn,\n PColumnDataUniversal,\n PColumnIdAndSpec,\n PFrameHandle,\n PlDataTableStateV2,\n PlMultiSequenceAlignmentModel,\n PlRef,\n TreeNodeAccessor,\n} from '@platforma-sdk/model';\nimport {\n BlockModel,\n createPFrameForGraphs,\n createPlDataTableSheet,\n createPlDataTableStateV2,\n createPlDataTableV2,\n getUniquePartitionKeys,\n isPColumnSpec,\n} from '@platforma-sdk/model';\n\nexport type UiState = {\n tableState: PlDataTableStateV2;\n pairsTableState: PlDataTableStateV2;\n title?: string;\n selectedChain?: 'alpha' | 'beta';\n cdSubsetColValid: boolean;\n graphState: GraphMakerState;\n pairsHeatmapState: GraphMakerState;\n frequenciesHeatmapState: GraphMakerState;\n alignmentModel: PlMultiSequenceAlignmentModel;\n};\n\nexport type BlockArgs = {\n name?: string;\n mainRef?: PlRef;\n cdRef?: PlRef;\n cdSubsetCol?: PlRef;\n pairingMetadataCol?: string;\n covariateRefs: PlRef[];\n contrastFactor?: PlRef;\n numerators: string[];\n denominators: string[];\n findTcrAbPairs: boolean;\n thresholdCounts: number;\n thresholdSamples: number;\n log2FcThreshold: number;\n pAdjThreshold: number;\n};\n\n// Filter columns for volcano plot\nfunction filterPCols(\n pCols: PColumn<TreeNodeAccessor>[]):\n PColumn<TreeNodeAccessor>[] {\n // Allow only log2 FC and -log10 Padjust as options for volcano axis\n pCols = pCols.filter(\n (col) => col.spec.name === 'pl7.app/differentialTCRAbundance/log2foldchange'\n || col.spec.name === 'pl7.app/differentialTCRAbundance/minlog10padj'\n || col.spec.name === 'pl7.app/differentialTCRAbundance/regulationDirection'\n || col.spec.name === 'pl7.app/differentialTCRAbundance/contrastGroup'\n || col.spec.name === 'pl7.app/differentialTCRAbundance/chain'\n || col.spec.name === 'pl7.app/differentialTCRAbundance/cdsubset'\n || col.spec.name === 'pl7.app/differentialTCRAbundance/robustEnrichment',\n );\n return pCols;\n}\n\nexport const model = BlockModel.create()\n\n .withArgs<BlockArgs>({\n covariateRefs: [],\n numerators: [],\n denominators: [],\n findTcrAbPairs: false,\n thresholdCounts: 10,\n thresholdSamples: 3,\n log2FcThreshold: 0,\n pAdjThreshold: 0.05,\n })\n\n .withUiState<UiState>({\n title: 'TCR Disco',\n tableState: createPlDataTableStateV2(),\n pairsTableState: createPlDataTableStateV2(),\n selectedChain: 'alpha',\n cdSubsetColValid: false,\n graphState: {\n title: 'Volcano plot',\n template: 'dots',\n currentTab: null,\n },\n pairsHeatmapState: {\n title: 'TCR A/B pairs correlation heatmap',\n template: 'heatmapClustered',\n layersSettings: {\n heatmapClustered: {\n dendrogramX: false,\n dendrogramY: false,\n },\n },\n axesSettings: {\n axisX: {\n cellSize: 20,\n },\n axisY: {\n cellSize: 20,\n },\n },\n },\n frequenciesHeatmapState: {\n title: 'Enriched clonotypes heatmap',\n template: 'heatmapClustered',\n layersSettings: {\n heatmapClustered: {\n normalizationDirection: 'row',\n normalizationMethod: 'standardScaling',\n dendrogramX: false,\n dendrogramY: false,\n },\n },\n axesSettings: {\n axisX: {\n cellSize: 20,\n },\n axisY: {\n cellSize: 20,\n },\n },\n },\n alignmentModel: {},\n })\n\n .argsValid((ctx) => (\n ((ctx.args.mainRef !== undefined)\n && (ctx.args.covariateRefs !== undefined)\n && (ctx.args.contrastFactor !== undefined)\n && (ctx.args.numerators.length > 0)\n && (ctx.args.denominators.length > 0)\n && (ctx.args.log2FcThreshold !== undefined)\n && (ctx.args.pAdjThreshold !== undefined)\n && (ctx.args.thresholdCounts !== undefined)\n && (ctx.args.thresholdSamples !== undefined)\n && (!ctx.args.cdRef || (ctx.args.cdSubsetCol !== undefined && ctx.uiState?.cdSubsetColValid)))\n ))\n\n // Allow user to choose Alpha chain, will pick beta if available\n // @TODO: Should we allow single analysis of beta chain?\n .output('inputOptions', (ctx) => {\n return ctx.resultPool.getOptions([{\n axes: [\n { name: 'pl7.app/sampleId' },\n { domain: {\n 'pl7.app/vdj/chain': 'TCRAlpha',\n },\n },\n ],\n annotations: { 'pl7.app/isAbundance': 'true',\n 'pl7.app/abundance/normalized': 'false',\n 'pl7.app/abundance/isPrimary': 'true',\n },\n },\n ], { label: { includeNativeLabel: false, addLabelAsSuffix: true,\n forceTraceElements: [],\n },\n refsWithEnrichments: false });\n })\n\n .output('metadataOptions', (ctx) =>\n ctx.resultPool.getOptions((spec) => isPColumnSpec(spec) && spec.name === 'pl7.app/metadata'),\n )\n\n .output('denominatorOptions', (ctx) => {\n if (!ctx.args.contrastFactor) return undefined;\n\n const pColumn = ctx.resultPool.getPColumnByRef(ctx.args.contrastFactor);\n if (!pColumn) return undefined;\n\n return ctx.createPFrame([pColumn]);\n })\n\n .output('cdSubsetOptions', (ctx) => {\n if (!ctx.args.cdSubsetCol) return undefined;\n\n const pColumn = ctx.resultPool.getPColumnByRef(ctx.args.cdSubsetCol);\n if (!pColumn) return undefined;\n\n return ctx.createPFrame([pColumn]);\n })\n\n // Check if \"Barcode ID\" column is present in metadata, otherwise return false\n // This column will be present in demultiplexed data and will relate same\n // samples from different chains\n .output('barcodeColPresent', (ctx) => {\n const metadataCols = ctx.resultPool.selectColumns(\n (spec) => spec.name === 'pl7.app/metadata',\n );\n if (metadataCols === undefined) {\n return false;\n }\n return metadataCols.some((col) => col.spec.annotations?.['pl7.app/label'] === 'Barcode ID');\n })\n\n .output('pt', (ctx) => {\n const selectedChain = ctx.uiState?.selectedChain ?? 'alpha';\n const outputName = selectedChain === 'alpha' ? 'topDegPFAlpha' : 'topDegPFBeta';\n const pCols = ctx.outputs?.resolve(outputName)?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n return createPlDataTableV2(ctx, pCols, ctx.uiState?.tableState);\n })\n\n .output('sheets', (ctx) => {\n const selectedChain = ctx.uiState?.selectedChain ?? 'alpha';\n const outputName = selectedChain === 'alpha' ? 'topDegPFAlpha' : 'topDegPFBeta';\n const pCols = ctx.outputs?.resolve(outputName)?.getPColumns();\n if (pCols === undefined || pCols.length === 0) {\n return undefined;\n }\n\n // Get unique partition keys if available\n const partitionKeys = getUniquePartitionKeys(pCols[0].data)?.[0];\n if (!partitionKeys) return undefined;\n\n return [createPlDataTableSheet(ctx, pCols[0].spec.axesSpec[0], partitionKeys)];\n })\n\n .output('pairsPt', (ctx) => {\n const pCols = ctx.outputs?.resolve({ field: 'pairsPF', allowPermanentAbsence: true })?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n return createPlDataTableV2(ctx, pCols, ctx.uiState?.pairsTableState);\n })\n\n .output('pairsSheets', (ctx) => {\n const pCols = ctx.outputs?.resolve({ field: 'pairsPF', allowPermanentAbsence: true })?.getPColumns();\n if (pCols === undefined || pCols.length === 0) {\n return undefined;\n }\n\n // Get unique partition keys if available\n const partitionKeys = getUniquePartitionKeys(pCols[0].data)?.[0];\n if (!partitionKeys) return undefined;\n\n return [createPlDataTableSheet(ctx, pCols[0].spec.axesSpec[0], partitionKeys)];\n })\n\n .output('topTablePf', (ctx): PFrameHandle | undefined => {\n const selectedChain = ctx.uiState?.selectedChain ?? 'alpha';\n const outputName = selectedChain === 'alpha' ? 'topDegPFAlpha' : 'topDegPFBeta';\n let pCols = ctx.outputs?.resolve(outputName)?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n pCols = filterPCols(pCols);\n\n return createPFrameForGraphs(ctx, pCols);\n })\n\n .output('topTablePcols', (ctx) => {\n const selectedChain = ctx.uiState?.selectedChain ?? 'alpha';\n const outputName = selectedChain === 'alpha' ? 'topDegPFAlpha' : 'topDegPFBeta';\n const pCols = ctx.outputs?.resolve(outputName)?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n return pCols.map(\n (c) =>\n ({\n columnId: c.id,\n spec: c.spec,\n } satisfies PColumnIdAndSpec),\n );\n })\n\n .output('pairsHeatmapPf', (ctx): PFrameHandle | undefined => {\n const pCols = ctx.outputs?.resolve({ field: 'pairsPF', allowPermanentAbsence: true })?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n // Filter out CDR3 and Vgene columns\n let filteredPcols = pCols.filter((col) => col.spec.name !== 'pl7.app/differentialTCRAbundance/tra_CDR3aa'\n && col.spec.name !== 'pl7.app/differentialTCRAbundance/trb_CDR3aa'\n && col.spec.name !== 'pl7.app/differentialTCRAbundance/tra_VGene'\n && col.spec.name !== 'pl7.app/differentialTCRAbundance/trb_VGene');\n\n // Get from the pool CDR3 aa and VGene pcolumns\n const cdr3Pcols = ctx.resultPool.selectColumns(\n (spec) => spec.name === 'pl7.app/vdj/sequence'\n && spec.domain?.['pl7.app/alphabet'] === 'aminoacid'\n && spec.domain?.['pl7.app/vdj/feature'] === 'CDR3',\n );\n const vGenePcols = ctx.resultPool.selectColumns(\n (spec) => spec.name === 'pl7.app/vdj/sequence'\n && spec.domain?.['pl7.app/alphabet'] === 'aminoacid'\n && spec.domain?.['pl7.app/vdj/feature'] === 'VGene',\n );\n\n if (cdr3Pcols !== undefined && vGenePcols !== undefined) {\n filteredPcols = [...filteredPcols, ...cdr3Pcols, ...vGenePcols] as PColumn<TreeNodeAccessor>[];\n }\n\n // Add sample ID to labels information\n const clonotypeIds = ctx.resultPool.selectColumns(\n (spec) => spec.name === 'pl7.app/label'\n && spec.axesSpec?.some((axis) => axis.name === 'pl7.app/vdj/clonotypeKey' || axis.name === 'pl7.app/vdj/scClonotypeKey'),\n ) as PColumn<PColumnDataUniversal>[];\n\n const allPcols = [...filteredPcols, ...clonotypeIds];\n\n return ctx.createPFrame(allPcols);\n })\n\n .output('pairsHeatmapPcols', (ctx) => {\n const pCols = ctx.outputs?.resolve({ field: 'pairsPF', allowPermanentAbsence: true })?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n // Filter out CDR3 and Vgene columns\n let filteredPcols = pCols.filter((col) => col.spec.name !== 'pl7.app/differentialTCRAbundance/tra_CDR3aa'\n && col.spec.name !== 'pl7.app/differentialTCRAbundance/trb_CDR3aa'\n && col.spec.name !== 'pl7.app/differentialTCRAbundance/tra_VGene'\n && col.spec.name !== 'pl7.app/differentialTCRAbundance/trb_VGene');\n\n // Get from the pool CDR3 aa and VGene pcolumns\n const cdr3Pcols = ctx.resultPool.selectColumns(\n (spec) => spec.name === 'pl7.app/vdj/sequence'\n && spec.domain?.['pl7.app/alphabet'] === 'aminoacid'\n && spec.domain?.['pl7.app/vdj/feature'] === 'CDR3',\n );\n if (cdr3Pcols !== undefined) {\n filteredPcols = [...filteredPcols, ...cdr3Pcols] as PColumn<TreeNodeAccessor>[];\n }\n return filteredPcols.map(\n (c) =>\n ({\n columnId: c.id,\n spec: c.spec,\n } satisfies PColumnIdAndSpec),\n );\n })\n\n .output('frequenciesHeatmapPf', (ctx): PFrameHandle | undefined => {\n const selectedChain = ctx.uiState?.selectedChain ?? 'alpha';\n const outputName = selectedChain === 'alpha' ? 'mainAlphaFrequenciesPF' : 'mainBetaFrequenciesPF';\n let allPcols = ctx.outputs?.resolve(outputName)?.getPColumns();\n if (allPcols === undefined) {\n return undefined;\n }\n\n // Get all metadata columns that are compatible with the Sample axis\n // const sampleIds = ctx.resultPool.selectColumns(\n // (spec) => spec.name === 'pl7.app/label'\n // && spec.axesSpec?.some((axis) => axis.name === 'pl7.app/sampleId'\n // || axis.name === 'pl7.app/vdj/clonotypeKey'\n // || axis.name === 'pl7.app/vdj/scClonotypeKey'\n // || axis.name === 'pl7.app/metadata'),\n // ) as PColumn<PColumnDataUniversal>[];\n\n // let allPcols = [...pCols, ...sampleIds];\n // let allPcols = pCols;\n\n const subtypeLabel = selectedChain === 'alpha' ? 'clonotypeToSubsetAlpha' : 'clonotypeToSubsetBeta';\n const clonotypeToSubsetPcols = ctx.outputs?.resolve({ field: subtypeLabel, allowPermanentAbsence: true })?.getPColumns();\n if (clonotypeToSubsetPcols !== undefined) {\n allPcols = [...allPcols, ...clonotypeToSubsetPcols];\n }\n\n // return ctx.createPFrame([...pCols, ...metadataCols]);\n // return ctx.createPFrame(allPcols);\n return createPFrameForGraphs(ctx, allPcols);\n })\n\n .output('frequenciesHeatmapPcols', (ctx) => {\n const selectedChain = ctx.uiState?.selectedChain ?? 'alpha';\n const outputName = selectedChain === 'alpha' ? 'mainAlphaFrequenciesPF' : 'mainBetaFrequenciesPF';\n const pCols = ctx.outputs?.resolve(outputName)?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n const subtypeLabel = selectedChain === 'alpha' ? 'clonotypeToSubsetAlpha' : 'clonotypeToSubsetBeta';\n const clonotypeToSubsetPcols = ctx.outputs?.resolve({ field: subtypeLabel, allowPermanentAbsence: true })?.getPColumns();\n\n // Get all metadata columns that are compatible with the Sample axis\n const metadataCols = ctx.resultPool.selectColumns(\n (spec) => spec.name === 'pl7.app/metadata',\n );\n\n // Get the sequence column for the sleected chain\n const chain = selectedChain === 'alpha' ? 'TCRAlpha' : 'TCRBeta';\n const sequenceCol = ctx.resultPool.selectColumns(\n (spec) => spec.name === 'pl7.app/vdj/sequence'\n && spec.domain?.['pl7.app/alphabet'] === 'aminoacid'\n && spec.domain?.['pl7.app/vdj/feature'] === 'CDR3'\n && spec.axesSpec[0].domain?.['pl7.app/vdj/chain'] === chain,\n );\n\n let allCols = [...pCols, ...metadataCols];\n if (clonotypeToSubsetPcols !== undefined) {\n allCols = [...allCols, ...clonotypeToSubsetPcols];\n }\n if (sequenceCol !== undefined) {\n allCols = [...allCols, ...sequenceCol];\n }\n\n return allCols.map(\n (c) =>\n ({\n columnId: c.id,\n spec: c.spec,\n } satisfies PColumnIdAndSpec),\n );\n })\n\n .output('msaPf', (ctx) => {\n const selectedChain = ctx.uiState?.selectedChain ?? 'alpha';\n const outputName = selectedChain === 'alpha' ? 'topDegPFAlpha' : 'topDegPFBeta';\n const msaCols = ctx.outputs?.resolve(outputName)?.getPColumns();\n if (!msaCols) return undefined;\n\n const datasetRef = ctx.args.mainRef;\n if (datasetRef === undefined)\n return undefined;\n\n return createPFrameForGraphs(ctx, msaCols);\n })\n\n .title((ctx) => ctx.uiState?.title ?? 'TCR Disco')\n\n .sections((ctx) => {\n const sections: Array<{ type: 'link'; href: `/${string}`; label: string }> = [\n { type: 'link' as const, href: '/' as const, label: 'Main' },\n { type: 'link' as const, href: '/graph' as const, label: 'Volcano plot' },\n { type: 'link' as const, href: '/freq-heatmap' as const, label: 'Enriched clonotypes heatmap' },\n ];\n\n if (ctx.args.findTcrAbPairs) {\n sections.push({ type: 'link' as const, href: '/pairs' as const, label: 'TCR AB Pairs' });\n sections.push({ type: 'link' as const, href: '/pairs-heatmap' as const, label: 'Pairs correlation heatmap' });\n }\n\n return sections;\n })\n\n .done(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