NaN in putative causality analysis
Closed this issue · 1 comments
Hello,
I've done the causality analysis and the output has given for the first trait was NAN.
trait1 local_gcor1 local_gcor1_se trait2 local_gcor2 local_gcor2_se
Trait1 nan 0 Trait2 0.36 0.1
I have found this error: RuntimeWarning: invalid value encountered in double_scalars.
gcor_all_data = all_gcov/(np.sqrt(all_hsq1)*np.sqrt(all_hsq2))
here, pointed out the same error: https://stackoverflow.com/questions/27784528/numpy-division-with-runtimewarning-invalid-value-encountered-in-double-scalars
"You can't solve it. Simply answer1.sum()==0, and you can't perform a division by zero.
This happens because answer1 is the exponential of 2 very large, negative numbers, so that the result is rounded to zero.
nan is returned in this case because of the division by zero.
Now to solve your problem you could:
go for a library for high-precision mathematics, like mpmath. But that's less fun.
as an alternative to a bigger weapon, do some math manipulation, as detailed below.
go for a tailored scipy/numpy function that does exactly what you want! Check out @warren Weckesser answer."
So, is there any solution? Any advice in that case?
Thank you in advance,
Alvaro
I've figured out how to solve the problem. I inadvertently used a raw summary stadistics in which I had included X in chr column for my GWAS hits files, and that's why it produced the error.
estimate gcor using all loci
all_gcov = np.sum(gcov_gwas_loci_list)
all_hsq1 = np.sum(hsq1_gwas_loci_list)
all_hsq2 = np.sum(hsq2_gwas_loci_list)
gcor_all_data = all_gcov/(np.sqrt(all_hsq1)*np.sqrt(all_hsq2))
I'm reporting it in case it happens to someone in the future.
Thank you very much,
Alvaro