splots 1.66.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.3.0 RC (2023-04-13 r84269)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.2 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.17-bioc/R/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
## [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
##
## time zone: America/New_York
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] BiocStyle_2.28.0
##
## loaded via a namespace (and not attached):
## [1] cli_3.6.1 knitr_1.42 rlang_1.1.0
## [4] magick_2.7.4 xfun_0.39 highr_0.10
## [7] assertthat_0.2.1 jsonlite_1.8.4 htmltools_0.5.5
## [10] sass_0.4.5 rmarkdown_2.21 grid_4.3.0
## [13] evaluate_0.20 jquerylib_0.1.4 fastmap_1.1.1
## [16] yaml_2.3.7 bookdown_0.33 BiocManager_1.30.20
## [19] compiler_4.3.0 codetools_0.2-19 RColorBrewer_1.1-3
## [22] Rcpp_1.0.10 digest_0.6.31 R6_2.5.1
## [25] magrittr_2.0.3 bslib_0.4.2 tools_4.3.0
## [28] splots_1.66.0 cachem_1.0.7