ChiLiubio / microeco

An R package for data analysis in microbial community ecology
GNU General Public License v3.0
194 stars 56 forks source link

Some questions about trans_network class #401

Closed Liuyuxinn closed 1 week ago

Liuyuxinn commented 2 weeks ago

Hi,Chi! Thank you very much for developing this versatile R package, it has been very helpful to me!

However, I still have some confusion about trans_network class:

I choose Sparcc method, from SpiecEasi package to calculate the correlation coefficient between otu.

1、In trans_network, I noticed that filter_thres is used to filter on abundance, however, I don't need to filter on abundance in my data, so do I need to set filter_thres=0(like this:trans_network$new(dataset = group_D25, cor_method = "sparcc", use_sparcc_method = "SpiecEasi", filter_thres=0), or don't set filter_thres(like this: trans_network$new(dataset = group_D25, cor_method = "sparcc", use_sparcc_method = "SpiecEasi")?

Also, is this abundance filtering threshold based on the mean abundance of each otu across all samples?

2、The correlation coefficients calculated between otu have positive and negative values. But how to filter the positivity and negativity of correlation coefficients in cal_network? In the example, it seems that COR_cut can only filter on positive correlations.

Also, is it possible to correct the p-value for each otu relation pair? How to set it ?

3、When using cluster_fast_greedy for network module partitioning,what is it based on for clustering? How is it different from WGCNA for module partitioning?

4、When performing microbial co-occurence analysis to find the key otus/core otus, based on the correlation between the otu calculated by spearman and sparcc (trans_network), which method do you think is more suitable?

5、If the data table of correlation coefficient between otu has been obtained externally, or the network module has been partitioned, how to convert these data tables into trans_network or cal_network class?

Thank you.

ChiLiubio commented 2 weeks ago

Hi.

  1. Yes. Your set is correct. The filtering rule is as you said - "mean abundance of each otu across all samples"
  2. COR_cut can filter both positive and negative correlations based on the absolute value.
  3. The clustering methods implemented in microeco are all from igraph package (not only cluster_fast_greedy). It is very hard to compare the algorithms of those method (including WGCNA).
  4. It is better to use sparcc if you successfully get the result.
  5. For this case, you should first have a basic understanding on the structure of class design, especially the Return part of new and cal_network functions. For example, when you use correlations in creating the trans_network object, there is a list stored in the object, namely res_cor_p. You should create your list instead of it. Here is an example
    data(dataset)
    # for correlation network
    t1 <- trans_network$new(dataset = dataset, cor_method = "pearson", taxa_level = "OTU", filter_thres = 0.005)
    # assume the list in t1 is yours
    your_list <- t1$res_cor_p
    # show the step
    t2 <- trans_network$new(dataset = dataset, cor_method = NULL)
    t2$res_cor_p <- your_list
    t2$cal_network()

    For the network, it is similar.

    t2 <- trans_network$new(dataset = dataset, cor_method = NULL)
    t2$res_network <- your_network
Liuyuxinn commented 2 weeks ago

你好。

  1. 是的。你的设置是正确的。过滤规则就像你说的一样——“所有样本中每个 otu 的平均丰度”
  2. COR_cut 可以根据绝对值过滤正相关和负相关。
  3. microeco 中实现的聚类方法全部来自 igraph 包(不仅仅是 cluster_fast_greedy)。很难比较这些方法(包括 WGCNA)的算法。
  4. 如果成功获得结果,最好使用 sparcc。
  5. 对于这种情况,您应该首先对类设计的结构有基本的了解,尤其是 new 和 cal_network 函数的 Return 部分。例如,当您在创建 trans_network 对象时使用相关性时,对象中会存储一个列表,即res_cor_p。您应该创建自己的列表来代替它。以下是一个例子
data(dataset)
# for correlation network
t1 <- trans_network$new(dataset = dataset, cor_method = "pearson", taxa_level = "OTU", filter_thres = 0.005)
# assume the list in t1 is yours
your_list <- t1$res_cor_p
# show the step
t2 <- trans_network$new(dataset = dataset, cor_method = NULL)
t2$res_cor_p <- your_list
t2$cal_network()

对于网络来说,也是类似的。

t2 <- trans_network$new(dataset = dataset, cor_method = NULL)
t2$res_network <- your_network

非常感谢您的回复,但是我还是有以下几个困惑: 1,第一个问题,如果我不设置丰度过滤阈值,trans_network的默认阈值是多少?

2、我有三个子组(IW/TW/CW)想要在网络之间进行比较,代码如下: IW <- trans_network$new(dataset = dataset_IW, cor_method ="spearman", filter_thres =0.0003) TW <- trans_network$new(dataset = dataset_IW, cor_method ="spearman", filter_thres =0.0003) CW<- trans_network$new(dataset = dataset_IW, cor_method ="spearman", filter_thres =0.0003) 我如何将这三个不同名称的合并为一个tmp(喜欢你的教程,因为我发现你的教程使用tmp进行后续分析)?

ChiLiubio commented 2 weeks ago

1、默认是不过滤 2、这个建议您参考这里的教程 https://chiliubio.github.io/microeco_tutorial/meconetcomp-package.html

Liuyuxinn commented 2 weeks ago

您好,您的教程里面是把三个分组的数据集都复制一个对象中(tmp),同时把这三个网络都放在了同一个对象中(tmp) 但事实上,我把三个分组的数据集复制成了不同的对象:IW <-clone(soil_amp);TM <-clone(soil_amp);CW<-clone(soil_amp),同时我生成了三个网络对象:IW <- trans_network$new(dataset = IW, cor_method = "spearman", filter_thres = 0.0005);TM <- trans_network$new(dataset = TM, cor_method = "spearman", filter_thres = 0.0005)  ;CW<-trans_network$new(dataset = CW, cor_method = "spearman", filter_thres = 0.0005) 。 您后面进行网络间的比较都是基于tmp进行的,而我这种情况最终得到了三个对象(IW TM CW),想请教您我这种情况该如何把这三个对象合并成一个呢(像您的tmp这种)?

1、默认是不过滤 2、这个建议请参考这里的教程https://chiliubio.github.io/microeco_tutorial/meconetcomp-package.html

ChiLiubio commented 2 weeks ago

是要合并到一个列表?是这个意义吗。教程里有讲用list,大概就是yourlist <- list(IW = IW, TW = TW, CW = CW) 。对于您的操作IW <-clone(soil_amp)只是复制了一遍数据,然后没有进行数据过滤IW就跟soil_amp是一模一样的,后面 IW <- trans_network$new(dataset = IW, cor_method = "spearman", filter_thres = 0.0005)也只计算了相关性没有做网络,缺少了步骤,建议再看下教程。