@platforma-open/milaboratories.mixcr-amplicon-alignment.workflow 1.19.2 → 1.19.3

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.
@@ -1,6 +1,6 @@
1
1
   WARN  Issue while reading "/home/runner/work/mixcr-amplicon-alignment/mixcr-amplicon-alignment/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
2
2
 
3
- > @platforma-open/milaboratories.mixcr-amplicon-alignment.workflow@1.19.2 build /home/runner/work/mixcr-amplicon-alignment/mixcr-amplicon-alignment/workflow
3
+ > @platforma-open/milaboratories.mixcr-amplicon-alignment.workflow@1.19.3 build /home/runner/work/mixcr-amplicon-alignment/mixcr-amplicon-alignment/workflow
4
4
  > rm -rf dist && pl-tengo check && pl-tengo build
5
5
 
6
6
  Processing "src/aggregate-by-clonotype-key.tpl.tengo"...
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @platforma-open/milaboratories.mixcr-amplicon-alignment.workflow
2
2
 
3
+ ## 1.19.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 8685e8d: Add new mutation columns
8
+
3
9
  ## 1.19.2
4
10
 
5
11
  ### Patch Changes
@@ -619,7 +619,74 @@ inFrameFeatures := {
619
619
  exportArgs += [ [ "-allAAMutationsCount", "FR1Begin", "FR4End" ] ]
620
620
 
621
621
  }
622
-
622
+
623
+
624
+ if assemblingFeature == "VDJRegion" {
625
+ orderP = 7500
626
+ nMutationsFeature := coreGeneFeatures["V"] + "," + coreGeneFeatures["J"]
627
+
628
+ crossRegionMutations := [ {
629
+ exportFlag: "nMutationsCount",
630
+ feature: nMutationsFeature,
631
+ id: "n-mutations-total",
632
+ label: "Nt mutations",
633
+ specName: "pl7.app/vdj/sequence/nMutations",
634
+ rankingOrder: "decreasing"
635
+ }, {
636
+ exportFlag: "aaMutationsCount",
637
+ feature: "CDR1,CDR2",
638
+ id: "aa-mutations-cdr",
639
+ label: "AA mutations (CDR)",
640
+ specName: "pl7.app/vdj/sequence/nAAMutationsCDR",
641
+ rankingOrder: "decreasing"
642
+ }, {
643
+ exportFlag: "aaMutationsCount",
644
+ feature: "FR1,FR2,FR3,FR4",
645
+ id: "aa-mutations-fwr",
646
+ label: "AA mutations (FWR)",
647
+ specName: "pl7.app/vdj/sequence/nAAMutationsFWR",
648
+ rankingOrder: "increasing"
649
+ } ]
650
+
651
+ for col in crossRegionMutations {
652
+ columnsSpecPerClonotypeNoAggregates += [ {
653
+ column: col.exportFlag + col.feature,
654
+ id: col.id,
655
+ allowNA: true,
656
+ naRegex: "region_not_covered",
657
+ spec: {
658
+ valueType: "Int",
659
+ name: col.specName,
660
+ annotations: a(orderP, false, {
661
+ "pl7.app/label": col.label,
662
+ "pl7.app/isScore": "true",
663
+ "pl7.app/score/rankingOrder": col.rankingOrder
664
+ })
665
+ }
666
+ } ]
667
+ exportArgs += [ [ "-" + col.exportFlag, col.feature ] ]
668
+ orderP -= 100
669
+ }
670
+
671
+
672
+ columnsSpecPerClonotypeNoAggregates += [ {
673
+ column: "fractionCDRMutations",
674
+ id: "fraction-cdr-mutations",
675
+ naRegex: "^[a-z_]*$",
676
+ allowNA: true,
677
+ spec: {
678
+ valueType: "Double",
679
+ name: "pl7.app/vdj/sequence/fractionCDRMutations",
680
+ annotations: a(orderP, false, {
681
+ "pl7.app/label": "CDR mutation fraction",
682
+ "pl7.app/isScore": "true",
683
+ "pl7.app/score/rankingOrder": "decreasing",
684
+ "pl7.app/format": ".2f"
685
+ })
686
+ }
687
+ } ]
688
+ }
689
+
623
690
 
624
691
 
625
692
  germlineVFeature := "GermlineVCDR3Part"
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-open/milaboratories.mixcr-amplicon-alignment.workflow",
3
- "version": "1.19.2",
3
+ "version": "1.19.3",
4
4
  "description": "MiXCR Amplicon Alignment Workflow",
5
5
  "type": "module",
6
6
  "dependencies": {
@@ -72,11 +72,16 @@ self.body(func(inputs) {
72
72
  }
73
73
 
74
74
  aggExpressions := []
75
+ hasFractionCDRMutations := false
75
76
 
76
77
  for colDef in schemaPerClonotypeNoAggregates {
77
78
  if colDef.column == "clonotypeLabel" {
78
79
  continue
79
80
  }
81
+ if colDef.column == "fractionCDRMutations" {
82
+ hasFractionCDRMutations = true
83
+ continue
84
+ }
80
85
  aggExpressions = append(aggExpressions,
81
86
  pt.col(colDef.column).maxBy(pt.col(mainAbundanceColumnNormalized)).alias(colDef.column)
82
87
  )
@@ -90,6 +95,24 @@ self.body(func(inputs) {
90
95
 
91
96
  aggregatedDf := currentDf.groupBy("clonotypeKey").agg(aggExpressions...)
92
97
 
98
+ // Calculate CDR mutation fraction: CDR / (CDR + FWR), fallback 1.0 when NA or zero denominator
99
+ if hasFractionCDRMutations {
100
+ cdr := "aaMutationsCountCDR1,CDR2"
101
+ fwr := "aaMutationsCountFR1,FR2,FR3,FR4"
102
+ aggregatedDf = aggregatedDf.withColumns(
103
+ pt.when(
104
+ pt.col(cdr).isNotNull().
105
+ and(pt.col(fwr).isNotNull()).
106
+ and(pt.col(cdr).cast("Double").plus(pt.col(fwr).cast("Double")).gt(0.0))
107
+ ).then(
108
+ pt.col(cdr).cast("Double").truediv(
109
+ pt.col(cdr).cast("Double").plus(pt.col(fwr).cast("Double"))
110
+ )
111
+ ).otherwise(pt.lit(1.0)).
112
+ alias("fractionCDRMutations")
113
+ )
114
+ }
115
+
93
116
  aggregatedDf = clonotypeLabel.addClonotypeLabelColumnsPt(aggregatedDf, "clonotypeKey", "clonotypeLabel", pt)
94
117
 
95
118
  cdr3Df := aggregatedDf.select(
@@ -619,7 +619,74 @@ inFrameFeatures := {
619
619
  exportArgs += [ [ "-allAAMutationsCount", "FR1Begin", "FR4End" ] ]
620
620
 
621
621
  }
622
-
622
+
623
+ // Cross-region SHM mutation counts (only for full VDJRegion assembling)
624
+ if assemblingFeature == "VDJRegion" {
625
+ orderP = 7500
626
+ nMutationsFeature := coreGeneFeatures["V"] + "," + coreGeneFeatures["J"]
627
+
628
+ crossRegionMutations := [ {
629
+ exportFlag: "nMutationsCount",
630
+ feature: nMutationsFeature,
631
+ id: "n-mutations-total",
632
+ label: "Nt mutations",
633
+ specName: "pl7.app/vdj/sequence/nMutations",
634
+ rankingOrder: "decreasing"
635
+ }, {
636
+ exportFlag: "aaMutationsCount",
637
+ feature: "CDR1,CDR2",
638
+ id: "aa-mutations-cdr",
639
+ label: "AA mutations (CDR)",
640
+ specName: "pl7.app/vdj/sequence/nAAMutationsCDR",
641
+ rankingOrder: "decreasing"
642
+ }, {
643
+ exportFlag: "aaMutationsCount",
644
+ feature: "FR1,FR2,FR3,FR4",
645
+ id: "aa-mutations-fwr",
646
+ label: "AA mutations (FWR)",
647
+ specName: "pl7.app/vdj/sequence/nAAMutationsFWR",
648
+ rankingOrder: "increasing"
649
+ } ]
650
+
651
+ for col in crossRegionMutations {
652
+ columnsSpecPerClonotypeNoAggregates += [ {
653
+ column: col.exportFlag + col.feature,
654
+ id: col.id,
655
+ allowNA: true,
656
+ naRegex: "region_not_covered",
657
+ spec: {
658
+ valueType: "Int",
659
+ name: col.specName,
660
+ annotations: a(orderP, false, {
661
+ "pl7.app/label": col.label,
662
+ "pl7.app/isScore": "true",
663
+ "pl7.app/score/rankingOrder": col.rankingOrder
664
+ })
665
+ }
666
+ } ]
667
+ exportArgs += [ [ "-" + col.exportFlag, col.feature ] ]
668
+ orderP -= 100
669
+ }
670
+
671
+ // CDR mutation fraction (computed in aggregate-by-clonotype-key)
672
+ columnsSpecPerClonotypeNoAggregates += [ {
673
+ column: "fractionCDRMutations",
674
+ id: "fraction-cdr-mutations",
675
+ naRegex: "^[a-z_]*$",
676
+ allowNA: true,
677
+ spec: {
678
+ valueType: "Double",
679
+ name: "pl7.app/vdj/sequence/fractionCDRMutations",
680
+ annotations: a(orderP, false, {
681
+ "pl7.app/label": "CDR mutation fraction",
682
+ "pl7.app/isScore": "true",
683
+ "pl7.app/score/rankingOrder": "decreasing",
684
+ "pl7.app/format": ".2f"
685
+ })
686
+ }
687
+ } ]
688
+ }
689
+
623
690
  // Export germline CDR3 part mutations for both VDJRegion and CDR3 assembling features
624
691
  // These will be summed to create the CDR3 mutations count columns
625
692
  germlineVFeature := "GermlineVCDR3Part"