BGCR: Bayesian Graphical Compositional Regression

Description Usage Arguments Value Examples

View source: R/BGCR.R

Description

Fit the Bayesian Graphical Compositional Regression for comparing two groups of microbiome count data.

Usage

1
2
3
BGCR(formula, data, PrJAP = 0.5, sum_PrMAP = "default",
  threshold = 0.005, kappa = 0, nu = 10^(seq(-1, 4)), sigma = 4,
  verbose = FALSE)

Arguments

formula

a one-sided formula that describes the covariates need to be adjusted.

data

a phyloseq object containing the otu table, the covariates and the phylogenetic tree. In the OTU table, taxa are rows. The covariate table must contain a grouping variable named "group", with factor levels 0 and 1.

PrJAP

a value between 0 and 1. The prior joint alternative probability used for choosing α.

sum_PrMAP

a positive value less than the total number of internal nodes in the phylogenetic tree. The sum of prior marginal alternative probability used for choosing τ. The default value is set to 2, recommended for 100 OTUs.

threshold

a positive value controls the accuracy used for the empirical Bayes estimate of τ.

kappa

a non-negative value controls the chaining pattern will occur along the phylogenetic tree. The default value 0 introduces an explaning away effect.

nu

a vector contains a sequence of the dispersion parameter ν used for numerically computing the marginal likelihood.

sigma

a positive value. The standard deviation of the normal prior on the regression coefficient.

verbose

logicals. If true, print the number of internal node processed while computing the marginal likelihoods.

Value

BGCR returns an object of class "BGCR". A "BGCR" object is a list containing the following components:

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
library(ape)
library(phyloseq)

#create a phyloseq object (https://joey711.github.io/phyloseq/import-data.html).

otumat = matrix(sample(1:100, 100, replace = TRUE), nrow = 10, ncol = 10)
rownames(otumat) <- paste0("OTU", 1:nrow(otumat))
colnames(otumat) <- paste0("Sample", 1:ncol(otumat))

taxmat = matrix(sample(letters, 70, replace = TRUE), nrow = nrow(otumat), ncol = 7)
rownames(taxmat) <- rownames(otumat)
colnames(taxmat) <- c("Domain", "Phylum", "Class", "Order", "Family", "Genus", "Species")

OTU = otu_table(otumat, taxa_are_rows = TRUE)
TAX = tax_table(taxmat)
sampledata = sample_data(data.frame(
  group = factor(c(rep(0, 4), rep(1, 6))),
  Location = factor(sample(c(0,1), size=nsamples(physeq), replace=TRUE)),
  Depth = sample(50:1000, size=nsamples(physeq), replace=TRUE),
  row.names=sample_names(physeq),
  stringsAsFactors=FALSE
))

random_tree = rtree(ntaxa(physeq), rooted=TRUE, tip.label=taxa_names(physeq))

data = phyloseq(OTU, TAX, sampledata, random_tree)

#run BGCR, first adjusting for no covariate
result <- BGCR(~group, data)

#run BGCR, adjusting for some covariate
result <- BGCR(~group + Location + Depth, data)

plot(x = result)

MaStatLab/BGCR documentation built on Nov. 25, 2019, 8:18 a.m.