Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the sum of generated count is 0, the division was returning null… #120

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
role = c("aut", "cre"))
)
Expand Down
2 changes: 1 addition & 1 deletion R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>%

Expand Down
2 changes: 1 addition & 1 deletion inst/stan/glm_multi_beta_binomial_generate_date.stan
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
Loading