Skip to content
Open
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,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.
Expand Down
4 changes: 2 additions & 2 deletions inst/stan/common_functions.stan
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
18 changes: 11 additions & 7 deletions inst/stan/glm_multi_beta_binomial.stan
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<lower=0> random_effect_sigma_sigma;

// For models with a single group (kept from the original design)
array[is_random_effect>0] real zero_random_effect;
Expand Down Expand Up @@ -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
);
}
Expand All @@ -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
);
}
Expand All @@ -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
);
}
Expand All @@ -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
);
}
Expand Down Expand Up @@ -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 <lower=0>
zero_random_effect ~ std_normal();
}

Expand Down
12 changes: 7 additions & 5 deletions inst/stan/glm_multi_beta_binomial_generate_data.stan
Original file line number Diff line number Diff line change
Expand Up @@ -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<lower=0> random_effect_sigma_sigma;
array[is_random_effect>0] real zero_random_effect;
}
transformed parameters {
Expand Down Expand Up @@ -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
);
}
Expand All @@ -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
);
}
Expand All @@ -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
);
}
Expand All @@ -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
);
}
Expand Down
4 changes: 3 additions & 1 deletion inst/stan/glm_multi_beta_binomial_simulate_data.stan
Original file line number Diff line number Diff line change
Expand Up @@ -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<lower=0> random_effect_sigma_sigma;

// Covariance
array[M-1 * (is_random_effect>0)] vector[how_many_factors_in_random_design[1]] random_effect_sigma_raw;
Expand Down