Пример #1
0
 def read10xCountsRaw(tenx_analysis, output):
     tenx_analysis.load()
     utils = DropletUtils()
     counts = utils.read10xCounts(tenx_analysis.raw_matrices())
     sce = SingleCellExperiment.fromRS4(counts)
     sce.save(output)
     return sce
Пример #2
0
 def test_raw_assay_type_equivelence(self):
     rdata = os.path.join(base_dir, "tests/example_sce.RData")
     sce_from_rdata = SingleCellExperiment.fromRData(rdata)
     tenx = DropletUtils()
     rs4_results = tenx.read10xCounts("/home/ceglian/data/raw_gene_bc_matrices/hg19/")
     sce_from_rs4 = SingleCellExperiment(rs4_results)
     self.assertEqual(type(sce_from_rdata.assays["counts"]),type(sce_from_rdata.assays["counts"]))
Пример #3
0
 def test_save_and_load_rdata(self):
     print("Reading")
     tenx = DropletUtils()
     rs4_result = tenx.read10xCounts("/home/ceglian/data/raw_gene_bc_matrices/hg19/")
     sce = SingleCellExperiment.fromRS4(rs4_result)
     print("Writing")
     sce.save("tests/sce_1.rdata")
     print("Loading...")
     sce_saved = SingleCellExperiment.fromRData("tests/sce_1.rdata")
     print(sce_saved.assays["counts"].shape)
Пример #4
0
def Run(sampleid, before, finished, use_corrected=False):
    if use_corrected and os.path.exists(".cache/corrected/"):
        sce = ".cache/corrected/corrected_sce.rdata"
        if not os.path.exists(sce):
            utils = DropletUtils()
            utils.read10xCounts(".cache/corrected/",
                                ".cache/corrected/corrected_sce.rdata")
    else:
        tenx = TenxDataStorage(sampleid, version="v3")
        tenx.download()
        analysis_path = tenx.tenx_path
        tenx_analysis = TenxAnalysis(analysis_path)
        tenx_analysis.load()
        tenx_analysis.extract()
        qc = QualityControl(tenx_analysis, sampleid)
        sce = qc.sce
    if not os.path.exists(".cache/{}/celltypes.rdata".format(sampleid)):
        CellAssign.run(sce, config.rho_matrix,
                       ".cache/{}/celltypes.rdata".format(sampleid))
    open(finished, "w").write("Completed")
Пример #5
0
def Analysis(sampleid, before, finished, use_corrected=False):
    if use_corrected and os.path.exists(".cache/corrected"):
        sce = ".cache/corrected/corrected_sce.rdata"
        if not os.path.exists(sce):
            utils = DropletUtils()
            utils.read10xCounts(".cache/corrected/",
                                ".cache/corrected/corrected_sce.rdata")
        filtered_sce = sce
    else:
        tenx = TenxDataStorage(sampleid, version="v3")
        tenx.download()
        analysis_path = tenx.tenx_path
        tenx_analysis = TenxAnalysis(analysis_path)
        tenx_analysis.load()
        tenx_analysis.extract()
        qc = QualityControl(tenx_analysis, sampleid)
        filtered_sce = os.path.join(os.path.split(qc.sce)[0], "sce_cas.rdata")
    cellassign_analysis = ".cache/{}/cellassignanalysis/".format(sampleid)
    if not os.path.exists(cellassign_analysis):
        os.makedirs(cellassign_analysis)
    pyfit = os.path.join(".cache/{}/cell_types.pkl".format(sampleid))
    assert os.path.exists(pyfit), "No Pyfit Found."
    pyfit = pickle.load(open(pyfit, "rb"))
    marker_list = GeneMarkerMatrix.read_yaml(config.rho_matrix)
    cell_types = marker_list.celltypes()
    if "B cell" not in cell_types: cell_types.append("B cell")
    celltypes(pyfit, sampleid, cellassign_analysis, known_types=cell_types)

    tsne_by_cell_type(filtered_sce,
                      pyfit,
                      sampleid,
                      cellassign_analysis,
                      known_types=cell_types)
    umap_by_cell_type(filtered_sce,
                      pyfit,
                      sampleid,
                      cellassign_analysis,
                      known_types=cell_types)
    open(finished, "w").write("Completed")
Пример #6
0
 def test_get_assay_with_row_col_data_rs4(self):
     tenx = DropletUtils()
     rs4_results = tenx.read10xCounts(
         "/home/ceglian/data/raw_gene_bc_matrices/hg19/")
     sce_from_rs4 = SingleCellExperiment.fromRS4(rs4_results)
Пример #7
0
 def test_read10x_counts_load_rs4(self):
     tenx = DropletUtils()
     rs4_result = tenx.read10xCounts(
         "/home/ceglian/data/raw_gene_bc_matrices/hg19/")
     sce_from_rs4 = SingleCellExperiment.fromRS4(rs4_result)
Пример #8
0
 def read10xCountsFiltered(tenx_analysis, output):
     utils = DropletUtils()
     counts = utils.read10xCounts(tenx_analysis.filtered_matrices())
     sce = SingleCellExperiment.fromRS4(counts)
     sce.save(output)
     return sce
Пример #9
0
 def read10xCounts(tenx_analysis):
     utils = DropletUtils()
     counts = utils.read10xCounts(tenx_analysis.raw_matrices(config.build))
     sce = SingleCellExperiment.fromRS4(counts)
     return sce