mbglm | R Documentation |
mbglm
fits Bayesian GLMs separately for many responses, and summary.mbglm
summarizes the fitted models.
mbglm(y, formula, data, family=NegBin(), prior=Student(0,1),
min.p=0, verbose=TRUE)
summary.mbglm(object)
y |
a matrix of responses; each column is a response and rows are samples. |
formula |
a one-sided formula of the form |
data , family , prior , verbose |
These arguments are the same as in |
min.p |
a value in [0, 1). The responses with the proportion of non-zero values > min.p are analyzed. |
object |
an object from |
This function analyzes the responses in y
by repeated calls to bglm
.
The function mbglm
returns a list including fit
, responses
, variables
, and call
:
fit |
fitted models for all the responses; |
responses |
names of all the responses; |
variables |
names of all covariates; |
The function summary.mbglm
returns a data frame consisting of responses, variables, estimates, standard deviations, p-vlaues and adjusted p-vlaues (using FDR method) for all coefficients.
Nengjun Yi, nyi@uab.edu
bglm
library(BhGLM)
library(NBZIMM)
# load data in NBZIMM
data(Romero)
names(Romero)
otu = Romero$OTU; dim(otu)
sam = Romero$SampleData; dim(sam)
colnames(sam)
Days = sam$GA_Days; Days = scale(Days)
Age = sam$Age; Age = scale(Age)
Race = sam$Race
preg = sam$pregnant; table(preg)
# calculate size factor using the cumulative sum scaling (CSS) method in metagenomeSeq
library(metagenomeSeq)
obj = newMRexperiment(counts=t(otu), phenoData=NULL, featureData=NULL,
libSize=NULL, normFactors=NULL)
obj = cumNorm(obj, p=cumNormStat(obj)) #set p=1: generate total reads
s = normFactors(obj)
s = unlist(s)
# analyze taxa with nonzero proportion > min.p
f = mbglm(y=otu, formula=~ Days + Age + Race + preg + offset(log(s)),
family=NegBin(), prior=Student(0, 1), min.p=0.1)
out = summary.mbglm(f)
out = out[out[,2]=="preg", ]
coefs = out[,3]; names(coefs) = out[,1]
sds = out[,4]
padj = out[,6]
plot.bh(coefs=coefs, sds=sds, pvalues=padj, threshold=0.001, gap=1000)
out = summary.mbglm(f)
df = out[,c(1:4, 6)]; colnames(df)[5] = "pvalue"
g = NBZIMM::heat.p(df=df, p.breaks = c(0.001, 0.01, 0.05),
colors = c("black", "darkgrey", "grey", "lightgrey"),
zigzag=c(T,F), abbrv=c(T,F), margin=c(2.5,0.5), y.size=8,
legend=T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.