Run CCCI¶
[1]:
import pandas as pd
import numpy as np
import scanpy as sc
import STCase as st
/home/user/BGM/qij/miniconda3/envs/stcase_tmp1/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
from .autonotebook import tqdm as notebook_tqdm
/home/user/BGM/qij/miniconda3/envs/stcase_tmp1/lib/python3.10/site-packages/torch_geometric/typing.py:54: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /home/user/BGM/qij/miniconda3/envs/stcase_tmp1/lib/python3.10/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
[2]:
DB_interaction = pd.read_csv('/home/user/data3/qij/project/cell_communication/interaction_database/selfdb_finalv/selfdb_human.csv',index_col=0)
DB_complex = pd.read_csv('/home/user/data3/qij/project/cell_communication/interaction_database/selfdb_finalv/selfdb_complex_human.csv',index_col=0)
DATABASES_GLOB = '/home/user/data3/qij/project/cell_communication/pySCENIC/databases/human_hg38_v10/*.genes_vs_motifs.rankings.feather'
MOTIF_ANNOTATIONS_FNAME = '/home/user/data3/qij/project/cell_communication/pySCENIC/resources/motifs-v10nr_clust-nr.hgnc-m0.001-o0.0.tbl'
[3]:
adata_sp311 = sc.read_h5ad('../NG-lung/spdata/sp311_nonceco.h5ad')
Running¶
There are three ways to run the CCCI module
(1) Stringent¶
[4]:
adata_sp311_stringent = st.ccci.spatial_cell_communication_run(adata_sp311,
DB_interaction,
DB_complex,
method='Hill',
ct_key='cell_type',
cell_type=None,
if_hvg=False,
if_filter=False,
if_self=True,
if_intra=True,
if_stringent=True,
DATABASES_GLOB=DATABASES_GLOB,
MOTIF_ANNOTATIONS_FNAME=MOTIF_ANNOTATIONS_FNAME,
background_number=1000,
threads=10,
scope=6,
min_exp=0.1,
cutoff=0.05)
##################################################################
Now start to calulate radius
The radius is: 220.41097976280582
##################################################################
Now start to get LR pair
The number of keep LR pair is 1866
##################################################################
get_LR_gene_exp
##################################################################
get_close_gene
##################################################################
Now start to get true weight matirx
Now processing the unsecreted
Computed weight matrix process: |██████████████████████████████| 100%
Now processing the secreted
Computed weight matrix process: |██████████████████████████████| 100%
##################################################################
Now start to permutation test
Permutation test process: |██████████████████████████████| 100%
Now filter low confidence value
Filter low confidence value process: |██████████████████████████████| 100%
##################################################################
Now start to add intracellular signals
Run SCENIC
Phase I: Inference of co-expression modules
preparing dask client
/home/user/BGM/qij/miniconda3/envs/stcase_tmp1/lib/python3.10/site-packages/distributed/node.py:182: UserWarning: Port 8787 is already in use.
Perhaps you already have a cluster running?
Hosting the HTTP server on port 46744 instead
parsing input
creating dask graph
16 partitions
computing dask graph
/home/user/BGM/qij/miniconda3/envs/stcase_tmp1/lib/python3.10/site-packages/distributed/client.py:3125: UserWarning: Sending large graph of size 107.19 MiB.
This may cause some slowdown.
Consider scattering data ahead of time and using futures.
shutting down client and local cluster
finished
2024-04-11 03:59:51,484 - pyscenic.utils - INFO - Calculating Pearson correlations.
2024-04-11 03:59:51,854 - pyscenic.utils - WARNING - Note on correlation calculation: the default behaviour for calculating the correlations has changed after pySCENIC verion 0.9.16. Previously, the default was to calculate the correlation between a TF and target gene using only cells with non-zero expression values (mask_dropouts=True). The current default is now to use all cells to match the behavior of the R verision of SCENIC. The original settings can be retained by setting 'rho_mask_dropouts=True' in the modules_from_adjacencies function, or '--mask_dropouts' from the CLI.
Dropout masking is currently set to [False].
2024-04-11 04:00:08,021 - pyscenic.utils - INFO - Creating modules.
Phase II: Prune modules for targets with cis regulatory footprints
Create regulons from a dataframe of enriched features.
Additional columns saved: []
Phase III: Cellular regulon enrichment matrix
Add intracellular signals: |██████████████████████████████| 100%
##################################################################
Now start to aggregate
Spatial cell communication finished!
[36]:
adata_sp311_stringent.write_h5ad('./adata_sp311_stringent.h5ad')
(2) non-stringent¶
[ ]:
adata_sp311_nonstringent = st.ccci.spatial_cell_communication_run(adata_sp311,
DB_interaction,
DB_complex,
method='Hill',
ct_key='cell_type',
cell_type=None,
if_hvg=False,
if_filter=False,
if_self=True,
if_intra=True,
if_stringent=True,
DATABASES_GLOB=DATABASES_GLOB,
MOTIF_ANNOTATIONS_FNAME=MOTIF_ANNOTATIONS_FNAME,
background_number=1000,
threads=10,
scope=6,
min_exp=0.1,
cutoff=0.05)
[ ]:
adata_sp311_nonstringent.write_h5ad('./adata_sp311_nonstringent.h5ad')
(3) With no regard for the downstream path¶
[ ]:
adata_sp311_nodownstram = st.ccci.spatial_cell_communication_run(adata_sp311,
DB_interaction,
DB_complex,
method='Hill',
ct_key='cell_type',
cell_type=None,
if_hvg=False,
if_filter=False,
if_self=True,
if_intra=False,
if_stringent=False,
DATABASES_GLOB=DATABASES_GLOB,
MOTIF_ANNOTATIONS_FNAME=MOTIF_ANNOTATIONS_FNAME,
background_number=1000,
threads=10,
scope=6,
min_exp=0.1,
cutoff=0.05)
[ ]:
adata_sp311_nodownstram.write_h5ad('./adata_sp311_nodownstram.h5ad')
Results¶
[10]:
adata_sp311_stringent
[10]:
AnnData object with n_obs × n_vars = 2238 × 12912
obs: 'in_tissue', 'array_row', 'array_col', 'sample', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_100_genes', 'pct_counts_in_top_200_genes', 'pct_counts_in_top_500_genes', 'mt_frac', 'Perichondrium', 'Weird_morphology', 'Cartilage', 'Glands', 'Tissue', 'Multilayer_epithelium', 'Nerve', 'Venous_vessel', 'Airway_Smooth_Muscle', 'Arterial_vessel', 'Parenchyma', 'Pulmonary_vessel', 'Mesothelium', 'Small_airway', 'iBALT', '_indices', '_scvi_batch', '_scvi_labels', 'cell_type', 'total_counts_mt', 'log1p_total_counts_mt', 'pct_counts_mt'
var: 'feature_types', 'genome', 'SYMBOL', 'mt', 'n_cells_by_counts-WSA_LngSP10193345', 'mean_counts-WSA_LngSP10193345', 'log1p_mean_counts-WSA_LngSP10193345', 'pct_dropout_by_counts-WSA_LngSP10193345', 'total_counts-WSA_LngSP10193345', 'log1p_total_counts-WSA_LngSP10193345', 'n_cells_by_counts-WSA_LngSP10193346', 'mean_counts-WSA_LngSP10193346', 'log1p_mean_counts-WSA_LngSP10193346', 'pct_dropout_by_counts-WSA_LngSP10193346', 'total_counts-WSA_LngSP10193346', 'log1p_total_counts-WSA_LngSP10193346', 'n_cells_by_counts-WSA_LngSP10193347', 'mean_counts-WSA_LngSP10193347', 'log1p_mean_counts-WSA_LngSP10193347', 'pct_dropout_by_counts-WSA_LngSP10193347', 'total_counts-WSA_LngSP10193347', 'log1p_total_counts-WSA_LngSP10193347', 'n_cells_by_counts-WSA_LngSP10193348', 'mean_counts-WSA_LngSP10193348', 'log1p_mean_counts-WSA_LngSP10193348', 'pct_dropout_by_counts-WSA_LngSP10193348', 'total_counts-WSA_LngSP10193348', 'log1p_total_counts-WSA_LngSP10193348', 'n_cells_by_counts-WSA_LngSP8759311', 'mean_counts-WSA_LngSP8759311', 'log1p_mean_counts-WSA_LngSP8759311', 'pct_dropout_by_counts-WSA_LngSP8759311', 'total_counts-WSA_LngSP8759311', 'log1p_total_counts-WSA_LngSP8759311', 'n_cells_by_counts-WSA_LngSP8759312', 'mean_counts-WSA_LngSP8759312', 'log1p_mean_counts-WSA_LngSP8759312', 'pct_dropout_by_counts-WSA_LngSP8759312', 'total_counts-WSA_LngSP8759312', 'log1p_total_counts-WSA_LngSP8759312', 'n_cells_by_counts-WSA_LngSP8759313', 'mean_counts-WSA_LngSP8759313', 'log1p_mean_counts-WSA_LngSP8759313', 'pct_dropout_by_counts-WSA_LngSP8759313', 'total_counts-WSA_LngSP8759313', 'log1p_total_counts-WSA_LngSP8759313', 'n_cells_by_counts-WSA_LngSP9258463', 'mean_counts-WSA_LngSP9258463', 'log1p_mean_counts-WSA_LngSP9258463', 'pct_dropout_by_counts-WSA_LngSP9258463', 'total_counts-WSA_LngSP9258463', 'log1p_total_counts-WSA_LngSP9258463', 'n_cells_by_counts-WSA_LngSP9258464', 'mean_counts-WSA_LngSP9258464', 'log1p_mean_counts-WSA_LngSP9258464', 'pct_dropout_by_counts-WSA_LngSP9258464', 'total_counts-WSA_LngSP9258464', 'log1p_total_counts-WSA_LngSP9258464', 'n_cells_by_counts-WSA_LngSP9258467', 'mean_counts-WSA_LngSP9258467', 'log1p_mean_counts-WSA_LngSP9258467', 'pct_dropout_by_counts-WSA_LngSP9258467', 'total_counts-WSA_LngSP9258467', 'log1p_total_counts-WSA_LngSP9258467', 'n_cells_by_counts-WSA_LngSP9258468', 'mean_counts-WSA_LngSP9258468', 'log1p_mean_counts-WSA_LngSP9258468', 'pct_dropout_by_counts-WSA_LngSP9258468', 'total_counts-WSA_LngSP9258468', 'log1p_total_counts-WSA_LngSP9258468', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts'
uns: '_scvi_manager_uuid', '_scvi_uuid', 'cell_type_colors', 'log1p', 'mod', 'spatial', 'radius', 'LR_pair_information', 'LR_gene_complex_information', 'LR_gene_complex_exp', 'LR_close_gene', 'LR_close_gene_exp', 'LR_cell_weight', 'Cell_neighbors', 'scenic_res', 'cell_type_list', 'LR_celltype_weight', 'LR_celltype_mean_weight', 'LR_celltype_edge_num', 'LR_celltype_aggregate_weight', 'LR_pathway_celltype_weight', 'LR_pathway_celltype_mean_weight', 'LR_pathway_celltype_edge_num', 'LR_pathway_celltype_count', 'LR_pathway_cell_weight', 'data_for_LRI'
obsm: 'means_cell_abundance_w_sf', 'q05_cell_abundance_w_sf', 'q95_cell_abundance_w_sf', 'spatial', 'stds_cell_abundance_w_sf', 'distances'
[39]:
## Read the CCC score of a ligand receptor pair at the cell/spot level
LRP_CellLevel_CCCscore = pd.DataFrame(adata_sp311_stringent.uns['LR_cell_weight']['IL6|COMPLEX:IL6R_IL6ST'].toarray(),
index=adata_sp311_stringent.obs.index, columns=adata_sp311_stringent.obs.index
)
[40]:
LRP_CellLevel_CCCscore.iloc[:10,:10]
[40]:
| spot_id | WSA_LngSP8759311_AAACAAGTATCTCCCA-1 | WSA_LngSP8759311_AAACAGAGCGACTCCT-1 | WSA_LngSP8759311_AAACATTTCCCGGATT-1 | WSA_LngSP8759311_AAACCCGAACGAAATC-1 | WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 | WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 | WSA_LngSP8759311_AAACGAAGAACATACC-1 | WSA_LngSP8759311_AAACGAGACGGTTGAT-1 | WSA_LngSP8759311_AAACGGGCGTACGGGT-1 | WSA_LngSP8759311_AAACGGTTGCGAACTG-1 |
|---|---|---|---|---|---|---|---|---|---|---|
| spot_id | ||||||||||
| WSA_LngSP8759311_AAACAAGTATCTCCCA-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACAGAGCGACTCCT-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACATTTCCCGGATT-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACCCGAACGAAATC-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACGAAGAACATACC-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACGAGACGGTTGAT-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACGGGCGTACGGGT-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACGGTTGCGAACTG-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
[41]:
## Read the sum CCC score of a ligand receptor pair at the cell type level
LRP_CellTypeLevel_weight = pd.DataFrame(adata_sp311_stringent.uns['LR_celltype_weight']['IL6|COMPLEX:IL6R_IL6ST'],
index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']
)
[42]:
LRP_CellTypeLevel_weight
[42]:
| Others | Arterial_vessel | Venous_vessel | Glands | Cartilage | Multilayer_epithelium | Nerve | Airway_Smooth_Muscle | Perichondrium | Weird_morphology | |
|---|---|---|---|---|---|---|---|---|---|---|
| Others | 44.895301 | 1.834348 | 5.810078 | 10.125569 | 3.698377 | 1.465692 | 3.854100 | 4.764654 | 2.223017 | 13.828947 |
| Arterial_vessel | 1.039287 | 2.237669 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| Venous_vessel | 0.000000 | 0.000000 | 3.908923 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.673586 |
| Glands | 1.417303 | 0.000000 | 0.000000 | 8.018459 | 0.000000 | 0.000000 | 0.000000 | 0.422328 | 0.000000 | 0.000000 |
| Cartilage | 2.722322 | 0.000000 | 0.000000 | 0.266071 | 5.055546 | 0.000000 | 0.000000 | 0.000000 | 0.707860 | 0.000000 |
| Multilayer_epithelium | 0.503930 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 4.177691 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| Nerve | 1.257532 | 0.000000 | 0.000000 | 0.423734 | 0.000000 | 0.000000 | 4.901593 | 0.000000 | 0.000000 | 0.538051 |
| Airway_Smooth_Muscle | 4.200898 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 2.972851 | 0.000000 | 6.919369 | 0.000000 | 0.000000 |
| Perichondrium | 2.433086 | 0.000000 | 0.000000 | 0.000000 | 1.191374 | 0.000000 | 0.000000 | 0.000000 | 3.054677 | 0.000000 |
| Weird_morphology | 12.403792 | 0.000000 | 0.000000 | 2.604088 | 0.000000 | 0.000000 | 2.724591 | 0.399174 | 0.000000 | 21.088744 |
[43]:
## Read the average interaction score for each interaction edge of a ligand receptor pair at the cell type level
LRP_CellTypeLevel_mean_weight = pd.DataFrame(adata_sp311_stringent.uns['LR_celltype_mean_weight']['IL6|COMPLEX:IL6R_IL6ST'],
index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']
)
[44]:
LRP_CellTypeLevel_mean_weight
[44]:
| Others | Arterial_vessel | Venous_vessel | Glands | Cartilage | Multilayer_epithelium | Nerve | Airway_Smooth_Muscle | Perichondrium | Weird_morphology | |
|---|---|---|---|---|---|---|---|---|---|---|
| Others | 0.774057 | 0.458587 | 0.830011 | 0.562532 | 0.924594 | 0.732846 | 0.770820 | 0.680665 | 0.741006 | 0.813467 |
| Arterial_vessel | 0.519643 | 0.447534 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| Venous_vessel | 0.000000 | 0.000000 | 0.781785 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.673586 |
| Glands | 0.354326 | 0.000000 | 0.000000 | 0.400923 | 0.000000 | 0.000000 | 0.000000 | 0.422328 | 0.000000 | 0.000000 |
| Cartilage | 0.544464 | 0.000000 | 0.000000 | 0.266071 | 0.561727 | 0.000000 | 0.000000 | 0.000000 | 0.707860 | 0.000000 |
| Multilayer_epithelium | 0.503930 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.696282 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| Nerve | 0.419177 | 0.000000 | 0.000000 | 0.423734 | 0.000000 | 0.000000 | 0.980319 | 0.000000 | 0.000000 | 0.538051 |
| Airway_Smooth_Muscle | 0.700150 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.371606 | 0.000000 | 0.864921 | 0.000000 | 0.000000 |
| Perichondrium | 1.216543 | 0.000000 | 0.000000 | 0.000000 | 0.397125 | 0.000000 | 0.000000 | 0.000000 | 1.018226 | 0.000000 |
| Weird_morphology | 0.729635 | 0.000000 | 0.000000 | 0.868029 | 0.000000 | 0.000000 | 0.908197 | 0.399174 | 0.000000 | 0.753169 |
[45]:
## Read the sum interaction edge number of a ligand receptor pair at the cell type level
LRP_CellTypeLevel_edge_num = pd.DataFrame(adata_sp311_stringent.uns['LR_celltype_edge_num']['IL6|COMPLEX:IL6R_IL6ST'],
index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']
)
[46]:
LRP_CellTypeLevel_edge_num
[46]:
| Others | Arterial_vessel | Venous_vessel | Glands | Cartilage | Multilayer_epithelium | Nerve | Airway_Smooth_Muscle | Perichondrium | Weird_morphology | |
|---|---|---|---|---|---|---|---|---|---|---|
| Others | 58.0 | 4.0 | 7.0 | 18.0 | 4.0 | 2.0 | 5.0 | 7.0 | 3.0 | 17.0 |
| Arterial_vessel | 2.0 | 5.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| Venous_vessel | 0.0 | 0.0 | 5.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
| Glands | 4.0 | 0.0 | 0.0 | 20.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 |
| Cartilage | 5.0 | 0.0 | 0.0 | 1.0 | 9.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 |
| Multilayer_epithelium | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 6.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| Nerve | 3.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 | 5.0 | 0.0 | 0.0 | 1.0 |
| Airway_Smooth_Muscle | 6.0 | 0.0 | 0.0 | 0.0 | 0.0 | 8.0 | 0.0 | 8.0 | 0.0 | 0.0 |
| Perichondrium | 2.0 | 0.0 | 0.0 | 0.0 | 3.0 | 0.0 | 0.0 | 0.0 | 3.0 | 0.0 |
| Weird_morphology | 17.0 | 0.0 | 0.0 | 3.0 | 0.0 | 0.0 | 3.0 | 1.0 | 0.0 | 28.0 |
[47]:
## Read the number of LRPs that occur between cell types
LRP_number_CellTypeLevel = pd.DataFrame(adata_sp311_stringent.uns['LR_celltype_aggregate_weight']['count'],
index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']
)
[48]:
LRP_number_CellTypeLevel
[48]:
| Others | Arterial_vessel | Venous_vessel | Glands | Cartilage | Multilayer_epithelium | Nerve | Airway_Smooth_Muscle | Perichondrium | Weird_morphology | |
|---|---|---|---|---|---|---|---|---|---|---|
| Others | 1025.0 | 563.0 | 313.0 | 875.0 | 413.0 | 768.0 | 487.0 | 770.0 | 587.0 | 598.0 |
| Arterial_vessel | 540.0 | 686.0 | 0.0 | 4.0 | 0.0 | 0.0 | 6.0 | 0.0 | 0.0 | 98.0 |
| Venous_vessel | 290.0 | 0.0 | 482.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 159.0 |
| Glands | 895.0 | 4.0 | 0.0 | 1007.0 | 37.0 | 130.0 | 177.0 | 384.0 | 370.0 | 277.0 |
| Cartilage | 411.0 | 0.0 | 0.0 | 80.0 | 839.0 | 0.0 | 22.0 | 0.0 | 491.0 | 38.0 |
| Multilayer_epithelium | 805.0 | 0.0 | 0.0 | 116.0 | 0.0 | 880.0 | 0.0 | 707.0 | 2.0 | 3.0 |
| Nerve | 476.0 | 18.0 | 7.0 | 157.0 | 18.0 | 0.0 | 567.0 | 0.0 | 13.0 | 323.0 |
| Airway_Smooth_Muscle | 768.0 | 0.0 | 0.0 | 335.0 | 0.0 | 646.0 | 0.0 | 861.0 | 0.0 | 73.0 |
| Perichondrium | 629.0 | 0.0 | 0.0 | 380.0 | 481.0 | 10.0 | 32.0 | 0.0 | 720.0 | 92.0 |
| Weird_morphology | 636.0 | 197.0 | 191.0 | 305.0 | 43.0 | 3.0 | 321.0 | 126.0 | 114.0 | 664.0 |
[49]:
## Read the CCC score of a pathway at the cell/spot level
Pathway_CellLevel_CCCscore = pd.DataFrame(adata_sp311_stringent.uns['LR_pathway_cell_weight']['CCL'].toarray(),
index=adata_sp311_stringent.obs.index, columns=adata_sp311_stringent.obs.index
)
[51]:
Pathway_CellLevel_CCCscore.iloc[:10,:10]
[51]:
| spot_id | WSA_LngSP8759311_AAACAAGTATCTCCCA-1 | WSA_LngSP8759311_AAACAGAGCGACTCCT-1 | WSA_LngSP8759311_AAACATTTCCCGGATT-1 | WSA_LngSP8759311_AAACCCGAACGAAATC-1 | WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 | WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 | WSA_LngSP8759311_AAACGAAGAACATACC-1 | WSA_LngSP8759311_AAACGAGACGGTTGAT-1 | WSA_LngSP8759311_AAACGGGCGTACGGGT-1 | WSA_LngSP8759311_AAACGGTTGCGAACTG-1 |
|---|---|---|---|---|---|---|---|---|---|---|
| spot_id | ||||||||||
| WSA_LngSP8759311_AAACAAGTATCTCCCA-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACAGAGCGACTCCT-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACATTTCCCGGATT-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACCCGAACGAAATC-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACGAAGAACATACC-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACGAGACGGTTGAT-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACGGGCGTACGGGT-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| WSA_LngSP8759311_AAACGGTTGCGAACTG-1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
[33]:
## Read the CCC score of a pathway at the cell type level
Pathway_CellTypeLevel_wight = pd.DataFrame(adata_sp311_stringent.uns['LR_pathway_celltype_weight']['CCL'],
index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']
)
Pathway_CellTypeLevel_mean_weight = pd.DataFrame(adata_sp311_stringent.uns['LR_pathway_celltype_mean_weight']['CCL'],
index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']
)
Pathway_CellTypeLevel_edge_num = pd.DataFrame(adata_sp311_stringent.uns['LR_pathway_celltype_edge_num']['CCL'],
index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']
)
Pathway_CellTypeLevel_count = pd.DataFrame(adata_sp311_stringent.uns['LR_pathway_celltype_count']['CCL'],
index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']
)
[35]:
## Read all Scenic result
Scenic_result = adata_sp311_stringent.uns['scenic_res']
[54]:
Scenic_result['auc_mtx'].head()
[54]:
| Regulon | ATF2(+) | ATF4(+) | ATF5(+) | CEBPB(+) | CLOCK(+) | DLX5(+) | E2F1(+) | E2F3(+) | E2F4(+) | EGR1(+) | ... | THRA(+) | THRB(+) | TP53(+) | TWIST1(+) | XBP1(+) | ZFHX3(+) | ZNF398(+) | ZNF430(+) | ZNF587(+) | ZNF611(+) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Cell | |||||||||||||||||||||
| WSA_LngSP8759311_AAACAAGTATCTCCCA-1 | 0.108328 | 0.093427 | 0.069433 | 0.012242 | 0.011166 | 0.0 | 0.014957 | 0.029883 | 0.008086 | 0.017228 | ... | 0.009210 | 0.014643 | 0.011487 | 0.073802 | 0.036905 | 0.006195 | 0.085418 | 0.0 | 0.0 | 0.000000 |
| WSA_LngSP8759311_AAACAGAGCGACTCCT-1 | 0.000000 | 0.074548 | 0.006270 | 0.021819 | 0.011246 | 0.0 | 0.020478 | 0.003840 | 0.010671 | 0.025917 | ... | 0.004947 | 0.061523 | 0.031192 | 0.029992 | 0.043080 | 0.034313 | 0.034427 | 0.0 | 0.0 | 0.038396 |
| WSA_LngSP8759311_AAACATTTCCCGGATT-1 | 0.000000 | 0.100603 | 0.025635 | 0.045186 | 0.009883 | 0.0 | 0.017017 | 0.000473 | 0.006903 | 0.031353 | ... | 0.031014 | 0.000000 | 0.009068 | 0.011124 | 0.093036 | 0.006681 | 0.037972 | 0.0 | 0.0 | 0.000000 |
| WSA_LngSP8759311_AAACCCGAACGAAATC-1 | 0.001860 | 0.124458 | 0.018883 | 0.063018 | 0.023382 | 0.0 | 0.026290 | 0.006872 | 0.012462 | 0.024987 | ... | 0.012721 | 0.000000 | 0.035857 | 0.045622 | 0.034919 | 0.044688 | 0.052010 | 0.0 | 0.0 | 0.000000 |
| WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 | 0.000000 | 0.142454 | 0.000000 | 0.011417 | 0.028632 | 0.0 | 0.015208 | 0.025063 | 0.006036 | 0.022820 | ... | 0.017319 | 0.000000 | 0.012471 | 0.007040 | 0.038779 | 0.024019 | 0.063190 | 0.0 | 0.0 | 0.000000 |
5 rows × 102 columns
[ ]: