R/histoRawp.R

Defines functions histoRawp

Documented in histoRawp

#' Histogram of raw p-values
#'
#' Histogram of raw p-values
#'
#' @param complete list of results from \code{exportComplete()} or \code{exportComplete.edgeR()}
#' @param out \code{TRUE} to export the figure
#' @param versionName versionName of the project
#' @return Histograms of the raw p-values
#' @author Marie-Agnes Dillies and Hugo Varet

# created Feb 14th, 2012
# modified Feb 17th, 2012
# modified Oct 30th, 2012 (png)
# modified Jan 16th, 2013 (pdf)
# modified Oct 15th, 2013 (grep "val" > $pvalue)
# modified Nov 8th, 2013 (res is now a list)
# modified Nov 15th, 2013 (first argument is now complete for compatibility with edgeR)
# modified Mar 21st, 2014 (removed outputfile argument)
# modified Aug 5th, 2014 (removed graphDir argument)
# modified August 26th, 2019 (ggplot2)

histoRawp <- function(complete, out = TRUE, versionName="."){
  if (out) pdf(file=paste0("figures/", versionName, "-histoRawp.pdf"))
  for (name in names(complete)){
    complete.name <- complete[[name]]
    complete.name <- complete.name[which(!is.na(complete.name$pvalue)),]
    print(ggplot(data=complete.name, aes(x=.data$pvalue)) +
            geom_histogram(binwidth=0.02) +
            scale_y_continuous(expand=expansion(mult=c(0.01, 0.05))) +
            xlab("Raw p-value") +
            ylab("Frequency") +
            ggtitle(paste0(versionName, " - Distribution of raw p-values\nComparison ", name)))
  }
  if (out) dev.off()
}
biomics-pasteur-fr/RNADiff documentation built on Aug. 27, 2020, 12:44 a.m.