get_cclasso_info: Get graph and networks using cclasso to measure correlation...

Description Usage Arguments Value Examples

Description

Measure taxa co-occurrence relationships using cclasso 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.

Usage

1
get_cclasso_info(orig_phylo, met_name)

Arguments

orig_phylo

Phyloseq including all taxa meeting threshold, produced from get_back_res_meeting_min_occ function

met_name

Name of environment

Value

Returns List of 2 objects: 1. cclasso igraph. 2. List of 2 plots: Hub and Class network plots

cclasso_igraph

Igraph of cclasso network

Plot_list

List of 2 plots: 1. Class network plot, 2. Hub network plot

Examples

 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)
{
    hy_cclasso_m <- as.matrix(t(otu_table(orig_phylo)))
    hy_test_cclasso_f <- cclasso(hy_cclasso_m, counts = TRUE)
    hy_cclasso_corr_m <- as.matrix(hy_test_cclasso_f$cor_w)
    rownames(hy_cclasso_corr_m) = colnames(hy_cclasso_corr_m) = rownames(otu_table(orig_phylo))
    hy_cclasso_pval_m <- as.matrix(hy_test_cclasso_f$p_vals)
    dim(hy_cclasso_pval_m)
    rownames(hy_cclasso_pval_m) = colnames(hy_cclasso_pval_m) = rownames(otu_table(orig_phylo))
    hy_cclasso_cormat1 <- ifelse(hy_cclasso_pval_m <= 0.05, hy_cclasso_corr_m,
        0)
    diag(hy_cclasso_cormat1) <- 0
    hy_cclasso_cormat1_corr_thresh_0.6 <- abs(hy_cclasso_cormat1) >=
        0.6
    hy_cclasso_cormat1_adjmat <- Matrix::Matrix(hy_cclasso_cormat1_corr_thresh_0.6,
        sparse = TRUE)
    library(SpiecEasi)
    hy_cclasso_igraph <- igraph::adj2igraph(hy_cclasso_cormat1_adjmat,
        vertex.attr = list(name = taxa_names(orig_phylo)))
    met_cclasso_graph = hy_cclasso_igraph
    plot_a <- phyloseq::plot_network(hy_cclasso_igraph, orig_phylo,
        type = "taxa", color = "Class", label = NULL, title = paste(met_name,
            "CCLASSO network", sep = " ")) + theme(legend.position = "none")
    plot_b <- phyloseq::plot_network(hy_cclasso_igraph, orig_phylo,
        type = "taxa", color = "Genus", label = NULL, title = paste(met_name,
            "CCLASSO hub network", sep = " "), point_size = hub_score(hy_cclasso_igraph)$vector *
            10) + theme(legend.position = "none")
    all_plots <- list(plot_a, plot_b)
    all_info <- list(met_cclasso_graph, all_plots)
    return(all_info)
  }

ConesaLab/MDM documentation built on Aug. 1, 2020, 11:47 a.m.