Skip to content

Commit

Permalink
fix phyloseq and parallel bugs appearing in new package versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob Russel committed Jun 5, 2018
1 parent 76a7334 commit d3205e9
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: DAtest
Title: Comparing Differential Abundance methods
Version: 2.7.10
Version: 2.7.11
Authors@R: person("Jakob", "Russel", email = "russel2620@gmail.com", role = c("aut", "cre"))
Description: What the title says.
Depends: R (>= 3.2.5)
Expand Down
2 changes: 1 addition & 1 deletion R/add.tax.DA.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
add.tax.DA <- function(data, res){

if(!is.null(tax_table(data, errorIfNULL = FALSE))){
tax <- tax_table(data)
tax <- unclass(tax_table(data))
res <- merge(res, tax, by.x = "Feature", by.y = "row.names")
rownames(res) <- NULL
}
Expand Down
4 changes: 2 additions & 2 deletions R/allDA.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ allDA <- function(data, predictor, paired = NULL, covars = NULL, tests = c("neb"
if(cores == 1) {
registerDoSEQ()
} else {
cl <- makeCluster(cores)
cl <- parallel::makeCluster(cores)
registerDoSNOW(cl)
on.exit(stopCluster(cl))
}
Expand Down Expand Up @@ -420,7 +420,7 @@ allDA <- function(data, predictor, paired = NULL, covars = NULL, tests = c("neb"
if(class(data) == "phyloseq"){
if(!is.null(tax_table(data, errorIfNULL = FALSE))){
newresults <- list()
tax <- tax_table(data)
tax <- unclass(tax_table(data))
for(i in 1:length(results)){
subres <- results[[i]]
subres <- merge(subres, tax, by.x = "Feature", by.y = "row.names")
Expand Down
2 changes: 1 addition & 1 deletion R/featurePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ featurePlot <- function(data, predictor, paired = NULL, covars = NULL, feature =

# Title
if(class(data) == "phyloseq"){
tax <- tax_table(data)
tax <- unclass(tax_table(data))
subtax <- tax[rownames(tax) == feature,]
p <- p + ggtitle(feature, subtitle = paste(subtax, collapse = "_"))
} else {
Expand Down
2 changes: 1 addition & 1 deletion R/powerDA.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ powerDA <- function(data, predictor, paired = NULL, covars = NULL, test = NULL,
if(cores == 1) {
registerDoSEQ()
} else {
cl <- makeCluster(cores)
cl <- parallel::makeCluster(cores)
registerDoSNOW(cl)
on.exit(stopCluster(cl))
}
Expand Down
2 changes: 1 addition & 1 deletion R/preDA.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ preDA <- function(data, min.samples = 0, min.reads = 0, min.abundance = 0){
# Output
if(class(data) == "phyloseq"){
# Fix tax_table
tax <- as.data.frame(tax_table(data))
tax <- as.data.frame(unclass(tax_table(data)))
tax.keep <- tax[-exclude,]
tax.new <- rbind(tax.keep,NA)
rownames(tax.new)[nrow(tax.new)] <- "Others"
Expand Down
6 changes: 3 additions & 3 deletions R/testDA.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,14 @@ testDA <- function(data, predictor, paired = NULL, covars = NULL, R = 10, tests
if(cores == 1) {
registerDoSEQ()
} else {
cl <- makeCluster(cores)
cl <- parallel::makeCluster(cores)
registerDoSNOW(cl)
on.exit(stopCluster(cl))
}

# Run the tests in parallel
results <- foreach(i = tests.par , .options.snow = opts) %dopar% {

results <- foreach(i = tests.par, .options.snow = opts) %dopar% {
t1.sub <- proc.time()

# Extract run info
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

.onLoad <- function(libname, pkgname){
message("DAtest version 2.7.10")
message("DAtest version 2.7.11")
}

21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ Installation of packages

It is advised not to have any packages loaded when installing DAtest.
Installation of DAtest and all dependencies has been tested to work on a
clean R version 3.4.1 by installing in the following order:
clean R version 3.5.0 by installing in the following order:

The DAtest package:

install.packages("devtools")

# Developmental version (this tutorial is written for this version):
# Developmental version (this tutorial is written for this version, recommended):
devtools::install_github("Russel88/DAtest")

# Version associated with bioRxiv paper:
Expand Down Expand Up @@ -173,6 +173,9 @@ The following are suggested, but not needed:
# For post-hoc testing (generalized) linear models
install.packages("lsmeans")

# Phyloseq, for organizing microbiome data
biocLite("phyloseq")

A short tutorial on a simulated dataset:
========================================

Expand All @@ -195,7 +198,7 @@ Below we simulate a simple dataset, just to show how it works

library(DAtest)

## DAtest version 2.7.9
## DAtest version 2.7.11

################# First we simulate a dataset ###################

Expand All @@ -218,14 +221,14 @@ Below we simulate a simple dataset, just to show how it works

## predictor is assumed to be a categorical variable with 2 levels: Control, Treatment

##
##
|=================================================================| 100%

## bay was excluded due to failure

summary(test)

## Method AUC FPR FDR Spike.detect.rate Score Score.5% Score.95%
## Method AUC FPR FDR Spike.detect.rate Score Score.5% Score.95%
## MgSeq Feature (msf) 1.000 0.000 0.000 1.0 0.500 0.500 0.500
## RAIDA (rai) 1.000 0.000 0.000 1.0 0.500 0.077 0.500
## LIMMA voom (vli) 1.000 0.035 0.031 1.0 0.469 0.035 0.500
Expand All @@ -239,8 +242,8 @@ Below we simulate a simple dataset, just to show how it works
## ZI-NegBin GLM (znb) 0.500 0.000 0.000 0.0 0.000 0.000 0.000
## ZI-Poisson GLM (zpo) 0.500 0.000 0.000 0.0 0.000 0.000 0.000
## MgSeq ZIG (zig) 0.980 0.127 0.434 0.9 -0.002 -0.364 0.219
## ALDEx2 wilcox (adx) 1.000 0.097 0.545 1.0 -0.045 -0.286 0.056
## ALDEx2 t-test (adx) 1.000 0.124 0.583 1.0 -0.083 -0.317 -0.045
## ALDEx2 wilcox (adx) 1.000 0.100 0.538 1.0 -0.038 -0.279 0.036
## ALDEx2 t-test (adx) 1.000 0.124 0.598 1.0 -0.098 -0.317 -0.016
## Log t-test (ltt) 1.000 0.670 0.901 1.0 -0.401 -0.419 -0.391
## Log LIMMA (lli) 1.000 0.689 0.906 1.0 -0.406 -0.419 -0.399
## Quasi-Poisson GLM (qpo) 1.000 0.970 0.924 1.0 -0.424 -0.457 -0.421
Expand All @@ -250,12 +253,14 @@ Below we simulate a simple dataset, just to show how it works
## Negbinom GLM (neb) 1.000 0.989 0.925 1.0 -0.425 -0.425 -0.421
## t-test (ttt) 0.986 0.968 0.924 1.0 -0.438 -0.509 -0.423
## Wilcox (wil) 0.884 0.957 0.924 1.0 -0.540 -0.584 -0.484
## Permutation (per) 0.595 0.962 0.924 1.0 -0.829 -0.863 -0.808
## Permutation (per) 0.604 0.970 0.924 1.0 -0.820 -0.874 -0.733

# From the above MetagenomeSeq Featue model appears to be the best (methods are ranked by the Score)
# Lets run MetagenomeSeq Featue model and check which features are significant:
res1 <- DA.msf(df, predictor = vec)

## Default value being used.

res1[res1$pval.adj < 0.05,"Feature"]

## [1] "10" "9" "3" "4" "7" "8" "1" "6" "2" "5"
Expand Down

0 comments on commit d3205e9

Please sign in to comment.