Skip to content

Add dirichlet#264

Open
stemangiola wants to merge 3 commits into
masterfrom
add-dirichlet
Open

Add dirichlet#264
stemangiola wants to merge 3 commits into
masterfrom
add-dirichlet

Conversation

@stemangiola

Copy link
Copy Markdown
Collaborator

No description provided.

- Introduced a new noise model option, 'dirichlet_multinomial', in the sccomp package, allowing for the use of Dirichlet-multinomial likelihoods for count data.
- Updated the `fit_model` function to accommodate different initialization parameters based on the selected noise model.
- Enhanced documentation for `sccomp_estimate` and related functions to clarify the new noise model options and their implications.
- Added tests to ensure functionality and correctness of the new model implementation, including checks for expected output structure and compatibility with existing models.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for a new Dirichlet(-multinomial) noise model option to sccomp_estimate(), including a new Stan model and accompanying documentation/tests.

Changes:

  • Add noise_model = "dirichlet_multinomial" option and route model fitting to a new Stan program.
  • Update Stan model initialization and proportion preprocessing (renormalization after 0 replacement).
  • Add test coverage and update generated documentation for the new noise model.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/testthat/test-dirichlet.R Adds tests for estimating/testing with dirichlet_multinomial, plus a correlation check vs. existing model.
R/sccomp_estimate.R Extends API to accept dirichlet_multinomial, validates via match.arg(), and selects the Stan model/parameters accordingly.
R/model_fitting.R Adjusts Stan init values by model name and renormalizes y_proportion rows after replacing zeros.
man/sccomp_estimate.Rd Documents the new noise_model option and behavior for counts vs proportions.
man/sccomp_calculate_residuals.Rd Clarifies meaning of residuals_unconstrained and updates details accordingly.
inst/stan/glm_dirichlet.stan Introduces a Dirichlet-multinomial / Dirichlet Stan model with reduce_sum and log_lik for LOO.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/sccomp_estimate.R Outdated
Comment on lines +89 to +102
est_bb <- sccomp_estimate(
counts_obj,
formula_composition = ~ type,
formula_variability = ~ 1,
sample = "sample",
cell_group = "cell_group",
abundance = "count",
noise_model = "multi_beta_binomial",
cores = 1,
verbose = FALSE,
inference_method = "hmc",
max_sampling_iterations = 500,
cache_stan_model = cache_dir
)

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests run HMC without setting mcmc_seed, but sccomp_estimate() defaults to a random seed (sample_seed()), which can make the test non-deterministic and flaky (especially the correlation threshold). Set an explicit mcmc_seed for the estimates in this test file (at least for the correlation test).

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants