Skip to content

Commit c53ed99

Browse files
authored
Merge pull request StatFunGen#466 from xueweic/main
Update sumstats_qc.R
2 parents d124464 + c277e0f commit c53ed99

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

R/sumstats_qc.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,18 @@ rss_basic_qc <- function(sumstats, LD_data, skip_region = NULL, keep_indel = TRU
2626
stop("Missing columns in sumstats: ", paste(missing_cols, collapse = ", "))
2727
}
2828

29+
# Dynamically detect which effect columns exist to flip
30+
# Must have at least one of beta or z
31+
flip_candidates <- c("beta", "z")
32+
col_to_flip <- intersect(flip_candidates, colnames(sumstats))
33+
if (length(col_to_flip) == 0) {
34+
stop("sumstats must contain at least one of: 'beta', 'z'")
35+
}
36+
2937
ref_variants <- LD_data$LD_variants
3038

3139
allele_flip <- allele_qc(sumstats, ref_variants,
32-
col_to_flip = c("beta", "z"),
40+
col_to_flip = col_to_flip,
3341
match_min_prop = 0, remove_dups = TRUE, remove_indels = !keep_indel,
3442
remove_strand_ambiguous = TRUE
3543
)

0 commit comments

Comments
 (0)