This function is directly modified from the original irwsva.build() in the SVA package. It was noticed that under certain circumstances a subscript out of bounds error would occur while running the SVA function. Therefore, this modified code has a single line altered that conditionally uses the generic singular decomposition, svd(), instead of fast singular decomposition, fast.svd().
irwsva.build2(dat, mod, mod0 = NULL, n.sv, B = 5)
A m CpG sites by n subjects matrix of methylation data.
A n by k model matrix corresponding to the primary model fit (see model.matrix)
A n by k0 model matrix corresponding to the null model to be compared to mod.
The number of surrogate variables to construct.
The number of iterations of the algorithm to perform.
A n by n.sv matrix where each column is a distinct surrogate variable.
A vector with the posterior probability estimates that each row is affected by dependence.
A vector with the posterior probabiliity estimates that each row is affected by the variables in mod, but not in mod0.
The number of suggorate variables estimated.
See http://www.bioconductor.org/packages/release/bioc/manuals/sva/man/sva.pdf
Original sva: Leek JT and Storey JD. (2008) A general framework for multiple testing dependence.Proceedings of the National Academy of Sciences, 105: 18718-18723.
Leek JT and Storey JD. (2007) Capturing heterogeneity in gene expression studies by surrogate variable analysis. PLoS Genetics, 3: e161.