From 9ae4f272e8182c10797850fe13fedb2ddb4cd085 Mon Sep 17 00:00:00 2001 From: Gabriel Hoffman Date: Wed, 28 Feb 2024 15:51:06 -0500 Subject: [PATCH] 1.1.19 --- DESCRIPTION | 4 ++-- NEWS.md | 3 +++ R/compositePosteriorTest.R | 16 ++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index bf7dcfee..9f1271ef 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 6cf07e33..191d8a98 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 163f45af..8a712079 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