ChiLiubio / meconetcomp

Compare microbial co-occurrence networks based on the trans_network class of microeco package
GNU General Public License v3.0
4 stars 0 forks source link

Input self-calculated correlation matrix #5

Open Shawane-Wang opened 7 months ago

Shawane-Wang commented 7 months ago

Hi. I have calculated correlation matrix by myself and I wonder may I directly input this matrix and use meconetcomp to calculate topology structure?

ChiLiubio commented 7 months ago

Hi. You must first use trans_network class of microeco package to generate network. To do so, you can first geneate a null trans_network object and put your correlation matrix into the trans_network object for the following network calculation. The reason is correlation matrix can not represent network totally.

Shawane-Wang commented 7 months ago

Cause I am working on the single sample network and want to use this package to further calculate topology structure. The single network for every sample has been calculated using specific method. But the correlation table was available. I am confused about how to generate a null trans_network object without inputting metadata or otu table and network generating parameters. Could you please show me a simple example(if you only have the correlation table for every sample with asv*asv)?

ChiLiubio commented 7 months ago

Could you please attach your data so that I can correctly show the usage? To save your data, please use save function as the tutorial shows (https://chiliubio.github.io/microeco_tutorial/notes.html#save-function) and attach the compressed object.

Shawane-Wang commented 7 months ago

So kind of you! Please see the attached file! The corsub object was the simple-sample network correlation table for each. test_data.zip

ChiLiubio commented 7 months ago

Hi. It seems like a feature table, not a correlation table. To understand the data generated from trans_network, you can first run the trans_network class as the tutorial show with the example data like.

library(microeco)
data(dataset)
test1 <- trans_network$new(dataset = dataset, cor_method = "pearson", use_WGCNA_pearson_spearman = TRUE, filter_thres = 0.0005)
# correlation table
View(test1$res_cor_p$cor)
# correlation p value table
View(test1$res_cor_p$p)
# so the res_cor list with two tables are necessary for the correlation-based network
# create a network
test1$cal_network(COR_p_thres = 0.05, COR_cut = 0.7)
test1$cal_module()