zhengrongbin / MEBOCOST

A python-based package and software to predict metabolite mediated cell-cell communications by single-cell RNA-seq data
BSD 3-Clause "New" or "Revised" License
63 stars 10 forks source link

metabolic communication inference #11

Closed flamesrui closed 2 months ago

flamesrui commented 1 year ago

Dear Dr Zheng, Thank you for providing MEBOCOST. When using "mebo_obj.infer_commu" function, i found one error below.

commu_res = mebo_obj.infer_commu( n_shuffle=1000, seed=12345, Return=True, thread=None, save_permuation=False, min_cell_number = 1 ) image

flamesrui commented 1 year ago

Dear Dr Zheng, Thank you for providing MEBOCOST. When using "mebo_obj.infer_commu" function, i found one error below.

commu_res = mebo_obj.infer_commu( n_shuffle=1000, seed=12345, Return=True, thread=None, save_permuation=False, min_cell_number = 1 ) image

could you provide a solution? Thank you. Looking forward to your reply.

zhengrongbin commented 1 year ago

Hi, thank you for using MEBOCOST. To be honest, I never met this error before. Could you please let me know more about your error report? The screenshot looks like a part of them. Do you mind letting me know your parameters in mebocost.create_obj function? I will try to figure it out.

flamesrui commented 1 year ago

Thank you for your reply! I used the GSE103322 dataset, which processed in Seurat, to run MEBOCOST.

the python code below:

载入包

import os,sys import scanpy as sc import pandas as pd import numpy as np from matplotlib import pyplot as plt import seaborn as sns

from mebocost import mebocost sc.settings.verbosity = 3 # verbosity: errors (0), warnings (1), info (2), hints (3)

sc.logging.print_versions()

results_file = './write/pa.h5ad'

sc.settings.set_figure_params(dpi=300, frameon=False, figsize=(3, 3), facecolor='white') adata = sc.read_h5ad('D:/单细胞/GSE103322/seurat2scanpy.h5ad') adata adata.X= adata.X.A

if you want to pass expression matrix and cell_annotation separately from adata, you can do:

exp_mat = pd.DataFrame(adata.X, columns = adata.var_names, index = adata.obs_names).T cell_ann = adata.obs

Infer metabolic communications

initiate the mebocost object

pass expression data by scanpy adata object

mebo_obj = mebocost.create_obj( adata = adata, group_col = ['celltype'], met_est = 'mebocost', config_path = 'D:\MEBOCOST\mebocost.conf', exp_mat=None, cell_ann=None, species='human', met_pred=None, met_enzyme=None, met_sensor=None, met_ann=None, scFEA_ann=None, compass_met_ann=None, compass_rxn_ann=None, gene_network=None, gmt_path=None, cutoff_exp=0, cutoff_met=0, cutoff_prop=0.25, sensor_type=['Receptor', 'Transporter', 'Nuclear Receptor'], thread=8 )

only estimate metabolite abundance for cells using expression data

two steps include loading config and run estimator

mebo_obj._loadconfig() mebo_obj.estimator()

check the metabolite estimation result

met_mat = pd.DataFrame(mebo_obj.met_mat.toarray(), index = mebo_obj.met_mat_indexer, columns = mebo_obj.met_mat_columns)

print head

met_mat.head() met_mat.to_csv(r'D:\singlecellpython\metabolite estimation result.csv')

metabolic communication inference

Note: by default, this function include estimator for metabolite abundance

commu_res = mebo_obj.infer_commu( n_shuffle=1000, seed=12345, Return=True, thread=None, save_permuation=False, min_cell_number=1 )

**_and the error happened in the "mebo_obj.infer_commu" function and it will not stop but rerun this function and the whole error report below:_**

error report.txt

Thank you. Looking forward to your next reply.

zhengrongbin commented 1 year ago

Hi, sorry for the late response, have you got any solutions already? It looks like that the problem may caused by windows system as discussed here. I can try to update MEBOCOST later, but now I may suggest to try without multiple threads or change to another system, such as linux if you have one, for you to quickly resolve the problem.