Python Logo

Contents:

  • Installation guide
  • Tutorials
    • Basic usage
      • Train DECIPHER model
      • Train DECIPHER model with multi-slices
      • Identify cells’ localization related Ligand-receptor pairs
        • Step 1: Check data
        • Step 2: Run DECIPHER
        • Step 3: Find localization related ligand-receptor pairs
        • Step 4: Visualize the results
      • Other technologies
    • Advanced topics
  • API documentation
  • Release notes
  • Credits
Python
  • Tutorials
  • Identify cells’ localization related Ligand-receptor pairs
  • View page source

Identify cells’ localization related Ligand-receptor pairs

(Estimated time: ~50 min with single GPU)

We shows how to identity cell localization related ligand-receptor pairs via decipher’s disentangled embeddings.

[ ]:
import scanpy as sc
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

from decipher import DECIPHER, CFG
[ ]:
# We modify the default configuration to set k=10 for spatial graph construction
CFG.omics.spatial_graph.k = 10

Step 1: Check data

We use a Lymph Node (LN) dataset captured by 10x Xenium 5k panel, which covers most of important ligan-receptor pairs. You can download the data from Google Drive.

[2]:
adata = sc.read_h5ad("./lymph_node_mini.h5ad")
[22]:
sc.pl.spatial(adata, color="cell_type", spot_size=6)
../_images/tutorials_3-select_LRs_5_0.png

Step 2: Run DECIPHER

[ ]:
model = DECIPHER(work_dir="./decipher_find_lr", overwrite=True)
model.register_data(adata, cell_type="cell_type")
model.fit_omics()
2024-11-03 22:04:07.371 | SUCCESS  | decipher.utils:global_seed:347 - Global seed set to 0.
2024-11-03 22:04:07.475 | DEBUG    | decipher.data.process:omics_data_process:68 - adata 0 has 708983 cells, 4624 genes.
2024-11-03 22:04:07.482 | INFO     | decipher.data.process:omics_data_process:86 - Input: 1 slice(s) with 708983 cells and 1 batches.
2024-11-03 22:04:07.483 | INFO     | decipher.data.process:_preprocess_adata:98 - Preprocessing 708983 cells.
/flash/grp/gglab/xiacr/DECIPHER-dev/conda/lib/python3.11/site-packages/scanpy/preprocessing/_normalization.py:234: UserWarning: Some cells have zero counts
  warn(UserWarning("Some cells have zero counts"))
WARNING: adata.X seems to be already log-transformed.
/flash/grp/gglab/xiacr/DECIPHER-dev/conda/lib/python3.11/site-packages/scanpy/preprocessing/_scale.py:318: UserWarning: Received a view of an AnnData. Making a copy.
  view_to_actual(adata)
2024-11-03 22:06:29.603 | SUCCESS  | decipher.data.process:_preprocess_adata:148 - Preprocessing finished in 142.12 seconds.
2024-11-03 22:06:49.407 | SUCCESS  | decipher.graphic.build:build_graph:102 - Built knn graph with 708983 nodes and 7089830 edges, 10.00 edges/node.

Step 3: Find localization related ligand-receptor pairs

Then we find localization related ligand-receptor pairs based on DECIPHER embeddings. First, we need load ligand-receptor pairs information from CellChatDB. You can download the file from here.

[24]:
adata = sc.read_h5ad("./lymph_node_mini.h5ad")  # need reload the data
lr = pd.read_csv('./cellchat.csv')

Then we focus on the localization related ligand-receptor pairs of B cells.

[25]:
model.train_gene_select(
    adata,
    cell_type='cell_type',
    subsets=['Bcell'],
    lr_mode=True,
    lr_data=lr,
    lr_radius=20,
    user_cfg=dict(gae_epochs = 100, lr_base = 0.01),
    n_jobs = 1
)
2024-11-03 23:26:19.506 | DEBUG    | decipher.explain.gene.mixin:train_gene_select:89 - Gene select config: {'k': 30, 'lr_base': 0.01, 'l1_weight': 1.0, 'gae_epochs': 100, 'test_ratio': 0.3, 'gumbel_threshold': 0.5, 'num_neighbors': [-1], 'fit': {'device': 'auto', 'select_gpu': True, 'device_num': 1, 'fp16': True, 'patient': 100, 'log_every_n_steps': 1, 'gradient_clip_val': 0, 'check_val_every_n_epoch': 1, 'max_steps': 10000, 'epochs': 300}, 'loader': {'batch_size': 32, 'shuffle': True, 'num_workers': 8, 'drop_last': True, 'pin_memory': True}, 'select_gpu': False, 'center_dim': 128, 'nbr_dim': 32, 'work_dir': 'decipher_find_lr/explain'}
/flash/grp/gglab/xiacr/DECIPHER-dev/conda/lib/python3.11/site-packages/scanpy/preprocessing/_normalization.py:234: UserWarning: Some cells have zero counts
  warn(UserWarning("Some cells have zero counts"))
2024-11-03 23:26:21.335 | INFO     | decipher.explain.gene.mixin:train_gene_select:99 - Run in Ligand-Receptor mode
2024-11-03 23:26:32.313 | INFO     | decipher.explain.gene.lr:get_lr_expr:77 - Find 704 LR-related genes.
/flash/grp/gglab/xiacr/DECIPHER-dev/decipher/utils.py:370: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  x, y = torch.tensor(x, dtype=torch.float), torch.tensor(y, dtype=torch.float)
2024-11-03 23:26:34.752 | SUCCESS  | decipher.graphic.build:build_graph:102 - Built radius graph with 708983 nodes and 21585674 edges, 30.45 edges/node.
2024-11-03 23:26:34.810 | INFO     | decipher.graphic.build:build_graph:107 - Mean number of neighbors: 30.45
2024-11-03 23:26:34.814 | INFO     | decipher.graphic.build:build_graph:108 - Max number of neighbors: 56.0
2024-11-03 23:26:34.815 | INFO     | decipher.graphic.build:build_graph:109 - Min number of neighbors: 0.0
2024-11-03 23:26:34.821 | INFO     | decipher.graphic.build:build_graph:110 - Median number of neighbors: 31.0
2024-11-03 23:26:34.828 | INFO     | decipher.graphic.build:build_graph:113 - 5.0th percentile of number of neighbors: 19.0
2024-11-03 23:26:34.835 | INFO     | decipher.graphic.build:build_graph:113 - 25.0th percentile of number of neighbors: 27.0
2024-11-03 23:26:34.845 | INFO     | decipher.graphic.build:build_graph:113 - 75.0th percentile of number of neighbors: 35.0
2024-11-03 23:26:34.856 | INFO     | decipher.graphic.build:build_graph:113 - 95.0th percentile of number of neighbors: 39.0
2024-11-03 23:26:54.534 | INFO     | decipher.explain.gene.mixin:train_gene_select:117 - Run on 1 cell types: ['Bcell']
2024-11-03 23:26:54.546 | DEBUG    | decipher.graphic.knn:knn:61 - Use cuml to compute KNN graph.
2024-11-03 23:26:59,823 INFO worker.py:1777 -- Started a local Ray instance. View the dashboard at http://127.0.0.1:8265 
2024-11-03 23:27:01.189 | DEBUG    | decipher.explain.gene.gene_selection:train_GAE_whole:196 - Train GAE with fp16
2024-11-03 23:27:05.660 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 0: Loss: 6.8750, Recon: 6.3125, L1: 0.5586
2024-11-03 23:27:05.953 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5255, AP: 0.5233

2024-11-03 23:27:08.838 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 1: Loss: 3.4531, Recon: 3.1250, L1: 0.3223
2024-11-03 23:27:09.079 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5286, AP: 0.5269

2024-11-03 23:27:12.020 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 2: Loss: 3.3906, Recon: 3.2188, L1: 0.1699
2024-11-03 23:27:12.240 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5387, AP: 0.5339

2024-11-03 23:27:15.104 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 3: Loss: 4.1250, Recon: 4.0312, L1: 0.0967
2024-11-03 23:27:15.335 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5461, AP: 0.5387

2024-11-03 23:27:18.282 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 4: Loss: 5.0938, Recon: 5.0312, L1: 0.0654
2024-11-03 23:27:18.515 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5499, AP: 0.5404

2024-11-03 23:27:21.441 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 5: Loss: 6.0625, Recon: 6.0000, L1: 0.0513
2024-11-03 23:27:21.667 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5524, AP: 0.5415

2024-11-03 23:27:24.530 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 6: Loss: 7.0000, Recon: 6.9688, L1: 0.0439
2024-11-03 23:27:24.762 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5542, AP: 0.5421

2024-11-03 23:27:27.619 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 7: Loss: 7.8125, Recon: 7.7812, L1: 0.0396
2024-11-03 23:27:27.853 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5555, AP: 0.5427

2024-11-03 23:27:30.701 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 8: Loss: 8.3750, Recon: 8.3125, L1: 0.0364
2024-11-03 23:27:30.934 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5565, AP: 0.5431

2024-11-03 23:27:33.746 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 9: Loss: 8.6875, Recon: 8.6250, L1: 0.0337
2024-11-03 23:27:33.978 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5572, AP: 0.5434

2024-11-03 23:27:36.822 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 10: Loss: 8.8750, Recon: 8.8125, L1: 0.0315
2024-11-03 23:27:37.059 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5581, AP: 0.5437

2024-11-03 23:27:39.881 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 11: Loss: 8.8125, Recon: 8.8125, L1: 0.0297
2024-11-03 23:27:40.118 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5593, AP: 0.5443

2024-11-03 23:27:42.935 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 12: Loss: 8.7500, Recon: 8.7500, L1: 0.0280
2024-11-03 23:27:43.173 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5598, AP: 0.5446

2024-11-03 23:27:46.028 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 13: Loss: 8.6250, Recon: 8.6250, L1: 0.0264
2024-11-03 23:27:46.258 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5608, AP: 0.5451

2024-11-03 23:27:49.093 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 14: Loss: 8.4375, Recon: 8.4375, L1: 0.0250
2024-11-03 23:27:49.327 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5615, AP: 0.5453

2024-11-03 23:27:52.163 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 15: Loss: 8.2500, Recon: 8.2500, L1: 0.0237
2024-11-03 23:27:52.397 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5622, AP: 0.5458

2024-11-03 23:27:55.247 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 16: Loss: 8.0625, Recon: 8.0625, L1: 0.0226
2024-11-03 23:27:55.474 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5624, AP: 0.5459

2024-11-03 23:27:58.332 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 17: Loss: 7.9062, Recon: 7.8750, L1: 0.0215
2024-11-03 23:27:58.566 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5629, AP: 0.5461

2024-11-03 23:28:01.373 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 18: Loss: 7.7500, Recon: 7.7188, L1: 0.0206
2024-11-03 23:28:01.598 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5634, AP: 0.5464

2024-11-03 23:28:04.393 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 19: Loss: 7.5938, Recon: 7.5625, L1: 0.0198
2024-11-03 23:28:04.619 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5634, AP: 0.5464

2024-11-03 23:28:07.461 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 20: Loss: 7.5000, Recon: 7.4688, L1: 0.0189
2024-11-03 23:28:07.688 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5638, AP: 0.5467

2024-11-03 23:28:10.550 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 21: Loss: 7.3750, Recon: 7.3438, L1: 0.0183
2024-11-03 23:28:10.779 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5640, AP: 0.5467

2024-11-03 23:28:13.666 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 22: Loss: 7.3125, Recon: 7.2812, L1: 0.0176
2024-11-03 23:28:13.901 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5640, AP: 0.5467

2024-11-03 23:28:16.744 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 23: Loss: 7.2500, Recon: 7.2188, L1: 0.0171
2024-11-03 23:28:16.966 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5642, AP: 0.5467

2024-11-03 23:28:19.767 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 24: Loss: 7.2188, Recon: 7.1875, L1: 0.0166
2024-11-03 23:28:19.988 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5643, AP: 0.5467

2024-11-03 23:28:22.842 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 25: Loss: 7.2188, Recon: 7.1875, L1: 0.0161
2024-11-03 23:28:23.076 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5647, AP: 0.5469

2024-11-03 23:28:25.928 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 26: Loss: 7.2188, Recon: 7.1875, L1: 0.0157
2024-11-03 23:28:26.159 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5649, AP: 0.5470

2024-11-03 23:28:29.047 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 27: Loss: 7.2500, Recon: 7.2500, L1: 0.0154
2024-11-03 23:28:29.274 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5650, AP: 0.5470

2024-11-03 23:28:32.148 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 28: Loss: 7.2812, Recon: 7.2812, L1: 0.0151
2024-11-03 23:28:32.379 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5652, AP: 0.5471

2024-11-03 23:28:35.245 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 29: Loss: 7.3438, Recon: 7.3438, L1: 0.0148
2024-11-03 23:28:35.468 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5653, AP: 0.5470

2024-11-03 23:28:38.352 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 30: Loss: 7.4062, Recon: 7.4062, L1: 0.0145
2024-11-03 23:28:38.579 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5655, AP: 0.5470

2024-11-03 23:28:41.401 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 31: Loss: 7.4375, Recon: 7.4375, L1: 0.0143
2024-11-03 23:28:41.635 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5655, AP: 0.5469

2024-11-03 23:28:44.442 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 32: Loss: 7.5312, Recon: 7.5312, L1: 0.0141
2024-11-03 23:28:44.667 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5657, AP: 0.5470

2024-11-03 23:28:47.509 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 33: Loss: 7.5938, Recon: 7.5938, L1: 0.0139
2024-11-03 23:28:47.733 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5658, AP: 0.5469

2024-11-03 23:28:50.549 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 34: Loss: 7.6250, Recon: 7.6250, L1: 0.0137
2024-11-03 23:28:50.775 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5659, AP: 0.5469

2024-11-03 23:28:53.570 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 35: Loss: 7.6875, Recon: 7.6875, L1: 0.0135
2024-11-03 23:28:53.791 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5660, AP: 0.5469

2024-11-03 23:28:56.684 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 36: Loss: 7.7188, Recon: 7.7188, L1: 0.0134
2024-11-03 23:28:56.911 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5660, AP: 0.5469

2024-11-03 23:28:59.723 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 37: Loss: 7.8125, Recon: 7.8125, L1: 0.0132
2024-11-03 23:28:59.953 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5661, AP: 0.5469

2024-11-03 23:29:02.832 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 38: Loss: 7.7812, Recon: 7.7812, L1: 0.0131
2024-11-03 23:29:03.056 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5663, AP: 0.5469

2024-11-03 23:29:05.875 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 39: Loss: 7.8125, Recon: 7.8125, L1: 0.0129
2024-11-03 23:29:06.100 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5660, AP: 0.5466

2024-11-03 23:29:08.922 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 40: Loss: 7.8125, Recon: 7.8125, L1: 0.0128
2024-11-03 23:29:09.151 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5661, AP: 0.5467

2024-11-03 23:29:11.980 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 41: Loss: 7.8125, Recon: 7.8125, L1: 0.0126
2024-11-03 23:29:12.208 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5663, AP: 0.5467

2024-11-03 23:29:15.066 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 42: Loss: 7.7812, Recon: 7.7812, L1: 0.0125
2024-11-03 23:29:15.289 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5662, AP: 0.5466

2024-11-03 23:29:18.109 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 43: Loss: 7.7812, Recon: 7.7812, L1: 0.0124
2024-11-03 23:29:18.329 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5663, AP: 0.5467

2024-11-03 23:29:21.213 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 44: Loss: 7.7500, Recon: 7.7500, L1: 0.0123
2024-11-03 23:29:21.443 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5664, AP: 0.5467

2024-11-03 23:29:24.272 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 45: Loss: 7.7188, Recon: 7.7188, L1: 0.0122
2024-11-03 23:29:24.500 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5666, AP: 0.5468

2024-11-03 23:29:27.360 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 46: Loss: 7.6875, Recon: 7.6875, L1: 0.0121
2024-11-03 23:29:27.583 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5667, AP: 0.5469

2024-11-03 23:29:30.424 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 47: Loss: 7.6562, Recon: 7.6562, L1: 0.0120
2024-11-03 23:29:30.650 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5666, AP: 0.5468

2024-11-03 23:29:33.421 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 48: Loss: 7.5938, Recon: 7.5938, L1: 0.0119
2024-11-03 23:29:33.643 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5668, AP: 0.5469

2024-11-03 23:29:36.457 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 49: Loss: 7.5938, Recon: 7.5938, L1: 0.0118
2024-11-03 23:29:36.680 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5667, AP: 0.5468

2024-11-03 23:29:39.479 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 50: Loss: 7.5625, Recon: 7.5625, L1: 0.0118
2024-11-03 23:29:39.706 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5668, AP: 0.5469

2024-11-03 23:29:42.503 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 51: Loss: 7.5312, Recon: 7.5312, L1: 0.0117
2024-11-03 23:29:42.726 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5670, AP: 0.5469

2024-11-03 23:29:45.585 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 52: Loss: 7.5312, Recon: 7.5312, L1: 0.0117
2024-11-03 23:29:45.822 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5670, AP: 0.5470

2024-11-03 23:29:48.699 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 53: Loss: 7.5000, Recon: 7.5000, L1: 0.0116
2024-11-03 23:29:48.918 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5670, AP: 0.5470

2024-11-03 23:29:51.711 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 54: Loss: 7.4688, Recon: 7.4688, L1: 0.0115
2024-11-03 23:29:51.933 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5670, AP: 0.5470

2024-11-03 23:29:54.797 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 55: Loss: 7.5000, Recon: 7.5000, L1: 0.0115
2024-11-03 23:29:55.027 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5669, AP: 0.5468

2024-11-03 23:29:57.845 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 56: Loss: 7.4688, Recon: 7.4688, L1: 0.0114
2024-11-03 23:29:58.070 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5673, AP: 0.5472

2024-11-03 23:30:00.917 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 57: Loss: 7.5000, Recon: 7.5000, L1: 0.0114
2024-11-03 23:30:01.144 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5671, AP: 0.5469

2024-11-03 23:30:04.011 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 58: Loss: 7.5000, Recon: 7.5000, L1: 0.0113
2024-11-03 23:30:04.240 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5673, AP: 0.5471

2024-11-03 23:30:07.076 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 59: Loss: 7.5000, Recon: 7.5000, L1: 0.0112
2024-11-03 23:30:07.302 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5672, AP: 0.5470

2024-11-03 23:30:10.177 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 60: Loss: 7.5625, Recon: 7.5625, L1: 0.0112
2024-11-03 23:30:10.402 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5673, AP: 0.5472

2024-11-03 23:30:13.259 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 61: Loss: 7.5938, Recon: 7.5938, L1: 0.0111
2024-11-03 23:30:13.485 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5672, AP: 0.5470

2024-11-03 23:30:16.335 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 62: Loss: 7.6250, Recon: 7.6250, L1: 0.0110
2024-11-03 23:30:16.561 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5673, AP: 0.5471

2024-11-03 23:30:19.417 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 63: Loss: 7.6562, Recon: 7.6562, L1: 0.0110
2024-11-03 23:30:19.638 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5675, AP: 0.5471

2024-11-03 23:30:22.476 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 64: Loss: 7.6562, Recon: 7.6562, L1: 0.0110
2024-11-03 23:30:22.697 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5675, AP: 0.5471

2024-11-03 23:30:25.544 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 65: Loss: 7.6875, Recon: 7.6875, L1: 0.0110
2024-11-03 23:30:25.770 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5677, AP: 0.5472

2024-11-03 23:30:28.602 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 66: Loss: 7.6875, Recon: 7.6875, L1: 0.0110
2024-11-03 23:30:28.827 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5677, AP: 0.5473

2024-11-03 23:30:31.641 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 67: Loss: 7.6875, Recon: 7.6875, L1: 0.0109
2024-11-03 23:30:31.873 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5676, AP: 0.5471

2024-11-03 23:30:34.702 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 68: Loss: 7.7188, Recon: 7.7188, L1: 0.0109
2024-11-03 23:30:34.933 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5674, AP: 0.5470

2024-11-03 23:30:37.795 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 69: Loss: 7.7188, Recon: 7.7188, L1: 0.0109
2024-11-03 23:30:38.023 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5675, AP: 0.5471

2024-11-03 23:30:40.862 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 70: Loss: 7.6562, Recon: 7.6562, L1: 0.0108
2024-11-03 23:30:41.088 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5676, AP: 0.5472

2024-11-03 23:30:43.912 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 71: Loss: 7.6562, Recon: 7.6562, L1: 0.0108
2024-11-03 23:30:44.139 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5675, AP: 0.5471

2024-11-03 23:30:46.952 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 72: Loss: 7.6250, Recon: 7.6250, L1: 0.0107
2024-11-03 23:30:47.176 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5675, AP: 0.5471

2024-11-03 23:30:50.016 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 73: Loss: 7.6250, Recon: 7.6250, L1: 0.0107
2024-11-03 23:30:50.238 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5676, AP: 0.5472

2024-11-03 23:30:53.102 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 74: Loss: 7.5625, Recon: 7.5625, L1: 0.0107
2024-11-03 23:30:53.329 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5676, AP: 0.5472

2024-11-03 23:30:56.176 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 75: Loss: 7.5312, Recon: 7.5312, L1: 0.0106
2024-11-03 23:30:56.401 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5679, AP: 0.5474

2024-11-03 23:30:59.214 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 76: Loss: 7.5312, Recon: 7.5312, L1: 0.0106
2024-11-03 23:30:59.441 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5676, AP: 0.5471

2024-11-03 23:31:02.262 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 77: Loss: 7.5312, Recon: 7.5312, L1: 0.0105
2024-11-03 23:31:02.487 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5677, AP: 0.5472

2024-11-03 23:31:05.328 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 78: Loss: 7.5000, Recon: 7.5000, L1: 0.0105
2024-11-03 23:31:05.553 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5676, AP: 0.5471

2024-11-03 23:31:08.350 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 79: Loss: 7.5000, Recon: 7.5000, L1: 0.0104
2024-11-03 23:31:08.580 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5678, AP: 0.5473

2024-11-03 23:31:11.417 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 80: Loss: 7.5312, Recon: 7.5312, L1: 0.0104
2024-11-03 23:31:11.646 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5676, AP: 0.5471

2024-11-03 23:31:14.509 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 81: Loss: 7.5312, Recon: 7.5312, L1: 0.0104
2024-11-03 23:31:14.731 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5675, AP: 0.5471

2024-11-03 23:31:17.547 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 82: Loss: 7.5312, Recon: 7.5312, L1: 0.0104
2024-11-03 23:31:17.771 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5676, AP: 0.5471

2024-11-03 23:31:20.610 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 83: Loss: 7.5625, Recon: 7.5625, L1: 0.0103
2024-11-03 23:31:20.838 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5677, AP: 0.5472

2024-11-03 23:31:23.665 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 84: Loss: 7.5625, Recon: 7.5625, L1: 0.0103
2024-11-03 23:31:23.895 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5677, AP: 0.5472

2024-11-03 23:31:26.742 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 85: Loss: 7.5625, Recon: 7.5625, L1: 0.0103
2024-11-03 23:31:26.966 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5678, AP: 0.5472

2024-11-03 23:31:29.793 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 86: Loss: 7.5938, Recon: 7.5938, L1: 0.0103
2024-11-03 23:31:30.016 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5677, AP: 0.5471

2024-11-03 23:31:32.825 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 87: Loss: 7.5625, Recon: 7.5625, L1: 0.0102
2024-11-03 23:31:33.048 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5676, AP: 0.5471

2024-11-03 23:31:35.869 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 88: Loss: 7.5938, Recon: 7.5938, L1: 0.0101
2024-11-03 23:31:36.092 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5676, AP: 0.5471

2024-11-03 23:31:38.902 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 89: Loss: 7.5938, Recon: 7.5938, L1: 0.0101
2024-11-03 23:31:39.126 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5677, AP: 0.5471

2024-11-03 23:31:41.964 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 90: Loss: 7.5938, Recon: 7.5938, L1: 0.0101
2024-11-03 23:31:42.193 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5678, AP: 0.5472

2024-11-03 23:31:44.998 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 91: Loss: 7.5938, Recon: 7.5938, L1: 0.0101
2024-11-03 23:31:45.223 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5678, AP: 0.5472

2024-11-03 23:31:48.097 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 92: Loss: 7.6250, Recon: 7.6250, L1: 0.0100
2024-11-03 23:31:48.319 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5677, AP: 0.5471

2024-11-03 23:31:51.120 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 93: Loss: 7.5938, Recon: 7.5938, L1: 0.0100
2024-11-03 23:31:51.340 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5679, AP: 0.5472

2024-11-03 23:31:54.195 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 94: Loss: 7.5938, Recon: 7.5938, L1: 0.0099
2024-11-03 23:31:54.421 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5678, AP: 0.5471

2024-11-03 23:31:57.214 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 95: Loss: 7.5938, Recon: 7.5938, L1: 0.0099
2024-11-03 23:31:57.443 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5678, AP: 0.5471

2024-11-03 23:32:00.279 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 96: Loss: 7.5625, Recon: 7.5625, L1: 0.0099
2024-11-03 23:32:00.507 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5678, AP: 0.5472

2024-11-03 23:32:03.329 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 97: Loss: 7.5625, Recon: 7.5625, L1: 0.0099
2024-11-03 23:32:03.555 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5680, AP: 0.5473

2024-11-03 23:32:06.355 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 98: Loss: 7.5312, Recon: 7.5312, L1: 0.0099
2024-11-03 23:32:06.578 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5679, AP: 0.5472

2024-11-03 23:32:09.398 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:239 - Epoch: 99: Loss: 7.5312, Recon: 7.5312, L1: 0.0099
2024-11-03 23:32:09.620 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:255 - Test: AUC: 0.5678, AP: 0.5472

2024-11-03 23:32:09.623 | SUCCESS  | decipher.explain.gene.gene_selection:train_GAE_whole:266 - Training finished in 306.91s
2024-11-03 23:32:09.631 | INFO     | decipher.explain.gene.gene_selection:train_GAE_whole:279 - Save explain model to decipher_find_lr/explain/select_celltype_Bcell
2024-11-03 23:32:12.121 | INFO     | decipher.explain.gene.mixin:train_gene_select:177 - Gene selection finished in 352.62s

Step 4: Visualize the results

At last, we get the top localization related ligand-receptor pairs found by model. Due to the randomness of optimization, the ranking of LRs may slightly differ from the results in our paper.

[26]:
gene_mask = np.load('./decipher_find_lr/explain/select_celltype_Bcell/gene_mask.npy')
lr_df = pd.read_csv('./decipher_find_lr/explain/lr.csv')

lr_df['counts'] = gene_mask.sum(0)
# sort by counts
lr_df = lr_df.sort_values('counts', ascending=False)
lr_df[['counts', 'interaction_name']].head(20)
lr_df['score'] = lr_df['counts'] / gene_mask.shape[0]
[27]:
# Bar plot of top 15 ligand-receptor pairs
sns.barplot(x='score', y='interaction_name', data=lr_df.head(15))
plt.ylabel('')
_ = plt.yticks(fontsize=9)
_ = plt.xticks(fontsize=9)
_ = plt.xlabel('Score', fontsize=10)
../_images/tutorials_3-select_LRs_14_0.png
Previous Next

© Copyright Gao Lab@2025.

Built with Sphinx using a theme provided by Read the Docs.