saigegit / SAIGE

Development for SAIGE and SAIGE-GENE(+)
GNU General Public License v3.0
64 stars 27 forks source link

SAIGE-Gene+ Step 2 crashes if a region is empty #56

Closed dvg-p4 closed 1 year ago

dvg-p4 commented 1 year ago

In previous versions of SAIGE (0.44.2 in particular), running a gene association job with empty regions would usually fail gracefully with an appropriate warning. However, in 1.1.6.1, empty regions cause a crash with the following error message:

Error in paste("This is a", AnalysisType, "level analysis.") : 
  object 'AnalysisType' not found
Calls: SPAGMMATtest -> SAIGE.Region -> paste
Execution halted

This line of code appears to be responsible: https://github.com/saigegit/SAIGE/blob/69738afc72de5daa31d76c16c64ef0e03e296069/R/SAIGE_SPATest_Region.R#L814 since the AnalysisType variable is set inside an if block which is skipped over for empty regions: https://github.com/saigegit/SAIGE/blob/69738afc72de5daa31d76c16c64ef0e03e296069/R/SAIGE_SPATest_Region.R#L786

In this function, that AnalysisType variable doesn't seem to be set or referenced anywhere else, so you could probably fix the bug by eliminating it entirely, and rewriting line 814 as:

message2 = "This is a Region level analysis."
dvg-p4 commented 1 year ago

It seems there's a related bug still happening--I'm now seeing the error:

Error in paste("nEachChunk =", nEachChunk) :
  object 'nEachChunk' not found
Calls: SPAGMMATtest -> SAIGE.Region -> paste
Execution halted
daniel-hui commented 1 year ago

Hi, I'm having the same issue. Were you ever able to find a work-around?

saigegit commented 1 year ago

Hi @daniel-hui and @dvg-p4,

The issue should have been fixed in the newest version 1.2.0

Thanks, Wei