R/boxPlate.R

Defines functions boxPlate

Documented in boxPlate

#' Generate a boxplot of normalized probeset intensities for each well on the plate 
#' @param eset ExpressionSet as generated by the 'preprocessing' function 
#' @param filePrefix prefix that will be used to generate the output files; for plate <i>, the default
#' name will be <filePrefix>Plate<i>.pdf; the default file prefix is "boxPlate"
#' @note the color codes correspond to the sampleColor column of the pData of the ExpressionSet passed to argument
#' 'eset'; if no sampleColor column is present, the boxplots will use 'blue' as the fill color 
#' @return no return value; for each of the plates contained in the ExpressionSet object 'eset' a plot is generated
#' @export
boxPlate <- function(eset, filePrefix = "boxPlate") {

  if (is.null(pData(eset)$sampleColor))
    pData(eset)$sampleColor <- "blue"
  
  for (plate in sort(unique(eset$titanPlateNo))) {
    
    pdf(file = paste(filePrefix, "Plate", plate, ".pdf", sep = ""), width = 10, height = 6) 
    
    esettemp <- eset[, eset$titanPlateNo == plate]
    esettemp <- esettemp[, order(esettemp$titanRow, esettemp$titanColumn)]
    boxdata <- as.data.frame(exprs(esettemp))
    colnames(boxdata) <- paste(esettemp$titanRow, esettemp$titanColumn, sep = "")
    ylim <- c(floor(quantile(exprs(eset), probs = 0.25)) - 1, ceiling(quantile(exprs(eset), probs = 0.75)) + 1)
    boxplot(boxdata, outline = FALSE, range = 0, col = esettemp$sampleColor, ylim = ylim, las = 2, cex.axis = 0.7)
    
    if (length(unique(eset$titanPlateNo)) == 1){
      title("Boxplots of intensity values", cex.main = 2)
    } else {
      title(paste("Boxplots of intensity values (Plate ", plate, ')', sep = ""), cex.main = 2)
    }
    
    dev.off()
  }
}

Try the titanQC package in your browser

Any scripts or data that you put into this service are public.

titanQC documentation built on May 2, 2019, 5:55 p.m.