Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.

Commit 9c9a0f7

Browse files
Merge pull request #34 from alexmccreight/master
ash grid scaling factor
2 parents 1fa80db + 7e653af commit 9c9a0f7

3 files changed

Lines changed: 12 additions & 16 deletions

File tree

R/sufficient_stats_methods.R

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -334,22 +334,18 @@ update_variance_components.ss <- function(data, params, model, ...) {
334334

335335
# Update the sparse effect variance
336336
sparse_var <- mean(colSums(model$alpha * model$V))
337-
338-
# Update sigma2 and tau2 via MoM
339-
mom_result <- mom_unmappable(data, params, model, omega, sparse_var, est_tau2 = TRUE, est_sigma2 = TRUE)
340-
337+
341338
# Remove the sparse effects
342339
b <- colSums(model$alpha * model$mu)
343340
residuals <- data$y - data$X %*% b
344341

345-
# Specify ash grid
346-
if (mom_result$tau2 > 0) {
347-
grid_factors <- exp(seq(log(0.1), log(100), length.out = 20 - 1))
348-
est_sa2 <- c(0, mom_result$tau2 * grid_factors)
342+
# Build ASH grid based on sparse variance and scaling factor
343+
if (sparse_var * params$ash_scaling_factor > 1e-8) {
344+
grid_factors <- exp(seq(log(0.01), log(10), length.out = 20 - 1))
345+
est_sa2 <- c(0, sparse_var * params$ash_scaling_factor * grid_factors)
349346
} else {
350-
# Fallback if MoM gives tau2 = 0
351347
est_sa2 <- c(0, (2^(0.05*(1:20-1)) - 1)^4)
352-
est_sa2 <- est_sa2 * (0.1 / max(est_sa2))
348+
est_sa2 <- est_sa2 * (0.01 / max(est_sa2))
353349
}
354350

355351
# Call mr.ash with residuals
@@ -359,8 +355,8 @@ update_variance_components.ss <- function(data, params, model, ...) {
359355
sa2 = est_sa2,
360356
intercept = FALSE,
361357
standardize = FALSE,
362-
sigma2 = mom_result$sigma2,
363-
update.sigma2 = params$update_ash_sigma2,
358+
sigma2 = model$sigma2,
359+
update.sigma2 = params$estimate_residual_variance,
364360
max.iter = 3000
365361
)
366362

R/susie.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ susie <- function(X, y, L = min(10, ncol(X)),
279279
estimate_prior_variance = TRUE,
280280
estimate_prior_method = c("optim", "EM", "simple"),
281281
unmappable_effects = c("none", "inf", "ash"),
282-
update_ash_sigma2 = FALSE,
282+
ash_scaling_factor = 0.15,
283283
check_null_threshold = 0,
284284
prior_tol = 1e-9,
285285
residual_variance_upperbound = Inf,
@@ -311,7 +311,7 @@ susie <- function(X, y, L = min(10, ncol(X)),
311311
prior_weights, null_weight, standardize, intercept,
312312
estimate_residual_variance, estimate_residual_method,
313313
estimate_prior_variance, estimate_prior_method,
314-
unmappable_effects, update_ash_sigma2, check_null_threshold, prior_tol,
314+
unmappable_effects, ash_scaling_factor, check_null_threshold, prior_tol,
315315
residual_variance_upperbound, model_init, coverage,
316316
min_abs_corr, compute_univariate_zscore, na.rm,
317317
max_iter, tol, convergence_method, verbose, track_fit,

R/susie_constructors.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ individual_data_constructor <- function(X, y, L = min(10, ncol(X)),
2424
estimate_prior_variance = TRUE,
2525
estimate_prior_method = "optim",
2626
unmappable_effects = "none",
27-
update_ash_sigma2 = FALSE,
27+
ash_scaling_factor = 0.15,
2828
check_null_threshold = 0,
2929
prior_tol = 1e-9,
3030
residual_variance_upperbound = Inf,
@@ -141,7 +141,7 @@ individual_data_constructor <- function(X, y, L = min(10, ncol(X)),
141141
estimate_prior_variance = estimate_prior_variance,
142142
estimate_prior_method = estimate_prior_method,
143143
unmappable_effects = unmappable_effects,
144-
update_ash_sigma2 = update_ash_sigma2,
144+
ash_scaling_factor = ash_scaling_factor,
145145
check_null_threshold = check_null_threshold,
146146
prior_tol = prior_tol,
147147
residual_variance_upperbound = residual_variance_upperbound,

0 commit comments

Comments
 (0)