privefl / bigsnpr

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

Error: 'chi2' should have only positive values. in snp_ldsc() #480

Closed koujiaodahan closed 4 months ago

koujiaodahan commented 4 months ago

Hi: I try to run the example code following the guide(https://privefl.github.io/bigsnpr/articles/LDpred2.html). Everything is ok until running the code "(ldsc <- with(df_beta, snp_ldsc(ld, length(ld), chi2 = (beta / beta_se)^2, sample_size = n_eff, blocks = NULL)))". There is a bug: "Error: 'chi2' should have only positive values." I checked the chi2 is certainly positive.

chi2<-(df_beta$beta/df_beta$beta_se)^2 chi2[which.min(chi2)] [1] 3.249873e-10

So, how can I address the bug.

In addition to it, In my job, there are only public summary statistics in A Case/Control study and 1000Genome as LD data. Yes, There is no genotype data. So I want to get the best prs module with specific SNP list by LDpred2-auto. So, how can I do it

privefl commented 4 months ago

First, this is not a bug, it is an assertion.

I guess you probably have missing values in chi2.

koujiaodahan commented 4 months ago

First, this is not a bug, it is an assertion.

I guess you probably have missing values in chi2.

Yes, but I completely followed your instructions and downloaded data, I didn't see any NA scene in your page. So ,how can I handle this NAs for next practice?

privefl commented 4 months ago

You're just running the code from the tutorial with the exact same data?

You should check the number of missing values you have in df_beta. If there aren't too many, you can use something like na.omit(). If there are a lot of missing values, you should try to understand why.

koujiaodahan commented 4 months ago

You're just running the code from the tutorial with the exact same data?

You should check the number of missing values you have in df_beta. If there aren't too many, you can use something like na.omit(). If there are a lot of missing values, you should try to understand why.

Thanks, I have dealt with it. I have another question: There is a summary statistic from the EAS population(No validation data, No bim, No genotype data), so how can I get the final snplist with corrected beta in the prs module? I plan to use LDpred2-auto based on some other public LD data such as 1000genome EAS. But I saw that LDpred2-auto still requires the same correlation file as LDpred2-grid in the guidance.

privefl commented 4 months ago

Please open a new issue if you have another question.