Closed liaojinyue closed 1 month ago
Hello, Thank you for your interest in our work! The way I generated figure 5 was by running a prediction for each condition and then identifying highly changed communications based on the index of dispersion of communication score across conditions. I am happy to share that chunk of the script with you, please send an email at Rongbin.Zheng@childrens.harvard.edu, I will send you the script by email. Best, Rongbin
Hello, Thank you for your interest in our work! The way I generated figure 5 was by running a prediction for each condition and then identifying highly changed communications based on the index of dispersion of communication score across conditions. I am happy to share that chunk of the script with you, please send an email at Rongbin.Zheng@childrens.harvard.edu, I will send you the script by email. Best, Rongbin
Dear Rongbin, I am glad to see that you could share the script that identified highly changed communications across different conditions. I think MEBOCOST comparing cell-cell communication among different conditions/groups could expand its applicability for more scRNA-seq datasets. I've tested Mebocost on my personal scRNA-seq dataset, and it basically worked well. However, my scRNA-seq dataset include two conditions and I want to compare the cell communications between these conditions. I am very appreciated that if you could send me the scripts that compared cell-cell communication among different conditions/groups by email? My email address is zhuguiqi37@163.com. Thank you very much. Looking forward to your reply.
Best, Guiqi Zhu
Here is what I used to find condition-specific communications. The idea is to run mebocost by pooling all cells but label each cell type by each condition. In this way, mebocost use same amount of cells for background estimation in permutation testing, and the communication score and significance are comparable.
adata.obs['label'] = adata.obs['cell_type'] + '~' + adata.obs['condition']
cellall_mebo = mebocost.load_obj(path = './scBAT_mebocost_allcond.pk')
commu_res = cellall_mebo.commu_res.copy()
commu_res['sender_cond'] = [x.split("~")[-1] for x in commu_res['Sender'].tolist()]
commu_res['receiver_cond'] = [x.split("~")[-1] for x in commu_res['Receiver'].tolist()]
commu_res_new = pd.DataFrame()
for c in commu_res['sender_cond'].unique().tolist():
tmp = commu_res[(commu_res['sender_cond'] == c) & (commu_res['receiver_cond'] == c)]
commu_res_new = pd.concat([commu_res_new, tmp])
cellall_mebo.commu_res = commu_res_new.copy()
commu_res_new['label'] = commu_res_new['Sender'].apply(lambda x: x.split('~')[0])+'~'+commu_res_new['Metabolite_Name']+'~'+commu_res_new['Sensor']+'~'+commu_res_new['Receiver'].apply(lambda x: x.split('~')[0])
significant = commu_res_new[commu_res_new['permutation_test_fdr'] < 0.05]
commu_res_need = commu_res_new[commu_res_new['label'].isin(significant['label'])]
commu_res_need_mat = commu_res_need.pivot_table(index = 'label', columns = 'sender_cond', values = 'Commu_Score')
IOD = commu_res_need_mat.apply(lambda row: np.var(row)/np.mean(row), axis = 1).sort_values(ascending=False)
top_n = 100
most_var_commu = commu_res_need_mat.loc[IOD.head(top_n).index]
most_var_commu = pd.concat([most_var_commu,
pd.DataFrame(most_var_commu.index.str.split('~').tolist(),
index = most_var_commu.index,
columns = ['Sender', 'Met', 'Sensor', 'Receiver'])],
axis = 1)
Dear Dear Rongbin, I am very grateful for the extremely useful tool you have provided. I tested Mebocost on the data you provided, and it performed well. However, when I applied Mebocost to my own database, I noticed that some cells were not represented in the visualizations. Specifically, I would like to know if the bar plots are capable of displaying cells with zero metabolic communication scores. It would be greatly helpful if you could provide some insights into this matter or suggest any potential solutions to ensure that all cells are accounted for in the visualizations. Thank you very much for your time and assistance. Looking forward to your response. Best regards, Ting Yi
The mebocost generates figures only based on significant metabolite-sensor communications (usually is FDR < 0.05 and Commu_Score > 0) since we focus on cell types with communications in most cases. Can you try to run several lines of scripts to draw the figure by yourself if the cell type with 0 communication number has to be displayed? The following code will be helpful: `## to obtain the data matrix for the bar plot ptmp=obj.CP._matrixcommu(comm_res=obj.comm_res, pval_method='permutation_test_fdr', pval_cutoff=0.05, comm_score_col = 'Commu_Score', comm_score_cutoff =0)
sender_n = ptmp.groupby('Sender')['Sender'].count() receiver_n = ptmp.groupby('Receiver')['Receiver'].count()
df = pd.concat([sender_n, receiver_n], axis = 1).fillna(0) df = df.sort_values('Sender', ascending = False)`
You can add cell type with zero communications to the df data frame, then plot the bar plot using matplotlib or seaborn.
Let me know if you still have any questions.
Hi Rongbin,
Thank you for providing such a useful tool. I've tested Mebocost on my personal scRNA-seq dataset, and it worked beautifully. I’m wondering whether you will include functions for direct comparison among different groups/conditions as shown in the figure 5 in the preprint? Could you perhaps provide the script that was used to create these figures?
Thanks, Jason