Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Error in density.default(BetaIV.in, weights = weights, bw = h) : non-finite 'bw' #570

Open
Julie1130 opened this issue Oct 10, 2024 · 8 comments
Labels

Comments

@Julie1130
Copy link

When I run the mr(datm), it gave me this error.

Error in density.default(BetaIV.in, weights = weights, bw = h) : non-finite 'bw'

@Julie1130 Julie1130 added the bug label Oct 10, 2024
@Julie1130
Copy link
Author

@explodecomputer Could you please take a look? Thanks!

@Julie1130
Copy link
Author

@mathspete Could you please take a look? Thanks!

@remlapmot
Copy link
Contributor

You have not provided a reproducible example. Please provide a full code example including the data which recreates the error otherwise it's very time consuming for us just to recreate your error.

(We ask for a reproducible example in the issue template - but you've deleted that.)

And please don't @ mention people without good reason.

@Julie1130
Copy link
Author

I am really sorry. Here are the codes:
data1 = read_csv("D:\Julie\Data\smaller_p_physical.csv")
exposure_dat = format_data(data1, type = "exposure",
snp_col = "SNP rsid", chr_col = "Chr",
beta_col = "beta", se_col = "SE", pval_col = "P",
effect_allele_col = "EA", other_allele_col = "OA",
eaf_col = "EAF",ncase_col="n",pos_col = "Position")
exposure_dat<-clump_data(exposure_dat)
exposure_dat$r2<-2 * exposure_dat$eaf.exposure * (1-exposure_dat$eaf.exposure) * exposure_dat$beta.exposure * exposure_dat$beta.exposure
exposure_dat$r2
sum(exposure_dat$r2)
outcome_datm_male <- extract_outcome_data(exposure_dat$SNP, c('ebi-a-GCST006701'), proxies = 1, rsq = 0.8, align_alleles = 1, palindromes = 1, maf_threshold = 0.45)

datm_male<- harmonise_data(exposure_dat, outcome_datm_male)
print(mr(datm_male)) #results from MR base


it works fine after harmonization, but mr(datm_male) gave the bug, is it because several of the beta.exposure is 0 in my data?

@Julie1130
Copy link
Author

You have not provided a reproducible example. Please provide a full code example including the data which recreates the error otherwise it's very time consuming for us just to recreate your error.

(We ask for a reproducible example in the issue template - but you've deleted that.)

And please don't @ mention people without good reason.

I am really sorry. I have provided the codes above.

@Julie1130
Copy link
Author

Additionally, when I use "MendelianRandomization" package, it works fine. So it's not because the number of SNPs is too small.

@remlapmot
Copy link
Contributor

The example is not reproducible because we don't have your dataset smaller_p_physical.csv.

@Julie1130
Copy link
Author

small_p_physical.csv
Here you are. Hopefully it can be downloaded. If not, please let me know. Thank you very much indeed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants