@platforma-open/milaboratories.mixcr-clonotyping-2.workflow 3.1.1 → 3.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-open/milaboratories.mixcr-clonotyping-2.workflow",
3
- "version": "3.1.1",
3
+ "version": "3.2.1",
4
4
  "description": "Tengo-based template",
5
5
  "dependencies": {
6
6
  "@platforma-sdk/workflow-tengo": "^5.0.3",
@@ -41,7 +41,7 @@ self.body(func(inputs) {
41
41
 
42
42
  baseSchemaForRead := schemaPerSample + [ { column: "clonotypeKey", type: "String" } ]
43
43
 
44
- ll.print("__THE_LOG__ AGGREGATE BY CLONOTYPE KEY: " + json.encode(maps.getKeys(inputMap)))
44
+ // ll.print("__THE_LOG__ AGGREGATE BY CLONOTYPE KEY: " + json.encode(maps.getKeys(inputMap)))
45
45
 
46
46
  for sKey in maps.getKeys(inputMap) {
47
47
  inputFile := inputMap[sKey]
@@ -545,12 +545,11 @@ calculateExportSpecs := func(presetSpecForBack, sampleIdAxisSpec, blockId) {
545
545
  junctionTypes := [ "VJ", "VD", "DJ" ]
546
546
  for junctionType in junctionTypes {
547
547
  feature := junctionType + "Junction"
548
- naRegex := junctionType == "VJ" ? "region_not_covered" : "no_d_gene"
549
548
 
550
549
  columnsSpecPerClonotypeNoAggregates += [ {
551
550
  column: "nLength" + feature,
552
551
  id: "n-length-" + text.to_lower(junctionType) + "-junction",
553
- naRegex: naRegex,
552
+ naRegex: "^[a-z_]*$",
554
553
  allowNA: true,
555
554
  spec: {
556
555
  name: "pl7.app/vdj/sequenceLength",
@@ -572,7 +571,7 @@ calculateExportSpecs := func(presetSpecForBack, sampleIdAxisSpec, blockId) {
572
571
  columnsSpecPerClonotypeNoAggregates += [ {
573
572
  column: "nLengthTotalAdded",
574
573
  id: "n-length-total-added",
575
- naRegex: "region_not_covered|no_d_gene",
574
+ naRegex: "^[a-z_]*$",
576
575
  allowNA: true,
577
576
  spec: {
578
577
  name: "pl7.app/vdj/sequenceLength",
@@ -24,11 +24,14 @@ ptablerSw := assets.importSoftware("@platforma-open/milaboratories.software-ptab
24
24
 
25
25
  self.body(func(inputs) {
26
26
  clnsData := inputs.clnsData
27
- isSingleCell := inputs.isSingleCell
28
- hasUmi := inputs.hasUmi
27
+ presetSpecForBack := inputs.presetSpecForBack
29
28
  sampleIdAxisSpec := inputs.sampleIdAxisSpec
30
29
  chains := inputs.chains
31
30
 
31
+ isSingleCell := len(presetSpecForBack.cellTags) > 0
32
+ hasUmi := !is_undefined(presetSpecForBack.umiTags) && len(presetSpecForBack.umiTags) > 0
33
+ cellTags := presetSpecForBack.cellTags
34
+
32
35
  chainInfos := {
33
36
  "IGHeavy": { mixcrFilter: "IGH", name: "IG Heavy", shortName: "Heavy" },
34
37
  "IGLight": { mixcrFilter: "IGK,IGL", name: "IG Light", shortName: "Light" },
@@ -98,7 +101,7 @@ self.body(func(inputs) {
98
101
 
99
102
  tsvFile := wfResult.getFile("qc-report-processed.tsv")
100
103
 
101
- qcReportColumns := qcReportColumns(hasUmi, isSingleCell, sampleIdAxisSpec, chainsForMixcr)
104
+ qcReportColumns := qcReportColumns(hasUmi, isSingleCell, sampleIdAxisSpec, chainsForMixcr, cellTags)
102
105
  reportColumnsSpec := qcReportColumns.reportColumnsSpec
103
106
 
104
107
  qcReportTable := xsv.importFile(
@@ -35,6 +35,7 @@ self.body(func(inputs) {
35
35
  }
36
36
 
37
37
  mainAbundanceColumnUnnormalizedArgs := params.mainAbundanceColumnUnnormalizedArgs
38
+ mainAbundanceColumnIsReadCount := params.mainAbundanceColumnIsReadCount == true
38
39
  mainIsProductiveArgs := params.mainIsProductiveArgs
39
40
 
40
41
  hashKeyDerivationExpressionPt := func(sourceColumns) {
@@ -145,7 +146,22 @@ self.body(func(inputs) {
145
146
  mem("4GiB").
146
147
  cpu(2)
147
148
 
148
- dfSingleCell := wfSingleCell.frame(unprocessedTsvForSingleCell, { xsvType: "tsv", inferSchema: false })
149
+ frameLoadOps := {
150
+ xsvType: "tsv",
151
+ inferSchema: false
152
+ }
153
+
154
+ if mainAbundanceColumnIsReadCount {
155
+ frameLoadOps.schema = [ { column: "readCount", type: "Double" } ]
156
+ }
157
+
158
+ dfSingleCell := wfSingleCell.frame(unprocessedTsvForSingleCell, frameLoadOps)
159
+
160
+ if mainAbundanceColumnIsReadCount {
161
+ dfSingleCell.addColumns(
162
+ pt.col("readCount").round().cast("Long").alias("readCount")
163
+ )
164
+ }
149
165
 
150
166
  dfSingleCell.addColumns(
151
167
  hashKeyDerivationExpressionPt(clonotypeKeyColumns).alias("clonotypeKey"),
@@ -22,7 +22,7 @@ self.defineOutputs("abundanceTsv", "clonotypeTsv",
22
22
  ptablerSw := assets.importSoftware("@platforma-open/milaboratories.software-ptabler:main")
23
23
 
24
24
  self.body(func(inputs) {
25
- ll.print("__THE_LOG__ PROCESS SINGLE CELL")
25
+ // ll.print("__THE_LOG__ PROCESS SINGLE CELL")
26
26
 
27
27
  byCellTagA := inputs[pConstants.VALUE_FIELD_NAME]
28
28
  inputDataMeta := byCellTagA.getDataAsJson()
@@ -391,7 +391,7 @@ self.body(func(inputs) {
391
391
  stepCache: 30 * times.minute,
392
392
 
393
393
  extra: {
394
- params: {
394
+ params: maps.clone({
395
395
  chains: chainInfo.mixcrFilter,
396
396
  clonotypeKeyColumns: clonotypeKeyColumns,
397
397
  clonotypeKeyArgs: clonotypeKeyArgs,
@@ -406,9 +406,11 @@ self.body(func(inputs) {
406
406
  cellTagColumns: cellTagColumns,
407
407
  hashCellKey: hashCellKey,
408
408
 
409
+ mainAbundanceColumnIsReadCount: (!is_undefined(cellTagColumns) && len(cellTagColumns) > 0 && mainAbundanceColumnUnnormalized == "readCount") ? true : undefined,
410
+
409
411
  exportArgs: exportArgs,
410
412
  isLibraryFileGzipped: isLibraryFileGzipped
411
- },
413
+ }, { removeUndefs: true }),
412
414
  library: library
413
415
  }
414
416
  }
@@ -675,14 +677,21 @@ self.body(func(inputs) {
675
677
  singleCellResult.addXsvOutputToBuilder(clonotypes, "propertiesBPrimary", "clonotypeProperties/" + receptor + "/bPrimary/")
676
678
  singleCellResult.addXsvOutputToBuilder(clonotypes, "propertiesBSecondary", "clonotypeProperties/" + receptor + "/bSecondary/")
677
679
 
678
- singleCellResult.addXsvOutputToBuilder(clonotypes, "cellsLinkerTable", "clonotypeProperties/" + receptor + "/cellsLinkerTable/")
680
+ for columnName in singleCellResult.listXsvColumns("cellsLinkerTable") {
681
+ anonymizedData := singleCellResult.outputData("cellsLinkerTable", columnName)
682
+ clonotypes.add(
683
+ "clonotypeProperties/" + receptor + "/cellsLinkerTable/" + columnName,
684
+ singleCellResult.outputSpec("cellsLinkerTable", columnName),
685
+ anonymize.deanonymizePKeys(anonymizedData, 0, [0], anonymizationResult.mapping)
686
+ )
687
+ resultsToCache["clonotypeProperties/" + receptor + "/cellsLinkerTable/" + columnName] = anonymizedData
688
+ }
679
689
  }
680
690
  }
681
691
 
682
692
  qcReportTable := render.create(exportReportTpl, {
683
693
  clnsData: mixcrResults.outputData("clns"),
684
- isSingleCell: isSingleCell,
685
- hasUmi: hasUmi,
694
+ presetSpecForBack: presetSpecForBack,
686
695
  sampleIdAxisSpec: sampleIdAxisSpec,
687
696
  chains: chains
688
697
  })