Skip to content

Commit bc18492

Browse files
authored
Merge pull request #1172 from fls-bioinformatics-core/10x-qc-fix-multi-metrics-for-immune-profiling
Fix extraction of 'reads_per_cell' metric from 'cellranger multi' metrics summary file for 5' immune profiling data
2 parents 89b1104 + 018bb5f commit bc18492

3 files changed

Lines changed: 97 additions & 5 deletions

File tree

auto_process_ngs/mock10xdata.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,80 @@
10901090
Library,Gene Expression,Probe barcode ID,BC016,UMIs per probe barcode,6380271
10911091
"""
10921092

1093+
IMMUNE_PROFILING_METRICS_SUMMARY_10_0_0 = """ategory,Library Type,Grouped By,Group Name,Metric Name,Metric Value
1094+
Cells,Antibody Capture,,,Cells,37930
1095+
Cells,Antibody Capture,,,Fraction antibody reads,0.9576988178341168
1096+
Cells,Antibody Capture,,,Mean antibody reads usable per cell,1149
1097+
Cells,Antibody Capture,,,Median UMI counts per cell,142
1098+
Cells,Antibody Capture,,,Number of reads in cells,45523645
1099+
Cells,Gene Expression,,,Cells,37930
1100+
Cells,Gene Expression,,,Confidently mapped reads in cells,0.7742347721158955
1101+
Cells,Gene Expression,,,Median UMI counts per cell,738
1102+
Cells,Gene Expression,,,Median genes per cell,572
1103+
Cells,Gene Expression,,,Total genes detected,20846
1104+
Cells,VDJ T,,,Cells with productive TRA contig,0.7531598114824336
1105+
Cells,VDJ T,,,Cells with productive TRB contig,0.9378748928877464
1106+
Cells,VDJ T,,,"Cells with productive V-J spanning (TRA, TRB) pair",0.69103470437018
1107+
Cells,VDJ T,,,Cells with productive V-J spanning pair,0.69103470437018
1108+
Cells,VDJ T,,,Fraction reads in cells,0.5911548487701712
1109+
Cells,VDJ T,,,Median TRA UMIs per Cell,2
1110+
Cells,VDJ T,,,Median TRB UMIs per Cell,5
1111+
Cells,VDJ T,,,Number of cells with productive V-J spanning pair,12903
1112+
Cells,VDJ T,,,Paired clonotype diversity,216.346707175433
1113+
Cells,VDJ T,,,VDJ cells,18672
1114+
Library,Antibody Capture,Fastq ID,JB1_CSP,Number of reads,69811606
1115+
Library,Antibody Capture,Fastq ID,JB1_CSP,Q30 RNA read,0.9762437927935841
1116+
Library,Antibody Capture,Fastq ID,JB1_CSP,Q30 UMI,0.9846448251503244
1117+
Library,Antibody Capture,Fastq ID,JB1_CSP,Q30 barcodes,0.9847557022976466
1118+
Library,Antibody Capture,Physical library ID,JB1_CSP,Antibody reads in cells,0.6876445113931148
1119+
Library,Antibody Capture,Physical library ID,JB1_CSP,Cells,37930
1120+
Library,Antibody Capture,Physical library ID,JB1_CSP,Fraction antibody reads,0.9214780132690258
1121+
Library,Antibody Capture,Physical library ID,JB1_CSP,Fraction antibody reads in aggregate barcodes,0
1122+
Library,Antibody Capture,Physical library ID,JB1_CSP,Fraction antibody reads usable,0.6245014331857657
1123+
Library,Antibody Capture,Physical library ID,JB1_CSP,Mean reads per cell,1841
1124+
Library,Antibody Capture,Physical library ID,JB1_CSP,Number of reads,69811606
1125+
Library,Antibody Capture,Physical library ID,JB1_CSP,Number of reads in the library,69811606
1126+
Library,Antibody Capture,Physical library ID,JB1_CSP,Sequencing saturation,0.78188226038764
1127+
Library,Antibody Capture,Physical library ID,JB1_CSP,Valid UMI Sequences,0.9999924367876596
1128+
Library,Antibody Capture,Physical library ID,JB1_CSP,Valid barcodes,0.9711250304139972
1129+
Library,Gene Expression,Fastq ID,JB1_GEX,Number of reads,242078038
1130+
Library,Gene Expression,Fastq ID,JB1_GEX,Q30 RNA read,0.9234313591844349
1131+
Library,Gene Expression,Fastq ID,JB1_GEX,Q30 UMI,0.9832914420899814
1132+
Library,Gene Expression,Fastq ID,JB1_GEX,Q30 barcodes,0.9770024510131342
1133+
Library,Gene Expression,Physical library ID,JB1_GEX,Cells,37930
1134+
Library,Gene Expression,Physical library ID,JB1_GEX,Confidently mapped antisense,0.07467201547626555
1135+
Library,Gene Expression,Physical library ID,JB1_GEX,Confidently mapped reads in cells,0.7742347721158955
1136+
Library,Gene Expression,Physical library ID,JB1_GEX,Confidently mapped to exonic regions,0.36597524390048136
1137+
Library,Gene Expression,Physical library ID,JB1_GEX,Confidently mapped to genome,0.6986533284774887
1138+
Library,Gene Expression,Physical library ID,JB1_GEX,Confidently mapped to intergenic regions,0.19662931587375143
1139+
Library,Gene Expression,Physical library ID,JB1_GEX,Confidently mapped to intronic regions,0.13604876870325594
1140+
Library,Gene Expression,Physical library ID,JB1_GEX,Confidently mapped to transcriptome,0.4246487531429844
1141+
Library,Gene Expression,Physical library ID,JB1_GEX,Mapped to genome,0.8234203550509609
1142+
Library,Gene Expression,Physical library ID,JB1_GEX,Mean reads per cell,6382
1143+
Library,Gene Expression,Physical library ID,JB1_GEX,Number of reads,242078038
1144+
Library,Gene Expression,Physical library ID,JB1_GEX,Number of reads in the library,242078038
1145+
Library,Gene Expression,Physical library ID,JB1_GEX,Sequencing saturation,0.5154908866258822
1146+
Library,Gene Expression,Physical library ID,JB1_GEX,Valid UMI Sequences,0.9988716572463298
1147+
Library,Gene Expression,Physical library ID,JB1_GEX,Valid barcodes,0.8568153382009813
1148+
Library,VDJ T,Fastq ID,JB1_TCR,Number of reads,68621222
1149+
Library,VDJ T,Fastq ID,JB1_TCR,Q30 RNA read,0.9348689369272873
1150+
Library,VDJ T,Fastq ID,JB1_TCR,Q30 UMI,0.9812304967404981
1151+
Library,VDJ T,Fastq ID,JB1_TCR,Q30 barcodes,0.9713749279974111
1152+
Library,VDJ T,Physical library ID,JB1_TCR,Cells with productive TRA contig,0.7531598114824336
1153+
Library,VDJ T,Physical library ID,JB1_TCR,Cells with productive TRB contig,0.9378748928877464
1154+
Library,VDJ T,Physical library ID,JB1_TCR,"Cells with productive V-J spanning (TRA, TRB) pair",0.69103470437018
1155+
Library,VDJ T,Physical library ID,JB1_TCR,Cells with productive V-J spanning pair,0.69103470437018
1156+
Library,VDJ T,Physical library ID,JB1_TCR,Fraction reads in cells,0.5911548487701712
1157+
Library,VDJ T,Physical library ID,JB1_TCR,Mean reads per cell,3675
1158+
Library,VDJ T,Physical library ID,JB1_TCR,Mean used reads per cell,1886
1159+
Library,VDJ T,Physical library ID,JB1_TCR,Number of reads,68621222
1160+
Library,VDJ T,Physical library ID,JB1_TCR,Reads mapped to TRA,0.2795949172716168
1161+
Library,VDJ T,Physical library ID,JB1_TCR,Reads mapped to TRB,0.5598595479538795
1162+
Library,VDJ T,Physical library ID,JB1_TCR,Reads mapped to any V(D)J gene,0.84426033700563
1163+
Library,VDJ T,Physical library ID,JB1_TCR,VDJ Cells,18672
1164+
Library,VDJ T,Physical library ID,JB1_TCR,Valid barcodes,0.9304403381216382
1165+
"""
1166+
10931167
MULTIOME_LIBRARIES = """#Local sample\tLinked sample
10941168
PB2_ATAC\tNEXTSEQ_210111/12:PB_GEX/PB2_GEX
10951169
PB1_ATAC\tNEXTSEQ_210111/12:PB_GEX/PB1_GEX

auto_process_ngs/tenx/metrics.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,12 @@ def reads_in_cells(self):
425425
"""
426426
Returns the number of reads in cells
427427
"""
428-
try:
429-
# Cellranger 10
430-
return self.fetch('Number of reads in cells')
431-
except MissingMetricError:
432-
pass
428+
# Cellranger 10
429+
for library_type in ("Gene Expression", "Antibody Capture"):
430+
try:
431+
return self.fetch('Number of reads in cells', library_type)
432+
except (KeyError, MissingMetricError):
433+
pass
433434
try:
434435
# Cellranger <= 9
435436
return self.fetch('Number of reads from cells called from this sample')

auto_process_ngs/test/tenx/test_metrics.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from auto_process_ngs.mock10xdata import FLEX_METRICS_SUMMARY_8_0_0
2222
from auto_process_ngs.mock10xdata import FLEX_METRICS_SUMMARY_9_0_0
2323
from auto_process_ngs.mock10xdata import FLEX_METRICS_SUMMARY_10_0_0
24+
from auto_process_ngs.mock10xdata import IMMUNE_PROFILING_METRICS_SUMMARY_10_0_0
2425
from auto_process_ngs.mock10xdata import MULTIOME_SUMMARY
2526
from auto_process_ngs.mock10xdata import MULTIOME_SUMMARY_2_0_0
2627
from auto_process_ngs.tenx.metrics import *
@@ -338,3 +339,19 @@ def test_flex_summary_cellranger_10_0_0(self):
338339
self.assertEqual(m.median_umi_counts_per_cell, 3152)
339340
self.assertRaises(MissingMetricError,
340341
getattr,m,"median_reads_per_cell")
342+
343+
def test_immune_profiling_summary_cellranger_10_0_0(self):
344+
"""MultiplexSummary: extract Immune Profiling metrics (Cellranger 10.0.0)
345+
"""
346+
summary_csv = os.path.join(self.wd,"metrics_summary.csv")
347+
with open(summary_csv,'w') as fp:
348+
fp.write(IMMUNE_PROFILING_METRICS_SUMMARY_10_0_0)
349+
m = MultiplexSummary(summary_csv)
350+
self.assertEqual(m.reads_in_cells, 45523645)
351+
self.assertEqual(m.cells, 37930)
352+
self.assertEqual(m.mean_reads_per_cell, 6382)
353+
self.assertEqual(m.median_genes_per_cell, 572)
354+
self.assertEqual(m.total_genes_detected, 20846)
355+
self.assertEqual(m.median_umi_counts_per_cell, 738)
356+
self.assertRaises(MissingMetricError,
357+
getattr,m,"median_reads_per_cell")

0 commit comments

Comments
 (0)