splots 1.58.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.1.0 (2021-05-18)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.2 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.13-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.13-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.20.0
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.6 knitr_1.33 magrittr_2.0.1
## [4] R6_2.5.0 rlang_0.4.11 stringr_1.4.0
## [7] highr_0.9 tools_4.1.0 grid_4.1.0
## [10] xfun_0.23 jquerylib_0.1.4 htmltools_0.5.1.1
## [13] yaml_2.2.1 digest_0.6.27 assertthat_0.2.1
## [16] bookdown_0.22 BiocManager_1.30.15 RColorBrewer_1.1-2
## [19] sass_0.4.0 splots_1.58.0 codetools_0.2-18
## [22] evaluate_0.14 rmarkdown_2.8 stringi_1.6.2
## [25] compiler_4.1.0 bslib_0.2.5.1 magick_2.7.2
## [28] jsonlite_1.7.2