@platforma-open/milaboratories.mixcr-clonotyping-2.workflow 3.0.3 → 3.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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@platforma-open/milaboratories.mixcr-clonotyping-2.workflow",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "Tengo-based template",
5
5
  "dependencies": {
6
- "@platforma-sdk/workflow-tengo": "^5.0.2",
6
+ "@platforma-sdk/workflow-tengo": "^5.0.3",
7
7
  "@platforma-open/milaboratories.software-mixcr": "4.7.0-223-develop"
8
8
  },
9
9
  "devDependencies": {
10
10
  "@platforma-sdk/tengo-builder": "^2.1.15",
11
11
  "@platforma-sdk/test": "^1.42.20",
12
12
  "vitest": "~2.1.9",
13
- "typescript": "~5.5.4"
13
+ "typescript": "~5.6.3"
14
14
  },
15
15
  "scripts": {
16
16
  "build": "rm -rf dist && pl-tengo check && pl-tengo build",
@@ -0,0 +1,115 @@
1
+ self := import("@platforma-sdk/workflow-tengo:tpl")
2
+ smart := import("@platforma-sdk/workflow-tengo:smart")
3
+ ll := import("@platforma-sdk/workflow-tengo:ll")
4
+ exec := import("@platforma-sdk/workflow-tengo:exec")
5
+ assets := import("@platforma-sdk/workflow-tengo:assets")
6
+ pcolumn := import("@platforma-sdk/workflow-tengo:pframes.pcolumn")
7
+ times := import("times")
8
+ text := import("text")
9
+ maps := import("@platforma-sdk/workflow-tengo:maps")
10
+ pframes := import("@platforma-sdk/workflow-tengo:pframes")
11
+ xsv := import("@platforma-sdk/workflow-tengo:pframes.xsv")
12
+ slices := import("@platforma-sdk/workflow-tengo:slices")
13
+ pConstants := import("@platforma-sdk/workflow-tengo:pframes.constants")
14
+ pt := import("@platforma-sdk/workflow-tengo:pt")
15
+ qcReportColumns := import(":qc-report-columns")
16
+
17
+ json := import("json")
18
+
19
+ self.defineOutputs("qcReportTable")
20
+
21
+ mixcrSw := assets.importSoftware("@platforma-open/milaboratories.software-mixcr:main")
22
+ ptablerSw := assets.importSoftware("@platforma-open/milaboratories.software-ptabler:main")
23
+
24
+
25
+ self.body(func(inputs) {
26
+ clnsData := inputs.clnsData
27
+ isSingleCell := inputs.isSingleCell
28
+ hasUmi := inputs.hasUmi
29
+ sampleIdAxisSpec := inputs.sampleIdAxisSpec
30
+ chains := inputs.chains
31
+
32
+ chainInfos := {
33
+ "IGHeavy": { mixcrFilter: "IGH", name: "IG Heavy", shortName: "Heavy" },
34
+ "IGLight": { mixcrFilter: "IGK,IGL", name: "IG Light", shortName: "Light" },
35
+ "TCRAlpha": { mixcrFilter: "TRA", name: "TCR Alpha", shortName: "Alpha" },
36
+ "TCRBeta": { mixcrFilter: "TRB", name: "TCR Beta", shortName: "Beta" },
37
+ "TCRGamma": { mixcrFilter: "TRG", name: "TCR Gamma", shortName: "Gamma" },
38
+ "TCRDelta": { mixcrFilter: "TRD", name: "TCR Delta", shortName: "Delta" }
39
+ }
40
+
41
+ chainsForMixcr := []
42
+
43
+ for chain in chains {
44
+ chainsForMixcr += text.split(chainInfos[chain].mixcrFilter, ",")
45
+ }
46
+
47
+ // Get all clns files from the input data
48
+ clnsFiles := clnsData.inputs()
49
+
50
+ // Build the exportReportsTable command
51
+ exportReportCmd := exec.builder().
52
+ software(mixcrSw).
53
+ secret("MI_LICENSE", "MI_LICENSE").
54
+ arg("exportReportsTable")
55
+
56
+ // Add all clns files as input
57
+ for i, clnsFile in clnsFiles {
58
+ fileName := json.decode(i)[0] + ".clns"
59
+ exportReportCmd.addFile(fileName, clnsFile)
60
+ exportReportCmd.arg(fileName)
61
+ }
62
+
63
+ exportReportCmd.arg("qc-report.tsv").saveFile("qc-report.tsv")
64
+
65
+ // Run the command
66
+ result := exportReportCmd.run()
67
+
68
+ rawTsvFile := result.getFile("qc-report.tsv")
69
+
70
+ // Use pTabler to remove ".clns" from fileName column
71
+ wf := pt.workflow().
72
+ inMediumQueue().
73
+ mem("8GiB").
74
+ cpu(2)
75
+
76
+ // Load the raw TSV file as a DataFrame
77
+ df := wf.frame(rawTsvFile, {
78
+ xsvType: "tsv",
79
+ inferSchema: true
80
+ })
81
+
82
+ // Add the sampleId column and remove ".clns" from fileName using pTabler string methods
83
+ processedDf := df.withColumns(
84
+ pt.col("fileName").strSlice(0, pt.col("fileName").strLenChars().minus(5)).alias("sampleId")
85
+ )
86
+
87
+ // For now, let's just use the processed DataFrame without zero column filtering
88
+ // since the columns() method is not available in this pTabler version
89
+ finalDf := processedDf
90
+
91
+ // Save the final DataFrame back to TSV
92
+ finalDf.save("qc-report-processed.tsv", {
93
+ xsvType: "tsv"
94
+ })
95
+
96
+ // Run the pTabler workflow
97
+ wfResult := wf.run()
98
+
99
+ tsvFile := wfResult.getFile("qc-report-processed.tsv")
100
+
101
+ qcReportColumns := qcReportColumns(hasUmi, isSingleCell, sampleIdAxisSpec, chainsForMixcr)
102
+ reportColumnsSpec := qcReportColumns.reportColumnsSpec
103
+
104
+ qcReportTable := xsv.importFile(
105
+ tsvFile,
106
+ "tsv",
107
+ reportColumnsSpec,
108
+ { cpu: 1, mem: "16GiB" }
109
+ )
110
+
111
+
112
+ return {
113
+ qcReportTable: qcReportTable
114
+ }
115
+ })
@@ -11,6 +11,7 @@ pframes := import("@platforma-sdk/workflow-tengo:pframes")
11
11
 
12
12
  calculatePresetInfoTpl := assets.importTemplate(":calculate-preset-info")
13
13
  processTpl := assets.importTemplate(":process")
14
+ exportReportTpl := assets.importTemplate(":export-report")
14
15
 
15
16
  wf.setPreRun(assets.importTemplate(":prerun"))
16
17
 
@@ -176,6 +177,10 @@ wf.body(func(args) {
176
177
  if !is_undefined(libraryImportHandle) {
177
178
  outputs.libraryImportHandle = libraryImportHandle
178
179
  }
180
+
181
+ qcReportTable := runMixcr.output("qcReportTable")
182
+
183
+ outputs.qcReportTable = pframes.exportFrame(qcReportTable)
179
184
 
180
185
  return {
181
186
  outputs: outputs,
@@ -1,7 +1,7 @@
1
1
  // process
2
2
 
3
3
  self := import("@platforma-sdk/workflow-tengo:tpl")
4
-
4
+ render := import("@platforma-sdk/workflow-tengo:render")
5
5
  ll := import("@platforma-sdk/workflow-tengo:ll")
6
6
  assets := import("@platforma-sdk/workflow-tengo:assets")
7
7
  pframes := import("@platforma-sdk/workflow-tengo:pframes")
@@ -19,7 +19,7 @@ times := import("times")
19
19
  mixcrAnalyzeTpl := assets.importTemplate(":mixcr-analyze")
20
20
  mixcrExportTpl := assets.importTemplate(":mixcr-export")
21
21
  aggregateByClonotypeKeyTpl := assets.importTemplate(":aggregate-by-clonotype-key")
22
-
22
+ exportReportTpl := assets.importTemplate(":export-report")
23
23
  processSingleCellTpl := assets.importTemplate(":process-single-cell")
24
24
 
25
25
  self.awaitState("InputsLocked")
@@ -99,6 +99,7 @@ self.body(func(inputs) {
99
99
  }
100
100
  }
101
101
  isSingleCell := len(presetSpecForBack.cellTags) > 0
102
+ hasUmi := !is_undefined(presetSpecForBack.umiTags) && len(presetSpecForBack.umiTags) > 0
102
103
 
103
104
  // calculating clns annotations
104
105
 
@@ -678,6 +679,14 @@ self.body(func(inputs) {
678
679
  }
679
680
  }
680
681
 
682
+ qcReportTable := render.create(exportReportTpl, {
683
+ clnsData: mixcrResults.outputData("clns"),
684
+ isSingleCell: isSingleCell,
685
+ hasUmi: hasUmi,
686
+ sampleIdAxisSpec: sampleIdAxisSpec,
687
+ chains: chains
688
+ })
689
+
681
690
  return {
682
691
  "qc.spec": mixcrResults.outputSpec("qc"),
683
692
  "qc.data": mixcrResults.outputData("qc"),
@@ -693,6 +702,7 @@ self.body(func(inputs) {
693
702
 
694
703
  "resultsToCache": resultsToCache,
695
704
 
696
- clonotypes: clonotypes.build()
705
+ clonotypes: clonotypes.build(),
706
+ qcReportTable: qcReportTable.output("qcReportTable")
697
707
  }
698
708
  })