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")) ) 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) %>% 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]; }