Skip to content
13 changes: 4 additions & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

export(QUAIL_pipeline)
export(QUAIL_rank_score_pipeline)
export(calculate_khmaladze_heterogeneity)
export(calculate_subsampling_heterogeneity)
export(calculate_wald_heterogeneity)
export(calculate_xi_correlation)
export(calculate_xi_correlation_calibrated)
export(load_quantile_twas_weights)
export(multicontext_ld_clumping)
export(perform_qr_analysis)
Expand All @@ -13,15 +17,6 @@ importFrom(dplyr,"%>%")
importFrom(dplyr,mutate)
importFrom(dplyr,select)
importFrom(parallel,mclapply)
importFrom(pecotmr,clean_context_names)
importFrom(pecotmr,enforce_design_full_rank)
importFrom(pecotmr,filter_variants_by_ld_reference)
importFrom(pecotmr,find_data)
importFrom(pecotmr,harmonize_twas)
importFrom(pecotmr,ld_clump_by_score)
importFrom(pecotmr,ld_prune_by_correlation)
importFrom(pecotmr,parse_variant_id)
importFrom(pecotmr,twas_analysis)
importFrom(stats,as.dist)
importFrom(stats,cov)
importFrom(stats,cutree)
Expand Down
1 change: 0 additions & 1 deletion R/qQTLR-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#' quantile TWAS weight training, and quantile TWAS pipelines.
#'
#' @importFrom pecotmr parse_variant_id harmonize_twas twas_analysis find_data
#' clean_context_names filter_variants_by_ld_reference
#' ld_prune_by_correlation ld_clump_by_score enforce_design_full_rank
#' @importFrom susieR univariate_regression
#' @keywords internal
Expand Down
640 changes: 630 additions & 10 deletions R/quantile_twas_weight.R

Large diffs are not rendered by default.

94 changes: 83 additions & 11 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,89 @@
# Lazy-bind unexported pecotmr helpers into qQTLR's namespace.
# Resolving at load time via utils::getFromNamespace means call sites can use
# bare names (no `pecotmr:::` prefix) without triggering the R CMD check
# warning "':::' calls which should be '::'".
# Lazy-bind unexported or renamed pecotmr helpers into qQTLR's namespace.

compute_qvalues <- NULL
pval_cauchy <- NULL
drop_collinear_columns <- NULL
build_twas_score_row <- NULL
compute_qvalues <- NULL
pval_cauchy <- NULL
drop_collinear_columns <- NULL
build_twas_score_row <- NULL
parse_variant_id <- NULL
filter_variants_by_ld_reference <- NULL
ld_prune_by_correlation <- NULL
ld_clump_by_score <- NULL
harmonize_twas <- NULL

.onLoad <- function(libname, pkgname) {
ns_self <- asNamespace(pkgname)
for (sym in c("compute_qvalues", "pval_cauchy",
"drop_collinear_columns", "build_twas_score_row")) {
assign(sym, utils::getFromNamespace(sym, "pecotmr"), envir = ns_self)

# Helper: bind a renamed pecotmr function under a legacy snake_case name.
bind_from_pecotmr <- function(new_name, old_name, fallback_msg) {
fn <- tryCatch(
utils::getFromNamespace(new_name, "pecotmr"),
error = function(e) NULL
)
if (!is.null(fn)) {
assign(old_name, fn, envir = ns_self)
} else {
msg <- fallback_msg
assign(old_name, function(...) stop(msg), envir = ns_self)
}
}

# pval_cauchy: Cauchy combination test, renamed to pvalAcat in current pecotmr.
bind_from_pecotmr("pvalAcat", "pval_cauchy",
"'pvalAcat' is not available in the installed version of pecotmr")

# drop_collinear_columns: renamed to dropCollinearColumns in current pecotmr.
bind_from_pecotmr("dropCollinearColumns", "drop_collinear_columns",
"'dropCollinearColumns' is not available in the installed version of pecotmr")

# filter_variants_by_ld_reference: renamed to filterVariantsByLdReference.
bind_from_pecotmr("filterVariantsByLdReference", "filter_variants_by_ld_reference",
"'filterVariantsByLdReference' is not available in the installed version of pecotmr")

# ld_prune_by_correlation: renamed to ldPruneByCorrelation.
bind_from_pecotmr("ldPruneByCorrelation", "ld_prune_by_correlation",
"'ldPruneByCorrelation' is not available in the installed version of pecotmr")

# ld_clump_by_score: renamed to ldClumpByScore.
bind_from_pecotmr("ldClumpByScore", "ld_clump_by_score",
"'ldClumpByScore' is not available in the installed version of pecotmr")

# harmonize_twas: renamed to harmonizeTwas.
bind_from_pecotmr("harmonizeTwas", "harmonize_twas",
"'harmonizeTwas' is not available in the installed version of pecotmr")

# compute_qvalues: q-value estimation via qvalue package, with FDR fallback.
assign("compute_qvalues", function(pvals) {
tryCatch(
qvalue::qvalue(pvals)$qvalues,
error = function(e) p.adjust(pvals, method = "fdr")
)
}, envir = ns_self)

# build_twas_score_row: not in current pecotmr; used only in the TWAS
# pipeline path which is not called when --no-twas-weight-calculate is set.
assign("build_twas_score_row", function(...) stop(
"'build_twas_score_row' is not available in the installed version of pecotmr"
), envir = ns_self)

# parse_variant_id was renamed to parseVariantId in pecotmr; provide a
# snake_case alias that calls the camelCase version, with column-name
# normalisation so callers expecting $chrom/$pos/$A2/$A1 still work.
parse_variant_id_fn <- tryCatch(
utils::getFromNamespace("parseVariantId", "pecotmr"),
error = function(e) NULL
)
if (!is.null(parse_variant_id_fn)) {
alias <- function(ids) {
res <- parse_variant_id_fn(ids)
if (is.data.frame(res) && !"chrom" %in% names(res)) {
if ("CHR" %in% names(res)) names(res)[names(res) == "CHR"] <- "chrom"
}
res
}
assign("parse_variant_id", alias, envir = ns_self)
} else {
assign("parse_variant_id", function(...) stop(
"'parseVariantId' is not available in the installed version of pecotmr"
), envir = ns_self)
}
}
94 changes: 94 additions & 0 deletions man/calculate_khmaladze_heterogeneity.Rd

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

87 changes: 87 additions & 0 deletions man/calculate_subsampling_heterogeneity.Rd

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

60 changes: 60 additions & 0 deletions man/calculate_wald_heterogeneity.Rd

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

Loading
Loading