privefl / bigsnpr

R package for the analysis of massive SNP arrays.
https://privefl.github.io/bigsnpr/
183 stars 43 forks source link

Should error when using a correlation matrix with NA / NaNs values #498

Open privefl opened 1 month ago

privefl commented 1 month ago
library(bigsnpr)
bigsnp <- snp_attachExtdata()
G <- bigsnp$genotypes
corr0 <- snp_cor(G)
corr <- as_SFBM(corr0)
gwas <- big_univLinReg(G, rnorm(nrow(G)))
df_beta <- dplyr::transmute(gwas, beta = estim, beta_se = std.err, 
                            n_eff = nrow(G))
snp_ldpred2_auto(corr, df_beta, 0.01)

G[, 1] <- 0
corr0.2 <- snp_cor(G)
corr.2 <- as_SFBM(corr0.2)

# Here should start to error, instead of returning some BS
snp_ldpred2_auto(corr.2, df_beta, 0.01)
snp_ldpred2_grid(corr.2, df_beta, data.frame(h2 = 0.01, p = 0.1, sparse = FALSE))
# snp_ldpred2_inf(corr.2, df_beta, h2 = 0.01)  # run indefinitely
snp_lassosum2(corr.2, df_beta, delta = 0.01)