Skip to content

New methylation features added#63

Open
JmWangBio wants to merge 11 commits into
jtleek:masterfrom
JmWangBio:new-met-feature
Open

New methylation features added#63
JmWangBio wants to merge 11 commits into
jtleek:masterfrom
JmWangBio:new-met-feature

Conversation

@JmWangBio

Copy link
Copy Markdown

New DNA methylation features, including ComBat-met, M-value ComBat, and the methylation-related helper functions, have been added.

@jessmcc22

Copy link
Copy Markdown

Please correct all BiocCheck errors, warnings, and notes associated with the files that you have updated. This includes:

Avoid sapply(); use vapply()
Found in files:
R/helper_met.R (line 6, column 36)
R/helper_met.R (line 369, column 17)
R/helper_met.R (line 370, column 14)
R/helper_met.R (line 371, column 15)
R/helper_met.R (line 372, column 17)
R/helper_met.R (line 485, column 11)
R/helper_met.R (line 521, column 16)
R/helper_seq.R (line 28, column 11)

Avoid 1:...; use seq_len() or seq_along()
helper_met.R (line 80, column 19)
helper_met.R (line 95, column 25)
helper_met.R (line 110, column 42)
helper_met.R (line 147, column 25)
helper_met.R (line 147, column 62)
helper_met.R (line 222, column 27)
helper_met.R (line 285, column 15)
helper_met.R (line 327, column 40)
helper_met.R (line 343, column 47)
helper_met.R (line 408, column 31)
helper_met.R (line 475, column 27)
helper_met.R (line 485, column 18)
helper_met.R (line 503, column 42)
helper_met.R (line 526, column 14)
helper_met.R (line 540, column 14)
helper_met.R (line 566, column 13)
helper_met.R (line 567, column 15)

Avoid 'cat' and 'print' outside of 'show' methods
cat() in R/helper_met.R (line 8, column 7)
cat() in R/helper_met.R (line 64, column 5)
cat() in R/helper_met.R (line 75, column 5)
cat() in R/helper_met.R (line 101, column 5)
cat() in R/helper_met.R (line 104, column 5)
cat() in R/helper_met.R (line 122, column 5)
cat() in R/helper_met.R (line 132, column 3)
cat() in R/helper_met.R (line 170, column 3)
cat() in R/helper_met.R (line 389, column 3)
cat() in R/helper_met.R (line 392, column 3)
cat() in R/helper_met.R (line 396, column 5)
cat() in R/helper_met.R (line 406, column 5)
cat() in R/helper_met.R (line 442, column 7)
cat() in R/helper_met.R (line 446, column 5)
cat() in R/helper_met.R (line 538, column 3)

Consider shorter lines; 349 lines (12%) are > 80 characters long.
First few lines:
R/ComBat_met.r#L1 #' Adjust for batch effects using a beta ...
R/ComBat_met.r#L4 #' calculates batch-free distributions, ...
R/ComBat_met.r#L8 #' @param dtype data type: b-value or M- ...
R/ComBat_met.r#L11 #' @param covar_mod optional model matri ...
R/ComBat_met.r#L12 #' @param full_mod Boolean variable indi ...
R/ComBat_met.r#L13 #' @param shrink Boolean variable indica ...
R/ComBat_met.r#L14 #' @param mean.only Boolean variable ind ...
R/ComBat_met.r#L15 #' @param feature.subset.n number of fea ...
R/ComBat_met.r#L16 #' @param pseudo_beta pseudo beta-values ...
R/ComBat_met.r#L18 #' @param ref.batch NULL by default. If ...
R/ComBat_met.r#L19 #' @param ncores number of cores to be u ...
R/ComBat_met.r#L21 #' @return \code{ComBat_met} returns a f ...
R/ComBat_met.r#L31 #' adj_bv_mat <- ComBat_met(bv_mat, dtyp ...
R/ComBat_met.r#L33 #' adj_bv_mat <- ComBat_met(bv_mat, dtyp ...
R/ComBat_met.r#L41 #' adj_mv_mat <- ComBat_met(mv_mat, dtyp ...
R/ComBat_met.r#L43 #' adj_mv_mat <- ComBat_met(mv_mat, dtyp ...
R/ComBat_met.r#L46 #' adj_mv_mat <- ComBat_met(mv_mat, dtyp ...
R/ComBat_met.r#L52 shrink = FALSE, m ...
R/ComBat_met.r#L68 design_data <- prepare_design_matrices ...
R/ComBat_met.r#L83 adjusted_params <- apply_shrinkage(shr ...
R/ComBat_met.r#L84 fea ...
R/helper_met.R#L10 stop("vmat must be a matrix of bet ...
R/helper_met.R#L29 if (dtype == "b-value" && (sum(vmat >= ...
R/helper_met.R#L64 cat("At least one batch contains onl ...
R/helper_met.R#L70 which(apply(vmat[, batch == b], 1, f ...
R/helper_met.R#L85 mean.only.vec <- if (mean.only) rep(TR ...
R/helper_met.R#L87 return(list(vmatOri = vmatOri, vmat = ...
R/helper_met.R#L91 prepare_design_matrices <- function(batc ...
R/helper_met.R#L120 stop("Reference level ref. batch i ...
R/helper_met.R#L132 cat("Adjusting for", ncol(design) - nc ...
R/helper_met.R#L138 return(list(design = design, batchmod ...
R/helper_met.R#L144 stop("The covariate is confounded wi ...
R/helper_met.R#L148 stop('The covariates are confounde ...
R/helper_met.R#L151 stop("At least one covariate is co ...
R/helper_met.R#L180 result_lst <- run_parallel_estimation( ...
R/helper_met.R#L210 run_parallel_estimation <- function(cl, ...
R/helper_met.R#L212 parallel::clusterExport(cl, varlist = ...
R/helper_met.R#L229 estimate_single_feature <- function(k, b ...
R/helper_met.R#L231 result<- list(gamma_hat = NULL, mu_hat ...
R/helper_met.R#L239 variance_check <- check_model_variance ...
R/helper_met.R#L244 glm_fit <- fit_glm_model(k, bv, design ...
R/helper_met.R#L252 calculate_parameters(glm_fit, n_batch, ...
R/helper_met.R#L264 result = list(gamma_hat ...
R/helper_met.R#L265 zero_modva ...
R/helper_met.R#L279 result = list(gamma_hat ...
R/helper_met.R#L280 zero_modva ...
R/helper_met.R#L283 # if precision correction enabled, che ...
R/helper_met.R#L286 if (qr(full_mat[intersect(batches_ ...
R/helper_met.R#L289 result = list(gamma_ ...
R/helper_met.R#L290 zero_m ...
R/helper_met.R#L318 calculate_parameters <- function(glm_f, ...
R/helper_met.R#L320 result <- list(gamma_hat = NULL, mu_ha ...
R/helper_met.R#L323 # compute mean and precision intercept ...
R/helper_met.R#L365 n_zero_modvar_batch <- sum(unlist(lapp ...
R/helper_met.R#L396 cat(sprintf("Found %s features with ...
R/helper_met.R#L404 feature.subs ...
R/helper_met.R#L418 invisible(utils::capture.output( ...
R/helper_met.R#L419 ...
R/helper_met.R#L420 ...
R/helper_met.R#L421 ...
R/helper_met.R#L422 ...
R/helper_met.R#L423 ...
R/helper_met.R#L435 ## set gamma and delta equal to 0 fo ...
R/helper_met.R#L460 monte_carlo_int_beta <- function(dat, mu ...
R/helper_met.R#L474 if (!is.null(feature.subset.n) & is. ...
R/helper_met.R#L527 logit_mu_star_subset <- log(mu_hat_m ...
R/helper_met.R#L529 mu_star_mat[, batches_ind[[jj]]] <- ...
R/helper_met.R#L568 tmp_p <- stats::pbeta(bv_sub[a, b] ...
R/helper_met.R#L573 new_bv_sub[a, b] <- stats::qbeta ...
R/helper_met.R#R/sva-package.R#L3 #' sva has functionality to estimate and ...
R/sva-package.R#L4 #' the \code{\link{sva}} function can be ...
R/sva-package.R#L5 #' the \code{\link{svaseq}} function can ...
R/sva-package.R#L6 #' RNA-sequencing (and other sequencing) ...
R/sva-package.R#L7 #' used to remove known batch effecs fro ...
R/sva-package.R#L11 #' A vignette is available by typing \co ...
R/sva-package.R#L13 #' @references For the package: Leek JT, ...
R/sva-package.R#L14 #' @references For sva: Leek JT and Stor ...
R/sva-package.R#L15 #' @references For sva: Leek JT and Stor ...
R/sva-package.R#L16 #' @references For Combat: Johnson WE, L ...
R/sva-package.R#L17 #' @references For svaseq: Leek JT (2014 ...
R/sva-package.R#L18 #' @references For fsva: Parker HS, Brav ...
R/sva-package.R#L19 #' @references For psva: Parker HS, Leek ...
R/sva-package.R#L22 #' @author Jeffrey T. Leek, W. Evan John ...L574 ...
R/Mvalue_ComBat.R#L1 #' Adjust for batch effects in DNA methy ...
R/
Mvalue_ComBat.R#L4 #' adjusts M-values for batch effects us ...
R/Mvalue_ComBat.R#L6 #' Forward and reverse logit-transformat ...
R/Mvalue_ComBat.R#L10 #' @return \code{Mvalue_ComBat} returns ...
R/sva-package.R#L3 #' sva has functionality to estimate and ...
R/sva-package.R#L4 #' the \code{\link{sva}} function can be ...
R/sva-package.R#L5 #' the \code{\link{svaseq}} function can ...
R/sva-package.R#L6 #' RNA-sequencing (and other sequencing) ...
R/sva-package.R#L7 #' used to remove known batch effecs fro ...
R/sva-package.R#L11 #' A vignette is available by typing \co ...
R/sva-package.R#L13 #' @references For the package: Leek JT, ...
R/sva-package.R#L14 #' @references For sva: Leek JT and Stor ...
R/sva-package.R#L15 #' @references For sva: Leek JT and Stor ...
R/sva-package.R#L16 #' @references For Combat: Johnson WE, L ...
R/sva-package.R#L17 #' @references For svaseq: Leek JT (2014 ...
R/sva-package.R#L18 #' @references For fsva: Parker HS, Brav ...
R/sva-package.R#L19 #' @references For psva: Parker HS, Leek ...
R/sva-package.R#L22 #' @author Jeffrey T. Leek, W. Evan John ...
vignettes/sva.Rnw#L17 \title{The SVA package for removing batc ...
vignettes/sva.Rnw#L18 \author{Jeffrey Leek$^1$*, W. Evan Johns ...
vignettes/sva.Rnw#L30 The \Rpackage{sva} package contains func ...
vignettes/sva.Rnw#L32 The \Rpackage{sva} package can be used t ...
vignettes/sva.Rnw#L36 Batch effects are sub-groups of measurem ...
vignettes/sva.Rnw#L38 The \Rpackage{sva} package includes the ...
vignettes/sva.Rnw#L40 This document provides a tutorial for us ...
vignettes/sva.Rnw#L42 As with any R package, detailed informat ...
vignettes/sva.Rnw#L54 The first step in using the \Rpackage{sv ...
vignettes/sva.Rnw#L56 Two model matrices must be made: the f ... vignettes/sva.Rnw#L61 For the bladder cancer study, the variab ... vignettes/sva.Rnw#L65 The expression data can be obtained from ... vignettes/sva.Rnw#L71 Next we create the full model matrix - i ... vignettes/sva.Rnw#L77 The null model contains only the adjustm ... vignettes/sva.Rnw#L82 Now that the model matrices have been cr ... vignettes/sva.Rnw#L84 \section{Applying the \Rfunction{sva} fu ... vignettes/sva.Rnw#L86 The \Rfunction{sva} function performs tw ... vignettes/sva.Rnw#L99 The \Rfunction{sva} function returns a l ... vignettes/sva.Rnw#L101 \section{Adjusting for surrogate variabl ... vignettes/sva.Rnw#L103 The \Rfunction{f.pvalue} function can be ... vignettes/sva.Rnw#L110 Note that nearly 70\% of the genes are s ... vignettes/sva.Rnw#L120 Now these are the adjusted P-values and ... vignettes/sva.Rnw#L124 The \Rpackage{limma} package is one of t ... vignettes/sva.Rnw#L130 From here, you can use the \Rpackage{lim ... vignettes/sva.Rnw#L133 contrast.matrix <- cbind("C1"=c(-1,1,0,r ... vignettes/sva.Rnw#L137 The next step is to calculate the test s ... vignettes/sva.Rnw#L147 The \Rfunction{ComBat} function adjusts ... vignettes/sva.Rnw#L153 Just as with \Rfunction{sva}, we then ne ... vignettes/sva.Rnw#L159 Note that adjustment variables will be t ... vignettes/sva.Rnw#L161 We now apply the \Rfunction{ComBat} func ... vignettes/sva.Rnw#L164 combat_edata = ComBat(dat=edata, batch=b ... vignettes/sva.Rnw#L167 This returns an expression matrix, with ... vignettes/sva.Rnw#L174 These P-values and Q-values now account ... vignettes/sva.Rnw#L176 There are a few additional options for t ... vignettes/sva.Rnw#L178 Also, we have now added the \texttt{mean ... vignettes/sva.Rnw#L180 Finally, we have now added a \texttt{ref ... vignettes/sva.Rnw#L181 When using the \texttt{mean.only=TRUE} o ... vignettes/sva.Rnw#L186 ComBat-Seq is an improved model based on ... vignettes/sva.Rnw#L196 In ComBat-Seq, user may specify biologic ... vignettes/sva.Rnw#L204 If users wish to specify multiple biolog ... vignettes/sva.Rnw#L217 Direct adjustment for batch effects can ... vignettes/sva.Rnw#L228 The goal of the \Rfunction{sva} is to re ... vignettes/sva.Rnw#L230 In some cases, the latent variables may ... vignettes/sva.Rnw#L232 In contrast, direct adjustment only remo ... vignettes/sva.Rnw#L236 \section{Variance filtering to speed com ... vignettes/sva.Rnw#L238 When the number of features is very larg ... vignettes/sva.Rnw#L246 \section{Applying the \Rfunction{fsva} f ... vignettes/sva.Rnw#L248 The surrogate variable analysis function ... vignettes/sva.Rnw#L250 Frozen'' surrogate variable analysis c ...
vignettes/sva.Rnw#L264 Using these data sets, the \Rpackage{pam ...
vignettes/sva.Rnw#L272 Next, the \Rfunction{sva} function can b ...
vignettes/sva.Rnw#L280 The \Rfunction{fsva} function can be use ...
vignettes/sva.Rnw#L292 In our original work we used the identif ...
vignettes/sva.Rnw#L294 First we set up the data by filtering lo ...
vignettes/sva.Rnw#L307 Now we can apply svaseq to estimate the ...
vignettes/sva.Rnw#L321 In our original work we introduced an al ...
vignettes/sva.Rnw#L328 Here we passed the controls argument, wh ...
vignettes/sva.Rnw#L332 The sva package includes multiple differ ...
vignettes/sva.Rnw#L337 \item Leek JT, Johnson WE, Parker HS, Ja ...
vignettes/sva.Rnw#L342 \item Leek JT and Storey JD. (2008) A ge ...
vignettes/sva.Rnw#L343 \item Leek JT and Storey JD. (2007) Capt ...
vignettes/sva.Rnw#L349 \item Johnson WE, Li C, Rabinovic A (200 ...
vignettes/sva.Rnw#L355 \item Zhang, Y., Jenkins, D. F., Manimar ...
vignettes/sva.Rnw#L361 \item Leek JT (2014) svaseq: removing ba ...
vignettes/sva.Rnw#L367 \item Leek JT (2014) svaseq: removing ba ...
vignettes/sva.Rnw#L368 \item Gagnon-Bartsch JA, Speed TP (2012) ...
vignettes/sva.Rnw#L374 \item Parker HS, Bravo HC, Leek JT (2013 ...
vignettes/sva.Rnw#L380 \item Parker HS, Leek JT, Favorov AV, Co ...

Consider multiples of 4 spaces for line indents; 855 lines (29%) are not.
First few lines:
R/ComBat_met.r#L51 batch, group = NU ...
R/ComBat_met.r#L52 shrink = FALSE, m ...
R/ComBat_met.r#L53 pseudo_beta = 1e- ...
R/ComBat_met.r#L54 # Preparation ...
R/ComBat_met.r#L55 validated <- validate_inputs(vmat, dty ...
R/ComBat_met.r#L56 vmat <- validated$vmat ...
R/ComBat_met.r#L57 batch <- validated$batch ...
R/ComBat_met.r#L58 group <- validated$group ...
R/ComBat_met.r#L60 # Handle extreme values and uniform fe ...
R/ComBat_met.r#L61 processed <- preprocess_data(vmat, dty ...
R/ComBat_met.r#L62 vmatOri <- processed$vmatOri ...
R/ComBat_met.r#L63 vmat <- processed$vmat ...
R/ComBat_met.r#L64 keep <- processed$keep ...
R/ComBat_met.r#L65 mean.only.vec <- processed$mean.only.v ...
R/ComBat_met.r#L67 # Prepare design matrices ...
R/ComBat_met.r#L68 design_data <- prepare_design_matrices ...
R/ComBat_met.r#L69 design <- design_data$design ...
R/ComBat_met.r#L70 batchmod <- design_data$batchmod ...
R/ComBat_met.r#L71 n_batch <- design_data$n_batch ...
R/ComBat_met.r#L72 batches_ind <- design_data$batches_ind ...
R/ComBat_met.r#L73 ref <- design_data$ref ...
R/ComBat_met.r#L75 # Convert to beta values if needed ...
R/ComBat_met.r#L76 bv <- convert_to_beta_values(vmat, dty ...
R/ComBat_met.r#L78 # Estimate parameters ...
R/ComBat_met.r#L79 params <- estimate_parameters(bv, desi ...
R/ComBat_met.r#L82 # Apply shrinkage if requqested ...
R/ComBat_met.r#L83 adjusted_params <- apply_shrinkage(shr ...
R/ComBat_met.r#L84 fea ...
R/ComBat_met.r#L86 # Adjust the data ...
R/ComBat_met.r#L87 adj_vmat <- adjust_data(vmatOri, dtype ...
R/ComBat_met.r#L88 batches_ind, m ...
R/ComBat_met.r#L90 return(adj_vmat) ...
R/helper_met.R#L4 ## check if vmat has the correct forma ...
R/helper_met.R#L5 if (!(is.matrix(vmat) && is.numeric(vm ...
R/helper_met.R#L7 vmat <- as.matrix(vmat) ...
R/helper_met.R#L8 cat("Input is numeric.\n") ...
R/helper_met.R#L10 stop("vmat must be a matrix of bet ...
R/helper_met.R#L12 } ...
R/helper_met.R#L13 ...
R/helper_met.R#L14 ## check if pseudo-beta values are val ...
R/helper_met.R#L15 if (dtype == "b-value" && (pseudo_beta ...
R/helper_met.R#L17 } ...
R/helper_met.R#L18 ...
R/helper_met.R#L19 ## check if coverage matrix, batch, an ...
R/helper_met.R#L20 if (ncol(vmat) != length(batch)) { ...
R/helper_met.R#L22 } ...
R/helper_met.R#L23 ...
R/helper_met.R#L24 if (!is.null(group) && ncol(vmat) != l ...
R/helper_met.R#L26 } ...
R/helper_met.R#L27 ...
R/helper_met.R#L28 ## Does not allow beta values outside ...
R/helper_met.R#L29 if (dtype == "b-value" && (sum(vmat >= ...
R/helper_met.R#L31 } ...
R/helper_met.R#L32 ...
R/helper_met.R#L33 ## check if batch is valid ...
R/helper_met.R#L34 if (length(dim(batch)) > 1) { ...
R/helper_met.R#L36 } ...
R/helper_met.R#L37 ...
R/helper_met.R#L38 batch <- as.factor(batch) ...
R/helper_met.R#L39 if (all(table(batch) <= 1)) { ...
R/helper_met.R#L41 } ...
R/helper_met.R#L42 ...
R/helper_met.R#L43 if (length(levels(batch)) <= 1) { ...
R/helper_met.R#L45 } ...
R/helper_met.R#L46 ...
R/helper_met.R#L47 if (!is.null(group)) { ...
R/helper_met.R#L49 } ...
R/helper_met.R#L50 ...
R/helper_met.R#L51 return(list(vmat = vmat, batch = batch ...
R/helper_met.R#L56 ## convert extreme 0 or 1 values to ps ...
R/helper_met.R#L57 if (dtype == "b-value") { ...
R/helper_met.R#L60 } ...
R/helper_met.R#L61 ...
R/helper_met.R#L62 ## Correct for mean batch effects only ...
R/helper_met.R#L63 if (any(table(batch) == 1)) { ...
R/helper_met.R#L66 } ...
R/helper_met.R#L67 ...
R/helper_met.R#L68 ## Remove features with zero variance ...
R/helper_met.R#L69 zero.var.rows.lst <- lapply(levels(bat ...
R/helper_met.R#L71 }) ...
R/helper_met.R#L72 all.zero.var.rows <- Reduce(intersect, ...
R/helper_met.R#L73 ...
R/helper_met.R#L74 if (length(all.zero.var.rows) > 0) { ...
R/helper_met.R#L78 } ...
R/helper_met.R#L79 ...
R/helper_met.R#L80 keep <- setdiff(1:nrow(vmat), all.zero ...
R/helper_met.R#L81 vmatOri <- vmat ...
R/helper_met.R#L82 vmat <- vmatOri[keep, ] ...
R/helper_met.R#L83 ...
R/helper_met.R#L84 ## Create a vector for correction type ...
R/helper_met.R#L85 mean.only.vec <- if (mean.only) rep(TR ...
R/helper_met.R#L86 ...
R/helper_met.R#L87 return(list(vmatOri = vmatOri, vmat = ...
R/helper_met.R#L92 # number of batches ...
R/helper_met.R#L93 n_batch <- nlevels(batch) ...
R/helper_met.R#L94 # list of samples in each batch ...
R/helper_met.R#L95 batches_ind <- lapply(1:n_batch, funct ...
R/helper_met.R#L97 }) ...
R/helper_met.R#L99 # biological condition matrix ...
R/helper_met.R#L100 if (full_mod & !is.null(group) & nleve ...
R/helper_met.R#L103 } else { ...
R/helper_met.R#L106 } ...
R/helper_met.R#L107 # covariate matrix ...
R/helper_met.R#L108 if (!is.null(covar_mod)) { ...
R/helper_met.R#L110 covar_mod <- do.call(cbind, lapply ...
R/helper_met.R#L112 })) ...
R/helper_met.R#L114 } ...
R/helper_met.R#L115 # combine covariate matrix with biolog ...
R/helper_met.R#L116 mod <- cbind(mod, covar_mod) ...
R/helper_met.R#L117 batchmod <- stats::model.matrix(~-1 + ...
R/helper_met.R#L118 if (!is.null(ref.batch)) { ...
R/helper_met.R#L120 stop("Reference level ref. batch i ...
R/helper_met.R#L124 } else { ...
R/helper_met.R#L126 } ...
R/helper_met.R#L127 ...
R/helper_met.R#L128 design <- cbind(batchmod, mod) ...
R/helper_met.R#L129 ## Check for intercept in covariates, ...
R/helper_met.R#L130 check <- apply(design, 2, function(x) ...
R/helper_met.R#L131 design <- as.matrix(design[, !check]) ...
R/helper_met.R#L132 cat("Adjusting for", ncol(design) - nc ...
R/helper_met.R#L133 ...
R/helper_met.R#L134 if (qr(design)$rank < ncol(design)) { ...
R/helper_met.R#L136 } ...
R/helper_met.R#L137 ...
R/helper_met.R#L138 return(list(design = design, batchmod ...
R/helper_met.R#L143 if (ncol(design) == (n_batch+1)) { ...
R/helper_met.R#L145 } ...
R/helper_met.R#L146 if (ncol(design) > (n_batch+1)) { ...
R/helper_met.R#L148 stop('The covariates are confounde ...
R/helper_met.R#L149 so the design is not confou ...
R/helper_met.R#L151 stop("At least one covariate is co ...
R/helper_met.R#L152 covariates and rerun ComBat ...
R/helper_met.R#L154 } ...
R/helper_met.R#L159 ## convert M-values to beta-values if ...
R/helper_met.R#L160 if (dtype == "b-value") { ...
R/helper_met.R#L162 } else { ...
R/helper_met.R#L164 } ...
R/helper_met.R#L170 cat("Fitting the GLM model\n") ...
R/helper_met.R#L171 ...
R/helper_met.R#L172 # Validate ncores ...
R/helper_met.R#L173 validate_ncores(ncores) ...
R/helper_met.R#L174 ...
R/helper_met.R#L175 # Set up parallel processing ...
R/helper_met.R#L176 cl <- setup_parallel_processing(ncores ...
R/helper_met.R#L177 on.exit(parallel::stopCluster(cl)) ...
R/helper_met.R#L178 ...
R/helper_met.R#L179 # Run parameter estimation in parallel ...
R/helper_met.R#L180 result_lst <- run_parallel_estimation( ...
R/helper_met.R#L182 ...
R/helper_met.R#L183 # Process and summarize results ...
R/helper_met.R#L184 processed_results <- process_estimatio ...
R/helper_met.R#L185 ...
R/helper_met.R#L186 # Report any issues found ...
R/helper_met.R#L187 report_estimation_issues(processed_res ...
R/helper_met.R#L188 processed_res ...
R/helper_met.R#L189 processed_res ...
R/helper_met.R#L190 mean.only.vec ...
R/helper_met.R#L191 ...
R/helper_met.R#L192 return(processed_results) ...
R/helper_met.R#L197 if (!is.numeric(ncores) || ncores != a ...
R/helper_met.R#L199 } ...
R/helper_met.R#L204 num_cores <- max(1, parallel::detectCo ...
R/helper_met.R#L205 num_cores <- min(ncores, num_cores) ...
R/helper_met.R#L206 parallel::makeCluster(num_cores) ...
R/helper_met.R#L212 parallel::clusterExport(cl, varlist = ...
R/helper_met.R#L213 ...
R/helper_met.R#L214 ...
R/helper_met.R#L215 ...
R/helper_met.R#L216 ...
R/helper_met.R#L217 ...
R/helper_met.R#L218 ...
R/helper_met.R#L219 envir = enviro ...
R/helper_met.R#L220 ...
R/helper_met.R#L221 # run in parallel ...
R/helper_met.R#L222 parallel::parLapply(cl, 1:nrow(bv), fu ...
R/helper_met.R#L225 }) ...
R/helper_met.R#L231 result<- list(gamma_hat = NULL, mu_hat ...
R/helper_met.R#L233 ...
R/helper_met.R#L234 # Check for NA values ...
R/helper_met.R#L235 na_check <- check_na_values(k, design, ...
R/helper_met.R#L236 if (na_check$has_issue) return(na_chec ...
R/helper_met.R#L237 ...
R/helper_met.R#L238 # Check model variance ...
R/helper_met.R#L239 variance_check <- check_model_variance ...
R/helper_met.R#L240 ...
R/helper_met.R#L241 if (variance_check$has_issue) return(v ...
R/helper_met.R#L242 ...
R/helper_met.R#L243 # Fit GLM ...
R/helper_met.R#L244 glm_fit <- fit_glm_model(k, bv, design ...
R/helper_met.R#L245 # if error with model fitting ...
R/helper_met.R#L246 if (inherits(glm_fit, "error")) { ...
R/helper_met.R#L249 } ...
R/helper_met.R#L250 ...
R/helper_met.R#L251 # Calculate parameters ...
R/helper_met.R#L252 calculate_parameters(glm_fit, n_batch, ...
R/helper_met.R#L257 # mark rows with NA values ...
R/helper_met.R#L258 full_mat <- cbind(design, bv[k, ]) ...
R/helper_met.R#L259 nona <- which(stats::complete.cases(fu ...
R/helper_met.R#L260 ...
R/helper_met.R#L261 # check if the data are all NAs ...
R/helper_met.R#L262 if (length(nona) == 0) { ...
R/helper_met.R#L265 zero_modva ...
R/helper_met.R#L266 } ...
R/helper_met.R#L267 ...
R/helper_met.R#L268 list(has_issue = FALSE, nona = nona) ...
R/helper_met.R#L273 mean.on ...
R/helper_met.R#L274 full_mat <- cbind(design, bv[k, ]) ...
R/helper_met.R#L275 ...
R/helper_met.R#L276 # check if the model has zero model va ...
R/helper_met.R#L277 if (qr(full_mat[nona, ])$rank < ncol(f ...
R/helper_met.R#L280 zero_modva ...
R/helper_met.R#L281 } ...
R/helper_met.R#L282 ...
R/helper_met.R#L283 # if precision correction enabled, che ...
R/helper_met.R#L284 if (!mean.only.vec[k]) { ...
R/helper_met.R#L286 if (qr(full_mat[intersect(batches_ ...
R/helper_met.R#L287 ncol(full_mat) - n_batch + 1) ...
R/helper_met.R#L290 zero_m ...
R/helper_met.R#L291 } ...
R/helper_met.R#L293 } ...
R/helper_met.R#L294 ...
R/helper_met.R#L295 list(has_issue = FALSE) ...
R/helper_met.R#L300 # model fit ...
R/helper_met.R#L301 if (mean.only.vec[k]) { ...
R/helper_met.R#L303 betareg::betareg.fit(x = design[no ...
R/helper_met.R#L305 e ...
R/helper_met.R#L307 } else { ...
R/helper_met.R#L309 betareg::betareg.fit(x = design[no ...
R/helper_met.R#L310 z = batchmod[ ...
R/helper_met.R#L312 e ...
R/helper_met.R#L314 } ...
R/helper_met.R#L319 tmp.mea ...
R/helper_met.R#L320 result <- list(gamma_hat = NULL, mu_ha ...
R/helper_met.R#L321 zero_modvar = 0, zero_m ...
R/helper_met.R#L322 ...
R/helper_met.R#L323 # compute mean and precision intercept ...
R/helper_met.R#L324 if (!is.null(ref.batch)) { ...
R/helper_met.R#L326 } else { ...
R/helper_met.R#L328 as.matrix(colSums(batchmod[nona, ] ...
R/helper_met.R#L329 } ...
R/helper_met.R#L330 ...
R/helper_met.R#L331 if (tmp.mean.only) { ...
R/helper_met.R#L333 } else { ...
R/helper_met.R#L335 alpha_z <- glm_f$coefficients$prec ...
R/helper_met.R#L337 alpha_z <- glm_f$coefficients$prec ...
R/helper_met.R#L340 } ...
R/helper_met.R#L341 ...
R/helper_met.R#L342 # estimate parameters ...
R/helper_met.R#L343 result$gamma_hat <- glm_f$coefficients ...
R/helper_met.R#L344 result$mu_hat <- rep(NA, nrow(batchmod ...
R/helper_met.R#L345 result$mu_hat[nona] <- glm_f$fitted.va ...
R/helper_met.R#L346 result$phi_hat <- as.numeric(exp(alpha ...
R/helper_met.R#L347 ...
R/helper_met.R#L348 if (tmp.mean.only) { ...
R/helper_met.R#L350 } else { ...
R/helper_met.R#L352 } ...
R/helper_met.R#L353 ...
R/helper_met.R#L354 result ...
R/helper_met.R#L359 gamma_hat_lst <- lapply(result_lst, fu ...
R/helper_met.R#L360 mu_hat_lst <- lapply(result_lst, funct ...
R/helper_met.R#L361 phi_hat_lst <- lapply(result_lst, func ...
R/helper_met.R#L362 delta_hat_lst <- lapply(result_lst, fu ...
R/helper_met.R#L363 ...
R/helper_met.R#L364 n_zero_modvar <- sum(unlist(lapply(res ...
R/helper_met.R#L365 n_zero_modvar_batch <- sum(unlist(lapp ...
R/helper_met.R#L366 n_moderr <- sum(unlist(lapply(result_l ...
R/helper_met.R#L367 ...
R/helper_met.R#L368 # convert NULLs to NAs ...
R/helper_met.R#L369 gamma_hat_lst[sapply(gamma_hat_lst, is ...
R/helper_met.R#L370 mu_hat_lst[sapply(mu_hat_lst, is.null) ...
R/helper_met.R#L371 phi_hat_lst[sapply(phi_hat_lst, is.nul ...
R/helper_met.R#L372 delta_hat_lst[sapply(delta_hat_lst, is ...
R/helper_met.R#L373 ...
R/helper_met.R#L374 # reformat lists as matrices ...
R/helper_met.R#L375 list( ...
R/helper_met.R#L383 ) ...
R/helper_met.R#L388 n_m ...
R/helper_met.R#L389 cat(sprintf("Found %s features with ze ...
R/helper_met.R#L390 these features won't be ad ...
R/helper_met.R#L391 n_zero_modvar)) ...
R/helper_met.R#L392 cat(sprintf("Errors encountered in %s ...
R/helper_met.R#L393 these features won't be ad ...
R/helper_met.R#L394 n_moderr)) ...
R/helper_met.R#L395 if (!all(mean.only.vec)) { ...
R/helper_met.R#L399 } ...
R/helper_met.R#L405 if (shrink) { ...
R/helper_met.R#L409 if (ii == 1) { ...
R/helper_met.R#L411 mu = params$m ...
R/helper_met.R#L412 gamma = param ...
R/helper_met.R#L413 phi = params$ ...
R/helper_met.R#L414 delta = param ...
R/helper_met.R#L415 feature.subse ...
R/helper_met.R#L416 ncores = ncor ...
R/helper_met.R#L417 } else { ...
R/helper_met.R#L419 ...
R/helper_met.R#L420 ...
R/helper_met.R#L421 ...
R/helper_met.R#L422 ...
R/helper_met.R#L423 ...
R/helper_met.R#L424 ...
R/helper_met.R#L425 } ...
R/helper_met.R#L426 return(mcres) ...
R/helper_met.R#L437 gamma_star_mat[, ref] <- 0 ...
R/helper_met.R#L438 delta_star_mat[, ref] <- 0 ...
R/helper_met.R#L442 cat("Apply shrinkage to mean only\ ...
R/helper_met.R#L443 delta_star_mat <- params$delta_hat ...
R/helper_met.R#L445 } else { ...
R/helper_met.R#L449 } ...
R/helper_met.R#L450 ...
R/helper_met.R#L451 return(list(gamma_star_mat = gamma_sta ...
R/helper_met.R#L456 return(matrix(rep(vec, n_times), ncol ...
R/helper_met.R#L461 cl <- parallel::makeCluster(ncores) ...
R/helper_met.R#L462 ...
R/helper_met.R#L463 MC_int <- function(i) { ...
R/helper_met.R#L465 delta.star = NA) ...
R/helper_met.R#L475 mcint_ind <- sample(1:(nrow(dat) - ...
R/helper_met.R#L476 m <- m[mcint_ind, ] ...
R/helper_met.R#L477 p <- p[mcint_ind, ] ...
R/helper_met.R#L478 gamma_sub <- gamma_sub[mcint_ind] ...
R/helper_met.R#L479 delta_sub <- delta_sub[mcint_ind] ...
R/helper_met.R#L480 G_sub <- feature.subset.n ...
R/helper_met.R#L482 G_sub <- nrow(dat) - 1 ...
R/helper_met.R#L486 prod(stats::dbeta(x, shape1 = m[j, ...
R/helper_met.R#L491 pos_res <- c(gamma.star = as.numer ...
R/helper_met.R#L492 delta.star = as.numer ...
R/helper_met.R#L494 pos_res["gamma.star"] <- sum(gamma ...
R/helper_met.R#L496 pos_res["delta.star"] <- sum(delta ...
R/helper_met.R#L500 } ...
R/helper_met.R#L501 ...
R/helper_met.R#L502 # run in parallel ...
R/helper_met.R#L503 pos_res_lst <- parallel::parLapply(cl, ...
R/helper_met.R#L504 parallel::stopCluster(cl) ...
R/helper_met.R#L505 pos_res_mat <- do.call(rbind, pos_res_ ...
R/helper_met.R#L506 res <- list(gamma_star = pos_res_mat[, ...
R/helper_met.R#L507 delta_star = pos_res_mat[, ...
R/helper_met.R#L508 return(res) ...
R/helper_met.R#L514 gamma_star_mat <- adjusted_params$gamm ...
R/helper_met.R#L515 delta_star_mat <- adjusted_params$delt ...
R/helper_met.R#L516 mu_hat_mat <- params$mu_hat_mat ...
R/helper_met.R#L517 phi_hat_mat <- params$phi_hat_mat ...
R/helper_met.R#L518 delta_hat_mat <- params$delta_hat_mat ...
R/helper_met.R#L519 ...
R/helper_met.R#L520 n_batch <- length(batches_ind) ...
R/helper_met.R#L521 n_batches <- sapply(batches_ind, lengt ...
R/helper_met.R#L522 ...
R/helper_met.R#L523 mu_star_mat <- matrix(NA, nrow = nrow( ...
R/helper_met.R#L524 phi_star_mat <- phi_hat_mat ...
R/helper_met.R#L525 ...
R/helper_met.R#L526 for (jj in 1:n_batch) { ...
R/helper_met.R#L528 vec2mat_met(gamma_star_mat[, jj], ...
R/helper_met.R#L531 log_phi_star_subset <- log(phi_hat ...
R/helper_met.R#L534 phi_star_mat[, batches_ind[[jj]]] ...
R/helper_met.R#L536 } ...
R/helper_met.R#L537 ...
R/helper_met.R#L538 cat("Adjusting the data\n") ...
R/helper_met.R#L539 adj_bv_raw <- matrix(NA, nrow = nrow(b ...
R/helper_met.R#L540 for (kk in 1:n_batch) { ...
R/helper_met.R#L551 } ...
R/helper_met.R#L552 ...
R/helper_met.R#L553 if (dtype == "b-value") { ...
R/helper_met.R#L556 } else { ...
R/helper_met.R#L559 } ...
R/helper_met.R#L560 return(adj_vmat) ...
R/helper_met.R#L565 new_bv_sub <- matrix(NA, nrow = nrow(b ...
R/helper_met.R#L566 for (a in 1:nrow(bv_sub)) { ...
R/helper_met.R#L568 tmp_p <- stats::pbeta(bv_sub[a, b] ...
R/helper_met.R#L570 if (is.na(tmp_p)) { ...
R/helper_met.R#L572 } else { ...
R/helper_met.R#L574 ...
R/helper_met.R#L575 } ...
R/helper_met.R#L577 } ...
R/helper_met.R#L578 return(new_bv_sub) ...
R/Mvalue_ComBat.R#L40 batch, group = ...
R/Mvalue_ComBat.R#L41 covar_mod = NU ...
R/Mvalue_ComBat.R#L42 mean.only = FA ...
R/Mvalue_ComBat.R#L43 ref.batch = NU ...
R/Mvalue_ComBat.R#L44 ## convert extreme 0 or 1 values to ps ...
R/Mvalue_ComBat.R#L45 if (dtype == "b-value") { ...
R/Mvalue_ComBat.R#L47 stop("Invalid pseudo beta-values." ...
R/Mvalue_ComBat.R#L51 } ...
R/Mvalue_ComBat.R#L52 ...
R/Mvalue_ComBat.R#L53 ## convert beta values to M values if ...
R/Mvalue_ComBat.R#L54 if (dtype == "b-value") { ...
R/Mvalue_ComBat.R#L56 } else { ...
R/Mvalue_ComBat.R#L58 } ...
R/Mvalue_ComBat.R#L59 ...
R/Mvalue_ComBat.R#L60 ## construct the model matrix ...
R/Mvalue_ComBat.R#L61 mod <- covar_mod ...
R/Mvalue_ComBat.R#L62 if (full_mod) { ...
R/Mvalue_ComBat.R#L64 } ...
R/Mvalue_ComBat.R#L65 ...
R/Mvalue_ComBat.R#L66 ## run ComBat ...
R/Mvalue_ComBat.R#L67 if (mean.only) { ...
R/Mvalue_ComBat.R#L69 par.prior = TRUE, r ...
R/Mvalue_ComBat.R#L70 } else { ...
R/Mvalue_ComBat.R#L72 par.prior = TRUE, r ...
R/Mvalue_ComBat.R#L73 } ...
R/Mvalue_ComBat.R#L74 ...
R/Mvalue_ComBat.R#L75 ## convert adjusted M values back to b ...
R/Mvalue_ComBat.R#L76 if (dtype == "b-value") { ...
R/Mvalue_ComBat.R#L78 } else { ...
R/Mvalue_ComBat.R#L80 } ...
R/Mvalue_ComBat.R#L81 return(adj_vmat) ...
vignettes/sva.Rnw#L190 nrow=50, ncol=8) ...
vignettes/sva.Rnw#L195 ...
vignettes/sva.Rnw#L201 group=grou ...
vignettes/sva.Rnw#L203 ...
vignettes/sva.Rnw#L211 group=NULL ...
vignettes/sva.Rnw#L213 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants