Description Usage Arguments Value Author(s) Examples
Calculate mean of residuals from user-specified drifting CpGs.
1  | 
df | 
 Beta-value data frame, where columns are samples and rows are markers.  | 
driftcg | 
 List of drifting CpGs for which to calculate residuals.  | 
chrage | 
 Sample chronological (patient) age, in same order as columns in df.  | 
showStatusDrift | 
 Whether to show detailed output of calculation status.  | 
keepres | 
 Whether to retain CpG-level residuals used in calculation of mean.  | 
Returns age estimate and specified additional information.
Sean K Maden
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  | ## The function is currently defined as
function(df, driftcg,chrage,showStatusDrift=TRUE,keepres=FALSE){
  # note: chrage sample age order must correspond to order of columns in df
  message("Beginning Drift CpG residuals calculations...")
  dfdrift <- df[rownames(df) 
  reslist <- c()
  for(i in 1:nrow(dfdrift)){
    reslist[[i]] <- lm(dfdrift[i,]~chrage)$residuals
    names(reslist)[i] <- rownames(dfdrift)[i]
    if(showStatusDrift){
#      message("Drift Residuals Status: finished ",i," or ",round((100*(i/nrow(dfdrift))),3),"%.")
    }
  }
  xvecti <- c(rep(0,ncol(dfdrift)))
  for(i in 1:ncol(dfdrift)){
    xvecti[i] <- mean(sapply(reslist, "[", i))
    names(xvecti)[i] <- colnames(dfdrift)[i]
  }
  driftlm <- data.frame(Mean.Residual=xvecti,Chr.Age=chrage)
  rownames(driftlm) <- colnames(dfdrift)
  return.list <- list(driftlm)
  if(keepres){
    return.list <- append(return.list,list(reslist))
    names(return.list)[[length(return.list)]] <- "All.Drift.Residuals"
  }
  return(return.list)
}
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.