From c277e0fba734bea963b467cb21684a261ba8d5c3 Mon Sep 17 00:00:00 2001 From: xuewei cao <36172337+xueweic@users.noreply.github.com> Date: Wed, 8 Apr 2026 08:57:35 -0500 Subject: [PATCH] Update sumstats_qc.R --- R/sumstats_qc.R | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/R/sumstats_qc.R b/R/sumstats_qc.R index 2200634e..1c000998 100644 --- a/R/sumstats_qc.R +++ b/R/sumstats_qc.R @@ -26,10 +26,18 @@ rss_basic_qc <- function(sumstats, LD_data, skip_region = NULL, keep_indel = TRU stop("Missing columns in sumstats: ", paste(missing_cols, collapse = ", ")) } + # Dynamically detect which effect columns exist to flip + # Must have at least one of beta or z + flip_candidates <- c("beta", "z") + col_to_flip <- intersect(flip_candidates, colnames(sumstats)) + if (length(col_to_flip) == 0) { + stop("sumstats must contain at least one of: 'beta', 'z'") + } + ref_variants <- LD_data$LD_variants allele_flip <- allele_qc(sumstats, ref_variants, - col_to_flip = c("beta", "z"), + col_to_flip = col_to_flip, match_min_prop = 0, remove_dups = TRUE, remove_indels = !keep_indel, remove_strand_ambiguous = TRUE )