splots 1.64.0
This package is provided to support legacy code and reverse dependencies, but it should not be used as a dependency for new code development. It provides a single function, plotScreen
, for visualising data in microtitre plate or slide format. As a better alternative for such functionality, please consider the platetools package (see also https://github.com/Swarchal/platetools), or generic ggplot2 graphics functionality.
Here we give a short demo. First, we load and explore some example data.
data("featuresPerWell", package = "HD2013SGI")
str(featuresPerWell[[1]])
## 'data.frame': 231840 obs. of 4 variables:
## $ plate: chr "001CIQ01IRI" "001CIQ01IRI" "001CIQ01IRI" "001CIQ01IRI" ...
## $ row : chr "B" "B" "B" "B" ...
## $ col : chr "1" "1" "1" "1" ...
## $ field: chr "1" "2" "3" "4" ...
str(featuresPerWell[[2]])
## num [1:231840, 1:353] 2780 3120 2242 2603 2170 ...
## - attr(*, "dimnames")=List of 2
## ..$ : NULL
## ..$ : chr [1:353] "count" "nuc.0.m.cx" "nuc.0.m.cy" "nuc.0.m.majoraxis" ...
stopifnot(nrow(featuresPerWell[[1]]) == nrow(featuresPerWell[[2]]))
We use a subset of these data and assemble them into the list xl
. The details of how this is done in the following code chunk are arcane and are likely not to matter much to you; what is important is that you bring your data into the same format.
np = 40
nx = 24
ny = 16
plateNames = unique(featuresPerWell[[1]]$plate)
assertthat::assert_that(length(plateNames) >= np)
plateNames = plateNames[seq_len(np)]
xl = lapply(plateNames, function(pl) {
sel = with(featuresPerWell[[1]], plate == pl & field == "1")
rv = rep(NA_real_, nx * ny)
r = match(featuresPerWell[[1]]$row[sel], LETTERS)
c = match(featuresPerWell[[1]]$col[sel], paste(seq_len(nx)))
i = (r-1) * nx + c
assertthat::assert_that(!any(is.na(r)), !any(is.na(c)), !any(duplicated(i)),
all(r>=1), all(r<=ny), all(c>=1), all(c<=nx))
rv[i] = featuresPerWell[[2]][sel, "count"]
rv
})
names(xl) = plateNames
So this the object xl
that is passed into plotScreen
:
class(xl)
## [1] "list"
length(xl)
## [1] 40
names(xl)[1:4]
## [1] "001CIQ01IRI" "002CIQ01IIRI" "003CIIQ01IRI" "004CIIQ01IIRI"
unique(vapply(xl, function(x) paste(class(x), length(x)), character(1)))
## [1] "numeric 384"
xl[[1]][1:30]
## [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [16] NA NA NA NA NA NA NA NA NA 2780 2170 2548 2673 2486 2611
splots::plotScreen(xl, nx = nx, ny = ny, ncol = 4,
fill = c("white", "darkgoldenrod4"),
main = "HD2013SGI", legend.label = "cell count",
zrange = c(0, max(unlist(xl), na.rm = TRUE)))
sessionInfo()
## R version 4.2.1 (2022-06-23)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.5 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.16-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.16-bioc/R/lib/libRlapack.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_GB LC_COLLATE=C
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] BiocStyle_2.26.0
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.9 knitr_1.40 magrittr_2.0.3
## [4] R6_2.5.1 rlang_1.0.6 fastmap_1.1.0
## [7] stringr_1.4.1 highr_0.9 tools_4.2.1
## [10] grid_4.2.1 xfun_0.34 cli_3.4.1
## [13] jquerylib_0.1.4 htmltools_0.5.3 yaml_2.3.6
## [16] digest_0.6.30 assertthat_0.2.1 bookdown_0.29
## [19] BiocManager_1.30.19 RColorBrewer_1.1-3 sass_0.4.2
## [22] splots_1.64.0 codetools_0.2-18 cachem_1.0.6
## [25] evaluate_0.17 rmarkdown_2.17 stringi_1.7.8
## [28] compiler_4.2.1 bslib_0.4.0 magick_2.7.3
## [31] jsonlite_1.8.3