Skip to content

Commit 065b49f

Browse files
Notebook unittests for absolute quant cases (#359)
* add tellseq notebook absquant tests, update absquant test files to reflect change in add_controls output and decimal formatting * limit decimal places in output formatting for absquant df files to handle CI/local differences * fix lint complaints
1 parent 5c4fc69 commit 065b49f

9 files changed

+1145
-868
lines changed

notebooks/tellseq_A_compression_and_barcoding.ipynb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,8 +1327,14 @@
13271327
"metadata": {},
13281328
"outputs": [],
13291329
"source": [
1330-
"# format INPUT_DNA_KEY column to avoid floating point weirdness, then write out\n",
1330+
"# format INPUT_DNA_KEY column to avoid floating point weirdness\n",
13311331
"plate_df[INPUT_DNA_KEY] = plate_df[INPUT_DNA_KEY].map(lambda x: f\"{x:.10g}\")\n",
1332+
"\n",
1333+
"if is_absquant(plate_df):\n",
1334+
" # format SYNDNA_VOL_KEY column to avoid floating point weirdness\n",
1335+
" plate_df[SYNDNA_VOL_KEY] = plate_df[SYNDNA_VOL_KEY].map(lambda x: f\"{x:.16g}\")\n",
1336+
"\n",
1337+
"# write out\n",
13321338
"plate_df.to_csv(plate_df_fp, sep='\\t', index=False)"
13331339
]
13341340
},
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
experiment_name: RKLtest
2+
studies:
3+
- Email: r@gmail.com
4+
HumanFiltering: 'True'
5+
Project Abbreviation: TestProjA
6+
Project Name: TestProjA_10002
7+
experiment_design_description: plasma sequencing
8+
qiita_id: '10002'
9+
qiita_metadata_fp: ./test_data/Plate_Maps/10002_20241004-110731.txt
10+
sample_accession_fp: ./test_data/Plate_Maps/Tellseq_TestProjA - 10002 - Sample Accession.csv

notebooks/test_output/QC/Tellseq_absquant_plate_df_A.txt

Lines changed: 385 additions & 385 deletions
Large diffs are not rendered by default.

notebooks/test_output/QC/Tellseq_absquant_plate_df_B.txt

Lines changed: 385 additions & 385 deletions
Large diffs are not rendered by default.

notebooks/test_output/QC/Tellseq_absquant_plate_df_C_set_col19to24.txt

Lines changed: 97 additions & 97 deletions
Large diffs are not rendered by default.

notebooks/tests/test_tellseq_A_compression_and_barcoding.py

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,126 @@ def test_main_path(self):
125125

126126
self._run_notebook_test(run_params, output_params)
127127

128+
def test_absquant_path(self):
129+
"""Verify notebook produces expected outputs for absquant."""
130+
131+
run_params = {
132+
'expt_name': 'RKLtest',
133+
'arbitrary_compression_fp': None,
134+
'studies_info': [
135+
{
136+
'Project Name': 'TestProjA_10002',
137+
'Project Abbreviation': 'TestProjA',
138+
'sample_accession_fp': (f"{self.test_data_dir}/Plate_Maps/"
139+
"Tellseq_TestProjA - 10002 - "
140+
"Sample Accession.csv"),
141+
'qiita_metadata_fp': (f"{self.test_data_dir}/Plate_Maps/"
142+
"10002_20241004-110731.txt"),
143+
'experiment_design_description': 'plasma sequencing',
144+
'HumanFiltering': 'True',
145+
'Email': 'r@gmail.com'
146+
}
147+
],
148+
'compression_layout': [
149+
{
150+
'Plate Position': 1,
151+
'Plate map file': (f"{self.test_data_dir}/Plate_Maps/"
152+
"Tellseq_Test_Plate_1.tsv"),
153+
'Project Name': 'TestProjA_10002',
154+
'Project Plate': 'Plate_1',
155+
'Plate elution volume': 70
156+
},
157+
{
158+
'Plate Position': 2,
159+
'Plate map file': (f"{self.test_data_dir}/Plate_Maps/"
160+
"Tellseq_Test_Plate_2.tsv"),
161+
'Project Name': 'TestProjA_10002',
162+
'Project Plate': 'Plate_2',
163+
'Plate elution volume': 70
164+
},
165+
{
166+
'Plate Position': 3,
167+
'Plate map file': (f"{self.test_data_dir}/Plate_Maps/"
168+
"Tellseq_Test_Plate_3.tsv"),
169+
'Project Name': 'TestProjA_10002',
170+
'Project Plate': 'Plate_3',
171+
'Plate elution volume': 70
172+
},
173+
{
174+
'Plate Position': 4,
175+
'Plate map file': (f"{self.test_data_dir}/Plate_Maps/"
176+
"Tellseq_Test_Plate_4.tsv"),
177+
'Project Name': 'TestProjA_10002',
178+
'Project Plate': 'Plate_4',
179+
'Plate elution volume': 70
180+
},
181+
],
182+
'blanks_dir': f"{self.test_data_dir}/BLANKS_for_tellseq",
183+
'katharoseq_dir': None,
184+
'dilutions_infos': {
185+
"10to1dilution": (f"{self.test_data_dir}/Quant/MiniPico/"
186+
"Tellseq_gDNA_diluted_10_to_1_Quant.txt"),
187+
"2to1dilution": (f"{self.test_data_dir}/Quant/MiniPico/"
188+
"Tellseq_gDNA_diluted_2_to_1_Quant.txt"),
189+
"undiluted": (f"{self.test_data_dir}/Quant/MiniPico/"
190+
"Tellseq_gDNA_Original_Quant.txt")
191+
},
192+
'min_conc_threshold': 1.5,
193+
'replicate_dict': None,
194+
'ng': 7.5,
195+
'total_vol': 5000,
196+
'min_vol': 25,
197+
'resolution': 2.5,
198+
'syndna_pool_number': 1,
199+
'undiluted_gdna_conc_fp': (f"{self.test_data_dir}/Quant/MiniPico/"
200+
"Tellseq_gDNA_Original_Quant.txt"),
201+
'barcodes_plate_name': ('TellSeq_Barcode_Plate_1_LN2409001_'
202+
'EXP052026'),
203+
'barcodes_fp': (f"{self.test_data_dir}/Tellseq/"
204+
"TELL-Seq_Barcodes_PP_Primer_Plate - "
205+
"PP_Primer_Position.csv"),
206+
'barcode_vol': 4000,
207+
}
208+
209+
output_params = {
210+
'syndna_picklist_fp': {
211+
self._OUT_PARAM_VARIABLE_KEY:
212+
'{path}/Input_Norm/Tellseq_matrix_syndna_absquant.txt',
213+
self._FILE_PATH_KEY: True,
214+
},
215+
'norm_picklist_fp': {
216+
self._OUT_PARAM_VARIABLE_KEY:
217+
'{path}/Input_Norm/Tellseq_absquant_inputnorm.txt',
218+
self._FILE_PATH_KEY: True,
219+
},
220+
'barcode_picklist_fp': {
221+
self._OUT_PARAM_VARIABLE_KEY:
222+
'{path}/Indices/Tellseq_absquant_barcode_matrix.txt',
223+
self._FILE_PATH_KEY: True,
224+
},
225+
'file_name_base': {
226+
self._OUT_PARAM_VARIABLE_KEY:
227+
'{path}/QC/Tellseq_absquant',
228+
self._FILE_PATH_KEY: False,
229+
},
230+
'plate_df_fp': {
231+
self._OUT_PARAM_VARIABLE_KEY:
232+
'{path}/QC/Tellseq_absquant_plate_df_A.txt',
233+
self._FILE_PATH_KEY: True,
234+
self._AUTOCONSTRUCTED_KEY: True,
235+
},
236+
'expt_info_fp': {
237+
self._OUT_PARAM_VARIABLE_KEY:
238+
'{path}/QC/Tellseq_absquant_expt_info.yml',
239+
self._FILE_PATH_KEY: True,
240+
self._AUTOCONSTRUCTED_KEY: True,
241+
self._ZERO_DATES_FUNC_KEY:
242+
self._replace_local_test_paths
243+
},
244+
}
245+
246+
self._run_notebook_test(run_params, output_params)
247+
128248

129249
if __name__ == "__main__":
130250
unittest.main()

notebooks/tests/test_tellseq_B_concentration_estimation.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,32 @@ def test_main_path(self):
3131

3232
self._run_notebook_test(run_params, output_params)
3333

34+
def test_absquant_path(self):
35+
"""Verify notebook produces expected outputs for absquant."""
36+
37+
run_params = {
38+
'full_plate_fp': (f"{self.test_output_dir}/QC/"
39+
"Tellseq_absquant_plate_df_A.txt"),
40+
'lib_concs_fp': (f"{self.test_data_dir}/Quant/MiniPico/"
41+
"Tellseq_clean_lib_quant.txt"),
42+
}
43+
44+
output_params = {
45+
'plate_df_fbase': {
46+
self._OUT_PARAM_VARIABLE_KEY:
47+
'{path}/QC/Tellseq_absquant',
48+
self._FILE_PATH_KEY: False,
49+
},
50+
'plate_df_fp': {
51+
self._OUT_PARAM_VARIABLE_KEY:
52+
'{path}/QC/Tellseq_absquant_plate_df_B.txt',
53+
self._FILE_PATH_KEY: True,
54+
self._AUTOCONSTRUCTED_KEY: True,
55+
},
56+
}
57+
58+
self._run_notebook_test(run_params, output_params)
59+
3460

3561
if __name__ == "__main__":
3662
unittest.main()

notebooks/tests/test_tellseq_C_equal_volume_pooling.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,86 @@ def test_main_path(self):
8181

8282
self._run_notebook_test(run_params, output_params)
8383

84+
def test_absquant_path(self):
85+
"""Verify notebook produces expected outputs for absquant."""
86+
87+
run_params = {
88+
'full_plate_fp': (f"{self.test_output_dir}/QC/"
89+
"Tellseq_absquant_plate_df_B.txt"),
90+
'expt_config_fp': (f"{self.test_output_dir}/QC/"
91+
"Tellseq_absquant_expt_info.yml"),
92+
'current_set_id': 'col19to24',
93+
'evp_total_vol': 190,
94+
'iseq_sequencer': 'iSeq',
95+
'novaseq_sequencer': 'NovaSeqXPlus',
96+
}
97+
98+
output_params = {
99+
'evp_picklist_fbase': {
100+
self._OUT_PARAM_VARIABLE_KEY:
101+
'{path}/Indices/Tellseq_evp',
102+
self._FILE_PATH_KEY: False,
103+
},
104+
'evp_picklist_fp': {
105+
self._OUT_PARAM_VARIABLE_KEY:
106+
'{path}/Indices/Tellseq_evp_set_col19to24.txt',
107+
self._FILE_PATH_KEY: True,
108+
self._AUTOCONSTRUCTED_KEY: True,
109+
},
110+
'machine_samplesheet_fbase': {
111+
self._OUT_PARAM_VARIABLE_KEY:
112+
'{path}/SampleSheets/'
113+
'Tellseq_absquant_samplesheet_instrument_iseq',
114+
self._FILE_PATH_KEY: False,
115+
},
116+
'machine_samplesheet_fp': {
117+
self._OUT_PARAM_VARIABLE_KEY:
118+
('{path}/SampleSheets/'
119+
'Tellseq_absquant_samplesheet_instrument_iseq'
120+
'_set_col19to24.csv'),
121+
self._FILE_PATH_KEY: True,
122+
self._AUTOCONSTRUCTED_KEY: True,
123+
self._ZERO_DATES_FUNC_KEY: self._replace_illumina_date,
124+
},
125+
'spp_samplesheet_fbase': {
126+
self._OUT_PARAM_VARIABLE_KEY:
127+
'{path}/SampleSheets/Tellseq_absquant_samplesheet_spp',
128+
self._FILE_PATH_KEY: False,
129+
},
130+
'iseq_spp_samplesheet_fp': {
131+
self._OUT_PARAM_VARIABLE_KEY:
132+
('{path}/SampleSheets/'
133+
'Tellseq_absquant_samplesheet_spp'
134+
'_iseq_set_col19to24.csv'),
135+
self._FILE_PATH_KEY: True,
136+
self._AUTOCONSTRUCTED_KEY: True,
137+
self._ZERO_DATES_FUNC_KEY: self._replace_illumina_date,
138+
},
139+
'novaseq_spp_samplesheet_fp': {
140+
self._OUT_PARAM_VARIABLE_KEY:
141+
('{path}/SampleSheets/'
142+
'Tellseq_absquant_samplesheet_spp_novaseqxplus'
143+
'_set_col19to24.csv'),
144+
self._FILE_PATH_KEY: True,
145+
self._AUTOCONSTRUCTED_KEY: True,
146+
self._ZERO_DATES_FUNC_KEY: self._replace_illumina_date,
147+
},
148+
'plate_set_base_dir': {
149+
self._OUT_PARAM_VARIABLE_KEY:
150+
'{path}/QC/',
151+
self._FILE_PATH_KEY: False,
152+
153+
},
154+
'plate_set_fp': {
155+
self._OUT_PARAM_VARIABLE_KEY:
156+
'{path}/QC/Tellseq_absquant_plate_df_C_set_col19to24.txt',
157+
self._FILE_PATH_KEY: True,
158+
self._AUTOCONSTRUCTED_KEY: True,
159+
},
160+
}
161+
162+
self._run_notebook_test(run_params, output_params)
163+
84164

85165
if __name__ == "__main__":
86166
unittest.main()

notebooks/tests/test_tellseq_D_variable_volume_pooling.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,41 @@ def test_main_path(self):
3434

3535
self._run_notebook_test(run_params, output_params)
3636

37+
def test_absquant_path(self):
38+
"""Verify notebook produces expected output for iSeqnormed picklist.
39+
40+
This test uses the same notebook but with absquant inputs, to verify
41+
that the notebook can be run with either quantification method without
42+
affecting the output.
43+
"""
44+
45+
run_params = {
46+
'plate_df_set_fp': (f"{self.test_output_dir}/QC/"
47+
f"Tellseq_absquant_plate_df_C"
48+
f"_set_col19to24.txt"),
49+
'read_counts_fps': [
50+
(f"{self.test_data_dir}/Demux/"
51+
"Tellseq_fastqc_sequence_counts.tsv")],
52+
'reads_column': 'Raw Reads',
53+
'dynamic_range': 5,
54+
}
55+
56+
output_params = {
57+
'iseqnormed_picklist_fbase': {
58+
self._OUT_PARAM_VARIABLE_KEY:
59+
('{path}/Pooling/Tellseq_iSeqnormpool'),
60+
self._FILE_PATH_KEY: False,
61+
},
62+
'iseqnormed_picklist_fp': {
63+
self._OUT_PARAM_VARIABLE_KEY:
64+
('{path}/Pooling/Tellseq_iSeqnormpool_set_col19to24.txt'),
65+
self._FILE_PATH_KEY: True,
66+
self._AUTOCONSTRUCTED_KEY: True,
67+
},
68+
}
69+
70+
self._run_notebook_test(run_params, output_params)
71+
3772

3873
if __name__ == "__main__":
3974
unittest.main()

0 commit comments

Comments
 (0)