MRCIEU / TwoSampleMR

R package for performing 2-sample MR using MR-Base database
https://mrcieu.github.io/TwoSampleMR
Other
424 stars 176 forks source link

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

Open Julie1130 opened 2 hours ago

Julie1130 commented 2 hours ago

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 commented 2 hours ago

@explodecomputer Could you please take a look? Thanks!

Julie1130 commented 2 hours ago

@mathspete Could you please take a look? Thanks!

remlapmot commented 2 hours ago

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 commented 2 hours ago

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 commented 2 hours ago

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 commented 2 hours ago

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