Description Usage Arguments Value Examples
Measure taxa co-occurrence relationships using pearson method and construct networks of taxa with significant direct co-occurrence relationships by this method.An igraph object to visualize networks or calculate network measures is returned as output. Class network and hub network plots are also plotted and returned as output.
1 | get_pearson_info(orig_phylo, met_name)
|
orig_phylo |
Phyloseq including all taxa meeting threshold, produced from get_back_res_meeting_min_occ function |
met_name |
Name of environment |
Returns List of 2 objects: 1. pearson igraph. 2. List of 2 plots: Hub and Class network plots
pearson_igraph |
Igraph of pearson network |
Plot_list |
List of 2 plots: 1. Class network plot, 2. Hub network plot |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (orig_phylo, met_name)
{
print(met_name)
hy_test_pearson <- Hmisc::rcorr(as.matrix(t(otu_table(orig_phylo))),
type = "pearson")
hy_test_pearson_cormat <- as.matrix(hy_test_pearson$r)
hy_test_pearson_pmat <- as.matrix(hy_test_pearson$P)
hy_test_pearson_pmat[is.na(hy_test_pearson_pmat)] <- 1
hy_test_pearson_cormat1 <- ifelse(hy_test_pearson_pmat <=
0.05, hy_test_pearson_cormat, 0)
hy_test_pearson_cormat2 <- abs(hy_test_pearson_cormat1) >=
0.6
hy_test_pearson_cormat2[1:10, 1:10]
hy_test_pearson_adjmat <- Matrix::Matrix(hy_test_pearson_cormat2,
sparse = TRUE)
hy_test_pearson_igraph <- igraph::adj2igraph(hy_test_pearson_adjmat,
vertex.attr = list(name = taxa_names(orig_phylo)))
print(hy_test_pearson_igraph)
plot_a <- phyloseq::plot_network(hy_test_pearson_igraph,
orig_phylo, type = "taxa", color = "Class", label = NULL,
title = paste(met_name, "Pearson network", sep = " ")) +
theme(legend.position = "none")
plot_b <- phyloseq::plot_network(hy_test_pearson_igraph,
orig_phylo, type = "taxa", color = "Genus", label = NULL,
title = paste(met_name, "Pearson hub network", sep = " "),
point_size = hub_score(hy_test_pearson_igraph)$vector *
10) + theme(legend.position = "none")
all_plots <- list(plot_a, plot_b)
all_info <- list(hy_test_pearson_igraph, all_plots)
return(all_info)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.