Description Usage Arguments Details Value See Also Examples
Convert data frames with user-defined plate types to
OPMX
or MOPMX
objects.
1 2 3 4 5 6 |
object |
Data frame containing numeric data with
growth or respiration measurements and optional or
mandatory additional columns, depending on the
|
format |
Character scalar indicating the data layout
within
|
position |
Character vector. In ‘horizontal’
format, the name of one to several columns to be joined
yielding ‘position’ indicators. These will be
used to uniquely identify each plate. The columns to be
joined will be kept, too; usually they will end up in the
The For plate position values to be used literally, integers
between 0 and 99 (inclusively) followed by a single
letters are recommended, because this allows opm to
normalise this entry. See the eponymous argument of
|
plate.type |
Character scalar. In
‘horizontal’ mode, the name of the column
containing the plate-type indicators. After
normalisation, these will be used for storing the mapping
of well coordinates. The argument is ignored if empty.
But then an accordingly named column must already be
present OR The In ‘horizontal’ mode, the plate type can be
registered beforehand, too, which is useful to enforce a
certain ordering of wells. But then the registered
well-coordinate map must contains all well coordinates
found in |
well |
Character scalar. In ‘horizontal’
format, the name of the column containing the well
indicators. These should be substrate names; an according
mapping from (newly assigned) well coordinates to these
substrate names will then be stored using
|
prefix |
Character scalar. In ‘horizontal’ format, used for identifying the measurements columns. |
sep |
Character vector, numeric scalar, or empty. In
‘rectangular’ format, used for identifying the
rows and column with time-points and well coordinates. If
empty, Well coordinates can be missing from each rectangle
unless |
full.name |
Named character vector indicating the
full plate names. Ignored if empty. Names should be
names of the plate types found within If the plate type is not found within |
setup.time |
Character scalar to be inserted if
missing in the data. Like the next argument, the value
goes into the |
filename |
Character scalar to be inserted if missing in the data. |
interval |
Numeric vector. If of length one,
indicating the time interval between measurements in the
‘rectangular’ format. If the length corresponds to
the number of measurements per well in In the case of the |
na.strings |
Character vector passed to
|
dec |
Likewise. |
The main purpose of this function is to convert objects
that hold non-PM data to OPMX
objects that can be analysed with opm. The
mechanism for dealing with user-defined plate types is
implemented in register_plate
, whereas
opmx
also takes care of the necessary changes in
format and naming for converting a data frame to a
MOPMX
object.
In contrast to functions for reading PM data,
opmx
allows for input NA
values by
removing, within each resulting pseudo-plate
(OPM
object) individually, all time points
that contain at least one NA
value. This might
lose information, of course, but not between plates, even
though it might yield OPMX
objects with
non-uniform measurement times. A warning is issued in the
case of removal.
OPMX
or MOPMX
object or
NULL
, depending on how many distinct plate types
are encountered within object
.
Other conversion-functions: as.data.frame
,
extract
, extract_columns
,
flatten
, merge
,
oapply
, plates
,
rep
, rev
, sort
,
split
, to_yaml
,
unique
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | ## 'horizontal' input format
# fake data frame containing growth or respiration measurements
x <- data.frame(
Treatment = c(rep("Control", 4), rep("Heat stress", 4)),
Strain = paste0("X", c(1, 2, 2, 1, 2, 1, 1, 2)),
Substrate = c(rep("Glucose", 2), rep("Galactose", 4), rep("Glucose", 2)),
T_0 = c(12, 5, 8, 6, 8, 9, 7, 10),
T_5 = c(23, 7, 7, 18, 30, 10, 8, 9),
T_10 = c(79, 9, 10, 64, 67, 8, 6, 11),
T_15 = c(103, 8, 46, 99, 101, 17, 9, 8),
T_20 = c(105, 9, 77, 112, 103, 44, 8, 12)
)
# The plate type is not contained and thus taken from 'full.name', but
# the wells are obviously within 'Substrate', and each combination of
# 'Treatment' and 'Strain' is apparently one group of measurements
# (interpreted as 'plate').
y <- opmx(x, well = "Substrate", position = c("Treatment", "Strain"),
full.name = c(sugars = "Fake sugar test plate"))
# This yields a single OPMX object as there is only one plate type.
stopifnot(is(y, "OPMX"), dim(y) == c(4, 5, 2))
print(xy_plot(y, include = list("Strain", "Treatment"),
theor.max = FALSE, main = list(in.parens = FALSE), ylab = "Hours"))
## 'rectangular' input format
# Get the input file. The rectangular format is hardly suitable for R
# but produced by plate readers such as those distributed by the TECAN
# company.
growth.data.file <- grep("tecan", opm_files("growth"), ignore.case = TRUE,
value = TRUE)
if (length(growth.data.file)) { # if the file was found
x <- read.table(growth.data.file)
head(x)
# Creating a fake well map. For really making sense of these data, one
# would need to know the real substrate names.
well.map <- rbind(1:6, 1:6, 1:6, 1:6)
well.map[] <- paste0("Substrate ", LETTERS[1:4], well.map)
# Registering the plate type beforehand is mandatory here because the
# file does not contain the real substrate names.
register_plate(XYZ = well.map)
(y <- opmx(x, "rectangular", plate.type = "XYZ", position = 1,
interval = 0.25))
plate_type(y) # => a custom (user-defined) plate
stopifnot(setequal(wells(y, full = TRUE, in.parens = FALSE), well.map))
register_plate(XYZ = NULL) # tidying up
} else {
warning("file with growth data not found")
}
## 'vertical' input format
# Fake data frame. It is safer to set all column names explicitly.
# If none are there, the first column yields the time points unless
# there are explicitly set row names.
x <- data.frame(
c(0, 5, 10, 15, 20),
c(12, 23, 79, 103, 105),
c(5, 7, 9, 8, 9),
c(8, 7, 10, 46, 77),
c(6, 18, 64, 99, 112),
c(8, 30, 67, 101, 103),
c(9, 10, 8, 17, 44),
c(7, 8, 6, 9, 8),
c(10, 9, 11, 8, 12)
)
colnames(x) <- NULL # necessary for this example
# Creating a fake well map for the fake data frame.
well.map <- paste("Substrate", 1:8)
names(well.map) <- paste0("A", 1:8)
# Registering the plate type beforehand is mandatory here because the
# input data frame does not contain the real substrate names.
register_plate(XYZ = well.map)
wells(plate = "CUSTOM:XYZ")[1:10]
(y <- opmx(x, "vertical", plate.type = "XYZ", position = 1))
plate_type(y) # => a custom (user-defined) plate
stopifnot(setequal(wells(y, full = TRUE, in.parens = FALSE), well.map))
register_plate(XYZ = NULL) # tidying up
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.