Skip to content

Commit

Permalink
1.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
ATpoint committed Dec 9, 2024
1 parent 6f3ce5f commit ee2f44d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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.8
Version: 1.0.9
Author: Alexander Bender [aut,cre]
Maintainer: Alexander Bender <[email protected]>
License: LGPL (>=2)
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
CHANGES IN VERSION 1.0.9
------------------------

o if returning the DGEList also return design and contrasts, and bugfixes

CHANGES IN VERSION 1.0.8
------------------------

Expand Down
14 changes: 11 additions & 3 deletions R/de_testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#' @param return_object Logical, whether to return the DGEList in the output.
#' @param delim A delimiter string used in the names of the output list.
#' @param return_confinf Logical, whether to return 95\% confidence intervals for the logFCs.
#' @param use_seed Integer, use this seed for subsampling genes to speed up duplicateCorrelation if there are more than 5000 genes
#'
#' @examples
#' # Testing on pseudobulk level with limma-voom
Expand Down Expand Up @@ -89,7 +90,7 @@ de_limma <- function(x, use_assay = "counts", aggregate_by = NULL, use_existing_
min_pct = 0, min_fc = 1.0, use_weights = FALSE,
mode = c("pairwise", "average"), use_trend = FALSE,
use_filterByExpr = FALSE, return_object = FALSE, delim = "_vs_",
return_confinf = FALSE) {
return_confinf = FALSE, use_seed = 1) {
# Checks
is_sce <- is(x, "SingleCellExperiment")
if (!is_sce) stop("x must be a SingleCellExperiment")
Expand Down Expand Up @@ -225,6 +226,7 @@ de_limma <- function(x, use_assay = "counts", aggregate_by = NULL, use_existing_
if (!use_trend) {
v <- voomLmFit(counts = pb, design = design, sample.weights = use_weights, block = blocker)
trend <- FALSE
aw <- NULL # it's a weight matrix and not a per-sample numeric value
} else {
lcpm <- cpm(pb, log = TRUE)

Expand All @@ -234,9 +236,13 @@ de_limma <- function(x, use_assay = "counts", aggregate_by = NULL, use_existing_

}

# If there is more than 2000 genes we randomly subsample to 2000 to speed up duplicateCorrelation
if (!is.null(block)) {
if (nrow(lcpm) > 2000) {
spl <- sample(x = 1:nrow(lcpm), size = 2000, replace = FALSE)
if (nrow(lcpm) > 5000) {
set.seed(use_seed)
spl <- sample(x = 1:nrow(lcpm), size = 5000, replace = FALSE)
} else {
spl <- 1:nrow(lcpm)
}

dcor <- duplicateCorrelation(object = lcpm[spl, ], design = design, block = blocker, weights = aw)
Expand Down Expand Up @@ -314,6 +320,8 @@ de_limma <- function(x, use_assay = "counts", aggregate_by = NULL, use_existing_

if (return_object) {
pb$samples$weights <- aw
pb$design <- design
pb$contrasts <- contrasts
to_return[["DGEList"]] <- pb
}

Expand Down
5 changes: 4 additions & 1 deletion man/de_limma.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ee2f44d

Please sign in to comment.