Anomalous contours using flowClust density method
2
1
Entering edit mode
geoff.lewen ▴ 10
@geofflewen-9074
Last seen 8.8 years ago
United States

The flowClust method density generates anomalous contours at the x- and y-axes, kinking them at the axes, or shunting them into narrow bands near the axes.  See example here (http://imgur.com/F3R8rIV)  This occurs over several versions of flowClust, and so does not seem to be version-dependent.  We also see this in R on Linux, Windows, and Mac OSX, so it is not platform-dependent.  Likewise, each OS is running a different version of R (for various reasons, including legacy), so the effect is not R-version-dependent. 

We are curious if others see this, and so if this is a bug in the program, or perhaps we are doing something wrong.  If we are doing something wrong, then please suggest corrections to our approach.  Many Thanks, Geoff.


Code to reproduce (understanding we have not provided data--this is to check syntax only.)  Note: setting or not setting nu=Inf does not make a difference.  Nor does using from and to in place of the data input when calling density.

plotDens(fF1,c(4,10),xlim=c(-.2,1),devn=F)
fc1<-flowClust(fF1,varNames=c(Name1,Name2),K=4,nu=Inf)
fc1.dens<-density(x=fc1,data=fF1)
plot(fc1.dens,add=T)

Browse[2]> sessionInfo()
R version 3.1.3 Patched (2015-03-16 r68060)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.1 (unknown)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] grid      parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] magic_1.5-6         abind_1.4-3         splancs_2.01-38     sp_1.1-1            spatstat_1.41-1    
 [6] sgeostat_1.0-26     tripack_1.3-7       colorRamps_2.3      hexbin_1.27.1       KernSmooth_2.23-15
[11] SDMTools_1.1-221    fields_8.3-6        maps_3.0.2          spam_1.3-0          stringr_1.0.0      
[16] ggplot2_2.0.0       gdata_2.17.0        GEOmap_2.3-8        flowDensity_1.0.0   flowClust_3.4.11   
[21] clue_0.3-51         corpcor_1.6.8       mnormt_1.5-3        ellipse_0.3-8       RBGL_1.42.0        
[26] graph_1.44.1        Biobase_2.26.0      BiocGenerics_0.12.1 flowViz_1.30.1      lattice_0.20-33    
[31] flowCore_1.32.2    

loaded via a namespace (and not attached):
 [1] alphahull_2.0       bitops_1.0-6        car_2.0-25          caTools_1.17.1      cluster_2.0.3      
 [6] coda_0.18-1         colorspace_1.2-6    deldir_0.1-9        DEoptimR_1.0-4      geometry_0.3-6     
[11] goftest_1.0-3       gplots_2.17.0       gtable_0.1.2        gtools_3.4.2        IDPmisc_1.1.17     
[16] igraph_1.0.1        latticeExtra_0.6-26 lme4_1.1-10         magrittr_1.5        MASS_7.3-45        
[21] Matrix_1.2-3        MatrixModels_0.4-1  MBA_0.0-8           MCMCpack_1.3-3      mgcv_1.8-10        
[26] minqa_1.2.4         munsell_0.4.2       mvtnorm_1.0-3       nlme_3.1-122        nloptr_1.0.4       
[31] nnet_7.3-11         pbkrtest_0.4-4      pcaPP_1.9-60        plyr_1.8.3          polyclip_1.3-2     
[36] quantreg_5.19       R.methodsS3_1.7.0   R.oo_1.19.0         R.utils_2.2.0       RColorBrewer_1.1-2
[41] Rcpp_0.12.3         RFOC_3.3-3          robustbase_0.92-5   RPMG_2.2-1          rrcov_1.3-8        
[46] RSEIS_3.5-2         Rwave_2.4           scales_0.3.0        SparseM_1.7         splines_3.1.3      
[51] stats4_3.1.3        stringi_1.0-1       tensor_1.5          tools_3.1.3 
flowclust density • 1.4k views
ADD COMMENT
0
Entering edit mode
Greg Finak ▴ 240
@greg-finak-4299
Last seen 7.9 years ago
United States

Hi, Geoff

Thanks for providing the data offline. 

I'll post my findings here so others can benefit. 

The apparent discontinuities you observe around 0 are caused by the display of the contours on the non-transfomred scale, whereas the model is fit with a Box-Cox transformation applied. In that space, the density is continuous and there is not anything to worry about. So if you need to do any further calculations with the densities, you should do them on the transformed scale. The transformation parameter can be accessed via fc1@lambda. The boxcox transformation and its inverse are box() and rbox(), respectively. If you wish to avoid this altogether, you can fit the model with a fixed transformation parameter, lambda=1 (equivalent to no transform) and pass trans=0 to flowClust, telling it not to estimate lambda.

Best,

Greg

 

Edit: One more minor comment, the contour density is evaluated on an equally spaced grid of size 100 by 100, by default. this can be increase by passing npoints=c(200,200) to density, for example. 

 

ADD COMMENT
0
Entering edit mode
SamGG ▴ 360
@samgg-6428
Last seen 10 days ago
France/Marseille/Inserm

Hi,

I prefer to apply a specific transformation such as asinh before flowClust. Doing so, I can visualize the transformed data and check the "potato" shapes by eye. IMHO asinh is better than BoxCox at coping events on the axes. IIRC the data of the original publication were log-transformed at the acquisition and not on the axes.

http://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-10-145

Best,

Samuel

ADD COMMENT

Login before adding your answer.

Traffic: 1450 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6