From 735fdf18fc9d431e2c0f6834e95a4bb9c4e876c2 Mon Sep 17 00:00:00 2001
From: "Gervaise H. Henry" <gervaise.henry@utsouthwestern.edu>
Date: Tue, 5 Mar 2019 18:46:17 -0600
Subject: [PATCH] Add 10x chemistry version as option to address #11

---
 astrocyte_pkg.yml           | 12 ++++++++++++
 workflow/conf/biohpc.config | 15 +++++++++++++++
 workflow/main.nf            | 19 +++++++++++++------
 3 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/astrocyte_pkg.yml b/astrocyte_pkg.yml
index e4ab49f..5d0a3a3 100755
--- a/astrocyte_pkg.yml
+++ b/astrocyte_pkg.yml
@@ -128,6 +128,17 @@ workflow_parameters:
     description: |
       Force pipeline to use this number of cells, bypassing the cell detection algorithm. Use this if the number of cells estimated by Cell Ranger is not consistent with the barcode rank plot. A value of 0 ignores this option. Any value other than 0 overrides expect-cells.
 
+  - id: kitVersion
+    type: select
+    default: 'auto'
+    choices:
+      - [ 'auto', 'Auto Detect']
+      - [ '3', '3']
+      - [ '2', '2']
+    required: true
+    description: |
+      10x single cell gene expression chemistry version (only used in cellranger version 2.x).
+
   - id: version
     type: select
     default: '3.0.2'
@@ -139,6 +150,7 @@ workflow_parameters:
     description: |
       10x cellranger version.
 
+
 # -----------------------------------------------------------------------------
 # SHINY APP CONFIGURATION
 # -----------------------------------------------------------------------------
diff --git a/workflow/conf/biohpc.config b/workflow/conf/biohpc.config
index 6e6832b..3b0eb73 100755
--- a/workflow/conf/biohpc.config
+++ b/workflow/conf/biohpc.config
@@ -52,6 +52,21 @@ params {
       loc = '/project/apps_database/cellranger/refdata-cellranger-'
     }
   }
+  // Chemistry mapping parameter
+  chemistry {
+    'auto' {
+      param = 'auto'
+    }
+    '1' {
+      param = 'SC3Pv1'
+    }
+   '2' {
+      param = 'SC3Pv2'
+    }
+   '3' {
+      param = 'SC3Pv3'
+    }
+  }
 }
 
 trace {
diff --git a/workflow/main.nf b/workflow/main.nf
index 9ed1726..bb2544a 100755
--- a/workflow/main.nf
+++ b/workflow/main.nf
@@ -6,11 +6,14 @@
 // Define Input variables
 params.fastq = "$baseDir/../test_data/*.fastq.gz"
 params.designFile = "$baseDir/../test_data/design.csv"
-params.genome = 'GRCh38-1.2.0'
+params.genome = 'GRCh38-3.0.0'
 params.genomes = []
 params.genomeLocation = params.genome ? params.genomes[ params.genome ].loc ?: false : false
 params.expectCells = 10000
 params.forceCells = 0
+params.kitVersion = '3'
+params.chemistry = []
+params.chemistryParam = params.kitVersion ? params.chemistry[ params.kitVersion ].param ?: false : false
 params.version = '3.0.2'
 params.outDir = "$baseDir/output"
 
@@ -28,6 +31,7 @@ refLocation = Channel
   .ifEmpty { exit 1, "referene not found: ${params.genome}" }
 expectCells = params.expectCells
 forceCells = params.forceCells
+chemistryParam = params.chemistryParam
 version = params.version
 outDir = params.outDir
 
@@ -69,13 +73,14 @@ refLocation.into {
   refLocation301
   refLocation302
 }
-
 expectCells211 = expectCells
 expectCells301 = expectCells
 expectCells302 = expectCells
 forceCells211 = forceCells
 forceCells301 = forceCells
 forceCells302 = forceCells
+chemistryParam301 = chemistryParam
+chemistryParam302 = chemistryParam
 
 process count211 {
   tag "count211-$sample"
@@ -119,6 +124,7 @@ process count301 {
   file ref from refLocation301.first()
   expectCells301
   forceCells301
+  chemistryParam301
 
   output:
 
@@ -130,11 +136,11 @@ process count301 {
   script:
   if (forceCells301 == 0){
     	"""
-    	cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --expect-cells=$expectCells301
+    	cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --expect-cells=$expectCells301 --chemistry="$chemistryParam301"
     	"""
   } else {
     	"""
-    	cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --force-cells=$forceCells301
+    	cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --force-cells=$forceCells301 --chemistry="$chemistryParam301"
     	"""
   }
 }
@@ -150,6 +156,7 @@ process count302 {
   file ref from refLocation302.first()
   expectCells302
   forceCells302
+  chemistryParam302
 
   output:
 
@@ -161,11 +168,11 @@ process count302 {
   script:
   if (forceCells302 == 0){
     	"""
-    	cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --expect-cells=$expectCells302
+    	cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --expect-cells=$expectCells302 --chemistry="$chemistryParam302"
     	"""
   } else {
     	"""
-    	cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --force-cells=$forceCells302
+    	cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --force-cells=$forceCells302 --chemistry="$chemistryParam302"
     	"""
   }
 }
-- 
GitLab