Skip to content

Commit

Permalink
checkParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
hvaret committed Aug 10, 2017
1 parent e236a45 commit 4101a8b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 68 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: SARTools
Type: Package
Title: Statistical Analysis of RNA-Seq Tools
Version: 1.5.0
Date: 2017-06-13
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
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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
------------------------
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

0 comments on commit 4101a8b

Please sign in to comment.