from descartes_rpa.convert.loom import loom_to_anndata
from descartes_rpa.analyze.analyze import scanpy_format
from descartes_rpa import get_pathways_for_group
from descartes_rpa.fetch.descartes import fetch_descartes_by_tissue
fetch_descartes_by_tissue(["Pancreas"], out_dir="../data/input")
Downloading Pancreas tissue Human Single-Cell data from Descartes database data url: https://shendure-web.gs.washington.edu/content/members/cao1025/public/FCA_RNA_supp_files/scanpy_cells_by_tissue/Pancreas_processed.loom Downloaded ../data/input/Pancreas_data.loom to ../data/input
adata = loom_to_anndata("../../data/input/Pancreas_data.loom")
scanpy_format(adata=adata)
get_pathways_for_group(adata)
/home/joao/miniconda3/envs/descartes-rpa/lib/python3.9/site-packages/anndata/_core/anndata.py:120: ImplicitModificationWarning: Transforming to str index. warnings.warn("Transforming to str index.", ImplicitModificationWarning) /home/joao/miniconda3/envs/descartes-rpa/lib/python3.9/site-packages/anndata/utils.py:111: UserWarning: Suffix used (-[0-9]+) to deduplicate index values may make index values difficult to interpret. There values with a similar suffixes in the index. Consider using a different delimiter by passing `join={delimiter}`Example key collisions generated by the make_index_unique algorithm: ['SNORD116-1', 'SNORD116-2', 'SNORD116-3', 'SNORD116-5', 'SNORD116-6'] warnings.warn( ... storing 'Assay' as categorical ... storing 'Batch' as categorical ... storing 'Experiment_batch' as categorical ... storing 'Fetus_id' as categorical ... storing 'Main_cluster_name' as categorical ... storing 'Organ' as categorical ... storing 'Organ_cell_lineage' as categorical ... storing 'RT_group' as categorical ... storing 'Sex' as categorical ... storing 'exon_intron' as categorical ... storing 'gene_type' as categorical
from descartes_rpa.io.save import save_data_with_pathways
dir_path = "../../data/output/Pancreas"
file = "Pancreas"
save_data_with_pathways(adata, directory=dir_path, file=file)
Saving AnnData structure to ../../data/output/Pancreas/Pancreas.h5ad Saving pathway data from Acinar cells clusters to ../../data/output/Pancreas Saving pathway data from Ductal cells clusters to ../../data/output/Pancreas Saving pathway data from Lymphoid cells clusters to ../../data/output/Pancreas Saving pathway data from Smooth muscle cells clusters to ../../data/output/Pancreas Saving pathway data from Erythroblasts clusters to ../../data/output/Pancreas Saving pathway data from ENS neurons clusters to ../../data/output/Pancreas Saving pathway data from Islet endocrine cells clusters to ../../data/output/Pancreas Saving pathway data from Myeloid cells clusters to ../../data/output/Pancreas Saving pathway data from Stromal cells clusters to ../../data/output/Pancreas Saving pathway data from Vascular endothelial cells clusters to ../../data/output/Pancreas Saving pathway data from CCL19_CCL21 positive cells clusters to ../../data/output/Pancreas Saving pathway data from ENS glia clusters to ../../data/output/Pancreas Saving pathway data from Mesothelial cells clusters to ../../data/output/Pancreas Saving pathway data from Lymphatic endothelial cells clusters to ../../data/output/Pancreas
from descartes_rpa.io.load import load_data_with_pathways
loaded_adata = load_data_with_pathways(directory=dir_path)
Loading ../../data/output/Pancreas/Lymphatic_endothelial_cells_pathways.csv pathway data. Loading ../../data/output/Pancreas/Smooth_muscle_cells_pathways.csv pathway data. Loading ../../data/output/Pancreas/CCL19_CCL21_positive_cells_pathways.csv pathway data. Loading ../../data/output/Pancreas/Myeloid_cells_pathways.csv pathway data. Loading ../../data/output/Pancreas/Acinar_cells_pathways.csv pathway data. Loading ../../data/output/Pancreas/Ductal_cells_pathways.csv pathway data. Loading ../../data/output/Pancreas/Lymphoid_cells_pathways.csv pathway data. Loading ../../data/output/Pancreas/ENS_glia_pathways.csv pathway data. Loading ../../data/output/Pancreas/Vascular_endothelial_cells_pathways.csv pathway data. Loading ../../data/output/Pancreas/Islet_endocrine_cells_pathways.csv pathway data. Loading ../../data/output/Pancreas/Mesothelial_cells_pathways.csv pathway data. Loading ../../data/output/Pancreas/Erythroblasts_pathways.csv pathway data. Loading ../../data/output/Pancreas/ENS_neurons_pathways.csv pathway data. Loading ../../data/output/Pancreas/Stromal_cells_pathways.csv pathway data. Loading ../../data/output/Pancreas/Pancreas.h5ad AnnData file.
loaded_adata.uns["pathways"].keys()
odict_keys(['Lymphatic_endothelial_cells', 'Smooth_muscle_cells', 'CCL19_CCL21_positive_cells', 'Myeloid_cells', 'Acinar_cells', 'Ductal_cells', 'Lymphoid_cells', 'ENS_glia', 'Vascular_endothelial_cells', 'Islet_endocrine_cells', 'Mesothelial_cells', 'Erythroblasts', 'ENS_neurons', 'Stromal_cells'])
loaded_adata.uns["pathways"]["Islet_endocrine_cells"]
stId | dbId | name | species | llp | entities | reactions | inDisease | |
---|---|---|---|---|---|---|---|---|
0 | R-HSA-186712 | 186712 | Regulation of beta-cell development | {'dbId': 48887, 'taxId': '9606', 'name': 'Homo... | False | {'resource': 'TOTAL', 'total': 67, 'found': 5,... | {'resource': 'TOTAL', 'total': 26, 'found': 4,... | False |
1 | R-HSA-1296052 | 1296052 | Ca2+ activated K+ channels | {'dbId': 48887, 'taxId': '9606', 'name': 'Homo... | True | {'resource': 'TOTAL', 'total': 10, 'found': 3,... | {'resource': 'TOTAL', 'total': 3, 'found': 1, ... | False |
2 | R-HSA-210745 | 210745 | Regulation of gene expression in beta cells | {'dbId': 48887, 'taxId': '9606', 'name': 'Homo... | True | {'resource': 'TOTAL', 'total': 35, 'found': 4,... | {'resource': 'TOTAL', 'total': 12, 'found': 3,... | False |
3 | R-HSA-112308 | 112308 | Presynaptic depolarization and calcium channel... | {'dbId': 48887, 'taxId': '9606', 'name': 'Homo... | True | {'resource': 'TOTAL', 'total': 14, 'found': 3,... | {'resource': 'TOTAL', 'total': 1, 'found': 1, ... | False |
4 | R-HSA-422356 | 422356 | Regulation of insulin secretion | {'dbId': 48887, 'taxId': '9606', 'name': 'Homo... | True | {'resource': 'TOTAL', 'total': 106, 'found': 5... | {'resource': 'TOTAL', 'total': 34, 'found': 8,... | False |
... | ... | ... | ... | ... | ... | ... | ... | ... |
102 | R-HSA-556833 | 556833 | Metabolism of lipids | {'dbId': 48887, 'taxId': '9606', 'name': 'Homo... | False | {'resource': 'TOTAL', 'total': 1437, 'found': ... | {'resource': 'TOTAL', 'total': 949, 'found': 1... | False |
103 | R-HSA-212436 | 212436 | Generic Transcription Pathway | {'dbId': 48887, 'taxId': '9606', 'name': 'Homo... | True | {'resource': 'TOTAL', 'total': 1555, 'found': ... | {'resource': 'TOTAL', 'total': 824, 'found': 3... | False |
104 | R-HSA-162582 | 162582 | Signal Transduction | {'dbId': 48887, 'taxId': '9606', 'name': 'Homo... | False | {'resource': 'TOTAL', 'total': 2993, 'found': ... | {'resource': 'TOTAL', 'total': 2445, 'found': ... | False |
105 | R-HSA-73857 | 73857 | RNA Polymerase II Transcription | {'dbId': 48887, 'taxId': '9606', 'name': 'Homo... | False | {'resource': 'TOTAL', 'total': 1694, 'found': ... | {'resource': 'TOTAL', 'total': 885, 'found': 3... | False |
106 | R-HSA-74160 | 74160 | Gene expression (Transcription) | {'dbId': 48887, 'taxId': '9606', 'name': 'Homo... | False | {'resource': 'TOTAL', 'total': 1855, 'found': ... | {'resource': 'TOTAL', 'total': 1000, 'found': ... | False |
107 rows × 8 columns
import scanpy as sc
sc.settings.set_figure_params(dpi=300, facecolor='white')
sc.pl.umap(loaded_adata, color="Main_cluster_name")
from descartes_rpa.pl import shared_pathways
In Jupyter Notebook is hard to check results. However, the high quality png file created can be zoomed with high resolution.
shared_pathways(adata)
Example with only some clusters
shared_pathways(
adata,
clusters=["Vascular endothelial cells", "Islet endocrine cells", "ENS glia"]
)