UW-GAC / GENESIS

GENetic EStimation and Inference in Structured samples (GENESIS): Statistical methods for analyzing genetic data from samples with population structure and/or relatedness
https://bioconductor.org/packages/GENESIS
34 stars 13 forks source link

Error in assocTestSingle with Score.SPA test #77

Closed ZeyuanSong closed 2 years ago

ZeyuanSong commented 3 years ago

Hi, When running the association test with test="Score", it executed successfully. However, when switching to test="Score.SPA", an error message showed as: Error in if (abs(q - m1)/sqrt(var1) < Cutoff) { : missing value where TRUE/FALSE needed

I guess this happens because there are monomorphic SNPs or missing genotypes that leads to NA in the if statement. But I am not sure if it is due to other reasons and how can I bypass it. (I also tried the SPA test on a small set of SNPs where there are no missing genotypes and no monomorphic SNPs, it executed successfully)

smgogarten commented 3 years ago

Missing genotypes are imputed to the mean and monomorphic variants are removed before the test is run, so that is unlikely to be the cause of the error. Can you generate a reproducible example from your dataset that you can share?

angelosarmen commented 1 year ago

Hi,

I had the same problem and identified the expit() function in spa.R as the culprit:

expit <- function(x){exp(x)/(1+exp(x))}

A large x results in NaN. I replaced

mu <- as.vector(expit(nullmod$fit$linear.predictor))

with

mu <- as.vector(plogis(nullmod$fit$linear.predictor))

in spa.R, and test = "Score.SPA" now works fine.

smgogarten commented 12 months ago

Thanks for the suggestion!