Skip to content
Merged
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
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ LinkingTo:
NeedsCompilation: yes
VignetteBuilder: knitr
Config/roxygen2/version: 8.0.0
RoxygenNote: 7.3.3
9 changes: 9 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export(coloc_wrapper)
export(colocboost_analysis_pipeline)
export(compute_LD)
export(compute_qtl_enrichment)
export(compute_sldsc_M_ref)
export(compute_sldsc_annot_sd)
export(ctwas_bimfile_loader)
export(dentist)
export(dentist_single_window)
Expand Down Expand Up @@ -49,6 +51,7 @@ export(glmnet_weights)
export(harmonize_gwas)
export(harmonize_twas)
export(invert_minmax_scaling)
export(is_binary_sldsc_annot)
export(l0learn_weights)
export(lasso_weights)
export(lassosum_rss)
Expand Down Expand Up @@ -79,6 +82,7 @@ export(match_ref_panel)
export(mcp_weights)
export(merge_mash_data)
export(merge_sumstats_matrices)
export(meta_sldsc_random)
export(mr_analysis)
export(mr_ash_rss_weights)
export(mr_format)
Expand All @@ -97,14 +101,17 @@ export(prs_cs)
export(prs_cs_weights)
export(raiss)
export(read_afreq)
export(read_sldsc_trait)
export(region_to_df)
export(rss_analysis_pipeline)
export(rss_basic_qc)
export(scad_weights)
export(sdpr)
export(sdpr_weights)
export(slalom)
export(sldsc_postprocessing_pipeline)
export(standardise_sumstats_columns)
export(standardize_sldsc_trait)
export(summary_stats_qc)
export(susie_ash_weights)
export(susie_inf_weights)
Expand Down Expand Up @@ -138,6 +145,7 @@ importFrom(IRanges,start)
importFrom(S4Vectors,queryHits)
importFrom(S4Vectors,subjectHits)
importFrom(coloc,coloc.bf_bf)
importFrom(data.table,fread)
importFrom(doFuture,registerDoFuture)
importFrom(dplyr,across)
importFrom(dplyr,all_of)
Expand Down Expand Up @@ -198,6 +206,7 @@ importFrom(stats,optim)
importFrom(stats,pchisq)
importFrom(stats,pnorm)
importFrom(stats,predict)
importFrom(stats,qnorm)
importFrom(stats,sd)
importFrom(stats,setNames)
importFrom(stats,var)
Expand Down
32 changes: 32 additions & 0 deletions R/sldsc_wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,11 @@ sldsc_postprocessing_pipeline <- function(trait_single_prefixes,
message("[sldsc] Detecting binary vs continuous annotations...")
is_binary_full <- is_binary_sldsc_annot(target_anno_dir = target_anno_dir)

# Polyfun renames target columns to `<col>_0` (file_idx=0 in --ref-ld-chr);
# mirror that suffix so intersect() with pivot_run$categories matches.
names(sd_annot_full) <- paste0(names(sd_annot_full), "_0")
names(is_binary_full) <- paste0(names(is_binary_full), "_0")

# Auto-detect target categories from a representative run.
if (is.null(target_categories)) {
pivot_run <- NULL
Expand All @@ -564,6 +569,33 @@ sldsc_postprocessing_pipeline <- function(trait_single_prefixes,
if (is.null(pivot_run))
stop("sldsc_postprocessing_pipeline: cannot auto-detect target_categories.")
target_categories <- intersect(pivot_run$categories, names(sd_annot_full))
# Fallback when .annot.gz names + "_0" do not match polyfun's .results
# Category. Happens when the pipeline ran with --snp-list, since
# ldsc.py --l2 hardcodes the LD score column to "L2" (single annot) or
# "<annot>L2" (joint), instead of preserving the .annot.gz names.
# Trust polyfun's invariant that target categories occupy the first
# length(sd_annot_full) rows of .results, then rename positionally.
if (length(target_categories) == 0L) {
n_target <- length(sd_annot_full)
n_baseline <- length(pivot_run$categories) - n_target
old_names <- names(sd_annot_full)
target_categories <- pivot_run$categories[seq_len(n_target)]
names(sd_annot_full) <- target_categories
names(is_binary_full) <- target_categories
baseline_preview <- if (n_baseline > 0L)
paste(utils::head(pivot_run$categories[-seq_len(n_target)], 3), collapse = ", ")
else "(none)"
message(sprintf(paste0(
"[sldsc] sd_annot/is_binary names did not match polyfun .results categories;\n",
" falling back to positional rename (target = first %d rows of .results)\n",
" target (%d): %s -> %s\n",
" baseline (%d): %s%s"),
n_target,
n_target, paste(old_names, collapse = ", "),
paste(target_categories, collapse = ", "),
n_baseline, baseline_preview,
if (n_baseline > 3L) ", ..." else ""))
}
message(sprintf("[sldsc] Auto-detected %d target categories", length(target_categories)))
}

Expand Down
34 changes: 34 additions & 0 deletions man/compute_sldsc_M_ref.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions man/compute_sldsc_annot_sd.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions man/is_binary_sldsc_annot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions man/meta_sldsc_random.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions man/read_sldsc_trait.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions man/sldsc_postprocessing_pipeline.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions man/standardize_sldsc_trait.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.