RGLab / flowStats

flowStats: algorithms for flow cytometry data analysis using BioConductor tools
15 stars 10 forks source link

Setting `target=` in `warpSet` doesn't preserve the target intensities #22

Closed LTLA closed 6 years ago

LTLA commented 6 years ago

Consider the following code:

library(flowStats)

set.seed(1000)
a <- rgamma(10000, 2, 2)
b <- rgamma(10000, 2, 2) + 2

ff.list <- list(
    A=flowFrame(cbind(X=a)),
    B=flowFrame(cbind(X=b))
)

fs <- as(ff.list, "flowSet")
new.fs <- warpSet(fs, "X", monwrd=TRUE, target="A")

summary(exprs(fs[[1]])[,1] - exprs(new.fs[[1]])[,1])
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.000e+00 0.000e+00 0.000e+00 1.056e-05 0.000e+00 1.056e-01 

One would expect that, by setting target="A", the intensities of sample A would be the same before and after warping. And indeed, this is the case except for one value that is quite different. This problem occurs intermittently and is not of great practical consequence, but it makes it hard for package developers to test methods that depend on warpSet; it would be nice to be able to expect_equal when target is set.

Edit: oops, forgot my session info:

R version 3.5.0 Patched (2018-04-30 r74679)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS

Matrix products: default
BLAS: /home/cri.camres.org/lun01/Software/R/R-3-5-branch/lib/libRblas.so
LAPACK: /home/cri.camres.org/lun01/Software/R/R-3-5-branch/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] splines   stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
[1] flowStats_3.39.0          flowWorkspace_3.29.5     
[3] ncdfFlow_2.27.0           BH_1.66.0-1              
[5] RcppArmadillo_0.9.100.5.0 cluster_2.0.7-1          
[7] fda_2.4.8                 Matrix_1.2-14            
[9] flowCore_1.47.5          

loaded via a namespace (and not attached):
 [1] tidyselect_0.2.4    ks_1.11.3           purrr_0.2.5        
 [4] lattice_0.20-35     pcaPP_1.9-73        colorspace_1.3-2   
 [7] stats4_3.5.0        XML_3.98-1.16       rlang_0.2.2        
[10] hexbin_1.27.2       pillar_1.3.0        glue_1.3.0         
[13] Rgraphviz_2.25.0    BiocGenerics_0.27.1 RColorBrewer_1.1-2 
[16] bindrcpp_0.2.2      matrixStats_0.54.0  bindr_0.1.1        
[19] stringr_1.3.1       robustbase_0.93-2   zlibbioc_1.27.0    
[22] munsell_0.5.0       gtable_0.2.0        mvtnorm_1.0-8      
[25] latticeExtra_0.6-28 Biobase_2.41.2      parallel_3.5.0     
[28] DEoptimR_1.0-8      Rcpp_0.12.18        KernSmooth_2.23-15 
[31] corpcor_1.6.9       scales_1.0.0        graph_1.59.0       
[34] IDPmisc_1.1.17      gridExtra_2.3       stringi_1.2.4      
[37] dplyr_0.7.6         grid_3.5.0          tools_3.5.0        
[40] magrittr_1.5        tibble_1.4.2        crayon_1.3.4       
[43] rrcov_1.4-4         pkgconfig_2.0.2     MASS_7.3-50        
[46] flowViz_1.45.0      data.table_1.11.4   assertthat_0.2.0   
[49] mclust_5.4.1        R6_2.2.2            compiler_3.5.0     
gfinak commented 6 years ago

Checkout the latest version for a fix.

LTLA commented 6 years ago

Thanks Greg. But I think this introduces another bug, as indexing fails when target=NULL. Perhaps:

    if (is.null(target)) {
        regSet[[target]] <- x[[target]]
    }

... would be more appropriate?

gfinak commented 6 years ago

Of course..

gfinak commented 6 years ago

Fixed in ead63f72513fada9f2b3654cff0ad703e4c73c59 Thanks @LTLA .

LTLA commented 6 years ago

Has this fix been propagated to Bioconductor yet? I'm seeing ERRORs on the build machines for flowStat related to warping, though I don't know if the problem above is the cause.

gfinak commented 6 years ago

ead63f7 wasn't propagated. Will appear in 3.39.2