MetaChat is a Python package to screen metabolic cell communication (MCC) from spatial multi-omics data of transcriptomics and metabolomics. It contains many intuitive visualization and downstream analysis tools, provides a great practical toolbox for biomedical researchers.
Metabolic cell-cell communication (MCC) occurs when sensor proteins in the receiver cells detect metabolites in their environment, activating intracellular signaling events. There are three major potential sensors of metabolites: surface receptors, nuclear receptors, and transporters. Metabolites secreted from cells are either transported over short-range distances (a few cells) via diffusion through extracellular space, or over long-range distances via the bloodstream and the cerebrospinal fluid (CSF).
![image](https://private-user-images.githubusercontent.com/138028157/341170917-f08f21de-eeae-4626-8fbe-c26a307ec225.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMyMDkxMjIsIm5iZiI6MTcyMzIwODgyMiwicGF0aCI6Ii8xMzgwMjgxNTcvMzQxMTcwOTE3LWYwOGYyMWRlLWVlYWUtNDYyNi04ZmJlLWMyNmEzMDdlYzIyNS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwOVQxMzA3MDJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03ZTRkMjVhZGQ3NGZlOWYxYWI1NWZiYmRiM2FjNDJjZTI1Y2QzODQyNWRiOTM1Y2UyNTY4M2Q4NGFjNTczOTZiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.Yh0DP3I_dMtfAjYMPvKi9GogF1lSPhbR3dBQWj0Hlz4)
MetaChatDB is a literature-supported database for metabolite-sensor interactions for both human and mouse. All the metabolite-sensor interactions are reported based on peer-reviewed publications. Specifically, we manually build MetaChatDB by integrating three high-quality databases (PDB, HMDB, UniProt) that are being continually updated.
![image](https://private-user-images.githubusercontent.com/138028157/341172612-20e168c2-2409-47c4-881f-3b80d38326f3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMyMDkxMjIsIm5iZiI6MTcyMzIwODgyMiwicGF0aCI6Ii8xMzgwMjgxNTcvMzQxMTcyNjEyLTIwZTE2OGMyLTI0MDktNDdjNC04ODFmLTNiODBkMzgzMjZmMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwOVQxMzA3MDJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hN2IxZWMzMjdkNDdmMTUzMGFjMWVmZTMzODk1NDJmMDM3YmFjMTZiZTQ1OGQ0YzU5ZTE1NDFhNGM1NTY2NzYzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.ZM8wuR8SNVd3WRryE8LOjbw9uytvCJMD-19vpPM8jBk)
Recommended operating systems: macOS or Linux. MetaChat was developed and tested on Linux and macOS.
MetaChat was developed using python 3.9.
We suggest setting up MetaChat in a separate mamba
or conda
environment to prevent conflicts with other software dependencies. Create a new Python environment specifically for MetaChat and install the required libraries within it.
mamba create -n metachat_env python=3.9 r-base=4.3.2
mamba activate metachat_env
pip install metachat
if you use conda
, r-base=4.3.2
may not included in the channels. Instead, you can r-base=4.3.1
in conda
.
For more realistic and simulation examples, please see MetaChat documentation that is available through the link https://metachat.readthedocs.io/en/latest/.
Let's get a quick start on using metachat to infer MCC by using simulation data generated from a PDE dynamic model.
import os
import numpy as np
import pandas as pd
import scanpy as sc
import squidpy as sq
import matplotlib.pyplot as plt
import metachat as mc
To run the examples, you'll need to download the some pre-existing files in docs/tutorials/simulated_data
folder and change your working directory to the simulated_data
folder.
os.chdir("your_path/simulated_data")
adata = sc.read("data/example1/adata_example1.h5ad")
This dataset consists of a metabolite M1
and a sensor S1
. Their spatial distributions are shown below:
fig, ax = plt.subplots(1, 2, figsize = (8,4))
sq.pl.spatial_scatter(adata = adata, color = "M1", size = 80, cmap = "Blues", shape = None, ax = ax[0])
ax[0].invert_yaxis()
ax[0].set_box_aspect(1)
sq.pl.spatial_scatter(adata = adata, color = "S1", size = 80, cmap = "Reds", shape = None, ax = ax[1])
ax[1].invert_yaxis()
ax[1].set_box_aspect(1)
plt.show()
![Spatial Distributions](https://private-user-images.githubusercontent.com/138028157/342168013-7176aabd-7e3e-4439-9f9c-9b0346fd5da8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMyMDkxMjIsIm5iZiI6MTcyMzIwODgyMiwicGF0aCI6Ii8xMzgwMjgxNTcvMzQyMTY4MDEzLTcxNzZhYWJkLTdlM2UtNDQzOS05ZjljLTliMDM0NmZkNWRhOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwOVQxMzA3MDJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00ZTgzYWY0YTcxMmNkNWFjZjMxZmI2NTBmYmNjMjk1NTllNzA0MGFkNjU2MjJlODhmMDllYzFmMmVmNDNhOWZjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.d_TgHM1nr2UY5Z1LXPBUeNLXq6nXFUyTZLgGlmiOJl8)
Import the pre-defined long range channel and add it to the adata
object.
LRC_channel = np.load('data/example1/LRC_channel.npy')
adata.obs['LRC_type1_filtered'] = LRC_channel.flatten()
adata.obs['LRC_type1_filtered'] = adata.obs['LRC_type1_filtered'].astype('category')
It's spatial distribution are shown in orange color:
fig, ax = plt.subplots(figsize = (3,3))
sq.pl.spatial_scatter(adata = adata, color = "LRC_type1_filtered", size = 80, shape = None, ax = ax)
ax.invert_yaxis()
ax.set_box_aspect(1)
plt.show()
![Spatial Distributions](https://private-user-images.githubusercontent.com/138028157/342168780-c7cc5dbd-1725-4726-a973-8555cf4f6ad0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMyMDkxMjIsIm5iZiI6MTcyMzIwODgyMiwicGF0aCI6Ii8xMzgwMjgxNTcvMzQyMTY4NzgwLWM3Y2M1ZGJkLTE3MjUtNDcyNi1hOTczLTg1NTVjZjRmNmFkMC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwOVQxMzA3MDJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hYjUxZTAxMjkwYjM3ZjJjNTk0NTkxZjg4MTBhOTczZDExMjFlMDdhYzhiYTE4NmVmZjljMGMwMDFiZTM1NGQ4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.ynxNa63WK93qAS_qfZliVD2_ysEQ99t813pji4Cw9QU)
We need to artificially create a simple database which must include three columns: 'Metabolite', 'Sensor', 'Long.Range.Channel', representing the metabolite name, the sensor name, and the type of long range channel that metabolites may be entered, respectively.
In this example, we assume that the metabolite M1
can communicate with proximal cells by short-range diffusion and with distal cells by long-range channel transport (type1
).
M_S_pair = [['M1', 'S1', 'type1']]
df_metasen = pd.DataFrame(M_S_pair)
df_metasen.columns = ['Metabolite', 'Sensor', 'Long.Range.Channel']
To utilize flow-optimal transport, we need to compute the cost matrix depends mainly on two parameters:maximum communication distance (dis_thr
) and long-range communication strength (LRC_strength
).
mc.pp.compute_costDistance(adata = adata,
LRC_type = ["type1"],
dis_thr = 10,
k_neighb = 5,
LRC_strength = 4,
plot = True,
spot_size = 1)
mc.tl.metabolic_communication(adata = adata,
database_name = 'msdb_example1',
df_metasen = df_metasen,
LRC_type = ["type1"],
dis_thr = 15,
fot_weights = (1.0,0.0,0.0,0.0),
fot_eps_p = 0.25,
fot_rho = 1.0,
cost_type = 'euc')
Comparative results showed that the distribution of M1-S1 inferred by MetaChat had a high correlation with that simulated by the PDE model.
MCC_PDE = np.load('data/example1/pde_result.npy')
MCC_infer = adata.obsm['MetaChat-msdb_example1-sum-receiver']['r-M1-S1'].values.reshape(50,50)
fig, ax = plt.subplots(1,2, figsize = (7,14))
ax[0].imshow(MCC_PDE[2].T, cmap='viridis', origin='lower')
ax[0].set_xlabel('x')
ax[0].set_ylabel('y')
ax[0].set_title('M1-S1 distribution from PDE')
ax[0].set_box_aspect(1)
ax[1].imshow(MCC_infer.T, cmap='viridis', origin='lower')
ax[1].set_xlabel('x')
ax[1].set_ylabel('y')
ax[1].set_title('M1-S1 distribution with LRC')
ax[1].set_box_aspect(1)
plt.tight_layout()
![Spatial Distributions](https://private-user-images.githubusercontent.com/138028157/342170761-9aec37b3-a266-4d86-b486-5b6409c06293.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMyMDkxMjIsIm5iZiI6MTcyMzIwODgyMiwicGF0aCI6Ii8xMzgwMjgxNTcvMzQyMTcwNzYxLTlhZWMzN2IzLWEyNjYtNGQ4Ni1iNDg2LTViNjQwOWMwNjI5My5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwOVQxMzA3MDJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yYTM1OGU4YTRkZDFjMDMzYWUyMWM1OWU2M2JjNjYzM2NiNGRiYzBlZjZmNGQxMjU3ZDNmYThmZGNjZmU0ZWQzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.h1GZzEVbW4H78KnDj6XODKY3chaTc4dAtWx4ENTLnyw)
Luo, S., Almet, A.A., Nie, Q.. Spatial metabolic communication flow of single cells.