From 66d246d4c786e1ab31fe8b04910f33376f0a9ebc Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Wed, 6 Mar 2024 10:24:46 +1030 Subject: [PATCH 1/3] When the sum of generated count is 0, the division was returning null. These has been fixed, adding one in the case --- inst/stan/glm_multi_beta_binomial_generate_date.stan | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/stan/glm_multi_beta_binomial_generate_date.stan b/inst/stan/glm_multi_beta_binomial_generate_date.stan index ec47ba06..7692729d 100755 --- a/inst/stan/glm_multi_beta_binomial_generate_date.stan +++ b/inst/stan/glm_multi_beta_binomial_generate_date.stan @@ -127,7 +127,7 @@ generated quantities{ } // Calculate the generated exposure - for(n in 1:N) generated_exposure[n] = sum(counts_uncorrected[n]); + for(n in 1:N) generated_exposure[n] = max( sum(counts_uncorrected[n]), 1); // avoid dividing by zero for(n in 1:N) counts[n] = to_row_vector(counts_uncorrected[n]) / generated_exposure[n] * exposure[n]; } From 0b7d55d31b89d8dc4e3b14649d216cc59bf6aef8 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Wed, 6 Mar 2024 10:26:01 +1030 Subject: [PATCH 2/3] version UP --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index fc1092b3..63b1232c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: sccomp Title: Robust Outlier-aware Estimation of Composition and Heterogeneity for Single-cell Data -Version: 1.7.5 +Version: 1.7.6 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")) ) From 651f064a7f5ee62c9885f000df111a35fd83e405 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Wed, 6 Mar 2024 11:20:41 +1030 Subject: [PATCH 3/3] avoid 0 division in the R code --- R/utilities.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utilities.R b/R/utilities.R index 191bb7b2..4c3742af 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -1410,7 +1410,7 @@ get_probability_non_zero = function(draws, test_above_logit_fold_change = 0, pro parse_generated_quantities = function(rng, number_of_draws = 1){ draws_to_tibble_x_y(rng, "counts", "N", "M", number_of_draws) %>% - with_groups(c(.draw, N), ~ .x %>% mutate(generated_proportions = .value/sum(.value))) %>% + with_groups(c(.draw, N), ~ .x %>% mutate(generated_proportions = .value/max(1, sum(.value)))) %>% filter(.draw<= number_of_draws) %>% rename(generated_counts = .value, replicate = .draw) %>%