diff --git a/DESCRIPTION b/DESCRIPTION index bf7dcfe..9f1271e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: dreamlet Type: Package Title: Scalable differential expression analysis of single cell transcriptomics datasets with complex study designs -Version: 1.1.18 -Date: 2024-02-14 +Version: 1.1.19 +Date: 2024-02-28 Authors@R: person("Gabriel", "Hoffman", role=c("aut", "cre"), email="gabriel.hoffman@mssm.edu", comment=c(ORCID="0000-0002-0957-0224")) Description: Recent advances in single cell/nucleus transcriptomic technology has enabled collection of cohort-scale datasets to study cell type specific gene expression differences associated disease state, stimulus, and genetic regulation. The scale of these data, complex study designs, and low read count per cell mean that characterizing cell type specific molecular mechanisms requires a user-frieldly, purpose-build analytical framework. We have developed the dreamlet package that applies a pseudobulk approach and fits a regression model for each gene and cell cluster to test differential expression across individuals associated with a trait of interest. Use of precision-weighted linear mixed models enables accounting for repeated measures study designs, high dimensional batch effects, and varying sequencing depth or observed cells per biosample. VignetteBuilder: knitr diff --git a/NEWS.md b/NEWS.md index 6cf07e3..191d8a9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,7 @@ +# dreamlet 1.1.19 + - bug fix in `compositePosteriorTest()` + # dreamlet 1.1.18 - bug fix diff --git a/R/compositePosteriorTest.R b/R/compositePosteriorTest.R index 163f45a..8a71207 100644 --- a/R/compositePosteriorTest.R +++ b/R/compositePosteriorTest.R @@ -62,16 +62,20 @@ compositePosteriorTest <- function(x, include, exclude = NULL, test = c("at least 1", "all")) { test <- match.arg(test) - stopifnot(is(x, "dreamlet_mash_result")) - - # get probability from lFSR - prob <- 1 - get_lfsr(x$model) + if( is(x, "dreamlet_mash_result") ){ + # get probability from lFSR + prob <- 1 - get_lfsr(x$model) + }else if(is(x, "data.frame") | is(x, "matrix")){ + prob = x + }else{ + stop("data type of x not recognized") + } .compositePosteriorTest(prob, include, exclude, test) } # Given matrix of posterior probabilities with genes on rows and columns as conditions, compute composite probability from include vs exclude set. -.compositePosteriorTest <- function(prob, include, exclude, test = c("at least 1", "all")) { +.compositePosteriorTest <- function(prob, include, exclude=NULL, test = c("at least 1", "all")) { test <- match.arg(test) # if probability is NA, set it to zero @@ -89,7 +93,7 @@ compositePosteriorTest <- function(x, include, exclude = NULL, test = c("at leas } else if (test == "all") { # for each gene # probability that *ALL* cell types have a non-zero effect - prob_incl <- apply(prob[, include], 1, prod, na.rm = TRUE) + prob_incl <- apply(prob[, include, drop = FALSE], 1, prod, na.rm = TRUE) } prob_incl * prob_excl