def test_set_cell_count_project_missing_library_type(self): """ set_cell_count_for_project: test for scRNA-seq when library not set """ # Set up mock project with library type not set project_dir = self._make_mock_analysis_project( "10xGenomics Chromium 3'v3", None) # Add metrics_summary.csv counts_dir = os.path.join(project_dir, "qc", "cellranger_count", "5.0.1", "refdata-gex-GRCh38-2020-A", "PJB1", "outs") mkdirs(counts_dir) metrics_summary_file = os.path.join(counts_dir, "metrics_summary.csv") with open(metrics_summary_file, 'w') as fp: fp.write(METRICS_SUMMARY) # Add QC info file with open(os.path.join(project_dir, "qc", "qc.info"), 'wt') as fp: fp.write( """Cellranger reference datasets\t/data/refdata-gex-GRCh38-2020-A Cellranger version\t5.0.1 """) # Check initial cell count print("Checking number of cells") self.assertEqual( AnalysisProject("PJB1", project_dir).info.number_of_cells, None) # Update the cell counts print("Updating number of cells") set_cell_count_for_project(project_dir) # Check updated cell count self.assertEqual( AnalysisProject("PJB1", project_dir).info.number_of_cells, 2272)
def test_set_cell_count_for_multiome_gex_project(self): """ set_cell_count_for_project: test for single cell multiome GEX """ # Set up mock project project_dir = self._make_mock_analysis_project( "10xGenomics Single Cell Multiome", "GEX") # Add metrics_summary.csv counts_dir = os.path.join(project_dir, "qc", "cellranger_count", "1.0.0", "refdata-cellranger-arc-GRCh38-2020-A", "PJB1", "outs") mkdirs(counts_dir) summary_file = os.path.join(counts_dir, "summary.csv") with open(summary_file, 'w') as fp: fp.write(MULTIOME_SUMMARY) # Add QC info file with open(os.path.join(project_dir, "qc", "qc.info"), 'wt') as fp: fp.write( """Cellranger reference datasets\t/data/refdata-cellranger-arc-GRCh38-2020-A Cellranger version\t1.0.0 """) # Check initial cell count print("Checking number of cells") self.assertEqual( AnalysisProject("PJB1", project_dir).info.number_of_cells, None) # Update the cell counts print("Updating number of cells") set_cell_count_for_project(project_dir) # Check updated cell count self.assertEqual( AnalysisProject("PJB1", project_dir).info.number_of_cells, 744)
def test_set_cell_count_for_atac_project_2_0_0(self): """ set_cell_count_for_project: test for scATAC-seq (Cellranger ATAC 2.0.0) """ # Set up mock project project_dir = self._make_mock_analysis_project( "10xGenomics Single Cell ATAC", "scATAC-seq") # Add metrics_summary.csv counts_dir = os.path.join( project_dir, "qc", "cellranger_count", "2.0.0", "refdata-cellranger-atac-GRCh38-2020-A-2.0.0", "PJB1", "outs") mkdirs(counts_dir) summary_file = os.path.join(counts_dir, "summary.csv") with open(summary_file, 'w') as fp: fp.write(ATAC_SUMMARY_2_0_0) # Add QC info file with open(os.path.join(project_dir, "qc", "qc.info"), 'wt') as fp: fp.write( """Cellranger reference datasets\t/data/refdata-cellranger-atac-GRCh38-2020-A-2.0.0 Cellranger version\t2.0.0 """) # Check initial cell count print("Checking number of cells") self.assertEqual( AnalysisProject("PJB1", project_dir).info.number_of_cells, None) # Update the cell counts print("Updating number of cells") set_cell_count_for_project(project_dir) # Check updated cell count self.assertEqual( AnalysisProject("PJB1", project_dir).info.number_of_cells, 3582)
def test_set_cell_count_for_cellplex_project(self): """ set_cell_count_for_project: test for multiplexed data (CellPlex) """ # Set up mock project project_dir = self._make_mock_analysis_project( "10xGenomics Chromium 3'v3", "CellPlex") # Build mock cellranger multi output directory multi_dir = os.path.join(project_dir, "qc", "cellranger_multi", "6.0.0", "refdata-cellranger-gex-GRCh38-2020-A", "outs") mkdirs(multi_dir) for sample in ( "PBA", "PBB", ): sample_dir = os.path.join(multi_dir, "per_sample_outs", sample) mkdirs(sample_dir) summary_file = os.path.join(sample_dir, "metrics_summary.csv") with open(summary_file, 'wt') as fp: fp.write(CELLPLEX_METRICS_SUMMARY) web_summary = os.path.join(sample_dir, "web_summary.html") with open(web_summary, 'wt') as fp: fp.write("Placeholder for web_summary.html\n") # Add QC info file with open(os.path.join(project_dir, "qc", "qc.info"), 'wt') as fp: fp.write( """Cellranger reference datasets\t/data/refdata-cellranger-gex-GRCh38-2020-A Cellranger version\t6.0.0 """) # Check initial cell count print("Checking number of cells") self.assertEqual( AnalysisProject("PJB1", project_dir).info.number_of_cells, None) # Update the cell counts print("Updating number of cells") set_cell_count_for_project(project_dir) # Check updated cell count self.assertEqual( AnalysisProject("PJB1", project_dir).info.number_of_cells, 10350)
def test_set_cell_count_project_missing_library_type_no_subdirs(self): """ set_cell_count_for_project: test for scRNA-seq when library not set (old-style output) """ # Set up mock project with library type not set project_dir = self._make_mock_analysis_project( "10xGenomics Chromium 3'v3", None) # Add metrics_summary.csv counts_dir = os.path.join(project_dir, "qc", "cellranger_count", "PJB1", "outs") mkdirs(counts_dir) metrics_summary_file = os.path.join(counts_dir, "metrics_summary.csv") with open(metrics_summary_file, 'w') as fp: fp.write(METRICS_SUMMARY) # Check initial cell count print("Checking number of cells") self.assertEqual( AnalysisProject("PJB1", project_dir).info.number_of_cells, None) # Update the cell counts print("Updating number of cells") set_cell_count_for_project(project_dir) # Check updated cell count self.assertEqual( AnalysisProject("PJB1", project_dir).info.number_of_cells, 2272)