Throwing an error when calling publish on DESeqResults objects, when no genes pass filters
Adding a unit test to check this behavior
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ReportingTools@91527 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
Package: ReportingTools |
2 | 2 |
Title: Tools for making reports in various formats |
3 |
-Version: 2.5.2 |
|
3 |
+Version: 2.5.3 |
|
4 | 4 |
Author: Jason A. Hackney, Melanie Huntley, Jessica L. Larson, Christina |
5 | 5 |
Chaivorapol, Gabriel Becker, and Josh Kaminker |
6 | 6 |
Maintainer: Jason A. Hackney <hackney.jason@gene.com>, Gabriel Becker |
... | ... |
@@ -9,7 +9,7 @@ Depends: methods, knitr |
9 | 9 |
Imports: Biobase,hwriter,Category,GOstats,limma(>= |
10 | 10 |
3.17.5),lattice,AnnotationDbi,edgeR, annotate,PFAM.db, |
11 | 11 |
GSEABase, BiocGenerics(>= 0.1.6), grid, XML, R.utils, |
12 |
- DESeq2(>= 1.3.41), S4Vectors, IRanges, ggplot2, ggbio |
|
12 |
+ DESeq2(>= 1.3.41), ggplot2, ggbio, IRanges |
|
13 | 13 |
Suggests: RUnit, ALL, hgu95av2.db, org.Mm.eg.db, shiny, pasilla, |
14 | 14 |
Type: Package |
15 | 15 |
LazyLoad: yes |
... | ... |
@@ -14,7 +14,6 @@ importFrom(edgeR, topTags, cpm) |
14 | 14 |
importFrom(GOstats, termGraphs, inducedTermGraph, plotGOTermGraph) |
15 | 15 |
importFrom(DESeq2, results, resultsNames) |
16 | 16 |
importFrom(ggplot2, ggplot) #we don't actually need this, we just need to be able to do setOldClass and have ggplot2 listed in imports |
17 |
-importFrom(S4Vectors, normalizeSingleBracketSubscript) |
|
18 | 17 |
|
19 | 18 |
importMethodsFrom(AnnotationDbi, select, summary, mget) |
20 | 19 |
importMethodsFrom(Category, summary, geneIdsByCategory, geneIdUniverse) |
... | ... |
@@ -26,8 +26,9 @@ setMethod("publish", |
26 | 26 |
if(ncol(object) == 0) |
27 | 27 |
stop("No columns available in data.") |
28 | 28 |
|
29 |
- filter.columns <- |
|
30 |
- normalizeSingleBracketSubscript(filter.columns, object) |
|
29 |
+ # filter.columns <- |
|
30 |
+ # normalizeSingleBracketSubscript(filter.columns, object) |
|
31 |
+ filter.columns <- .normalizeSubscript(filter.columns, object) |
|
31 | 32 |
|
32 | 33 |
sort.class.map <- c( |
33 | 34 |
"numeric" = "sort-num-robust", |
... | ... |
@@ -21,9 +21,11 @@ setMethod("getDefaultColumnClasses", |
21 | 21 |
filter.columns = sapply(object, is.numeric), ...) |
22 | 22 |
{ |
23 | 23 |
|
24 |
- filter.columns <- |
|
25 |
- normalizeSingleBracketSubscript(filter.columns,object) |
|
26 |
- |
|
24 |
+ # filter.columns <- |
|
25 |
+ # normalizeSingleBracketSubscript(filter.columns, object) |
|
26 |
+ filter.columns <- .normalizeSubscript(filter.columns, object) |
|
27 |
+ # filter.columns <- which(filter.columns) |
|
28 |
+ |
|
27 | 29 |
## For all columns, get the appropriate CSS class for sorting the |
28 | 30 |
## data type |
29 | 31 |
sort.class.map <- c( |
... | ... |
@@ -280,3 +282,19 @@ setMethod("getDefaultColumnClasses", |
280 | 282 |
} |
281 | 283 |
) |
282 | 284 |
|
285 |
+.normalizeSubscript <- function(i, x) |
|
286 |
+{ |
|
287 |
+ if( is.logical(i) ) |
|
288 |
+ { |
|
289 |
+ |
|
290 |
+ i <- rep(i, length.out = length(x)) |
|
291 |
+ i <- which(i) |
|
292 |
+ |
|
293 |
+ } else if( is.character(i) || is.factor(i) ) |
|
294 |
+ { |
|
295 |
+ |
|
296 |
+ i <- match(i, names(x)) |
|
297 |
+ |
|
298 |
+ } |
|
299 |
+ i |
|
300 |
+} |
|
283 | 301 |
\ No newline at end of file |
... | ... |
@@ -82,7 +82,11 @@ setMethod("toReportDF", |
82 | 82 |
resTab <- as.data.frame(object[ |
83 | 83 |
which(object$pad < pvalueCutoff & |
84 | 84 |
abs(object$log2FoldChange) > abs(lfc)), ]) |
85 |
- |
|
85 |
+ |
|
86 |
+ if(nrow(resTab) < 1){ |
|
87 |
+ stop("No features meet selection criteria.\nTry changing the log-fold change or p-value cutoff.") |
|
88 |
+ } |
|
89 |
+ |
|
86 | 90 |
if(!is.null(sort.by) & sort.by %in% colnames(resTab)) |
87 | 91 |
resTab <- resTab[order(resTab[, sort.by]), ] |
88 | 92 |
|
... | ... |
@@ -20,6 +20,13 @@ test_1dataframe <- function(){ |
20 | 20 |
"3 columns are returned for the default data.frame") |
21 | 21 |
} |
22 | 22 |
|
23 |
+test_1nogenes <- function(){ |
|
24 |
+ minp <- min(ddsRes$padj, na.rm=TRUE) / 2 |
|
25 |
+ df <- try(toReportDF(ddsRes, n = 100, pvalueCutoff = minp, |
|
26 |
+ make.plots = FALSE), silent=TRUE) |
|
27 |
+ checkTrue(class(df) == "try-error") |
|
28 |
+} |
|
29 |
+ |
|
23 | 30 |
test_2objectToHTML <- function(){ |
24 | 31 |
rv <- objectToHTML(ddsRes, rep=NULL, factor = ddsRes$condition, |
25 | 32 |
n = 100, make.plots=FALSE) |