Skip to content

Commit

Permalink
Merge pull request #34 from PF2-pasteur-fr/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
hvaret authored Aug 10, 2017
2 parents ffd6d18 + 4101a8b commit b59f57c
Show file tree
Hide file tree
Showing 19 changed files with 1,008 additions and 719 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: SARTools
Type: Package
Title: Statistical Analysis of RNA-Seq Tools
Version: 1.4.1
Date: 2017-05-02
Version: 1.5.0
Date: 2017-08-10
Author: Marie-Agnes Dillies and Hugo Varet
Maintainer: Hugo Varet <[email protected]>
Depends: R (>= 3.3.0), DESeq2 (>= 1.12.0), edgeR (>= 3.12.0), xtable
Imports: stats, utils, graphics, grDevices, knitr, SummarizedExperiment, S4Vectors, limma, genefilter (>= 1.44.0)
Imports: stats, utils, graphics, grDevices, knitr, rmarkdown, SummarizedExperiment, S4Vectors, limma, genefilter (>= 1.44.0)
Suggests: optparse
VignetteBuilder: knitr
Encoding: latin1
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ importFrom(graphics,par)
importFrom(graphics,plot)
importFrom(graphics,points)
importFrom(graphics,text)
importFrom(knitr,knit2html)
importFrom(limma,plotMDS)
importFrom(rmarkdown,render)
importFrom(stats,density)
importFrom(stats,dist)
importFrom(stats,dnorm)
Expand Down
6 changes: 6 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
CHANGES IN VERSION 1.5.0
------------------------
o new HTML report (dynamic table of contents, automatic bibliography)
o simplified SERE calculations
o use of warning() instead of print() in checkParameters.edgeR() and checkParameters.DESeq2()

CHANGES IN VERSION 1.4.1
------------------------
o SARTools now accepts count files generated by featureCounts (still one count file per sample)
Expand Down
2 changes: 1 addition & 1 deletion R/NAMESPACE.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @importFrom graphics abline barplot boxplot curve hist legend lines pairs par plot points text
#' @importFrom stats density dist dnorm formula hclust lm model.matrix p.adjust.methods prcomp quantile relevel sd var
#' @importFrom utils combn head installed.packages packageVersion read.table tail write.table
#' @importFrom knitr knit2html
#' @importFrom rmarkdown render
#' @importFrom SummarizedExperiment assay colData
#' @importFrom S4Vectors mcols metadata
#' @importFrom limma plotMDS
Expand Down
74 changes: 37 additions & 37 deletions R/checkParameters.DESeq2.r
Original file line number Diff line number Diff line change
Expand Up @@ -25,80 +25,80 @@

checkParameters.DESeq2 <- function(projectName,author,targetFile,rawDir,
featuresToRemove,varInt,condRef,batch,fitType,
cooksCutoff,independentFiltering,alpha,pAdjustMethod,
typeTrans,locfunc,colors){
cooksCutoff,independentFiltering,alpha,pAdjustMethod,
typeTrans,locfunc,colors){
problem <- FALSE
if (!is.character(projectName) | length(projectName)!=1){
print("projectName must be a character vector of length 1")
problem <- TRUE
warning("projectName must be a character vector of length 1")
problem <- TRUE
}
if (!is.character(author) | length(author)!=1){
print("author must be a character vector of length 1")
problem <- TRUE
warning("author must be a character vector of length 1")
problem <- TRUE
}
if (!is.character(targetFile) | length(targetFile)!=1 || !file.exists(targetFile)){
print("targetFile must be a character vector of length 1 specifying an accessible file")
problem <- TRUE
warning("targetFile must be a character vector of length 1 specifying an accessible file")
problem <- TRUE
}
if (!is.character(rawDir) | length(rawDir)!=1 || is.na(file.info(rawDir)[1,"isdir"]) | !file.info(rawDir)[1,"isdir"]){
print("rawDir must be a character vector of length 1 specifying an accessible directory")
problem <- TRUE
warning("rawDir must be a character vector of length 1 specifying an accessible directory")
problem <- TRUE
}
if (!is.null(featuresToRemove) && !is.character(featuresToRemove)){
print("featuresToRemove must be a character vector or equal to NULL")
problem <- TRUE
warning("featuresToRemove must be a character vector or equal to NULL")
problem <- TRUE
}
if (!is.character(varInt) | length(varInt)!=1){
print("varInt must be a character vector of length 1")
problem <- TRUE
warning("varInt must be a character vector of length 1")
problem <- TRUE
}
if (!is.character(condRef) | length(condRef)!=1){
print("condRef must be a character vector of length 1")
problem <- TRUE
warning("condRef must be a character vector of length 1")
problem <- TRUE
}
if (!is.null(batch) && I(!is.character(batch) | length(batch)!=1)){
print("batch must be NULL or a character vector of length 1")
problem <- TRUE
warning("batch must be NULL or a character vector of length 1")
problem <- TRUE
}
if (!is.character(fitType) | length(fitType)!=1 || !I(fitType %in% c("parametric","local"))){
print("fitType must be equal to 'parametric' or 'local'")
problem <- TRUE
warning("fitType must be equal to 'parametric' or 'local'")
problem <- TRUE
}
if (!is.logical(cooksCutoff) | length(cooksCutoff)!=1){
print("cooksCutoff must be a boolean vector of length 1")
problem <- TRUE
warning("cooksCutoff must be a boolean vector of length 1")
problem <- TRUE
}
if (!is.logical(independentFiltering) | length(independentFiltering)!=1){
print("independentFiltering must be a boolean vector of length 1")
problem <- TRUE
warning("independentFiltering must be a boolean vector of length 1")
problem <- TRUE
}
if (!is.numeric(alpha) | length(alpha)!=1 || I(alpha<=0 | alpha>=1)){
print("alpha must be a numeric vector of length 1 with a value between 0 and 1")
problem <- TRUE
warning("alpha must be a numeric vector of length 1 with a value between 0 and 1")
problem <- TRUE
}
if (!is.character(pAdjustMethod) | length(pAdjustMethod)!=1 || !I(pAdjustMethod %in% p.adjust.methods)){
print(paste("pAdjustMethod must be a value in", paste(p.adjust.methods, collapse=", ")))
problem <- TRUE
warning(paste("pAdjustMethod must be a value in", paste(p.adjust.methods, collapse=", ")))
problem <- TRUE
}
if (!is.character(typeTrans) | length(typeTrans)!=1 || !I(typeTrans %in% c("VST","rlog"))){
print("typeTrans must be equal to 'VST' or 'rlog'")
problem <- TRUE
warning("typeTrans must be equal to 'VST' or 'rlog'")
problem <- TRUE
}
if (!is.character(locfunc) | length(locfunc)!=1 || !I(locfunc %in% c("median","shorth"))){
print("locfunc must be equal to 'median' or 'shorth'")
problem <- TRUE
warning("locfunc must be equal to 'median' or 'shorth'")
problem <- TRUE
} else{
if (locfunc=="shorth" & !I("genefilter" %in% installed.packages()[,"Package"])){
print("Package genefilter is needed if using locfunc='shorth'")
problem <- TRUE
}
warning("Package genefilter is needed if using locfunc='shorth'")
problem <- TRUE
}
}
areColors <- function(col){
sapply(col, function(X){tryCatch(is.matrix(col2rgb(X)), error=function(e){FALSE})})
}
if (!is.vector(colors) || !all(areColors(colors))){
print("colors must be a vector of colors")
problem <- TRUE
warning("colors must be a vector of colors")
problem <- TRUE
}

if (!problem){
Expand Down
60 changes: 30 additions & 30 deletions R/checkParameters.edgeR.r
Original file line number Diff line number Diff line change
Expand Up @@ -23,67 +23,67 @@

checkParameters.edgeR <- function(projectName,author,targetFile,rawDir,
featuresToRemove,varInt,condRef,batch,alpha,
pAdjustMethod,cpmCutoff,gene.selection,
normalizationMethod,colors){
pAdjustMethod,cpmCutoff,gene.selection,
normalizationMethod,colors){
problem <- FALSE
if (!is.character(projectName) | length(projectName)!=1){
print("projectName must be a character vector of length 1")
problem <- TRUE
warning("projectName must be a character vector of length 1")
problem <- TRUE
}
if (!is.character(author) | length(author)!=1){
print("author must be a character vector of length 1")
problem <- TRUE
warning("author must be a character vector of length 1")
problem <- TRUE
}
if (!is.character(targetFile) | length(targetFile)!=1 || !file.exists(targetFile)){
print("targetFile must be a character vector of length 1 specifying an accessible file")
problem <- TRUE
warning("targetFile must be a character vector of length 1 specifying an accessible file")
problem <- TRUE
}
if (!is.character(rawDir) | length(rawDir)!=1 || is.na(file.info(rawDir)[1,"isdir"]) | !file.info(rawDir)[1,"isdir"]){
print("rawDir must be a character vector of length 1 specifying an accessible directory")
problem <- TRUE
warning("rawDir must be a character vector of length 1 specifying an accessible directory")
problem <- TRUE
}
if (!is.null(featuresToRemove) && !is.character(featuresToRemove)){
print("featuresToRemove must be a character vector or equal to NULL")
problem <- TRUE
warning("featuresToRemove must be a character vector or equal to NULL")
problem <- TRUE
}
if (!is.character(varInt) | length(varInt)!=1){
print("varInt must be a character vector of length 1")
problem <- TRUE
warning("varInt must be a character vector of length 1")
problem <- TRUE
}
if (!is.character(condRef) | length(condRef)!=1){
print("condRef must be a character vector of length 1")
problem <- TRUE
warning("condRef must be a character vector of length 1")
problem <- TRUE
}
if (!is.null(batch) && I(!is.character(batch) | length(batch)!=1)){
print("batch must be NULL or a character vector of length 1")
problem <- TRUE
warning("batch must be NULL or a character vector of length 1")
problem <- TRUE
}
if (!is.numeric(alpha) | length(alpha)!=1 || I(alpha<=0 | alpha>=1)){
print("alpha must be a numeric vector of length 1 with a value between 0 and 1")
problem <- TRUE
warning("alpha must be a numeric vector of length 1 with a value between 0 and 1")
problem <- TRUE
}
if (!is.character(pAdjustMethod) | length(pAdjustMethod)!=1 || !I(pAdjustMethod %in% p.adjust.methods)){
print(paste("pAdjustMethod must be a value in", paste(p.adjust.methods, collapse=", ")))
problem <- TRUE
warning(paste("pAdjustMethod must be a value in", paste(p.adjust.methods, collapse=", ")))
problem <- TRUE
}
if (!is.numeric(cpmCutoff) | length(cpmCutoff)!=1 || cpmCutoff<0){
print("cpmCutoff must be a numeric vector of length 1 with a value equal to or greater than 0")
problem <- TRUE
warning("cpmCutoff must be a numeric vector of length 1 with a value equal to or greater than 0")
problem <- TRUE
}
if (!is.character(normalizationMethod) | length(normalizationMethod)!=1 || !I(normalizationMethod %in% c("TMM","RLE","upperquartile"))){
print("gene.selection must be equal to 'TMM', 'RLE' or 'upperquartile'")
problem <- TRUE
warning("gene.selection must be equal to 'TMM', 'RLE' or 'upperquartile'")
problem <- TRUE
}
if (!is.character(gene.selection) | length(gene.selection)!=1 || !I(gene.selection %in% c("pairwise","common"))){
print("gene.selection must be equal to 'pairwise' or 'common'")
problem <- TRUE
warning("gene.selection must be equal to 'pairwise' or 'common'")
problem <- TRUE
}
areColors <- function(col){
sapply(col, function(X){tryCatch(is.matrix(col2rgb(X)), error=function(e){FALSE})})
}
if (!is.vector(colors) || !all(areColors(colors))){
print("colors must be a vector of colors")
problem <- TRUE
warning("colors must be a vector of colors")
problem <- TRUE
}

if (!problem){
Expand Down
6 changes: 1 addition & 5 deletions R/descriptionPlots.r
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ descriptionPlots <- function(counts, group, col=c("lightblue","orange","MediumVi
# SERE and pairwise scatter plots
cat("Matrix of SERE statistics:\n")
print(tabSERE(counts))
if (ncol(counts)<=30){
pairwiseScatterPlots(counts=counts, group=group)
} else{
warning("No pairwise scatter-plot produced because of a too high number of samples (>30).")
}
pairwiseScatterPlots(counts=counts, group=group)

return(majSequences)
}
25 changes: 17 additions & 8 deletions R/pairwiseScatterPlots.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,26 @@

pairwiseScatterPlots <- function(counts, group, outfile=TRUE){
ncol <- ncol(counts)
if (outfile) png(filename="figures/pairwiseScatter.png",width=700*ncol,height=700*ncol,res=300)
if (ncol <= 30){
if (outfile) png(filename="figures/pairwiseScatter.png", width=700*ncol, height=700*ncol, res=300)
# defining panel and lower.panel functions
panel <- function(x,y,...){points(x, y, pch=".");abline(a=0,b=1,lty=2);}
lower.panel <- function(x,y,...){
horizontal <- (par("usr")[1] + par("usr")[2]) / 2;
panel <- function(x,y,...){points(x, y, pch=".");abline(a=0,b=1,lty=2);}
lower.panel <- function(x,y,...){
horizontal <- (par("usr")[1] + par("usr")[2]) / 2;
vertical <- (par("usr")[3] + par("usr")[4]) / 2;
text(horizontal, vertical, round(SERE(2^cbind(x,y) - 1), digits=2), cex=ncol/2.5)
}
# use of the paris function
text(horizontal, vertical, round(SERE(2^cbind(x,y) - 1), digits=2), cex=ncol/2.5)
}
# use of the paris function
pairs(log2(counts+1), panel=panel, lower.panel=lower.panel,
las=1, labels=paste(colnames(counts),group,sep="\n"),
main="Pairwise scatter plot",cex.labels=ncol/2,cex.main=ncol/4)
if (outfile) dev.off()
if (outfile) dev.off()
} else{
warning("No pairwise scatter-plot produced because of a too high number of samples (>30).")
if (outfile) png(filename="figures/pairwiseScatter.png", width=1900, height=1900, res=300)
par(mar=c(1.5, 1.5, 1.5, 1.5))
plot(0, 0, bty="o", pch=".", col="white", xaxt="n", yaxt="n", xlab="", ylab="")
text(0, 0.3, "No pairwise scatter-plot produced because of\na too high number of samples (>30).", pos=1, cex=1.5)
if (outfile) dev.off()
}
}
8 changes: 4 additions & 4 deletions R/tabSERE.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#' @author Marie-Agnes Dillies and Hugo Varet

tabSERE <- function(counts){
sere <- matrix(NA, ncol=ncol(counts), nrow=ncol(counts))
for (i in 1:ncol(counts)){
for (j in 1:ncol(counts)){
sere[i,j] <- SERE(counts[,c(i,j)])
sere <- matrix(0, ncol=ncol(counts), nrow=ncol(counts))
for (i in 1:(ncol(counts)-1)){
for (j in (i+1):ncol(counts)){
sere[i,j] <- sere[j,i] <- SERE(counts[,c(i,j)])
}
}
colnames(sere) <- rownames(sere) <- colnames(counts)
Expand Down
21 changes: 13 additions & 8 deletions R/writeReport.DESeq2.r
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@

writeReport.DESeq2 <- function(target, counts, out.DESeq2, summaryResults, majSequences,
workDir, projectName, author, targetFile, rawDir,
featuresToRemove, varInt, condRef, batch, fitType,
cooksCutoff, independentFiltering, alpha, pAdjustMethod,
typeTrans, locfunc, colors){
knit2html(input=system.file("report_DESeq2.rmd", package="SARTools"),
output=paste0(projectName, "_report.html"),
quiet=TRUE, title="Statistical report")
featuresToRemove, varInt, condRef, batch, fitType,
cooksCutoff, independentFiltering, alpha, pAdjustMethod,
typeTrans, locfunc, colors){
rmarkdown::render(input=system.file("report_DESeq2.rmd", package="SARTools"),
output_file=paste0(projectName, "_report.html"),
output_dir=workDir,
intermediates_dir=workDir,
knit_root_dir=workDir,
run_pandoc=TRUE,
quiet=TRUE,
clean=TRUE)
# delete unwanted directory/file
unlink("cache",force=TRUE,recursive=TRUE)
unlink("report_DESeq2.md",force=TRUE)
# unlink("cache",force=TRUE,recursive=TRUE)
# unlink("report_DESeq2.md",force=TRUE)
cat("HTML report created\n")
}
21 changes: 13 additions & 8 deletions R/writeReport.edgeR.r
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@

writeReport.edgeR <- function(target,counts,out.edgeR,summaryResults,majSequences,
workDir,projectName,author,targetFile,rawDir,
featuresToRemove,varInt,condRef,batch,
alpha,pAdjustMethod,colors,gene.selection,
normalizationMethod){
knit2html(input=system.file("report_edgeR.rmd", package="SARTools"),
output=paste0(projectName, "_report.html"),
quiet=TRUE, title="Statistical report")
featuresToRemove,varInt,condRef,batch,
alpha,pAdjustMethod,colors,gene.selection,
normalizationMethod){
rmarkdown::render(input=system.file("report_edgeR.rmd", package="SARTools"),
output_file=paste0(projectName, "_report.html"),
output_dir=workDir,
intermediates_dir=workDir,
knit_root_dir=workDir,
run_pandoc=TRUE,
quiet=TRUE,
clean=TRUE)
# delete unwanted directory/file
unlink("cache",force=TRUE,recursive=TRUE)
unlink(paste0("report_edgeR.md"),force=TRUE)
# unlink("cache",force=TRUE,recursive=TRUE)
# unlink(paste0("report_edgeR.md"),force=TRUE)
cat("HTML report created\n")
}
Loading

0 comments on commit b59f57c

Please sign in to comment.