setPriorDfRobust: The Robust Counterpart of 'setPriorDf'

View source: R/robustMeanVarCurve.R

setPriorDfRobustR Documentation

The Robust Counterpart of setPriorDf

Description

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

Usage

setPriorDfRobust(
  conds,
  d0,
  occupy.only = TRUE,
  p_low = 0.01,
  p_up = 0.1,
  nw = gauss.quad(128, kind = "legendre"),
  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.

p_low

Lower- and upper-proportions of extreme values to be Winsorized (see "References"). Each of them must be strictly larger than 0, and their sum must be strictly smaller than 1.

p_up

Lower- and upper-proportions of extreme values to be Winsorized (see "References"). Each of them must be strictly larger than 0, and their sum must be strictly smaller than 1.

nw

A list containing nodes and weights variables for calculating the definite integral of a function f over the interval [-1, 1], which is approximated by sum(nw$weights * f(nw$nodes)). By default, a set of Gauss-Legendre nodes along with the corresponding weights calculated by gauss.quad is 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 setPriorDf, except that this function adjusts variance ratio factors in a manner that is robust to potential outliers (see also "References").

Value

setPriorDfRobust 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, setPriorDfRobust won't adjust existing variance ratio factors. In this case, you may want to use setPriorDfVarRatio to explicitly specify variance ratio factors.

References

Tukey, J.W., The future of data analysis. The annals of mathematical statistics, 1962. 33(1): p. 1-67.

Phipson, B., et al., Robust Hyperparameter Estimation Protects against Hypervariable Genes and Improves Power to Detect Differential Expression. Annals of Applied Statistics, 2016. 10(2): p. 946-963.

See Also

bioCond for creating a bioCond object; fitMeanVarCurve for fitting a mean-variance curve and using a fit.info field to characterize it; estimatePriorDfRobust for estimating the number of prior degrees of freedom and adjusting the variance ratio factors of a set of bioConds in a robust manner; setPriorDf for the ordinary (non-robust) version of setPriorDfRobust; 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")

# Fit a mean-variance curve by using the parametric method.
GM12892 <- fitMeanVarCurve(list(GM12892), method = "parametric",
                           occupy.only = TRUE, init.coef = c(0.1, 10))[[1]]

# Set the number of prior degrees of freedom to Inf.
GM12892_2 <- setPriorDf(list(GM12892), Inf, occupy.only = TRUE)[[1]]

# Use the robust version of setPriorDf.
GM12892_3 <- setPriorDfRobust(list(GM12892), Inf, occupy.only = TRUE)[[1]]

# In this case, there is little difference in estimated variance ratio
# factor between the ordinary routine and the robust one.
summary(GM12892_2)
summary(GM12892_3)


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