get_back_res_meeting_min_occ: Create phyloseq and igraph objects of taxa meeting certain...

Description Usage Arguments Value Examples

View source: R/MDMAnalyzer_v0.R

Description

To create suitable networks for each environment, we model the most prevalent taxa, excluding rarer taxa that do not meet a strict sample prevalence threshold. Using the original OTU table information, we set a threshold of sample prevalence percentage and discard any taxa not meeting this threshold. All taxa that remain are saved to a new phyloseq object containing the updated, reduced OTU table information. The direct co-occurrence relationships are then measured for remaining taxa using the SpiecEasi MB neighborhood algorithm and stored in an igraph object.

Usage

1
get_back_res_meeting_min_occ(phylo, filter_val_percent = 0.4)

Arguments

phylo

Phyloseq object of OTU table and taxonomic information

filter_val_percent

Minimum sample percent threshold (from 0 to 1) taxa must meet to be included in the environmental network. Default threshold is 0.4 (40 percent of all samples). Using this default threshold would mean that all taxa present in less than 40 percent of all samples will be discarded from network creation and subsequent steps.

Value

Returns list of 2 objects.

silva_phyloseqobj.final

Phyloseq object including only taxa meeting sample prevalence threshold

silva_spiec.graph

Igraph object of direct co-occurrence relationships between these taxa calculated by SpiecEasi MB algorithm.

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
##---- 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 (phylo, filter_val_percent = 0.4)
{
    silva_otus = phyloseq::otu_table(phylo)
    newsilva_taxa = phyloseq::tax_table(phylo)
    silva_filterobj = seqtime::filterTaxonMatrix(silva_otus,
        minocc = filter_val_percent * length(rownames(sample_data(phylo))),
        keepSum = TRUE, return.filtered.indices = TRUE)
    silva_otus.f = silva_filterobj$mat
    silva_taxa.f = newsilva_taxa[setdiff(1:nrow(newsilva_taxa),
        silva_filterobj$filtered.indices), ]
    dummyTaxonomy = c("D_0__dummy", "D_1__", "D_2__", "D_3__",
        "D_4__", "D_5__", "D_6__")
    silva_taxa.f = rbind(silva_taxa.f, dummyTaxonomy)
    rownames(silva_taxa.f)[nrow(silva_taxa.f)] = "0"
    rownames(silva_otus.f)[nrow(silva_otus.f)] = "0"
    silva_updatedotus = otu_table(silva_otus.f, taxa_are_rows = TRUE)
    silva_updatedtaxa = tax_table(silva_taxa.f)
    silva_phyloseqobj.final = phyloseq::phyloseq(silva_updatedotus,
        silva_updatedtaxa)
    silva_spiec.out = SpiecEasi::spiec.easi(silva_phyloseqobj.final,
        method = "mb", icov.select.params = list(rep.num = 20))
    silva_spiec.graph = igraph::adj2igraph(silva_spiec.out$refit,
        vertex.attr = list(name = taxa_names(silva_phyloseqobj.final)))
    phylo_and_graph <- list(silva_phyloseqobj.final, silva_spiec.graph)
    return(phylo_and_graph)
  }

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