diff --git a/DESCRIPTION b/DESCRIPTION index a56c5f2..211ca1a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: SigGenes Title: Automated differential analysis and signature generation for bulk and single-cell data Description: Automated differential analysis between groups based on limma-voom and generation of per-group signatures via custom filtering. -Version: 1.0.3 +Version: 1.0.4 Author: Alexander Bender [aut,cre] Maintainer: Alexander Bender License: LGPL (>=2) @@ -21,4 +21,4 @@ Suggests: testthat URL: https://github.com/atpoint/SigGenes BugReports: https://github.com/atpoint/SigGenes/issues -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 diff --git a/NEWS b/NEWS index 8f10d51..5eb60d5 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +CHANGES IN VERSION 1.0.4 +------------------------ + + o internal bug fixes and additional checks + CHANGES IN VERSION 1.0.0 ------------------------ diff --git a/R/de_testing.R b/R/de_testing.R index 93b278c..5f7fbb6 100644 --- a/R/de_testing.R +++ b/R/de_testing.R @@ -99,14 +99,22 @@ de_limma <- function(x, use_assay = "counts", aggregate_by=NULL, use_existing_sf if(!is(use_existing_sf, "logical")) stop("use_existing_sf must be logical") - is_main <- main_covariate %in% colnames(colData(x)) + is_too_long_main <- length(main_covariate) + if(is_too_long_main > 1) stop("main_covariate must be length 1") + + is_main <- all(main_covariate %in% colnames(colData(x))) if(!is_main) stop("Not all entries in are in colData(x)") if(!is.null(other_covariates)){ - is_other <- other_covariates %in% colnames(colData(x)) + is_other <- all(other_covariates %in% colnames(colData(x))) if(!is_other) stop("Not all entries in are in colData(x)") } + if(!is.null(aggregate_by)){ + is_agg <- all(aggregate_by %in% colnames(colData(x))) + if(!is_agg) stop("Not all entries in are in colData(x)") + } + is_pct <- min_pct >= 0 & is.numeric(min_pct) if(!is_pct) stop("min_pct must be numeric and not negative") @@ -160,8 +168,8 @@ de_limma <- function(x, use_assay = "counts", aggregate_by=NULL, use_existing_sf if(max_n == 1) stop("No replication in any group -- DE analysis not possible!") # Design, allowing any additional covariates - others <- if(!is.null(other_covariates)) paste0(" + ", other_covariates) else "" - f <- as.formula(paste0("~ 0 + ", main_covariate, others)) + others <- if(!is.null(other_covariates)) paste(other_covariates, collapse = " + ") else "" + f <- as.formula(paste("~ 0", main_covariate, others, sep = "+ ")) design <- model.matrix(f, pb$samples) colnames(design) <- gsub(paste0("^", main_covariate), "", colnames(design)) @@ -289,6 +297,8 @@ de_limma <- function(x, use_assay = "counts", aggregate_by=NULL, use_existing_sf to_return[["params"]]$mode <- mode to_return[["params"]]$delim <- delim to_return[["params"]]$min_pct <- min_pct + to_return[["params"]]$formula <- paste(f, collapse = "") + return(to_return)