matter
matter copied to clipboard
Implement or fix tuning of spatial smooting in spatialDGMM
As far as I remember, in older versions of spatialDGMM, the r
parameter could be used to increase or decrease the amount of spatial smoothing (higher r
values gave smoother segments). This was a very useful feature. In the current version, the segmentation is almost identical for different values of r
.
An example to reproduce the issue:
set.seed(2020)
mse <- simulateImage(preset=3, dim=c(30,30), npeaks=9,
peakheight=c(3,6,9), centroided=TRUE, from=495, to=505)
peaks <- mz(metadata(mse)$design$featureData)
peak_IDs <- sapply(peaks, function(x) which.min(abs(x-mse@featureData$mz)))
for(r in c(1,2,5,10,15)) {
gmm <- spatialDGMM(mse, r=r, k=4, weights="adaptive")
show(image(gmm, i=peak_IDs))
}
The segments produced for these five values of r
are nearly identical, only individual pixels change between them. In particular, even for r=15
many segments are very rugged.
My session info:
> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.5 LTS
Matrix products: default
BLAS: /home/mciach/Programs/R/4.4.1/lib/libRblas.so
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=pl_PL.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=pl_PL.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=pl_PL.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=pl_PL.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Warsaw
tzcode source: system (glibc)
attached base packages:
[1] stats4 stats graphics grDevices utils datasets methods base
other attached packages:
[1] Cardinal_3.6.5 S4Vectors_0.42.1 BiocParallel_1.38.0 BiocGenerics_0.50.0
[5] ProtGenerics_1.36.0
loaded via a namespace (and not attached):
[1] nlme_3.1-166 cli_3.6.3 knitr_1.48 rlang_1.1.4
[5] xfun_0.48 DBI_1.2.3 tiff_0.1-12 png_0.1-8
[9] RCurl_1.98-1.16 htmltools_0.5.8.1 ontologyIndex_2.12 Biobase_2.64.0
[13] locfit_1.5-9.10 rmarkdown_2.28 grid_4.4.1 evaluate_1.0.1
[17] abind_1.4-8 bitops_1.0-9 fastmap_1.2.0 yaml_2.3.10
[21] compiler_4.4.1 codetools_0.2-20 CardinalIO_1.2.1 irlba_2.3.5.1
[25] htmlwidgets_1.6.4 fftwtools_0.9-11 EBImage_4.46.0 lattice_0.22-6
[29] digest_0.6.37 matter_2.6.3 parallel_4.4.1 Matrix_1.7-1
[33] tools_4.4.1 jpeg_0.1-10 biglm_0.9-3