stephenslab / mashr

An R package for multivariate adaptive shrinkage.
https://stephenslab.github.io/mashr
Other
88 stars 19 forks source link

Division by zero in mash_set_data with df matrix after applying p2z #133

Open dorolin opened 1 week ago

dorolin commented 1 week ago

Hello, I'm trying to read my data with the mash_set_data function. This works fine when only submitting Bhat and Shat matrices. As soon as I provide a df matrix as well, I'm getting the following error: "_Error in mashr::mash_setdata(Bhat = , Shat = , df = ) : Missing data pattern is inconsistent between Bhat and Shat". I verified that all three matrices have missing data at the same positions. After tracking this down, I found that the issue comes from Shat = Bhat / p2z(2 * pt(-abs(Bhat/Shat), df), Bhat): the p2z function returns some zeros in the output matrix, which then leads to a few extra NaN in Shat. At these positions, also my Bhat matrix contains zeros. What do you suggest to fix this issue?

Many thanks, Doro