jean997 / cause

R package for CAUSE
https://jean997.github.io/cause/
52 stars 15 forks source link

error: all(unique(joint_post[[start_nm]]) %in% starts) is not TRUE #46

Closed sherryfan030 closed 6 months ago

sherryfan030 commented 8 months ago

Hi Jean, Thanks for your hard work in providing a wonderful MR tool. I have run this procedure many times, and it works. However, when I tried cause for a pair of traits, it produced an error as follows:

res.cause <- cause(X=combineddata, variants = top_vars, param_ests = params) Estimating CAUSE posteriors using 916 variants. Fitting confounder only model. Setting ranges Error in marge_dists(res, params, priors, ranges) : all(unique(joint_post[[start_nm]]) %in% starts) is not TRUE

Under the recovery mode, I found that an error occurred in the merge_list function (joining joint_post[[start_nm]] and starts) when the rounded results of the same number were not equal. I do not know why. **recover mode (traceback): joint_post[[start_nm]] <- round(joint_post[[start_nm]], digits = 6) joint_post[[stop_nm]] <- round(joint_post[[stop_nm]], digits = 6) width_nm <- paste0(param, "width") min_width <- min(joint_post[, width_nm]) starts <- seq(r1, r2, by = min_width) %>% round(., digits = 6) stopifnot(all(unique(joint_post[[start_nm]]) %in% starts))

github1

Do you have any recommendations or suggestions that you could offer?

jean997 commented 8 months ago

Interesting. I haven't seen that error before. It does look like you found the offending part of the code. Would you be willing to share your input data so I can test a fix?

jean997 commented 8 months ago

I actually had an idea about what the fix might be. There is a new branch called issue_46 that might fix your problem. If you'd like you can give it a try and see if the problem is resolved. To install from the new branch use devtools::install_github("jean997/cause", ref = "issue_46")

sherryfan030 commented 8 months ago

I actually had an idea about what the fix might be. There is a new branch called issue_46 that might fix your problem. If you'd like you can give it a try and see if the problem is resolved. To install from the new branch use devtools::install_github("jean997/cause", ref = "issue_46")

Hi Jean, I reinstalled the 'cause' package, but the problem still exists. I've shared the corresponding data on Google Drive(https://drive.google.com/drive/folders/1FIBOw2b1oWBoHIvFG9zLNJWfEabHPgsD?usp=share_link), and you can access it. Thanks!

sherryfan030 commented 6 months ago

I tried to reinstall the old version of cause package(v1.2.0)and Suddenly it worked, although I don't know why.