microeco icon indicating copy to clipboard operation
microeco copied to clipboard

Plotting the colors with the positive and negative correlations.

Open Aristotle1992 opened this issue 1 year ago • 4 comments

#for root samples root_bac_sub_no_bad_Filtered_final_non_normalized <- readRDS(file = "C:/Microbiome/RDS/root_bac_sub_no_bad_Filtered_final_non_normalized.rds")

root_norm = transform_sample_counts(root_bac_sub_no_bad_Filtered_final_non_normalized, function(x) x / sum(x) ) root_network = filter_taxa(root_norm, function(x) mean(x) > 0.0001, TRUE) root_network

#first convert to microtable root_amp <- phyloseq2meco(root_network) root_amp

The parameter cor_method in trans_network is used to select correlation calculation method.

default pearson or spearman correlation invoke R base cor.test, a little slow

#net_root <- trans_network$new(dataset = root_amp, cor_method = "spearman", filter_thres = 0.001)

return net_root$res_cor_p list, containing two tables: correlation coefficient table and p value table

require WGCNA package

if(!require("WGCNA")) install.packages("WGCNA", repos = BiocManager::repositories()) net_root <- trans_network$new(dataset = root_amp, cor_method = "spearman", use_WGCNA_pearson_spearman = TRUE, filter_thres = 0.0001)

write.csv(t1[["res_cor_p"]][["p"]], "C:/Microbiome/network files/root_cor.csv")

use arbitrary coefficient threshold to contruct network

net_root$cal_network(COR_p_thres = 0.05, COR_cut = 0.6, COR_p_adjust = "fdr")

return net_root$res_network

invoke igraph cluster_fast_greedy function for this undirected network

net_root$cal_module(method = "cluster_fast_greedy")

require rgexf package to be installed

net_root$save_network(filepath = "C:/Microbiome/network files/root_network.gexf")

My next goal is to plot the colors with the positive and negative correlations using gephi and my problem is how do I add the correlation matrix to the gephi file format as they are in matrix. In essence i want my network plot to show just the negative and positive correlations between the phylum. Thanks

Aristotle1992 avatar Jul 20 '23 00:07 Aristotle1992

Hi. The positive and negative labels (+ and -) have been added into the network. When you open the saved root_network.gexf, please try to find it following those steps: Click Overview -> Appearance (in top left cornor) -> Edges -> Partition -> Select label. That is it.

ChiLiubio avatar Jul 20 '23 02:07 ChiLiubio

Thanks so much for your reply but when i followed the step you stated i only found + and no -. What could be a likely cause?

Aristotle1992 avatar Jul 20 '23 04:07 Aristotle1992

The reason should be that there is no negative significant correlation after the filtering with your parameters. To test this, you can lower the correlation coefficient threshold and try again.

ChiLiubio avatar Jul 20 '23 05:07 ChiLiubio

oh ok thanks. I will try that out.

Aristotle1992 avatar Jul 20 '23 05:07 Aristotle1992