{
"cells": [
{
"cell_type": "markdown",
"id": "e98c92a2",
"metadata": {},
"source": [
"# Run CCCI"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "1f55d803",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-10T12:42:48.984671Z",
"start_time": "2024-04-10T12:42:38.771151Z"
},
"collapsed": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/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\n",
" from .autonotebook import tqdm as notebook_tqdm\n",
"/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)\n",
" warnings.warn(f\"An issue occurred while importing 'pyg-lib'. \"\n",
"During startup - Warning message:\n",
"package ‘stats’ in options(\"defaultPackages\") was not found \n"
]
}
],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import scanpy as sc\n",
"import STCase as st"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "a86d5bf0",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-10T12:42:49.055135Z",
"start_time": "2024-04-10T12:42:48.994458Z"
}
},
"outputs": [],
"source": [
"DB_interaction = pd.read_csv('/home/user/data3/qij/project/cell_communication/interaction_database/selfdb_finalv/selfdb_human.csv',index_col=0)\n",
"DB_complex = pd.read_csv('/home/user/data3/qij/project/cell_communication/interaction_database/selfdb_finalv/selfdb_complex_human.csv',index_col=0)\n",
"DATABASES_GLOB = '/home/user/data3/qij/project/cell_communication/pySCENIC/databases/human_hg38_v10/*.genes_vs_motifs.rankings.feather'\n",
"MOTIF_ANNOTATIONS_FNAME = '/home/user/data3/qij/project/cell_communication/pySCENIC/resources/motifs-v10nr_clust-nr.hgnc-m0.001-o0.0.tbl'"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "5ddc7c4b",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-10T12:42:50.574602Z",
"start_time": "2024-04-10T12:42:49.560645Z"
}
},
"outputs": [],
"source": [
"adata_sp311 = sc.read_h5ad('../NG-lung/spdata/sp311_nonceco.h5ad')"
]
},
{
"cell_type": "markdown",
"id": "7bed2e71",
"metadata": {},
"source": [
"## Running\n",
"There are three ways to run the CCCI module"
]
},
{
"cell_type": "markdown",
"id": "ff25c245",
"metadata": {},
"source": [
"### (1) Stringent"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "e4fd7c8c",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-10T20:22:07.104214Z",
"start_time": "2024-04-10T12:43:16.874412Z"
},
"collapsed": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"##################################################################\n",
"Now start to calulate radius\n",
"The radius is: 220.41097976280582\n",
"##################################################################\n",
"Now start to get LR pair\n",
"The number of keep LR pair is 1866\n",
"##################################################################\n",
"get_LR_gene_exp\n",
"##################################################################\n",
"get_close_gene\n",
"##################################################################\n",
"Now start to get true weight matirx\n",
"Now processing the unsecreted\n",
"Computed weight matrix process: |██████████████████████████████| 100%\n",
"Now processing the secreted\n",
"Computed weight matrix process: |██████████████████████████████| 100%\n",
"##################################################################\n",
"Now start to permutation test\n",
"Permutation test process: |██████████████████████████████| 100%\n",
"Now filter low confidence value\n",
"Filter low confidence value process: |██████████████████████████████| 100%\n",
"##################################################################\n",
"Now start to add intracellular signals\n",
"Run SCENIC\n",
"Phase I: Inference of co-expression modules\n",
"preparing dask client\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/user/BGM/qij/miniconda3/envs/stcase_tmp1/lib/python3.10/site-packages/distributed/node.py:182: UserWarning: Port 8787 is already in use.\n",
"Perhaps you already have a cluster running?\n",
"Hosting the HTTP server on port 46744 instead\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"parsing input\n",
"creating dask graph\n",
"16 partitions\n",
"computing dask graph\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/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.\n",
"This may cause some slowdown.\n",
"Consider scattering data ahead of time and using futures.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"shutting down client and local cluster\n",
"finished\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
"2024-04-11 03:59:51,484 - pyscenic.utils - INFO - Calculating Pearson correlations.\n",
"\n",
"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.\n",
"\tDropout masking is currently set to [False].\n",
"\n",
"2024-04-11 04:00:08,021 - pyscenic.utils - INFO - Creating modules.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Phase II: Prune modules for targets with cis regulatory footprints\n",
"Create regulons from a dataframe of enriched features.\n",
"Additional columns saved: []\n",
"Phase III: Cellular regulon enrichment matrix\n",
"Add intracellular signals: |██████████████████████████████| 100%\n",
"##################################################################\n",
"Now start to aggregate\n",
"Spatial cell communication finished!\n"
]
}
],
"source": [
"adata_sp311_stringent = st.ccci.spatial_cell_communication_run(adata_sp311,\n",
" DB_interaction,\n",
" DB_complex,\n",
" method='Hill',\n",
" ct_key='cell_type',\n",
" cell_type=None,\n",
" if_hvg=False,\n",
" if_filter=False,\n",
" if_self=True,\n",
" if_intra=True,\n",
" if_stringent=True,\n",
" DATABASES_GLOB=DATABASES_GLOB,\n",
" MOTIF_ANNOTATIONS_FNAME=MOTIF_ANNOTATIONS_FNAME,\n",
" background_number=1000,\n",
" threads=10,\n",
" scope=6,\n",
" min_exp=0.1,\n",
" cutoff=0.05)"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "711d5919",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:56:01.778604Z",
"start_time": "2024-04-11T05:55:00.341386Z"
}
},
"outputs": [],
"source": [
"adata_sp311_stringent.write_h5ad('./adata_sp311_stringent.h5ad')"
]
},
{
"cell_type": "markdown",
"id": "b3abba74",
"metadata": {},
"source": [
"### (2) non-stringent"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1753c1ba",
"metadata": {},
"outputs": [],
"source": [
"adata_sp311_nonstringent = st.ccci.spatial_cell_communication_run(adata_sp311,\n",
" DB_interaction,\n",
" DB_complex,\n",
" method='Hill',\n",
" ct_key='cell_type',\n",
" cell_type=None,\n",
" if_hvg=False,\n",
" if_filter=False,\n",
" if_self=True,\n",
" if_intra=True,\n",
" if_stringent=True,\n",
" DATABASES_GLOB=DATABASES_GLOB,\n",
" MOTIF_ANNOTATIONS_FNAME=MOTIF_ANNOTATIONS_FNAME,\n",
" background_number=1000,\n",
" threads=10,\n",
" scope=6,\n",
" min_exp=0.1,\n",
" cutoff=0.05)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3747d188",
"metadata": {},
"outputs": [],
"source": [
"adata_sp311_nonstringent.write_h5ad('./adata_sp311_nonstringent.h5ad')"
]
},
{
"cell_type": "markdown",
"id": "1e4cf23a",
"metadata": {},
"source": [
"### (3) With no regard for the downstream path"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e3a845a9",
"metadata": {},
"outputs": [],
"source": [
"adata_sp311_nodownstram = st.ccci.spatial_cell_communication_run(adata_sp311,\n",
" DB_interaction,\n",
" DB_complex,\n",
" method='Hill',\n",
" ct_key='cell_type',\n",
" cell_type=None,\n",
" if_hvg=False,\n",
" if_filter=False,\n",
" if_self=True,\n",
" if_intra=False,\n",
" if_stringent=False,\n",
" DATABASES_GLOB=DATABASES_GLOB,\n",
" MOTIF_ANNOTATIONS_FNAME=MOTIF_ANNOTATIONS_FNAME,\n",
" background_number=1000,\n",
" threads=10,\n",
" scope=6,\n",
" min_exp=0.1,\n",
" cutoff=0.05)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2623f5e6",
"metadata": {},
"outputs": [],
"source": [
"adata_sp311_nodownstram.write_h5ad('./adata_sp311_nodownstram.h5ad')"
]
},
{
"cell_type": "markdown",
"id": "bd018283",
"metadata": {},
"source": [
"## Results"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "1acd8888",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T02:14:56.369222Z",
"start_time": "2024-04-11T02:14:56.361685Z"
},
"collapsed": true
},
"outputs": [
{
"data": {
"text/plain": [
"AnnData object with n_obs × n_vars = 2238 × 12912\n",
" 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'\n",
" 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'\n",
" 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'\n",
" obsm: 'means_cell_abundance_w_sf', 'q05_cell_abundance_w_sf', 'q95_cell_abundance_w_sf', 'spatial', 'stds_cell_abundance_w_sf', 'distances'"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"adata_sp311_stringent"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "e9980928",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:56:58.551101Z",
"start_time": "2024-04-11T05:56:58.515690Z"
}
},
"outputs": [],
"source": [
"## Read the CCC score of a ligand receptor pair at the cell/spot level\n",
"LRP_CellLevel_CCCscore = pd.DataFrame(adata_sp311_stringent.uns['LR_cell_weight']['IL6|COMPLEX:IL6R_IL6ST'].toarray(),\n",
" index=adata_sp311_stringent.obs.index, columns=adata_sp311_stringent.obs.index\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "a7637a4a",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:56:58.850516Z",
"start_time": "2024-04-11T05:56:58.795645Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | spot_id | \n",
" WSA_LngSP8759311_AAACAAGTATCTCCCA-1 | \n",
" WSA_LngSP8759311_AAACAGAGCGACTCCT-1 | \n",
" WSA_LngSP8759311_AAACATTTCCCGGATT-1 | \n",
" WSA_LngSP8759311_AAACCCGAACGAAATC-1 | \n",
" WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 | \n",
" WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 | \n",
" WSA_LngSP8759311_AAACGAAGAACATACC-1 | \n",
" WSA_LngSP8759311_AAACGAGACGGTTGAT-1 | \n",
" WSA_LngSP8759311_AAACGGGCGTACGGGT-1 | \n",
" WSA_LngSP8759311_AAACGGTTGCGAACTG-1 | \n",
"
\n",
" \n",
" | spot_id | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | WSA_LngSP8759311_AAACAAGTATCTCCCA-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACAGAGCGACTCCT-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACATTTCCCGGATT-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACCCGAACGAAATC-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACGAAGAACATACC-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACGAGACGGTTGAT-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACGGGCGTACGGGT-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACGGTTGCGAACTG-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
"spot_id WSA_LngSP8759311_AAACAAGTATCTCCCA-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACAGAGCGACTCCT-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACATTTCCCGGATT-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACCCGAACGAAATC-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACGAAGAACATACC-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACGAGACGGTTGAT-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACGGGCGTACGGGT-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACGGTTGCGAACTG-1 \n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 "
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"LRP_CellLevel_CCCscore.iloc[:10,:10]"
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "79f6ab51",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:56:59.184785Z",
"start_time": "2024-04-11T05:56:59.179903Z"
}
},
"outputs": [],
"source": [
"## Read the sum CCC score of a ligand receptor pair at the cell type level\n",
"LRP_CellTypeLevel_weight = pd.DataFrame(adata_sp311_stringent.uns['LR_celltype_weight']['IL6|COMPLEX:IL6R_IL6ST'],\n",
" index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "95a3e2c7",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:56:59.670465Z",
"start_time": "2024-04-11T05:56:59.622826Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Others | \n",
" Arterial_vessel | \n",
" Venous_vessel | \n",
" Glands | \n",
" Cartilage | \n",
" Multilayer_epithelium | \n",
" Nerve | \n",
" Airway_Smooth_Muscle | \n",
" Perichondrium | \n",
" Weird_morphology | \n",
"
\n",
" \n",
" \n",
" \n",
" | Others | \n",
" 44.895301 | \n",
" 1.834348 | \n",
" 5.810078 | \n",
" 10.125569 | \n",
" 3.698377 | \n",
" 1.465692 | \n",
" 3.854100 | \n",
" 4.764654 | \n",
" 2.223017 | \n",
" 13.828947 | \n",
"
\n",
" \n",
" | Arterial_vessel | \n",
" 1.039287 | \n",
" 2.237669 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | Venous_vessel | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 3.908923 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.673586 | \n",
"
\n",
" \n",
" | Glands | \n",
" 1.417303 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 8.018459 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.422328 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | Cartilage | \n",
" 2.722322 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.266071 | \n",
" 5.055546 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.707860 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | Multilayer_epithelium | \n",
" 0.503930 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 4.177691 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | Nerve | \n",
" 1.257532 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.423734 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 4.901593 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.538051 | \n",
"
\n",
" \n",
" | Airway_Smooth_Muscle | \n",
" 4.200898 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 2.972851 | \n",
" 0.000000 | \n",
" 6.919369 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | Perichondrium | \n",
" 2.433086 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 1.191374 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 3.054677 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | Weird_morphology | \n",
" 12.403792 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 2.604088 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 2.724591 | \n",
" 0.399174 | \n",
" 0.000000 | \n",
" 21.088744 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Others Arterial_vessel Venous_vessel Glands \\\n",
"Others 44.895301 1.834348 5.810078 10.125569 \n",
"Arterial_vessel 1.039287 2.237669 0.000000 0.000000 \n",
"Venous_vessel 0.000000 0.000000 3.908923 0.000000 \n",
"Glands 1.417303 0.000000 0.000000 8.018459 \n",
"Cartilage 2.722322 0.000000 0.000000 0.266071 \n",
"Multilayer_epithelium 0.503930 0.000000 0.000000 0.000000 \n",
"Nerve 1.257532 0.000000 0.000000 0.423734 \n",
"Airway_Smooth_Muscle 4.200898 0.000000 0.000000 0.000000 \n",
"Perichondrium 2.433086 0.000000 0.000000 0.000000 \n",
"Weird_morphology 12.403792 0.000000 0.000000 2.604088 \n",
"\n",
" Cartilage Multilayer_epithelium Nerve \\\n",
"Others 3.698377 1.465692 3.854100 \n",
"Arterial_vessel 0.000000 0.000000 0.000000 \n",
"Venous_vessel 0.000000 0.000000 0.000000 \n",
"Glands 0.000000 0.000000 0.000000 \n",
"Cartilage 5.055546 0.000000 0.000000 \n",
"Multilayer_epithelium 0.000000 4.177691 0.000000 \n",
"Nerve 0.000000 0.000000 4.901593 \n",
"Airway_Smooth_Muscle 0.000000 2.972851 0.000000 \n",
"Perichondrium 1.191374 0.000000 0.000000 \n",
"Weird_morphology 0.000000 0.000000 2.724591 \n",
"\n",
" Airway_Smooth_Muscle Perichondrium Weird_morphology \n",
"Others 4.764654 2.223017 13.828947 \n",
"Arterial_vessel 0.000000 0.000000 0.000000 \n",
"Venous_vessel 0.000000 0.000000 0.673586 \n",
"Glands 0.422328 0.000000 0.000000 \n",
"Cartilage 0.000000 0.707860 0.000000 \n",
"Multilayer_epithelium 0.000000 0.000000 0.000000 \n",
"Nerve 0.000000 0.000000 0.538051 \n",
"Airway_Smooth_Muscle 6.919369 0.000000 0.000000 \n",
"Perichondrium 0.000000 3.054677 0.000000 \n",
"Weird_morphology 0.399174 0.000000 21.088744 "
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"LRP_CellTypeLevel_weight"
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "a3d23412",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:57:00.164524Z",
"start_time": "2024-04-11T05:57:00.160393Z"
}
},
"outputs": [],
"source": [
"## Read the average interaction score for each interaction edge of a ligand receptor pair at the cell type level\n",
"LRP_CellTypeLevel_mean_weight = pd.DataFrame(adata_sp311_stringent.uns['LR_celltype_mean_weight']['IL6|COMPLEX:IL6R_IL6ST'],\n",
" index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 44,
"id": "9adfbf89",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:57:00.786104Z",
"start_time": "2024-04-11T05:57:00.770835Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Others | \n",
" Arterial_vessel | \n",
" Venous_vessel | \n",
" Glands | \n",
" Cartilage | \n",
" Multilayer_epithelium | \n",
" Nerve | \n",
" Airway_Smooth_Muscle | \n",
" Perichondrium | \n",
" Weird_morphology | \n",
"
\n",
" \n",
" \n",
" \n",
" | Others | \n",
" 0.774057 | \n",
" 0.458587 | \n",
" 0.830011 | \n",
" 0.562532 | \n",
" 0.924594 | \n",
" 0.732846 | \n",
" 0.770820 | \n",
" 0.680665 | \n",
" 0.741006 | \n",
" 0.813467 | \n",
"
\n",
" \n",
" | Arterial_vessel | \n",
" 0.519643 | \n",
" 0.447534 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | Venous_vessel | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.781785 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.673586 | \n",
"
\n",
" \n",
" | Glands | \n",
" 0.354326 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.400923 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.422328 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | Cartilage | \n",
" 0.544464 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.266071 | \n",
" 0.561727 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.707860 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | Multilayer_epithelium | \n",
" 0.503930 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.696282 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | Nerve | \n",
" 0.419177 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.423734 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.980319 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.538051 | \n",
"
\n",
" \n",
" | Airway_Smooth_Muscle | \n",
" 0.700150 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.371606 | \n",
" 0.000000 | \n",
" 0.864921 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | Perichondrium | \n",
" 1.216543 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.397125 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 1.018226 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | Weird_morphology | \n",
" 0.729635 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.868029 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.908197 | \n",
" 0.399174 | \n",
" 0.000000 | \n",
" 0.753169 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Others Arterial_vessel Venous_vessel Glands \\\n",
"Others 0.774057 0.458587 0.830011 0.562532 \n",
"Arterial_vessel 0.519643 0.447534 0.000000 0.000000 \n",
"Venous_vessel 0.000000 0.000000 0.781785 0.000000 \n",
"Glands 0.354326 0.000000 0.000000 0.400923 \n",
"Cartilage 0.544464 0.000000 0.000000 0.266071 \n",
"Multilayer_epithelium 0.503930 0.000000 0.000000 0.000000 \n",
"Nerve 0.419177 0.000000 0.000000 0.423734 \n",
"Airway_Smooth_Muscle 0.700150 0.000000 0.000000 0.000000 \n",
"Perichondrium 1.216543 0.000000 0.000000 0.000000 \n",
"Weird_morphology 0.729635 0.000000 0.000000 0.868029 \n",
"\n",
" Cartilage Multilayer_epithelium Nerve \\\n",
"Others 0.924594 0.732846 0.770820 \n",
"Arterial_vessel 0.000000 0.000000 0.000000 \n",
"Venous_vessel 0.000000 0.000000 0.000000 \n",
"Glands 0.000000 0.000000 0.000000 \n",
"Cartilage 0.561727 0.000000 0.000000 \n",
"Multilayer_epithelium 0.000000 0.696282 0.000000 \n",
"Nerve 0.000000 0.000000 0.980319 \n",
"Airway_Smooth_Muscle 0.000000 0.371606 0.000000 \n",
"Perichondrium 0.397125 0.000000 0.000000 \n",
"Weird_morphology 0.000000 0.000000 0.908197 \n",
"\n",
" Airway_Smooth_Muscle Perichondrium Weird_morphology \n",
"Others 0.680665 0.741006 0.813467 \n",
"Arterial_vessel 0.000000 0.000000 0.000000 \n",
"Venous_vessel 0.000000 0.000000 0.673586 \n",
"Glands 0.422328 0.000000 0.000000 \n",
"Cartilage 0.000000 0.707860 0.000000 \n",
"Multilayer_epithelium 0.000000 0.000000 0.000000 \n",
"Nerve 0.000000 0.000000 0.538051 \n",
"Airway_Smooth_Muscle 0.864921 0.000000 0.000000 \n",
"Perichondrium 0.000000 1.018226 0.000000 \n",
"Weird_morphology 0.399174 0.000000 0.753169 "
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"LRP_CellTypeLevel_mean_weight"
]
},
{
"cell_type": "code",
"execution_count": 45,
"id": "02ed1e77",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:57:01.279176Z",
"start_time": "2024-04-11T05:57:01.274940Z"
}
},
"outputs": [],
"source": [
"## Read the sum interaction edge number of a ligand receptor pair at the cell type level\n",
"LRP_CellTypeLevel_edge_num = pd.DataFrame(adata_sp311_stringent.uns['LR_celltype_edge_num']['IL6|COMPLEX:IL6R_IL6ST'],\n",
" index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "8f55556e",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:57:01.731667Z",
"start_time": "2024-04-11T05:57:01.689298Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Others | \n",
" Arterial_vessel | \n",
" Venous_vessel | \n",
" Glands | \n",
" Cartilage | \n",
" Multilayer_epithelium | \n",
" Nerve | \n",
" Airway_Smooth_Muscle | \n",
" Perichondrium | \n",
" Weird_morphology | \n",
"
\n",
" \n",
" \n",
" \n",
" | Others | \n",
" 58.0 | \n",
" 4.0 | \n",
" 7.0 | \n",
" 18.0 | \n",
" 4.0 | \n",
" 2.0 | \n",
" 5.0 | \n",
" 7.0 | \n",
" 3.0 | \n",
" 17.0 | \n",
"
\n",
" \n",
" | Arterial_vessel | \n",
" 2.0 | \n",
" 5.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | Venous_vessel | \n",
" 0.0 | \n",
" 0.0 | \n",
" 5.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 1.0 | \n",
"
\n",
" \n",
" | Glands | \n",
" 4.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 20.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 1.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | Cartilage | \n",
" 5.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 1.0 | \n",
" 9.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 1.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | Multilayer_epithelium | \n",
" 1.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 6.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | Nerve | \n",
" 3.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 1.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 5.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 1.0 | \n",
"
\n",
" \n",
" | Airway_Smooth_Muscle | \n",
" 6.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 8.0 | \n",
" 0.0 | \n",
" 8.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | Perichondrium | \n",
" 2.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | Weird_morphology | \n",
" 17.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 3.0 | \n",
" 1.0 | \n",
" 0.0 | \n",
" 28.0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Others Arterial_vessel Venous_vessel Glands \\\n",
"Others 58.0 4.0 7.0 18.0 \n",
"Arterial_vessel 2.0 5.0 0.0 0.0 \n",
"Venous_vessel 0.0 0.0 5.0 0.0 \n",
"Glands 4.0 0.0 0.0 20.0 \n",
"Cartilage 5.0 0.0 0.0 1.0 \n",
"Multilayer_epithelium 1.0 0.0 0.0 0.0 \n",
"Nerve 3.0 0.0 0.0 1.0 \n",
"Airway_Smooth_Muscle 6.0 0.0 0.0 0.0 \n",
"Perichondrium 2.0 0.0 0.0 0.0 \n",
"Weird_morphology 17.0 0.0 0.0 3.0 \n",
"\n",
" Cartilage Multilayer_epithelium Nerve \\\n",
"Others 4.0 2.0 5.0 \n",
"Arterial_vessel 0.0 0.0 0.0 \n",
"Venous_vessel 0.0 0.0 0.0 \n",
"Glands 0.0 0.0 0.0 \n",
"Cartilage 9.0 0.0 0.0 \n",
"Multilayer_epithelium 0.0 6.0 0.0 \n",
"Nerve 0.0 0.0 5.0 \n",
"Airway_Smooth_Muscle 0.0 8.0 0.0 \n",
"Perichondrium 3.0 0.0 0.0 \n",
"Weird_morphology 0.0 0.0 3.0 \n",
"\n",
" Airway_Smooth_Muscle Perichondrium Weird_morphology \n",
"Others 7.0 3.0 17.0 \n",
"Arterial_vessel 0.0 0.0 0.0 \n",
"Venous_vessel 0.0 0.0 1.0 \n",
"Glands 1.0 0.0 0.0 \n",
"Cartilage 0.0 1.0 0.0 \n",
"Multilayer_epithelium 0.0 0.0 0.0 \n",
"Nerve 0.0 0.0 1.0 \n",
"Airway_Smooth_Muscle 8.0 0.0 0.0 \n",
"Perichondrium 0.0 3.0 0.0 \n",
"Weird_morphology 1.0 0.0 28.0 "
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"LRP_CellTypeLevel_edge_num"
]
},
{
"cell_type": "code",
"execution_count": 47,
"id": "0171b6f3",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:57:02.784671Z",
"start_time": "2024-04-11T05:57:02.780233Z"
}
},
"outputs": [],
"source": [
"## Read the number of LRPs that occur between cell types\n",
"LRP_number_CellTypeLevel = pd.DataFrame(adata_sp311_stringent.uns['LR_celltype_aggregate_weight']['count'],\n",
" index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "27f8c01e",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:57:03.532467Z",
"start_time": "2024-04-11T05:57:03.498784Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Others | \n",
" Arterial_vessel | \n",
" Venous_vessel | \n",
" Glands | \n",
" Cartilage | \n",
" Multilayer_epithelium | \n",
" Nerve | \n",
" Airway_Smooth_Muscle | \n",
" Perichondrium | \n",
" Weird_morphology | \n",
"
\n",
" \n",
" \n",
" \n",
" | Others | \n",
" 1025.0 | \n",
" 563.0 | \n",
" 313.0 | \n",
" 875.0 | \n",
" 413.0 | \n",
" 768.0 | \n",
" 487.0 | \n",
" 770.0 | \n",
" 587.0 | \n",
" 598.0 | \n",
"
\n",
" \n",
" | Arterial_vessel | \n",
" 540.0 | \n",
" 686.0 | \n",
" 0.0 | \n",
" 4.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 6.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 98.0 | \n",
"
\n",
" \n",
" | Venous_vessel | \n",
" 290.0 | \n",
" 0.0 | \n",
" 482.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 159.0 | \n",
"
\n",
" \n",
" | Glands | \n",
" 895.0 | \n",
" 4.0 | \n",
" 0.0 | \n",
" 1007.0 | \n",
" 37.0 | \n",
" 130.0 | \n",
" 177.0 | \n",
" 384.0 | \n",
" 370.0 | \n",
" 277.0 | \n",
"
\n",
" \n",
" | Cartilage | \n",
" 411.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 80.0 | \n",
" 839.0 | \n",
" 0.0 | \n",
" 22.0 | \n",
" 0.0 | \n",
" 491.0 | \n",
" 38.0 | \n",
"
\n",
" \n",
" | Multilayer_epithelium | \n",
" 805.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 116.0 | \n",
" 0.0 | \n",
" 880.0 | \n",
" 0.0 | \n",
" 707.0 | \n",
" 2.0 | \n",
" 3.0 | \n",
"
\n",
" \n",
" | Nerve | \n",
" 476.0 | \n",
" 18.0 | \n",
" 7.0 | \n",
" 157.0 | \n",
" 18.0 | \n",
" 0.0 | \n",
" 567.0 | \n",
" 0.0 | \n",
" 13.0 | \n",
" 323.0 | \n",
"
\n",
" \n",
" | Airway_Smooth_Muscle | \n",
" 768.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 335.0 | \n",
" 0.0 | \n",
" 646.0 | \n",
" 0.0 | \n",
" 861.0 | \n",
" 0.0 | \n",
" 73.0 | \n",
"
\n",
" \n",
" | Perichondrium | \n",
" 629.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 380.0 | \n",
" 481.0 | \n",
" 10.0 | \n",
" 32.0 | \n",
" 0.0 | \n",
" 720.0 | \n",
" 92.0 | \n",
"
\n",
" \n",
" | Weird_morphology | \n",
" 636.0 | \n",
" 197.0 | \n",
" 191.0 | \n",
" 305.0 | \n",
" 43.0 | \n",
" 3.0 | \n",
" 321.0 | \n",
" 126.0 | \n",
" 114.0 | \n",
" 664.0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Others Arterial_vessel Venous_vessel Glands \\\n",
"Others 1025.0 563.0 313.0 875.0 \n",
"Arterial_vessel 540.0 686.0 0.0 4.0 \n",
"Venous_vessel 290.0 0.0 482.0 0.0 \n",
"Glands 895.0 4.0 0.0 1007.0 \n",
"Cartilage 411.0 0.0 0.0 80.0 \n",
"Multilayer_epithelium 805.0 0.0 0.0 116.0 \n",
"Nerve 476.0 18.0 7.0 157.0 \n",
"Airway_Smooth_Muscle 768.0 0.0 0.0 335.0 \n",
"Perichondrium 629.0 0.0 0.0 380.0 \n",
"Weird_morphology 636.0 197.0 191.0 305.0 \n",
"\n",
" Cartilage Multilayer_epithelium Nerve \\\n",
"Others 413.0 768.0 487.0 \n",
"Arterial_vessel 0.0 0.0 6.0 \n",
"Venous_vessel 0.0 0.0 0.0 \n",
"Glands 37.0 130.0 177.0 \n",
"Cartilage 839.0 0.0 22.0 \n",
"Multilayer_epithelium 0.0 880.0 0.0 \n",
"Nerve 18.0 0.0 567.0 \n",
"Airway_Smooth_Muscle 0.0 646.0 0.0 \n",
"Perichondrium 481.0 10.0 32.0 \n",
"Weird_morphology 43.0 3.0 321.0 \n",
"\n",
" Airway_Smooth_Muscle Perichondrium Weird_morphology \n",
"Others 770.0 587.0 598.0 \n",
"Arterial_vessel 0.0 0.0 98.0 \n",
"Venous_vessel 0.0 0.0 159.0 \n",
"Glands 384.0 370.0 277.0 \n",
"Cartilage 0.0 491.0 38.0 \n",
"Multilayer_epithelium 707.0 2.0 3.0 \n",
"Nerve 0.0 13.0 323.0 \n",
"Airway_Smooth_Muscle 861.0 0.0 73.0 \n",
"Perichondrium 0.0 720.0 92.0 \n",
"Weird_morphology 126.0 114.0 664.0 "
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"LRP_number_CellTypeLevel"
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "a541f3e5",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:57:04.167691Z",
"start_time": "2024-04-11T05:57:04.139439Z"
}
},
"outputs": [],
"source": [
"## Read the CCC score of a pathway at the cell/spot level\n",
"Pathway_CellLevel_CCCscore = pd.DataFrame(adata_sp311_stringent.uns['LR_pathway_cell_weight']['CCL'].toarray(),\n",
" index=adata_sp311_stringent.obs.index, columns=adata_sp311_stringent.obs.index\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "1cb39076",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:57:25.223284Z",
"start_time": "2024-04-11T05:57:25.175201Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | spot_id | \n",
" WSA_LngSP8759311_AAACAAGTATCTCCCA-1 | \n",
" WSA_LngSP8759311_AAACAGAGCGACTCCT-1 | \n",
" WSA_LngSP8759311_AAACATTTCCCGGATT-1 | \n",
" WSA_LngSP8759311_AAACCCGAACGAAATC-1 | \n",
" WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 | \n",
" WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 | \n",
" WSA_LngSP8759311_AAACGAAGAACATACC-1 | \n",
" WSA_LngSP8759311_AAACGAGACGGTTGAT-1 | \n",
" WSA_LngSP8759311_AAACGGGCGTACGGGT-1 | \n",
" WSA_LngSP8759311_AAACGGTTGCGAACTG-1 | \n",
"
\n",
" \n",
" | spot_id | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | WSA_LngSP8759311_AAACAAGTATCTCCCA-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACAGAGCGACTCCT-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACATTTCCCGGATT-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACCCGAACGAAATC-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACGAAGAACATACC-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACGAGACGGTTGAT-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACGGGCGTACGGGT-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACGGTTGCGAACTG-1 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
"spot_id WSA_LngSP8759311_AAACAAGTATCTCCCA-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACAGAGCGACTCCT-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACATTTCCCGGATT-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACCCGAACGAAATC-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACGAAGAACATACC-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACGAGACGGTTGAT-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACGGGCGTACGGGT-1 \\\n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 \n",
"\n",
"spot_id WSA_LngSP8759311_AAACGGTTGCGAACTG-1 \n",
"spot_id \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 \n",
"WSA_LngSP8759311_AAACCTAAGCAGCCGG-1 0.0 \n",
"WSA_LngSP8759311_AAACGAAGAACATACC-1 0.0 \n",
"WSA_LngSP8759311_AAACGAGACGGTTGAT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGGCGTACGGGT-1 0.0 \n",
"WSA_LngSP8759311_AAACGGTTGCGAACTG-1 0.0 "
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Pathway_CellLevel_CCCscore.iloc[:10,:10]"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "7a8a4e80",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T02:45:25.233196Z",
"start_time": "2024-04-11T02:45:25.226359Z"
}
},
"outputs": [],
"source": [
"## Read the CCC score of a pathway at the cell type level\n",
"Pathway_CellTypeLevel_wight = pd.DataFrame(adata_sp311_stringent.uns['LR_pathway_celltype_weight']['CCL'],\n",
" index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']\n",
" )\n",
"Pathway_CellTypeLevel_mean_weight = pd.DataFrame(adata_sp311_stringent.uns['LR_pathway_celltype_mean_weight']['CCL'],\n",
" index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']\n",
" )\n",
"Pathway_CellTypeLevel_edge_num = pd.DataFrame(adata_sp311_stringent.uns['LR_pathway_celltype_edge_num']['CCL'],\n",
" index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']\n",
" )\n",
"Pathway_CellTypeLevel_count = pd.DataFrame(adata_sp311_stringent.uns['LR_pathway_celltype_count']['CCL'],\n",
" index=adata_sp311_stringent.uns['cell_type_list'], columns=adata_sp311_stringent.uns['cell_type_list']\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "f0c573ee",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T02:46:20.179100Z",
"start_time": "2024-04-11T02:46:20.175133Z"
}
},
"outputs": [],
"source": [
"## Read all Scenic result\n",
"Scenic_result = adata_sp311_stringent.uns['scenic_res']"
]
},
{
"cell_type": "code",
"execution_count": 54,
"id": "95e6feec",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T05:57:45.268624Z",
"start_time": "2024-04-11T05:57:45.245568Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | Regulon | \n",
" ATF2(+) | \n",
" ATF4(+) | \n",
" ATF5(+) | \n",
" CEBPB(+) | \n",
" CLOCK(+) | \n",
" DLX5(+) | \n",
" E2F1(+) | \n",
" E2F3(+) | \n",
" E2F4(+) | \n",
" EGR1(+) | \n",
" ... | \n",
" THRA(+) | \n",
" THRB(+) | \n",
" TP53(+) | \n",
" TWIST1(+) | \n",
" XBP1(+) | \n",
" ZFHX3(+) | \n",
" ZNF398(+) | \n",
" ZNF430(+) | \n",
" ZNF587(+) | \n",
" ZNF611(+) | \n",
"
\n",
" \n",
" | Cell | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | WSA_LngSP8759311_AAACAAGTATCTCCCA-1 | \n",
" 0.108328 | \n",
" 0.093427 | \n",
" 0.069433 | \n",
" 0.012242 | \n",
" 0.011166 | \n",
" 0.0 | \n",
" 0.014957 | \n",
" 0.029883 | \n",
" 0.008086 | \n",
" 0.017228 | \n",
" ... | \n",
" 0.009210 | \n",
" 0.014643 | \n",
" 0.011487 | \n",
" 0.073802 | \n",
" 0.036905 | \n",
" 0.006195 | \n",
" 0.085418 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACAGAGCGACTCCT-1 | \n",
" 0.000000 | \n",
" 0.074548 | \n",
" 0.006270 | \n",
" 0.021819 | \n",
" 0.011246 | \n",
" 0.0 | \n",
" 0.020478 | \n",
" 0.003840 | \n",
" 0.010671 | \n",
" 0.025917 | \n",
" ... | \n",
" 0.004947 | \n",
" 0.061523 | \n",
" 0.031192 | \n",
" 0.029992 | \n",
" 0.043080 | \n",
" 0.034313 | \n",
" 0.034427 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.038396 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACATTTCCCGGATT-1 | \n",
" 0.000000 | \n",
" 0.100603 | \n",
" 0.025635 | \n",
" 0.045186 | \n",
" 0.009883 | \n",
" 0.0 | \n",
" 0.017017 | \n",
" 0.000473 | \n",
" 0.006903 | \n",
" 0.031353 | \n",
" ... | \n",
" 0.031014 | \n",
" 0.000000 | \n",
" 0.009068 | \n",
" 0.011124 | \n",
" 0.093036 | \n",
" 0.006681 | \n",
" 0.037972 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACCCGAACGAAATC-1 | \n",
" 0.001860 | \n",
" 0.124458 | \n",
" 0.018883 | \n",
" 0.063018 | \n",
" 0.023382 | \n",
" 0.0 | \n",
" 0.026290 | \n",
" 0.006872 | \n",
" 0.012462 | \n",
" 0.024987 | \n",
" ... | \n",
" 0.012721 | \n",
" 0.000000 | \n",
" 0.035857 | \n",
" 0.045622 | \n",
" 0.034919 | \n",
" 0.044688 | \n",
" 0.052010 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.000000 | \n",
"
\n",
" \n",
" | WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 | \n",
" 0.000000 | \n",
" 0.142454 | \n",
" 0.000000 | \n",
" 0.011417 | \n",
" 0.028632 | \n",
" 0.0 | \n",
" 0.015208 | \n",
" 0.025063 | \n",
" 0.006036 | \n",
" 0.022820 | \n",
" ... | \n",
" 0.017319 | \n",
" 0.000000 | \n",
" 0.012471 | \n",
" 0.007040 | \n",
" 0.038779 | \n",
" 0.024019 | \n",
" 0.063190 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.000000 | \n",
"
\n",
" \n",
"
\n",
"
5 rows × 102 columns
\n",
"
"
],
"text/plain": [
"Regulon ATF2(+) ATF4(+) ATF5(+) CEBPB(+) \\\n",
"Cell \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.108328 0.093427 0.069433 0.012242 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.000000 0.074548 0.006270 0.021819 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.000000 0.100603 0.025635 0.045186 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.001860 0.124458 0.018883 0.063018 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.000000 0.142454 0.000000 0.011417 \n",
"\n",
"Regulon CLOCK(+) DLX5(+) E2F1(+) E2F3(+) \\\n",
"Cell \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.011166 0.0 0.014957 0.029883 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.011246 0.0 0.020478 0.003840 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.009883 0.0 0.017017 0.000473 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.023382 0.0 0.026290 0.006872 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.028632 0.0 0.015208 0.025063 \n",
"\n",
"Regulon E2F4(+) EGR1(+) ... THRA(+) \\\n",
"Cell ... \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.008086 0.017228 ... 0.009210 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.010671 0.025917 ... 0.004947 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.006903 0.031353 ... 0.031014 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.012462 0.024987 ... 0.012721 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.006036 0.022820 ... 0.017319 \n",
"\n",
"Regulon THRB(+) TP53(+) TWIST1(+) XBP1(+) \\\n",
"Cell \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.014643 0.011487 0.073802 0.036905 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.061523 0.031192 0.029992 0.043080 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.000000 0.009068 0.011124 0.093036 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.000000 0.035857 0.045622 0.034919 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.000000 0.012471 0.007040 0.038779 \n",
"\n",
"Regulon ZFHX3(+) ZNF398(+) ZNF430(+) \\\n",
"Cell \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.006195 0.085418 0.0 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.034313 0.034427 0.0 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.006681 0.037972 0.0 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.044688 0.052010 0.0 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.024019 0.063190 0.0 \n",
"\n",
"Regulon ZNF587(+) ZNF611(+) \n",
"Cell \n",
"WSA_LngSP8759311_AAACAAGTATCTCCCA-1 0.0 0.000000 \n",
"WSA_LngSP8759311_AAACAGAGCGACTCCT-1 0.0 0.038396 \n",
"WSA_LngSP8759311_AAACATTTCCCGGATT-1 0.0 0.000000 \n",
"WSA_LngSP8759311_AAACCCGAACGAAATC-1 0.0 0.000000 \n",
"WSA_LngSP8759311_AAACCGTTCGTCCAGG-1 0.0 0.000000 \n",
"\n",
"[5 rows x 102 columns]"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Scenic_result['auc_mtx'].head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "39145a36",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "stcase_tmp1",
"language": "python",
"name": "stcase_tmp1"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
}
},
"nbformat": 4,
"nbformat_minor": 5
}