diff --git a/NAMESPACE b/NAMESPACE index 9328ad5f..8e0a54d5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -169,7 +169,6 @@ importFrom(stats,cor) importFrom(stats,cov) importFrom(stats,cutree) importFrom(stats,hclust) -importFrom(stats,lag) importFrom(stats,lm.fit) importFrom(stats,pchisq) importFrom(stats,pnorm) diff --git a/R/LD.R b/R/LD.R index 4bbe8b2d..7d6f9dd9 100644 --- a/R/LD.R +++ b/R/LD.R @@ -7,6 +7,10 @@ check_consecutive_regions <- function(df) { as.integer(sub("^chr", "", df$chrom)), # Remove 'chr' and convert to integer as.integer(df$chrom) ) # Convert to integer if not already + + # Remove duplicated rows based on 'chrom' and 'start' columns + df <- distinct(df, chrom, start, .keep_all = TRUE) %>% + arrange(chrom, start) for (chr in unique(df$chrom)) { chr_rows <- which(df$chrom == chr) @@ -20,9 +24,6 @@ check_consecutive_regions <- function(df) { } } - # Remove duplicated rows based on 'chrom' and 'start' columns - df <- distinct(df, chrom, start, .keep_all = TRUE) %>% - arrange(chrom, start) return(df) } diff --git a/R/RcppExports.R b/R/RcppExports.R index 814b38fd..efa6874d 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -2,21 +2,22 @@ # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 dentist_iterative_impute <- function(LD_mat, nSample, zScore, pValueThreshold, propSVD, gcControl, nIter, gPvalueThreshold, ncpus, seed, correct_chen_et_al_bug, verbose = FALSE) { - .Call("_pecotmr_dentist_iterative_impute", PACKAGE = "pecotmr", LD_mat, nSample, zScore, pValueThreshold, propSVD, gcControl, nIter, gPvalueThreshold, ncpus, seed, correct_chen_et_al_bug, verbose) + .Call('_pecotmr_dentist_iterative_impute', PACKAGE = 'pecotmr', LD_mat, nSample, zScore, pValueThreshold, propSVD, gcControl, nIter, gPvalueThreshold, ncpus, seed, correct_chen_et_al_bug, verbose) } rcpp_mr_ash_rss <- function(bhat, shat, z, R, var_y, n, sigma2_e, s0, w0, mu1_init, tol = 1e-8, max_iter = 1e5L, update_w0 = TRUE, update_sigma = TRUE, compute_ELBO = TRUE, standardize = FALSE, ncpus = 1L) { - .Call("_pecotmr_rcpp_mr_ash_rss", PACKAGE = "pecotmr", bhat, shat, z, R, var_y, n, sigma2_e, s0, w0, mu1_init, tol, max_iter, update_w0, update_sigma, compute_ELBO, standardize, ncpus) + .Call('_pecotmr_rcpp_mr_ash_rss', PACKAGE = 'pecotmr', bhat, shat, z, R, var_y, n, sigma2_e, s0, w0, mu1_init, tol, max_iter, update_w0, update_sigma, compute_ELBO, standardize, ncpus) } prs_cs_rcpp <- function(a, b, phi, bhat, maf, n, ld_blk, n_iter, n_burnin, thin, verbose, seed) { - .Call("_pecotmr_prs_cs_rcpp", PACKAGE = "pecotmr", a, b, phi, bhat, maf, n, ld_blk, n_iter, n_burnin, thin, verbose, seed) + .Call('_pecotmr_prs_cs_rcpp', PACKAGE = 'pecotmr', a, b, phi, bhat, maf, n, ld_blk, n_iter, n_burnin, thin, verbose, seed) } qtl_enrichment_rcpp <- function(r_gwas_pip, r_qtl_susie_fit, pi_gwas = 0, pi_qtl = 0, ImpN = 25L, shrinkage_lambda = 1.0, num_threads = 1L) { - .Call("_pecotmr_qtl_enrichment_rcpp", PACKAGE = "pecotmr", r_gwas_pip, r_qtl_susie_fit, pi_gwas, pi_qtl, ImpN, shrinkage_lambda, num_threads) + .Call('_pecotmr_qtl_enrichment_rcpp', PACKAGE = 'pecotmr', r_gwas_pip, r_qtl_susie_fit, pi_gwas, pi_qtl, ImpN, shrinkage_lambda, num_threads) } sdpr_rcpp <- function(bhat, LD, n, per_variant_sample_size = NULL, array = NULL, a = 0.1, c = 1.0, M = 1000L, a0k = 0.5, b0k = 0.5, iter = 1000L, burn = 200L, thin = 5L, n_threads = 1L, opt_llk = 1L, verbose = TRUE) { - .Call("_pecotmr_sdpr_rcpp", PACKAGE = "pecotmr", bhat, LD, n, per_variant_sample_size, array, a, c, M, a0k, b0k, iter, burn, thin, n_threads, opt_llk, verbose) + .Call('_pecotmr_sdpr_rcpp', PACKAGE = 'pecotmr', bhat, LD, n, per_variant_sample_size, array, a, c, M, a0k, b0k, iter, burn, thin, n_threads, opt_llk, verbose) } + diff --git a/R/raiss.R b/R/raiss.R index c13ffdbb..73fd06c3 100644 --- a/R/raiss.R +++ b/R/raiss.R @@ -131,10 +131,10 @@ raiss <- function(ref_panel, known_zscores, LD_matrix, lamb = 0.01, rcond = 0.01 combine_with_boundary_check <- function(combined_result, new_result) { # If either is empty, simply return the non-empty one or empty data frame - if (nrow(combined_result) == 0) { + if (is.null(combined_result)) { return(new_result) } - if (nrow(new_result) == 0) { + if (is.null(new_result)) { return(combined_result) } diff --git a/man/raiss.Rd b/man/raiss.Rd index dc08c4de..a8ed89b8 100644 --- a/man/raiss.Rd +++ b/man/raiss.Rd @@ -8,7 +8,6 @@ raiss( ref_panel, known_zscores, LD_matrix, - variant_indices = NULL, lamb = 0.01, rcond = 0.01, R2_threshold = 0.6, @@ -23,8 +22,6 @@ raiss( \item{LD_matrix}{Either a square matrix or a list of matrices for LD blocks.} -\item{variant_indices}{Optional data frame mapping variant IDs to block IDs when LD_matrix is a list.} - \item{lamb}{Regularization term added to the diagonal of the LD_matrix.} \item{rcond}{Threshold for filtering eigenvalues in the pseudo-inverse computation.}