R/diagLogFC.r

Defines functions diagLogFC

Documented in diagLogFC

#' Plot the distribution of the log2 Fold Changes
#'
#' Plot the distribution of the log2 Fold Changes for each comparison
#'
#' @param complete an element of the list created by of \code{exportComplete.DESeq2()} or \code{exportComplete.DESeq2()}
#' @param out \code{TRUE} to export the figure
#' @param versionName versionName of the project
#' @return A hisogram of the log2(Fold-Changes) for each comparison performed
#' @author Hugo Varet

# created Janurary 26th, 2017
# modified August 26th, 2019 (ggplot2)

diagLogFC <- function(complete, out = TRUE, versionName="."){
  if (out) pdf(file=paste0("figures/", versionName, "-diagLog2FoldChange.pdf"))
  for (name in names(complete)){
    complete.name <- complete[[name]]
    complete.name <- complete.name[which(!is.na(complete.name$log2FoldChange)),]
    print(ggplot(data=complete.name, aes(x=.data$log2FoldChange)) +
            geom_histogram(binwidth=0.5) +
            scale_y_continuous(expand=expansion(mult=c(0.01, 0.05))) +
            xlab(expression(log[2] ~ (FC))) +
            ylab("Frequency") +
            ggtitle(paste0(versionName," - log(Fold-Change) distribution\ncomparison ", name)))
  }
  if (out) dev.off()
}
biomics-pasteur-fr/RNADiff documentation built on Aug. 27, 2020, 12:44 a.m.