diff --git a/DESCRIPTION b/DESCRIPTION index da8a8cb7..0c7d39c4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: sccomp Type: Package Title: Differential Composition and Variability Analysis for Single-Cell Data -Version: 2.1.32 +Version: 2.1.33 Date: 2026-05-11 Authors@R: c(person("Stefano", "Mangiola", email = "stefano.mangiola@unimelb.edu.au", role = c("aut", "cre")), person("Alexandra J.", "Roth-Schulze", role = "aut"), person("Marie", "Trussart", role = "aut"), person("Enrique", "Zozaya-Valdés", role = "aut"), person("Mengyao", "Ma", role = "aut"), person("Zijie", "Gao", role = "aut"), person("Alan F.", "Rubin", role = "aut"), person("Terence P.", "Speed", role = "aut"), person("Heejung", "Shim", role = "aut"), person("Anthony T.", "Papenfuss", role = "aut")) Description: Comprehensive R package for differential composition and variability analysis in single-cell RNA sequencing, CyTOF, and microbiome data. Provides robust Bayesian modeling with outlier detection, random effects, and advanced statistical methods for cell type proportion analysis. Features include probabilistic outlier identification, mixed-effect modeling, differential variability testing, and comprehensive visualization tools. Perfect for cancer research, immunology, developmental biology, and single-cell genomics applications. diff --git a/inst/stan/common_functions.stan b/inst/stan/common_functions.stan index dc2a35df..5e8ac484 100644 --- a/inst/stan/common_functions.stan +++ b/inst/stan/common_functions.stan @@ -109,8 +109,8 @@ int ncol, // # cols in this block's design matrix array[,] int group_factor_indexes, // factor x group -> col index array[] vector raw_vec, // length ncol, each length M - real sigma_mu, // hierarchical hyperprior mean - real sigma_sigma, // hierarchical hyperprior SD + real sigma_mu, // hierarchical hyperprior mean (callers pass 0.0; see fitting model) + real sigma_sigma, // hierarchical hyperprior SD (callers pass 1.0; see fitting model) array[] vector sigma_raw, // length M, each length n_factors array[] matrix corr_chol // length M, each n_factors x n_factors ) { diff --git a/inst/stan/glm_multi_beta_binomial.stan b/inst/stan/glm_multi_beta_binomial.stan index e74600de..b7243074 100755 --- a/inst/stan/glm_multi_beta_binomial.stan +++ b/inst/stan/glm_multi_beta_binomial.stan @@ -405,7 +405,8 @@ parameters{ // * sigma_correlation_factor_k: per-category Cholesky of correlation matrix // (n_factors[k] x n_factors[k]; 1x1 = no LKJ work) // - // Hyperprior scalars sigma_mu / sigma_sigma are shared in length-4 arrays. + // Hyperprior scalars retained for backward compatibility. build_re_block uses + // fixed sigma_mu = 0.0 and sigma_sigma = 1.0 (see transformed parameters). // ---------------------------------------------------------------------- // Slot 1 @@ -429,8 +430,11 @@ parameters{ array[M * (ncol_X_random_eff[4]>0)] cholesky_factor_corr[how_many_factors_in_random_design[4] * (ncol_X_random_eff[4]>0)] sigma_correlation_factor_4; // Shared hyperprior scalars (one mu, one sigma per slot) + // Retained for backward compatibility; not used in the likelihood + // (build_re_block is called with sigma_mu = 0.0, sigma_sigma = 1.0). + // Priors below keep both names in draws. array[4 * (is_random_effect>0)] real random_effect_sigma_mu; - array[4 * (is_random_effect>0)] real random_effect_sigma_sigma; + array[4 * (is_random_effect>0)] real random_effect_sigma_sigma; // For models with a single group (kept from the original design) array[is_random_effect>0] real zero_random_effect; @@ -479,7 +483,7 @@ transformed parameters{ random_effect_1 = build_re_block( M, n_groups[1], how_many_factors_in_random_design[1], ncol_X_random_eff[1], group_factor_indexes_for_covariance_1, raw_vec, - random_effect_sigma_mu[1], random_effect_sigma_sigma[1], + 0.0, 1.0, random_effect_sigma_raw_1, sigma_correlation_factor_1 ); } @@ -490,7 +494,7 @@ transformed parameters{ random_effect_2 = build_re_block( M, n_groups[2], how_many_factors_in_random_design[2], ncol_X_random_eff[2], group_factor_indexes_for_covariance_2, raw_vec, - random_effect_sigma_mu[2], random_effect_sigma_sigma[2], + 0.0, 1.0, random_effect_sigma_raw_2, sigma_correlation_factor_2 ); } @@ -501,7 +505,7 @@ transformed parameters{ random_effect_3 = build_re_block( M, n_groups[3], how_many_factors_in_random_design[3], ncol_X_random_eff[3], group_factor_indexes_for_covariance_3, raw_vec, - random_effect_sigma_mu[3], random_effect_sigma_sigma[3], + 0.0, 1.0, random_effect_sigma_raw_3, sigma_correlation_factor_3 ); } @@ -512,7 +516,7 @@ transformed parameters{ random_effect_4 = build_re_block( M, n_groups[4], how_many_factors_in_random_design[4], ncol_X_random_eff[4], group_factor_indexes_for_covariance_4, raw_vec, - random_effect_sigma_mu[4], random_effect_sigma_sigma[4], + 0.0, 1.0, random_effect_sigma_raw_4, sigma_correlation_factor_4 ); } @@ -616,7 +620,7 @@ model{ // ---------------------------------------------------------------------- if (is_random_effect > 0) { random_effect_sigma_mu ~ std_normal(); - random_effect_sigma_sigma ~ std_normal(); + random_effect_sigma_sigma ~ std_normal(); // half-normal via zero_random_effect ~ std_normal(); } diff --git a/inst/stan/glm_multi_beta_binomial_generate_data.stan b/inst/stan/glm_multi_beta_binomial_generate_data.stan index 4427d86c..061fc8cd 100755 --- a/inst/stan/glm_multi_beta_binomial_generate_data.stan +++ b/inst/stan/glm_multi_beta_binomial_generate_data.stan @@ -117,7 +117,9 @@ parameters { array[M * (ncol_X_random_eff[4]>0)] cholesky_factor_corr[how_many_factors_in_random_design[4] * (ncol_X_random_eff[4]>0)] sigma_correlation_factor_4; array[4 * (is_random_effect>0)] real random_effect_sigma_mu; - array[4 * (is_random_effect>0)] real random_effect_sigma_sigma; + // Retained for backward compatibility when binding saved draws; build_re_block + // uses sigma_mu = 0.0 and sigma_sigma = 1.0 (same as the fitting model). + array[4 * (is_random_effect>0)] real random_effect_sigma_sigma; array[is_random_effect>0] real zero_random_effect; } transformed parameters { @@ -149,7 +151,7 @@ transformed parameters { random_effect_1 = build_re_block( M, n_groups[1], how_many_factors_in_random_design[1], ncol_X_random_eff[1], group_factor_indexes_for_covariance_1, raw_vec, - random_effect_sigma_mu[1], random_effect_sigma_sigma[1], + 0.0, 1.0, random_effect_sigma_raw_1, sigma_correlation_factor_1 ); } @@ -159,7 +161,7 @@ transformed parameters { random_effect_2 = build_re_block( M, n_groups[2], how_many_factors_in_random_design[2], ncol_X_random_eff[2], group_factor_indexes_for_covariance_2, raw_vec, - random_effect_sigma_mu[2], random_effect_sigma_sigma[2], + 0.0, 1.0, random_effect_sigma_raw_2, sigma_correlation_factor_2 ); } @@ -169,7 +171,7 @@ transformed parameters { random_effect_3 = build_re_block( M, n_groups[3], how_many_factors_in_random_design[3], ncol_X_random_eff[3], group_factor_indexes_for_covariance_3, raw_vec, - random_effect_sigma_mu[3], random_effect_sigma_sigma[3], + 0.0, 1.0, random_effect_sigma_raw_3, sigma_correlation_factor_3 ); } @@ -179,7 +181,7 @@ transformed parameters { random_effect_4 = build_re_block( M, n_groups[4], how_many_factors_in_random_design[4], ncol_X_random_eff[4], group_factor_indexes_for_covariance_4, raw_vec, - random_effect_sigma_mu[4], random_effect_sigma_sigma[4], + 0.0, 1.0, random_effect_sigma_raw_4, sigma_correlation_factor_4 ); } diff --git a/inst/stan/glm_multi_beta_binomial_simulate_data.stan b/inst/stan/glm_multi_beta_binomial_simulate_data.stan index a719643e..27ddd8da 100755 --- a/inst/stan/glm_multi_beta_binomial_simulate_data.stan +++ b/inst/stan/glm_multi_beta_binomial_simulate_data.stan @@ -34,7 +34,9 @@ parameters{ // sd of random intercept array[is_random_effect>0] real random_effect_sigma_mu; - array[is_random_effect>0] real random_effect_sigma_sigma; + // Retained for backward compatibility; fitting model fixes sigma_mu = 0.0 and + // sigma_sigma = 1.0 in build_re_block but keeps these parameters for draw structure. + array[is_random_effect>0] real random_effect_sigma_sigma; // Covariance array[M-1 * (is_random_effect>0)] vector[how_many_factors_in_random_design[1]] random_effect_sigma_raw;