Skip to content

Commit b205126

Browse files
authored
Merge pull request #25 from plinders/main
Add 1536-well plate format
2 parents c1f6bff + 5791769 commit b205126

9 files changed

+85
-14
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: ggplate
22
Title: Create Layout Plots of Biological Culture Plates and Microplates
3-
Version: 0.1.4
3+
Version: 0.1.5
44
Authors@R: person(given = "Jan-Philipp",
55
family = "Quast",
66
role = c("aut", "cre"),
@@ -11,7 +11,7 @@ License: MIT + file LICENSE
1111
Encoding: UTF-8
1212
LazyData: true
1313
Roxygen: list(markdown = TRUE)
14-
RoxygenNote: 7.3.1
14+
RoxygenNote: 7.3.2
1515
Imports:
1616
dplyr,
1717
ggplot2,

NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# ggplate 0.1.5
2+
3+
* The package received the 1536-well format. Thanks to @plinders!
4+
15
# ggplate 0.1.4
26

37
* Fix issue #23. If not all possible rows were part of the data, wells were shifted down to the bottom of the plate. This has been fixed and every well is in the correct position irrespective of the completeness of the data.

R/data.R

+9
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,12 @@
108108
#' @format A data frame with a `Value` and a `well` column.
109109
#' @source Drugs were chosen from a standard FDA approved drug library.
110110
"data_discrete_96"
111+
112+
#' Continuous 1536-well plate dataset
113+
#'
114+
#' A dataset containing 1536 positive numeric values randomly generated using a normal distribution (`rnorm()`).
115+
#' Each value is assigned to a position in a 1536-well plate.
116+
#'
117+
#' @format A data frame with a `Value` and a `well` column.
118+
#' @source Randomly generated.
119+
"data_continuous_1536"

R/plate_plot.R

+32-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#' @param label a character or numeric column in the `data` data frame that contains values that should be plotted as labels
1313
#' on the plate layout. Can be the same column as `value`.
1414
#' @param plate_size a numeric value that specifies the plate size (number of wells) used for the plot. Possible values
15-
#' are: 6, 12, 24, 48, 96 and 384.
15+
#' are: 6, 12, 24, 48, 96, 384 and 1536.
1616
#' @param plate_type a character value that specifies the well type. Possible values are "round" and "square". The default is
1717
#' "square".
1818
#' @param colour optional, a character vector that contains colours used for the plot. If the `value` argument is discrete
@@ -127,7 +127,7 @@ plate_plot <- function(data,
127127
label_size,
128128
silent = TRUE,
129129
scale) {
130-
if (!plate_size %in% c(6, 12, 24, 48, 96, 384)) {
130+
if (!plate_size %in% c(6, 12, 24, 48, 96, 384, 1536)) {
131131
stop("Selected plate_size not available!")
132132
}
133133

@@ -223,15 +223,17 @@ plate_plot <- function(data,
223223
nchar() |>
224224
max()
225225

226+
MORELETTERS <- c(LETTERS, "AA", "AB", "AC", "AD", "AE", "AF")
227+
226228
data_prep <- data |>
227229
dplyr::ungroup() |>
228230
dplyr::mutate(
229231
row = stringr::str_extract({{ position }}, pattern = "[:upper:]+"),
230232
col = as.numeric(stringr::str_extract({{ position }}, pattern = "\\d+")),
231-
row_num = as.numeric(match(.data$row, LETTERS)),
233+
row_num = as.numeric(match(.data$row, MORELETTERS)),
232234
colours = data_colours,
233235
label_colours = label_col
234-
)
236+
)
235237

236238
if (!is.numeric(dplyr::pull(data, {{ value }}))) {
237239
# Convert character values to factors
@@ -413,7 +415,26 @@ plate_plot <- function(data,
413415
size <- (4.4 - max((max_label_length - 13) * 0.07, 0)) * scale
414416
}
415417
}
416-
418+
419+
if (plate_size == 1536) {
420+
n_cols <- 48
421+
n_rows <- 32
422+
size <- 1.8 * scale
423+
min_x_axis <- 0.95
424+
max_x_axis <- n_cols
425+
min_y_axis <- 0.9
426+
max_y_axis <- n_rows
427+
text_size <- 4 * scale
428+
legend_text_size <- text_size
429+
legend_title_size <- text_size
430+
title_size_preset <- 10 * scale
431+
legend_size <- size
432+
stroke_width <- 0.3 * scale
433+
if (show_legend) {
434+
size <- (2.2 - max((max_label_length - 13) * 0.07, 0)) * scale
435+
}
436+
}
437+
417438
# Update row number to be reversed
418439
# This depends on the n_rows variable, which depends on the plate size
419440
data_prep <- data_prep |>
@@ -465,7 +486,7 @@ plate_plot <- function(data,
465486
xlim = c(min_x_axis, max_x_axis),
466487
ylim = c(min_y_axis, max_y_axis)
467488
) +
468-
ggplot2::scale_y_continuous(breaks = seq(1, n_rows), labels = rev(LETTERS[1:n_rows])) +
489+
ggplot2::scale_y_continuous(breaks = seq(1, n_rows), labels = rev(MORELETTERS[1:n_rows])) +
469490
ggplot2::scale_x_continuous(breaks = seq(1, n_cols), position = "top") +
470491
{
471492
if (is.numeric(dplyr::pull(data, {{ value }}))) {
@@ -485,15 +506,15 @@ plate_plot <- function(data,
485506
y = ""
486507
) +
487508
{
488-
if (!missing(label)) ggplot2::geom_text(ggplot2::aes(x = col,
489-
y = .data$row_num,
509+
if (!missing(label)) ggplot2::geom_text(ggplot2::aes(x = col,
510+
y = .data$row_num,
490511
label = format(
491-
{{ label }},
512+
{{ label }},
492513
drop0Trailing = FALSE, # does not drop trailing 0
493514
justify = "none", # does not add white spaces for justification
494515
trim = TRUE) # removes leading white spaces
495-
),
496-
colour = data_prep$label_colours,
516+
),
517+
colour = data_prep$label_colours,
497518
size = label_size_scaled)
498519
} +
499520
ggplot2::theme_bw() +

README.Rmd

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Currently the package supports the following plate sizes:
3131
* 48-well plate
3232
* 96-well plate
3333
* 384-well plate
34+
* 1536-well plate
3435

3536

3637
## Installation

data-raw/example_data.R

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
library(dplyr)
22
library(tidyr)
3+
library(stringr)
34

45
set.seed(1234)
56

@@ -167,3 +168,18 @@ data_continuous_384 <- data.frame(matrix(round(abs(rnorm(384)), 2), nrow = 16, n
167168
distinct(well, Value)
168169

169170
usethis::use_data(data_continuous_384, overwrite = TRUE)
171+
172+
#1536-well plate
173+
174+
MORELETTERS <- c(LETTERS, "AA", "AB", "AC", "AD", "AE", "AF")
175+
176+
data_continuous_1536 <- data.frame(matrix(round(abs(rnorm(1536)), 2), nrow = 32, ncol = 48)) |>
177+
mutate(rows = MORELETTERS[1:32]) |>
178+
pivot_longer(cols = -rows, names_to = "cols", values_to = "Value") |>
179+
mutate(
180+
cols = as.numeric(str_remove(cols, pattern = "V|X")),
181+
well = paste0(rows, cols)
182+
) |>
183+
distinct(well, Value)
184+
185+
usethis::use_data(data_continuous_1536, overwrite = TRUE)

data/data_continuous_1536.rda

4.03 KB
Binary file not shown.

man/data_continuous_1536.Rd

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plate_plot.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)