setPriorDf: Set the Number of Prior Degrees of Freedom of Mean-Variance...

View source: R/meanVarCurve.R

setPriorDfR Documentation

Set the Number of Prior Degrees of Freedom of Mean-Variance Curves

Description

Given a set of bioCond objects of which each has been associated with a mean-variance curve, setPriorDf assigns a common number of prior degrees of freedom to all the bioConds and accordingly adjusts their variance ratio factors.

Usage

setPriorDf(conds, d0, occupy.only = TRUE, no.rep.rv = NULL, .call = TRUE)

Arguments

conds

A list of bioCond objects, of which each has a fit.info field describing its mean-variance curve (see also fitMeanVarCurve).

d0

A non-negative real specifying the number of prior degrees of freedom. Inf is allowed.

occupy.only

A logical scalar. If it is TRUE (default), only occupied intervals are used to adjust the variance ratio factors. Otherwise, all intervals are used.

no.rep.rv

A positive real specifying the variance ratio factor of those bioConds without replicate samples, if any. By default, it's set to the geometric mean of variance ratio factors of the other bioConds.

.call

Never care about this argument.

Details

The specific behavior of this function is pretty much the same as estimatePriorDf, except that the number of prior degrees of freedom is directly specified by users rather than estimated based on the observed data. Refer to estimatePriorDf for more information.

Note also that there is a robust version of this function that uses Winsorized statistics to derive variance ratio factors (see setPriorDfRobust for details).

Value

setPriorDf returns the argument list of bioCond objects, with the specified number of prior degrees of freedom substituted for the "df.prior" component of each of them. Besides, their "ratio.var" components have been adjusted accordingly, and an attribute named "no.rep.rv" is added to the list if it's ever been used as the variance ratio factor of the bioConds without replicate samples.

To be noted, if the specified number of prior degrees of freedom is 0, setPriorDf won't adjust existing variance ratio factors. In this case, you may want to use setPriorDfVarRatio to explicitly specify variance ratio factors.

See Also

bioCond for creating a bioCond object; fitMeanVarCurve for fitting a mean-variance curve and using a fit.info field to characterize it; estimatePriorDf for estimating the number of prior degrees of freedom and adjusting the variance ratio factors of a set of bioConds; setPriorDfRobust for a robust version of setPriorDf; diffTest for calling differential intervals between two bioCond objects.

Examples

data(H3K27Ac, package = "MAnorm2")
attr(H3K27Ac, "metaInfo")

## Fit a mean-variance curve for the GM12892 cell line (i.e., individual)
## and set the number of prior degrees of freedom of the curve to Inf.

# Perform the MA normalization and construct a bioCond to represent GM12892.
norm <- normalize(H3K27Ac, 7:8, 12:13)
GM12892 <- bioCond(norm[7:8], norm[12:13], name = "GM12892")

# Variations in ChIP-seq signals across biological replicates of a cell line
# are generally of a low level, and typically their relationship with the
# mean signal intensities could be well modeled by the presumed parametric
# form.
GM12892 <- fitMeanVarCurve(list(GM12892), method = "parametric",
                           occupy.only = TRUE, init.coef = c(0.1, 10))[[1]]

# In the vast majority of cases for modeling biological replicates of cell
# lines, the associated variance structure is so regular that variances of
# individual genomic intervals could be reliably estimated by fully
# depending on the mean-variance curve.
GM12892_2 <- setPriorDf(list(GM12892), Inf, occupy.only = TRUE)[[1]]

# The resulting model makes few differences from the original one, though.
# This is because MAnorm2 will adaptively deduce a large number of prior
# degrees of freedom for the mean-variance curve if the underlying variance
# structure is of high regularity. In practice, we recommend leaving the
# specification of prior df to the estimation method implemented in MAnorm2
# all the time.
summary(GM12892)
summary(GM12892_2)


MAnorm2 documentation built on Oct. 29, 2022, 1:12 a.m.