Skip to content

Commit 208fa92

Browse files
authored
port all fixes (#509)
1 parent 54319e4 commit 208fa92

41 files changed

Lines changed: 741 additions & 122 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NAMESPACE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export(penalized_rss)
192192
export(postprocess_finemapping_fits)
193193
export(prs_cs)
194194
export(prs_cs_weights)
195-
export(qc_individual_data)
195+
export(qc_regional_data)
196196
export(raiss)
197197
export(readAnnotations)
198198
export(readGenotypes)
@@ -201,7 +201,9 @@ export(read_afreq)
201201
export(read_sldsc_trait)
202202
export(region_data_to_colocboost_input)
203203
export(region_data_to_ind_input)
204+
export(region_data_to_mvsusie_rss_input)
204205
export(region_data_to_rss_input)
206+
export(region_data_to_susie_rss_input)
205207
export(region_to_df)
206208
export(regions_overlap)
207209
export(robust_mahalanobis)

R/AllClasses.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#' @description All S4 class definitions for pecotmr: genotype handles,
33
#' summary statistics, LD references, annotations, fine-mapping results,
44
#' TWAS weights, regional data, and heritability estimates.
5+
#' @name pecotmr-classes
6+
#' @keywords internal
57
#' @importFrom methods setClass setMethod new is validObject
68
#' @importFrom S4Vectors mcols mcols<-
79
NULL

R/AllGenerics.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#' @title S4 Generic Function Definitions
22
#' @description All S4 generic function definitions for pecotmr.
3+
#' @name pecotmr-generics
4+
#' @keywords internal
35
#' @include AllClasses.R
46
#' @importFrom methods setGeneric
57
NULL

R/AllMethods.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#' @title S4 Method Implementations
22
#' @description Constructors and accessor method implementations for all
33
#' S4 classes: LDData, RegionalData, FineMappingResult, TWASWeights.
4+
#' @name pecotmr-methods
5+
#' @keywords internal
46
#' @include AllGenerics.R
57
#' @importFrom SummarizedExperiment assay
68
#' @importFrom S4Vectors DataFrame mcols mcols<-

R/colocboost_pipeline.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ region_data_to_colocboost_input <- function(region_data) {
179179
#' # Use richer LD metadata from load_LD_matrix() for QC, while still passing
180180
#' # ColocBoost's native LD input.
181181
#' ld_data <- load_LD_matrix(ld_meta_file, region)
182-
#' fit <- colocboost_analysis(sumstat = sumstat, LD = ld_data$LD_matrix,
182+
#' fit <- colocboost_analysis(sumstat = sumstat, LD = getCorrelation(ld_data),
183183
#' LD_reference_info = ld_data, qc_method = "none")
184184
#'
185185
#' # Individual-level input with explicit genotype QC thresholds.
@@ -678,14 +678,16 @@ colocboost_pipeline <- function(
678678
#' @param region_data A region data loaded from \code{load_regional_data}.
679679
#' @param maf_cutoff A scalar to remove variants with maf < maf_cutoff.
680680
#' @param pip_cutoff_to_skip_ind A vector of cutoff values for skipping individual contexts.
681+
#' @param keep_indel Logical; if \code{FALSE}, remove indel variants during
682+
#' summary-statistic allele harmonization.
681683
#' @param pip_cutoff_to_skip_sumstat A vector of cutoff values for skipping summary-stat studies.
682684
#' @param qc_method Quality control method to use. Options are "none",
683685
#' "slalom", or "dentist". \code{NULL} is treated as \code{"none"} for
684686
#' basic-only summary-stat preprocessing.
685687
#' @param impute Logical; if TRUE, performs imputation when required metadata are available.
686688
#' @param impute_opts A list of imputation options.
687689
#' @return A list containing post-QC \code{individual_data} and \code{sumstat_data}.
688-
#' @noRd
690+
#' @export
689691
qc_regional_data <- function(region_data,
690692
# - individual
691693
maf_cutoff = 0.0005,
@@ -694,7 +696,7 @@ qc_regional_data <- function(region_data,
694696
keep_indel = TRUE,
695697
pip_cutoff_to_skip_sumstat = 0,
696698
qc_method = NULL,
697-
impute = TRUE,
699+
impute = FALSE,
698700
impute_opts = list(rcond = 0.01, R2_threshold = 0.6, minimum_ld = 5, lamb = 0.01)) {
699701
qc_method <- .resolve_summary_qc_method(qc_method)
700702
qced_individual_to_region_data <- function(ind_qc) {
@@ -793,7 +795,7 @@ qc_regional_data <- function(region_data,
793795
#' @param pip_cutoff_to_skip Optional single-effect PIP cutoff.
794796
#' @return A named list of cleaned context-level \code{X}/\code{Y} records, or
795797
#' one cleaned record for matrix inputs.
796-
#' @export
798+
#' @noRd
797799
qc_individual_data <- function(X, Y, maf = NULL, X_variance = NULL,
798800
missing_rate_thresh = NULL,
799801
maf_cutoff = 0.0005,

R/file_utils.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,9 @@ standardise_sumstats_columns <- function(sumstats, column_file_path = NULL, comm
13761376
#' @export
13771377
load_rss_data <- function(sumstat_path, column_file_path = NULL, n_sample = 0, n_case = 0, n_control = 0, region = NULL,
13781378
extract_region_name = NULL, region_name_col = NULL, comment_string = "#") {
1379+
n_sample <- if (length(n_sample) == 1L && is.na(n_sample)) 0 else n_sample
1380+
n_case <- if (length(n_case) == 1L && is.na(n_case)) 0 else n_case
1381+
n_control <- if (length(n_control) == 1L && is.na(n_control)) 0 else n_control
13791382
# Validate input files exist
13801383
if (!file.exists(sumstat_path)) {
13811384
stop("Summary statistics file not found: ", sumstat_path)

R/genotype_io.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#' @description Read genotype data from various formats (VCF, plink1,
33
#' plink2, GDS) and provide block-level genotype extraction without
44
#' requiring format conversion.
5+
#' @name pecotmr-genotype-io
6+
#' @keywords internal
57
#' @importFrom SummarizedExperiment SummarizedExperiment rowRanges
68
#' @importFrom GenomicRanges GRanges seqnames
79
#' @importFrom S4Vectors DataFrame mcols mcols<-

R/gwas_sumstats.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#' @title Summary Statistics Handling
22
#' @description Functions for reading, validating, and constructing
33
#' \code{GWASSumStats} objects from various input formats.
4+
#' @name pecotmr-gwas-sumstats
5+
#' @keywords internal
46
#' @importFrom GenomicRanges GRanges seqnames start
57
#' @importFrom S4Vectors DataFrame mcols mcols<-
68
#' @importFrom MungeSumstats format_sumstats

R/h2_annotations.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#' @title Annotation Handling for Stratified Heritability
22
#' @description Read and manage genomic annotations for stratified
33
#' heritability analysis. Supports BED, BigWig, and LDSC .annot formats.
4+
#' @name pecotmr-h2-annotations
5+
#' @keywords internal
46
#' @importFrom tools file_ext
57
#' @importFrom GenomicRanges GRanges
68
#' @include AllGenerics.R

R/h2_estimate_wrappers.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#' @description Top-level entry point for heritability estimation,
33
#' LD score computation methods, H2Estimate accessors, and a converter
44
#' to bridge H2Estimate into the sldsc_wrapper.R postprocessing pipeline.
5+
#' @name pecotmr-h2-wrappers
6+
#' @keywords internal
57
#' @include AllGenerics.R
68
#' @importFrom stats median
79
NULL

0 commit comments

Comments
 (0)