diff --git a/DESCRIPTION b/DESCRIPTION index 6878f3b..c69a29e 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: SARTools Type: Package Title: Statistical Analysis of RNA-Seq Tools -Version: 1.6.6 -Date: 2018-10-04 +Version: 1.6.7 +Date: 2019-05-07 Author: Marie-Agnes Dillies and Hugo Varet Maintainer: Hugo Varet Depends: R (>= 3.3.0), DESeq2 (>= 1.12.0), edgeR (>= 3.12.0), xtable diff --git a/NEWS b/NEWS index 88d6ff5..45ea8a3 100755 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +CHANGES IN VERSION 1.6.7 +------------------------ + o modified the installation guidelines for the Bioconductor packages + o new parameters in the MAPlot() and volcanoPlot() functions thanks to Ken Field suggestion on GitHub + CHANGES IN VERSION 1.6.6 ------------------------ o fixed a bug introduced in version 1.6.4 when giving featureCounts files as input diff --git a/R/MAPlot.R b/R/MAPlot.R index b8bfc38..db4827f 100755 --- a/R/MAPlot.R +++ b/R/MAPlot.R @@ -5,10 +5,11 @@ #' @param complete A \code{list} of \code{data.frame} containing features results (from \code{exportResults.DESeq2()} or \code{exportResults.edgeR()}) #' @param alpha cut-off to apply on each adjusted p-value #' @param outfile TRUE to export the figure in a png file +#' @param log2FClim numeric vector containing both upper and lower y-axis limits for all the MA-plots produced (NULL by default to set them automatically) #' @return A file named MAPlot.png in the figures directory containing one MA-plot per comparison #' @author Marie-Agnes Dillies and Hugo Varet -MAPlot <- function(complete, alpha=0.05, outfile=TRUE){ +MAPlot <- function(complete, alpha=0.05, outfile=TRUE, log2FClim=NULL){ ncol <- ifelse(length(complete)<=4, ceiling(sqrt(length(complete))), 3) nrow <- ceiling(length(complete)/ncol) if (outfile) png(filename="figures/MAPlot.png", width=cairoSizeWrapper(1800*ncol), height=cairoSizeWrapper(1800*nrow), res=300) @@ -18,7 +19,11 @@ MAPlot <- function(complete, alpha=0.05, outfile=TRUE){ complete.name <- complete.name[complete.name$baseMean>0,] complete.name$padj <- ifelse(is.na(complete.name$padj),1,complete.name$padj) log2FC <- complete.name$log2FoldChange - ylim <- 1.1 * c(-1,1) * quantile(abs(log2FC[is.finite(log2FC)]), probs=0.99) + if (is.null(log2FClim)){ + ylim <- 1.1 * c(-1,1) * quantile(abs(log2FC[is.finite(log2FC)]), probs=0.99) + } else{ + ylim <- log2FClim + } plot(complete.name$baseMean, pmax(ylim[1], pmin(ylim[2], log2FC)), log = "x", cex=0.45, las = 1, ylim = ylim, col = ifelse(complete.name[,"padj"] < alpha, "red", "black"), diff --git a/R/cairoSizeWrapper.R b/R/cairoSizeWrapper.R old mode 100644 new mode 100755 diff --git a/R/summarizeResults.DESeq2.r b/R/summarizeResults.DESeq2.r index 393792a..897cfac 100755 --- a/R/summarizeResults.DESeq2.r +++ b/R/summarizeResults.DESeq2.r @@ -8,11 +8,14 @@ #' @param cooksCutoff outliers detection threshold (TRUE to let DESeq2 choosing it or FALSE to disable the outliers detection) #' @param alpha significance threshold to apply to the adjusted p-values #' @param col colors for the plots +#' @param log2FClim numeric vector containing both upper and lower y-axis limits for all the MA-plots produced (NULL by default to set them automatically) +#' @param padjlim numeric value between 0 and 1 for the adjusted p-value upper limits for all the volcano plots produced (NULL by default to set them automatically) #' @return A list containing: (i) a list of \code{data.frames} from \code{exportResults.DESeq2()}, (ii) the table summarizing the independent filtering procedure and (iii) a table summarizing the number of differentially expressed features #' @author Hugo Varet summarizeResults.DESeq2 <- function(out.DESeq2, group, independentFiltering=TRUE, cooksCutoff=TRUE, - alpha=0.05, col=c("lightblue","orange","MediumVioletRed","SpringGreen")){ + alpha=0.05, col=c("lightblue","orange","MediumVioletRed","SpringGreen"), + log2FClim=NULL, padjlim=NULL){ # create the figures/tables directory if does not exist if (!I("figures" %in% dir())) dir.create("figures", showWarnings=FALSE) if (!I("tables" %in% dir())) dir.create("tables", showWarnings=FALSE) @@ -50,10 +53,10 @@ summarizeResults.DESeq2 <- function(out.DESeq2, group, independentFiltering=TRUE rawpHist(complete=complete) # MA-plots - MAPlot(complete=complete, alpha=alpha) + MAPlot(complete=complete, alpha=alpha, log2FClim=log2FClim) # Volcano plots - volcanoPlot(complete=complete, alpha=alpha) + volcanoPlot(complete=complete, alpha=alpha, padjlim=padjlim) return(list(complete=complete, tabIndepFiltering=tabIndepFiltering, nDiffTotal=nDiffTotal)) } diff --git a/R/summarizeResults.edgeR.r b/R/summarizeResults.edgeR.r index cc0d738..0017954 100755 --- a/R/summarizeResults.edgeR.r +++ b/R/summarizeResults.edgeR.r @@ -7,11 +7,14 @@ #' @param counts matrix of raw counts #' @param alpha significance threshold to apply to the adjusted p-values #' @param col colors for the plots +#' @param log2FClim numeric vector containing both upper and lower y-axis limits for all the MA-plots produced (NULL by default to set them automatically) +#' @param padjlim numeric value between 0 and 1 for the adjusted p-value upper limits for all the volcano plots produced (NULL by default to set them automatically) #' @return A list containing: (i) a list of \code{data.frames} from \code{exportResults.edgeR()} and (ii) a table summarizing the number of differentially expressed features #' @author Hugo Varet summarizeResults.edgeR <- function(out.edgeR, group, counts, alpha=0.05, - col=c("lightblue","orange","MediumVioletRed","SpringGreen")){ + col=c("lightblue","orange","MediumVioletRed","SpringGreen"), + log2FClim=NULL, padjlim=NULL){ # create the figures/tables directory if does not exist if (!I("figures" %in% dir())) dir.create("figures", showWarnings=FALSE) if (!I("tables" %in% dir())) dir.create("tables", showWarnings=FALSE) @@ -34,10 +37,10 @@ summarizeResults.edgeR <- function(out.edgeR, group, counts, alpha=0.05, rawpHist(complete=complete) # MA-plots - MAPlot(complete=complete, alpha=alpha) + MAPlot(complete=complete, alpha=alpha, log2FClim=log2FClim) # Volcano plots - volcanoPlot(complete=complete, alpha=alpha) + volcanoPlot(complete=complete, alpha=alpha, padjlim=padjlim) return(list(complete=complete, nDiffTotal=nDiffTotal)) } diff --git a/R/volcanoPlot.r b/R/volcanoPlot.r index 8f81e65..f75bf00 100755 --- a/R/volcanoPlot.r +++ b/R/volcanoPlot.r @@ -5,10 +5,11 @@ #' @param complete A \code{list} of \code{data.frame} containing features results (from \code{exportResults.DESeq2()} or \code{exportResults.edgeR()}) #' @param alpha cut-off to apply on each adjusted p-value #' @param outfile TRUE to export the figure in a png file +#' @param padjlim numeric value between 0 and 1 for the adjusted p-value upper limits for all the volcano plots produced (NULL by default to set them automatically) #' @return A file named volcanoPlot.png in the figures directory containing one volcano plot per comparison #' @author Hugo Varet -volcanoPlot <- function(complete, alpha=0.05, outfile=TRUE){ +volcanoPlot <- function(complete, alpha=0.05, outfile=TRUE, padjlim=NULL){ ncol <- ifelse(length(complete)<=4, ceiling(sqrt(length(complete))), 3) nrow <- ceiling(length(complete)/ncol) if (outfile) png(filename="figures/volcanoPlot.png", width=cairoSizeWrapper(1800*ncol), height=cairoSizeWrapper(1800*nrow), res=300) @@ -17,7 +18,11 @@ volcanoPlot <- function(complete, alpha=0.05, outfile=TRUE){ complete.name <- complete[[name]] complete.name$padj[which(complete.name$padj==0)] <- .Machine$double.xmin log10pval <- -log10(complete.name$padj) - ylim <- c(0,1) * quantile(log10pval, probs=0.99, na.rm=TRUE) + if (is.null(padjlim)){ + ylim <- c(0,1) * quantile(log10pval, probs=0.99, na.rm=TRUE) + } else{ + ylim <- c(0,1) * -log10(padjlim) + } plot(complete.name$log2FoldChange, pmin(ylim[2], log10pval), ylim=ylim, las=1, cex=0.45, xlab=expression(log[2]~fold~change), ylab=expression(-log[10]~adjusted~P~value), col=ifelse(complete.name$padj <= alpha, "red", "black"), pch=ifelse(log10pval >= ylim[2], 2, 20), diff --git a/README.md b/README.md index 9263734..6032330 100755 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ How to install SARTools? In addition to the SARTools package itself, the workflow requires the installation of several packages: DESeq2, edgeR, genefilter, xtable and knitr (all available online, see the dedicated webpages). SARTools needs R version 3.3.0 or higher, DESeq2 1.12.0 or higher and edgeR 3.12.0 or higher: old versions of DESeq2 or edgeR may be incompatible with SARTools. To install the SARTools package from GitHub, open a R session and: -- install DESeq2, edgeR and genefilter with `source("http://bioconductor.org/biocLite.R")` and `biocLite(c("DESeq2", "edgeR", "genefilter"))` (if not installed yet) +- install DESeq2, edgeR and genefilter with `if (!requireNamespace("BiocManager")){install.packages("BiocManager")}` and `BiocManager::install(c("DESeq2", "edgeR", "genefilter"))` (if not installed yet) - install devtools with `install.packages("devtools")` (if not installed yet) - Notes: diff --git a/man/MAPlot.Rd b/man/MAPlot.Rd index cd4145d..d85bc9e 100644 --- a/man/MAPlot.Rd +++ b/man/MAPlot.Rd @@ -4,7 +4,7 @@ \alias{MAPlot} \title{MA-plots} \usage{ -MAPlot(complete, alpha = 0.05, outfile = TRUE) +MAPlot(complete, alpha = 0.05, outfile = TRUE, log2FClim = NULL) } \arguments{ \item{complete}{A \code{list} of \code{data.frame} containing features results (from \code{exportResults.DESeq2()} or \code{exportResults.edgeR()})} @@ -12,6 +12,8 @@ MAPlot(complete, alpha = 0.05, outfile = TRUE) \item{alpha}{cut-off to apply on each adjusted p-value} \item{outfile}{TRUE to export the figure in a png file} + +\item{log2FClim}{numeric vector containing both upper and lower y-axis limits for all the MA-plots produced (NULL by default to set them automatically)} } \value{ A file named MAPlot.png in the figures directory containing one MA-plot per comparison diff --git a/man/summarizeResults.DESeq2.Rd b/man/summarizeResults.DESeq2.Rd index 63d7f95..b990d9b 100644 --- a/man/summarizeResults.DESeq2.Rd +++ b/man/summarizeResults.DESeq2.Rd @@ -6,7 +6,7 @@ \usage{ summarizeResults.DESeq2(out.DESeq2, group, independentFiltering = TRUE, cooksCutoff = TRUE, alpha = 0.05, col = c("lightblue", "orange", - "MediumVioletRed", "SpringGreen")) + "MediumVioletRed", "SpringGreen"), log2FClim = NULL, padjlim = NULL) } \arguments{ \item{out.DESeq2}{the result of \code{run.DESeq2()}} @@ -20,6 +20,10 @@ summarizeResults.DESeq2(out.DESeq2, group, independentFiltering = TRUE, \item{alpha}{significance threshold to apply to the adjusted p-values} \item{col}{colors for the plots} + +\item{log2FClim}{numeric vector containing both upper and lower y-axis limits for all the MA-plots produced (NULL by default to set them automatically)} + +\item{padjlim}{numeric value between 0 and 1 for the adjusted p-value upper limits for all the volcano plots produced (NULL by default to set them automatically)} } \value{ A list containing: (i) a list of \code{data.frames} from \code{exportResults.DESeq2()}, (ii) the table summarizing the independent filtering procedure and (iii) a table summarizing the number of differentially expressed features diff --git a/man/summarizeResults.edgeR.Rd b/man/summarizeResults.edgeR.Rd index 627f3ab..da61372 100644 --- a/man/summarizeResults.edgeR.Rd +++ b/man/summarizeResults.edgeR.Rd @@ -5,7 +5,8 @@ \title{Summarize edgeR analysis} \usage{ summarizeResults.edgeR(out.edgeR, group, counts, alpha = 0.05, - col = c("lightblue", "orange", "MediumVioletRed", "SpringGreen")) + col = c("lightblue", "orange", "MediumVioletRed", "SpringGreen"), + log2FClim = NULL, padjlim = NULL) } \arguments{ \item{out.edgeR}{the result of \code{run.edgeR()}} @@ -17,6 +18,10 @@ summarizeResults.edgeR(out.edgeR, group, counts, alpha = 0.05, \item{alpha}{significance threshold to apply to the adjusted p-values} \item{col}{colors for the plots} + +\item{log2FClim}{numeric vector containing both upper and lower y-axis limits for all the MA-plots produced (NULL by default to set them automatically)} + +\item{padjlim}{numeric value between 0 and 1 for the adjusted p-value upper limits for all the volcano plots produced (NULL by default to set them automatically)} } \value{ A list containing: (i) a list of \code{data.frames} from \code{exportResults.edgeR()} and (ii) a table summarizing the number of differentially expressed features diff --git a/man/volcanoPlot.Rd b/man/volcanoPlot.Rd index 2243243..57398d9 100644 --- a/man/volcanoPlot.Rd +++ b/man/volcanoPlot.Rd @@ -4,7 +4,7 @@ \alias{volcanoPlot} \title{Volcano plots} \usage{ -volcanoPlot(complete, alpha = 0.05, outfile = TRUE) +volcanoPlot(complete, alpha = 0.05, outfile = TRUE, padjlim = NULL) } \arguments{ \item{complete}{A \code{list} of \code{data.frame} containing features results (from \code{exportResults.DESeq2()} or \code{exportResults.edgeR()})} @@ -12,6 +12,8 @@ volcanoPlot(complete, alpha = 0.05, outfile = TRUE) \item{alpha}{cut-off to apply on each adjusted p-value} \item{outfile}{TRUE to export the figure in a png file} + +\item{padjlim}{numeric value between 0 and 1 for the adjusted p-value upper limits for all the volcano plots produced (NULL by default to set them automatically)} } \value{ A file named volcanoPlot.png in the figures directory containing one volcano plot per comparison diff --git a/template_script_DESeq2.r b/template_script_DESeq2.r index c592f67..5c893ab 100755 --- a/template_script_DESeq2.r +++ b/template_script_DESeq2.r @@ -2,7 +2,7 @@ ### R script to compare several conditions with the SARTools and DESeq2 packages ### Hugo Varet ### March 20th, 2018 -### designed to be executed with SARTools 1.6.6 +### designed to be executed with SARTools 1.6.7 ################################################################################ ################################################################################ diff --git a/template_script_DESeq2_CL.r b/template_script_DESeq2_CL.r index 390a5e0..e509f8b 100755 --- a/template_script_DESeq2_CL.r +++ b/template_script_DESeq2_CL.r @@ -2,7 +2,7 @@ ### R script to compare several conditions with the SARTools and DESeq2 packages ### Hugo Varet ### March 20th, 2018 -### designed to be executed with SARTools 1.6.6 +### designed to be executed with SARTools 1.6.7 ### run "Rscript template_script_DESeq2_CL.r --help" to get some help ################################################################################ diff --git a/template_script_edgeR.r b/template_script_edgeR.r index 0e71063..82ec7da 100755 --- a/template_script_edgeR.r +++ b/template_script_edgeR.r @@ -2,7 +2,7 @@ ### R script to compare several conditions with the SARTools and edgeR packages ### Hugo Varet ### March 20th, 2018 -### designed to be executed with SARTools 1.6.6 +### designed to be executed with SARTools 1.6.7 ################################################################################ ################################################################################ diff --git a/template_script_edgeR_CL.r b/template_script_edgeR_CL.r index 3527159..b0f3945 100755 --- a/template_script_edgeR_CL.r +++ b/template_script_edgeR_CL.r @@ -2,7 +2,7 @@ ### R script to compare several conditions with the SARTools and edgeR packages ### Hugo Varet ### May 16th, 2018 -### designed to be executed with SARTools 1.6.6 +### designed to be executed with SARTools 1.6.7 ### run "Rscript template_script_edgeR_CL.r --help" to get some help ################################################################################