Skip to content

Commit

Permalink
Fix samr error options
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob Russel committed Sep 25, 2017
1 parent 20910f5 commit 30bfb72
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Version: 2.6.0
Authors@R: person("Jakob", "Russel", email = "[email protected]", role = c("aut", "cre"))
Description: What the title says.
Depends: R (>= 3.2.5)
Imports: foreach, doParallel, doSNOW, snow, MASS, pROC, ggplot2, cowplot, lme4, nlme, stats, methods, statmod, pscl, samr, minqa, nloptr, venneuler
Imports: foreach, doParallel, doSNOW, snow, MASS, pROC, ggplot2, cowplot, lme4, nlme, stats, methods, utils, statmod, pscl, samr, minqa, nloptr, venneuler
License: GPL (>= 3)
Encoding: UTF-8
LazyData: true
Expand Down
10 changes: 4 additions & 6 deletions R/DA.sam.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#' @export
DA.sam <- function(data, predictor, paired = NULL, fdr.output = 0.05, allResults = FALSE, ...){

library(samr, quietly = TRUE)

# Extract from phyloseq
if(class(data) == "phyloseq"){
if(length(predictor) > 1 | length(paired) > 1) stop("When data is a phyloseq object predictor and paired should only contain the name of the variables in sample_data")
Expand All @@ -29,21 +27,21 @@ DA.sam <- function(data, predictor, paired = NULL, fdr.output = 0.05, allResults

if(is.numeric(predictor)){
# Quantitative
res <- SAMseq(count_table, predictor, resp.type = "Quantitative", genenames = rownames(count_table), fdr.output = fdr.output, ...)
res <- samr::SAMseq(count_table, predictor, resp.type = "Quantitative", genenames = rownames(count_table), fdr.output = fdr.output, ...)
} else {
# Categorical
predictor <- as.numeric(as.factor(predictor))

if(length(levels(as.factor(predictor))) == 2){
if(is.null(paired)){
res <- SAMseq(count_table, predictor, resp.type = "Two class unpaired", genenames = rownames(count_table), fdr.output = fdr.output)
res <- samr::SAMseq(count_table, predictor, resp.type = "Two class unpaired", genenames = rownames(count_table), fdr.output = fdr.output)
} else {
predictor[predictor == 2] <- -1
predictor <- as.numeric(as.factor(paired)) * predictor
res <- SAMseq(count_table, predictor, resp.type = "Two class paired", genenames = rownames(count_table), fdr.output = fdr.output, ...)
res <- samr::SAMseq(count_table, predictor, resp.type = "Two class paired", genenames = rownames(count_table), fdr.output = fdr.output, ...)
}
} else {
res <- SAMseq(count_table, predictor, resp.type = "Multiclass", genenames = rownames(count_table), fdr.output = fdr.output, ...)
res <- samr::SAMseq(count_table, predictor, resp.type = "Multiclass", genenames = rownames(count_table), fdr.output = fdr.output, ...)
}
}

Expand Down
2 changes: 1 addition & 1 deletion R/testDA.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
#' \item run.times - A dataframe with average run times of the different methods
#' }
#'
#' @import snow doSNOW foreach
#' @import snow doSNOW foreach utils
#' @importFrom parallel detectCores
#' @importFrom pROC roc
#' @export
Expand Down
6 changes: 6 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Fix samr options problem

.onLoad <- function(libname, pkgname){
options(error=utils::dump.frames)
}

0 comments on commit 30bfb72

Please sign in to comment.