ShrinkBayesWrap: ShrinkBayes wrapper

View source: R/shrinkbayes.R

ShrinkBayesWrapR Documentation

ShrinkBayes wrapper

Description

This function enables applying ShrinkBayes using a one-line command. It includes the ShrinkSeq() (counts) or ShrinkGauss() (Gaussian data) functions, the FitAllShrink() function, the MixtureUpdatePrior() function, the MixtureUpdatePosterior() function and the SummaryTable() function.

Usage

ShrinkBayesWrap(data, form, paramtotest = NULL, allcontrasts = FALSE, multvscontrol = FALSE, fams = NULL, notfit = NULL, ncpus2use = 8, priorsimple = FALSE, approx0 = TRUE, diffthr = 0, direction = "two-sided", saveposteriors = TRUE, fileposteriors = "Posteriors.Rdata", sparse=FALSE, designlist=NULL, ...)

Arguments

data

Matrix, data frame or list containing the data. Rows are features, columns are samples. For lists: each component represents a feature.

form

Formula starting with ~. See inla and f for specification of the model formula.

paramtotest

Character. Name of variable to test. If NULL defaults to the first variable in form.

allcontrasts

Boolean. If TRUE all contrasts are tested if paramtotest is a factor with more than 2 levels.

multvscontrol

Boolean. If TRUE all comparisons with the first level of paramtotest are tested.

fams

Character string. Only relevant for count data. Either equal to "poisson", "zip" (zero-inflated Poisson), "nb" (negative binomial), or the "zinb" (zero-inflated negative binomial): likelihood to be used. Defaults to "zinb".

notfit

Numeric vector of integers. Indices of data rows for which fitting is NOT required.

ncpus2use

Integer. Number of cpus to use for calculations.

priorsimple

Boolean. If TRUE a simple pointmass-Normal prior is fit instead of the default a mixture (overruled by sparse=TRUE)

approx0

Boolean. If TRUE Savage-Dickey approximation is used for the null model (faster).

diffthr

Numeric. Threshold for the null-probability to compute. It demarcates the null-domain from the alternative domain.

direction

Character string. Use direction="greater" if the null-hypothesis if of the form “parameter >= thr”, direction="lesser" if the null-hypothesis if of the form “parameter <= thr”, use direction="two-sided" if the null-hypothesis is of the form “parameter = thr”, use direction="equal" for multi-parameter inference.

saveposteriors

Boolean. If TRUE posterior distributions of the parameters of interest are saved.

fileposteriors

Character. Name of file containing the posterior distributions.

sparse

Boolean. If TRUE a point mass plus laplace mixture is used.

designlist

List. Components are data frames containting the variables in form. Length of list should equal nr of features in data. If NULL design is assumed to be the same for all features (and inferred from form)

...

Further arguments passed on to ShrinkGauss (Gaussian data) or to ShrinkSeq (Counts). See details.

Details

About notfit: note that this is not the same as removing the corresponding rows from the data. For correct fitting of the priors it is essential to use all data. For final fitting, however, computing time can be considerably reduced if a quick screen was used, e.g. by ScreenData. For saveposteriors: please note that he object containing the posterior distributions can be large. Note that direction is automatically set to equal when multi-parameter inference is performed. Specification of further arguments is particularly useful for shrinking other parameters of the model than paramtotest and the dispersion-related parameters (which are shrunken by default). In addition, the ntag and maxiter arguments (see ShrinkSeq or ShrinkGauss) can be used to reduce computing time when testing. About sparse: in case one expects few very large effects, shrinkage to a simple Gaussian should be avoided, because this may over-shirnk those large effects. Hence, setting sparse=TRUE shrinks to a point mass plus Laplace prior.

Value

List containing:

FDRs

Matrix of (B)FDRs, lfdrs, and effect size estimates

nsigsFDR01

Numeric containing the number of significant results for each comparison at (B)FDR<=0.1

shrink

Output of ShrinkSeq or ShrinkGauss function

prior

Output of MixtureUpdatePrior function, if applicable, NULL otherwise

Author(s)

Mark A. van de Wiel

References

Van de Wiel MA, Neerincx M, Buffart TE, Sie D, Verheul HMW (2014). ShrinkBayes: a versatile R-package for analysis of count-based sequencing data in complex study designs. BMC Bioinformatics. 15(1):116.

Van de Wiel MA, Leday GGR, Pardo L, Rue H, Van der Vaart AW, Van Wieringen WN (2012). Bayesian analysis of RNA sequencing data by estimating multiple shrinkage priors. Biostatistics. 14, 113-128.

See Also

ShrinkSeq, ShrinkGauss, MixtureUpdatePrior, ScreenData, BFUpdatePosterior, SummaryTable, plotPoster

Examples

## Not run: 
#To empty current R memory and enlarge memory.limit (Windows) consider, before applying 'ShrinkBayes', using 
#rm(list=ls());gc();
#memory.limit(size = 4000)

#FIRST EXAMPLE
library(ShrinkBayes)
data(CAGEdata10000)
CAGEdata <- CAGEdata10000

#FOR FIRST TRY: USE 500 DATA ROWS ONLY
CAGEdata <- CAGEdata[1:500,]

#loads design of the brain study; includes 
data(design_brain)

#retrieves covariates from the design matrix
pers <- design_brain$pers  #persons
batch<-design_brain$batch   #batch
groupfac <- design_brain$groupfac #group (= brain region)

#Formula as used by INLA
form = ~ 1 + groupfac + batch + f(pers,model="iid") #'batch' and 'group' as fixed effect, 'pers' as random effect

#defaults to K-sample testing
SBcage <- ShrinkBayesWrap(CAGEdata,form)  

#Multiple Comparisons:
SBcagemc <- ShrinkBayesWrap(CAGEdata,form, allcontrasts = TRUE)  


#2ND EXAMPLE 
library(ShrinkBayes)
data(mirseqnorm)
data(designmirseq)

#Then, retrieve the covariates:
PM <- designmirseq$PM
indiv <- designmirseq$indiv
timepos <- designmirseq$timepos
chemo <- designmirseq$chemo
organ <- designmirseq$organ

#FORMULA; indiv IS A RANDOM EFFECT
form = ~ 1 + PM + timepos + chemo + organ + f(indiv)

#TRY IT FOR FIRST 200 DATA ROWS. USE ADDITIONAL SHRINKAGE;
#LIMIT ntag AND maxiter to save computing time; USE DEFAULTS FOR FINAL RUN
SBmir <- ShrinkBayesWrap(mirseqnorm[1:200,],form,shrinkaddfixed=c("organ","chemo","timepos"),ntag=c(50,100),maxiter=5,priorsimple=TRUE)  #2-sample testing for PM, with additional shrinkage for other fixed effects

## End(Not run)

markvdwiel/ShrinkBayes documentation built on March 27, 2022, 7:47 p.m.