saeyslab / FlowSOM

Using self-organizing maps for visualization and interpretation of cytometry data
26 stars 7 forks source link

BuildSOM - Error in if (length(y) > 0 && mean(y) != 0) { : missing value where TRUE/FALSE needed #9

Closed BexMillard closed 1 year ago

BexMillard commented 2 years ago

Hi, thanks a lot for developing the FlowSOM package.

I just encountered an issue when using CytoNorm (which utilises FlowSOM under the hood). After a few layers of debugging from function to function I pinpointed the issue to the UpdateDerivedValues function: FlowSOM::FlowSOM > FlowSOM::BuildSOM > FlowSOM::UpdateDerivedValues

I have a channel with a .fcs file I'm working with that contains NA values. This is probably not right for this function, but it throws the following error:

Error in if (length(y) > 0 && mean(y) != 0) { : missing value where TRUE/FALSE needed

This error occurs because mean(y) is equal to NA for this particular channel column, so the IF statement is not returning TRUE or FALSE as expected. The code is lines 78 - 88 of the R/2_buildSOM.R file.

As this took a lot of debugging to get to, and I have seen this error elsewhere on FlowSOM GitHub repositories (https://github.com/lmweber/FlowSOM-Rtsne-example/issues/1), I think it might be useful to add a check here and a more informative error message stating the reason why to help other users fix this issue if encountered with their files?

If not, at least the information is here now - if you have this issue, you probably have a channel that contains NA in your .fcs file :)

artuurC commented 2 years ago

Hi,

Thank you for bringing this to our attention and sorry for the late answer. We hope to have fixed it with the latest push (2.1.35). When using FlowSOM with an .fcs file with NA values, the UpdateDerivedValues should automatically test if there are any NAs in the data. If there are, it should throw an error saying where the NA is found.

Have a nice day The FlowSOM team