SofieVG / FlowSOM

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

BuildSOM produces NaN/Infs error on the C part #34

Closed pcm32 closed 4 years ago

pcm32 commented 4 years ago

Using different versions of FlowSOM from bioconda I get this strange behaviour where BuilSOM C part produces:

Building SOM

Error: NA/NaN/Inf in foreign function call (arg 1)

If I look at the traceback:

> traceback()
3: .C("C_SOM", data = as.double(data), codes = as.double(codes),
       nhbrdist = as.double(nhbrdist), alpha = as.double(alpha[[i]]),
       radius = as.double(radius[[i]]), xdists = double(nCodes),
       n = as.integer(nrow(data)), px = as.integer(ncol(data)),
       ncodes = as.integer(nCodes), rlen = as.integer(rlen), distf = as.integer(distf))
2: SOM(fsom$data[, colsToUse], silent = silent, ...)
1: BuildSOM(fs, colsToUse = columns, xdim = xgrid, ydim = ygrid)

I have tried different versions of flowsom, flowdensity and flowcore (within conda) in the steps that generate the merged fcs used as input for BuildSOM, with the same result. However, certain combination of versions installed directly over R does work. The direct R version does fail when I feed it the input file created with the conda flowsom/flowdensity/flowcore installations. Any ideas or anything I should be looking for?

Thanks!

pcm32 commented 4 years ago

Ok, dataset did have NaNs and removing them solves the problem. What is not clear to me then is why one R setup produces NaNs and not the other....

>   fs <- ReadInput(ff, compensate=F, transform=F, scale=T)
Scaling the data
> summary(is.nan(fs$data[complete.cases(fs$data[,columns]),columns]))
 Blue A 710_50-A Blue B 515_20-A Green A 780_40-A Green D 610_20-A
 Mode :logical   Mode :logical   Mode :logical    Mode :logical
 FALSE:255946    FALSE:255946    FALSE:255946     FALSE:255946
 Green E 575_25-A Red A 780_60-A  Red B 710_50-A  Red C 660_20-A
 Mode :logical    Mode :logical   Mode :logical   Mode :logical
 FALSE:255946     FALSE:255946    FALSE:255946    FALSE:255946
 Violet A 780_60-A Violet B 705_70-A Violet C 660_40-A Violet D 605_40-A
 Mode :logical     Mode :logical     Mode :logical     Mode :logical
 FALSE:255946      FALSE:255946      FALSE:255946      FALSE:255946
 Violet E 585_42-A Violet H 450_50-A
 Mode :logical     Mode :logical
 FALSE:255946      FALSE:255946
> fs$data<-fs$data[complete.cases(fs$data[,columns]),]
> xgrid
[1] 10
> ygrid
[1] 10
> fs <- BuildSOM(fs, colsToUse = columns, xdim=xgrid, ydim=ygrid)
Building SOM
Mapping data to SOM
>

but I'm guessing that this is no longer a problem of this library, but of the previous steps I guess.

pcm32 commented 4 years ago

...unless that the problem is with ReadInput...

pcm32 commented 4 years ago

no, ff has NaNs as well.