Skip to content

Commit

Permalink
tenx/utils: update 'make_multi_config_template' for Cellranger 9.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbriggs committed Jan 13, 2025
1 parent 0135203 commit f7c66f7
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 3 deletions.
13 changes: 10 additions & 3 deletions auto_process_ngs/tenx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,13 @@ def make_multi_config_template(f,reference=None,probe_set=None,
cellranger_version = DEFAULT_CELLRANGER_VERSION
else:
cellranger_version = str(cellranger_version)
# Major version
try:
cellranger_major_version = int(cellranger_version.split(".")[0])
except Exception as ex:
raise Exception(f"'{cellranger_version}': unable to extract "
f"Cellranger major version from version string: "
f"{ex}")
# Normalise and check supplied library type
if library_type.startswith("CellPlex"):
library_type = "cellplex"
Expand Down Expand Up @@ -605,14 +612,14 @@ def make_multi_config_template(f,reference=None,probe_set=None,
(probe_set if probe_set
else "/path/to/probe/set"))
fp.write("#force-cells,n\n")
if cellranger_version.startswith("7."):
if cellranger_major_version == 7:
# Cellranger 7.* targetted
if no_bam is not None:
fp.write("no-bam,%s\n" % str(no_bam).lower())
else:
fp.write("#no-bam,true|false\n")
elif cellranger_version.startswith("8."):
# Cellranger 8.* targetted
elif cellranger_major_version in (8, 9):
# Cellranger 8.* or 9.* targetted
if no_bam is not None:
fp.write("create-bam,%s\n" % str(not no_bam).lower())
else:
Expand Down
106 changes: 106 additions & 0 deletions auto_process_ngs/test/tenx/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,41 @@ def test_make_multi_config_template_cellplex_scrnaseq_800(self):
if not line.startswith('##')])
self.assertEqual(expected_content,actual_content)

def test_make_multi_config_template_cellplex_900(self):
"""
make_multi_config_template: check CellPlex template (9.0.0)
"""
expected_content = """[gene-expression]
reference,/data/mm10_transcriptome
#force-cells,n
create-bam,true
#cmo-set,/path/to/custom/cmo/reference
#[feature]
#reference,/path/to/feature/reference
[libraries]
fastq_id,fastqs,lanes,physical_library_id,feature_types,subsample_rate
PJB_CML,/runs/novaseq_50/fastqs,any,PJB_CML,[Gene Expression|Multiplexing Capture],
PJB_GEX,/runs/novaseq_50/fastqs,any,PJB_GEX,[Gene Expression|Multiplexing Capture],
[samples]
sample_id,cmo_ids,description
MULTIPLEXED_SAMPLE,CMO1|CMO2|...,DESCRIPTION
"""
out_file = os.path.join(self.wd,"10x_multi_config.csv")
make_multi_config_template(out_file,
reference="/data/mm10_transcriptome",
fastq_dir="/runs/novaseq_50/fastqs",
samples=("PJB_CML","PJB_GEX"),
library_type="CellPlex",
cellranger_version="9.0.0")
self.assertTrue(os.path.exists(out_file))
with open(out_file,'rt') as fp:
actual_content = '\n'.join([line for line in fp.read().split('\n')
if not line.startswith('##')])
self.assertEqual(expected_content,actual_content)

def test_make_multi_config_template_flex_700(self):
"""
make_multi_config_template: check Flex template (7.1.0)
Expand Down Expand Up @@ -863,6 +898,43 @@ def test_make_multi_config_template_flex_800(self):
if not line.startswith('##')])
self.assertEqual(expected_content,actual_content)

def test_make_multi_config_template_flex_900(self):
"""
make_multi_config_template: check Flex template (9.0.0)
"""
expected_content = """[gene-expression]
reference,/data/mm10_transcriptome
probe-set,/data/mm10_probe_set.csv
#force-cells,n
create-bam,false
#cmo-set,/path/to/custom/cmo/reference
#[feature]
#reference,/path/to/feature/reference
[libraries]
fastq_id,fastqs,lanes,physical_library_id,feature_types,subsample_rate
PJB_Flex,/runs/novaseq_50/fastqs,any,PJB_Flex,[Gene Expression|Antibody Capture],
[samples]
sample_id,probe_barcode_ids,description
MULTIPLEXED_SAMPLE,BC001|BC002|...,DESCRIPTION
"""
out_file = os.path.join(self.wd,"10x_multi_config.csv")
make_multi_config_template(out_file,
reference="/data/mm10_transcriptome",
probe_set="/data/mm10_probe_set.csv",
fastq_dir="/runs/novaseq_50/fastqs",
samples=("PJB_Flex",),
no_bam=True,
library_type="Flex",
cellranger_version="9.0.0")
self.assertTrue(os.path.exists(out_file))
with open(out_file,'rt') as fp:
actual_content = '\n'.join([line for line in fp.read().split('\n')
if not line.startswith('##')])
self.assertEqual(expected_content,actual_content)

def test_make_multi_config_template_immune_profiling_710(self):
"""
make_multi_config_template: check Single Cell Immune Profiling template (7.0.0)
Expand Down Expand Up @@ -931,6 +1003,40 @@ def test_make_multi_config_template_immune_profiling_800(self):
if not line.startswith('##')])
self.assertEqual(expected_content,actual_content)

def test_make_multi_config_template_immune_profiling_900(self):
"""
make_multi_config_template: check Single Cell Immune Profiling template (9.0.0)
"""
expected_content = """[gene-expression]
reference,/data/mm10_transcriptome
#force-cells,n
create-bam,true
#cmo-set,/path/to/custom/cmo/reference
#[feature]
#reference,/path/to/feature/reference
#[vdj]
#reference,/path/to/vdj/reference
[libraries]
fastq_id,fastqs,lanes,physical_library_id,feature_types,subsample_rate
PJB_CML,/runs/novaseq_50/fastqs,any,PJB_CML,[Gene Expression|Antibody Capture|VDJ-B|VDJ-T],
PJB_GEX,/runs/novaseq_50/fastqs,any,PJB_GEX,[Gene Expression|Antibody Capture|VDJ-B|VDJ-T],
"""
out_file = os.path.join(self.wd,"10x_multi_config.csv")
make_multi_config_template(out_file,
reference="/data/mm10_transcriptome",
fastq_dir="/runs/novaseq_50/fastqs",
samples=("PJB_CML","PJB_GEX"),
library_type="Single Cell Immune Profiling",
cellranger_version="9.0.0")
self.assertTrue(os.path.exists(out_file))
with open(out_file,'rt') as fp:
actual_content = '\n'.join([line for line in fp.read().split('\n')
if not line.startswith('##')])
self.assertEqual(expected_content,actual_content)

def test_make_multi_config_template_unsupported_library(self):
"""
make_multi_config_template: exception for unsupported library type
Expand Down

0 comments on commit f7c66f7

Please sign in to comment.