merge {opm}R Documentation

Merge or split plates

Description

Combine all plates in a single OPM object by treating them as originating from subsequent runs of the same experimental plate. Adjust the times accordingly. Alternatively, split plates according to the contained regular series of substrates, if any. The MOPMX method merges according to plate types, optionally including a novel element.

Usage

  ## S4 method for signature 'CMAT,ANY'
merge(x, y) 
  ## S4 method for signature 'CMAT,factor'
merge(x, y) 
  ## S4 method for signature 'CMAT,logical'
merge(x, y) 
  ## S4 method for signature 'MOPMX,ANY'
merge(x, y) 
  ## S4 method for signature 'MOPMX,missing'
merge(x, y) 
  ## S4 method for signature 'OPM,OPM'
merge(x, y, sort.first = TRUE, parse = TRUE)
  ## S4 method for signature 'OPM,missing'
merge(x, y, sort.first = TRUE, parse = TRUE)
  ## S4 method for signature 'OPM,numeric'
merge(x, y, sort.first = TRUE, parse = TRUE)
  ## S4 method for signature 'OPMS,missing'
merge(x, y, sort.first = TRUE, parse = TRUE)
  ## S4 method for signature 'OPMS,numeric'
merge(x, y, sort.first = TRUE, parse = TRUE)

  ## S4 method for signature 'MOPMX,ANY,ANY'
split(x, f, drop) 
  ## S4 method for signature 'MOPMX,ANY,missing'
split(x, f, drop) 
  ## S4 method for signature 'MOPMX,factor,ANY'
split(x, f, drop) 
  ## S4 method for signature 'MOPMX,factor,missing'
split(x, f, drop) 
  ## S4 method for signature 'MOPMX,list,ANY'
split(x, f, drop) 
  ## S4 method for signature 'MOPMX,list,missing'
split(x, f, drop) 
  ## S4 method for signature 'OPM,ANY,missing'
split(x, f, drop) 
  ## S4 method for signature 'OPM,factor,ANY'
split(x, f, drop) 
  ## S4 method for signature 'OPM,factor,missing'
split(x, f, drop) 
  ## S4 method for signature 'OPM,missing,ANY'
split(x, f, drop) 
  ## S4 method for signature 'OPM,missing,missing'
split(x, f, drop) 
  ## S4 method for signature 'OPMS,ANY,missing'
split(x, f, drop) 
  ## S4 method for signature 'OPMS,factor,ANY'
split(x, f, drop) 
  ## S4 method for signature 'OPMS,factor,missing'
split(x, f, drop) 
  ## S4 method for signature 'OPMS,missing,ANY'
split(x, f, drop) 
  ## S4 method for signature 'OPMS,missing,missing'
split(x, f, drop) 
  ## S4 method for signature 'OPMX,ANY,ANY'
split(x, f, drop) 

Arguments

x

OPMX or MOPMX object.

y

For the OPMS method a numeric vector indicating the time(s) (in hours) between two subsequent plates. Must be positive throughout, and its length should fit to the number of plates (e.g., either 1 or length(x) - 1 would work). If missing, 0.25 is used.

If x is an OPM object, a missing or numeric y argument causes merge to just return x because there is nothing to merge. But y can be an OPM object in that case, which, if compatible, will be merged with x.

For the MOPMX method, the optional y can be any object that can be convert to the class of x using as.

sort.first

Logical scalar. Sort the plates according to their setup times before merging?

parse

Logical scalar. Ignored unless sort.first is TRUE. For sorting, parse the setup times using strptime from the base package? It is an error if this does not work, but see ‘Details’.

f

For the OPMX methods, a factor or missing. If missing, the behaviour is special. Splitting is applied to the plates themselves and attempted according to the positions of substrates within series as revealed by substrate_info in ‘concentration’ mode.

If a factor, f is used as in the default split method from the base package, yielding a list (MOPMX object) of single or multiple plates.

If neither missing nor a factor, f is used as key argument of metadata. The resulting entries are pasted together per plate and converted to a factor used for splitting x.

For the MOPMX methods, f is a factor, a list of factors, or an object suitable as metadata key. If a factor, it is directly used for splitting x. If a list of factors, the factor lengths must correspond to the lengths of the elements of x, in turn. Each element of x is then split separately, and the resulting MOPMX objects are reassigned, yielding a list with one MOPMX object per factor level. Factor levels that do not occur in some of the elements of x are dropped, with a warning, independent of drop argument.

If f is neither a factor nor a list of factors, such a list of factors is generated from the metadata, with NULL results replaced by NA.

drop

Passed to [. The default is FALSE.

Details

This OPMS method of merge is intended for dealing with slowly growing or reacting organisms that need to be analysed with subsequent runs of the same plate in PM mode. Results obtained with Geodermatophilus strains and Generation-III plates indicate that this works well in practice. See the references, and see the documentation of the montero_et_al data set in the opmdata package.

See the arguments time.fmt and time.zone of opm_opt for modifying the parsing of setup-time entries. If it does not work, additional time-string templates must be stored.

The CMAT method of merge is only for internal use.

The split methods with missing f are for splitting plates that contain series of substrate-usage assays as indicated in the full substrate names (mostly interpretable as concentrations). OPMS objects are generated that contain each replicate within the series in a separate plate and the replicate ID indicated in the metadata entry given by opm_opt("series.key"). This allows for comparisons between within-plate replicates.

Splitting according to substrate series will not work if these are not regular, i.e. the same substrates occur in each replicate. In such cases x will be returned, with a warning. Substrates without a replicate (‘concentration’) indicator would silently be skipped, however. The composition and order of the wells per pseudo-plate must be made uniform. This is done by enforcing well names and well ordering of the first replicate in all forthcoming replicates.

After a successful splitting, the numeric suffixes in the full well names make no sense any more, as each plate contains a constant set of such suffixes. The no.num argument of wells and the dependent methods can be used to remove the suffixes before displaying the full well names.

The MOPMX method for merge will raise an error if elements occur within x (and optionally y) that have the same plate type but cannot be combined any way because they contain distinct sets of wells. See the comments on combining plates into a OPMS object.

Value

The OPMX method of merge yields an OPM object. The metadata and csv_data will be taken from the first contained plate, but aggregated values, if any, will be dropped.

The MOPMX method for merge yields a MOPMX object with a potentially different number of elements.

The split methods yield either an OPMS or an MOPMX object; the MOPMX method for split yields a list of MOPMX objects.

References

Montero-Calasanz, M. d. C., Goeker, M., Poetter, G., Rohde, M., Sproeer, C., Schumann, P., Gorbushina, A. A., Klenk, H.-P. 2012 Geodermatophilus arenarius sp. nov., a xerophilic actinomycete isolated from Saharan desert sand in Chad. Extremophiles 16, 903–909.

Montero-Calasanz, M. d. C., Goeker, M., Rohde, M., Schumann, P., Poetter, G., Sproeer, C., Gorbushina, A. A., Klenk, H.-P. 2013 Geodermatophilus siccatus sp. nov., isolated from arid sand of the Saharan desert in Chad. Antonie van Leeuwenhoek 103, 449–456.

See Also

opmdata::montero_et_al

Other conversion-functions: as.data.frame, extract, extract_columns, flatten, oapply, opmx, plates, rep, rev, sort, to_yaml, unique

Examples

## merge: OPM methods
stopifnot(identical(merge(vaas_1, 0.5), vaas_1)) # nothing to merge
summary(x <- merge(vaas_1, vaas_1)) # biologically unreasonable!
## Class                 OPM
## From file             ./E. coli DSM
##                       30083T_vim10_7B__1_28_PMX_0_8#30#2010_F_
##                       7B_5.csv
## Hours measured        191.75
## Number of wells       96
## Plate type            Gen III
## Position              7-B
## Setup time            8/30/2010 1:53:08 PM
## Metadata              5
## Aggregated            FALSE
## Discretized           FALSE
stopifnot(is(x, "OPM"), dim(x) == c(2 * hours(vaas_1, "size"), 96))

## merge: OPMS methods
summary(x <- merge(vaas_4)) # biologically unreasonable for these data!
## Class                 OPM
## From file             ./P. aeruginosa St.
##                       429_vim10_22B__1_28_PMX_0_8#30#2010_C_22B_5.csv
## Hours measured        383.75
## Number of wells       96
## Plate type            Gen III
## Position              22-B
## Setup time            8/30/2010 11:28:54 AM
## Metadata              5
## Aggregated            FALSE
## Discretized           FALSE
stopifnot(is(x, "OPM"), dim(x) == c(sum(hours(vaas_4, "size")), 96))

# See opmdata::montero_et_al for an object to which this can be sensibly
# applied. An according example is given in the montero_et_al documentation.

## split: OPM methods
(x <- split(vaas_1))
## 1
## Class                 OPMD
## From file             ./E. coli DSM
##                       30083T_vim10_7B__1_28_PMX_0_8#30#2010_F_
##                       7B_5.csv
## Hours measured        95.75
## Number of wells       1
## Plate type            Gen III
## Position              7-B
## Setup time            8/30/2010 1:53:08 PM
## Metadata              6
## Aggregated            TRUE
## Discretized           TRUE
## 
## 2
## Class                 OPMD
## From file             ./E. coli DSM
##                       30083T_vim10_7B__1_28_PMX_0_8#30#2010_F_
##                       7B_5.csv
## Hours measured        95.75
## Number of wells       1
## Plate type            Gen III
## Position              7-B
## Setup time            8/30/2010 1:53:08 PM
## Metadata              6
## Aggregated            TRUE
## Discretized           TRUE
## 
## => OPMS object with 2 plates (2 aggregated, 2 discretized) of type 'Gen III', 1 well(s) and about 384 time point(s).
metadata(x, opm_opt("series.key"))
## [1] 1 2
stopifnot(is(x, "OPMS"), dim(x) == c(2, hours(vaas_1, "size"), 1))
# only D-Serine is present as series, all other wells are skipped
# thus split is more useful when applied to other plate types such as "ECO"

(x <- split(vaas_1, "Species"))
##                  Length Plate.type Aggregated Discretized
## Escherichia.coli      1    Gen III       TRUE        TRUE
## 
## => MOPMX object with 1 element(s), details are shown above.
##  Access the elements with [[ or $ to apply specific methods.
stopifnot(is(x, "MOPMX"), length(x) == 1)

## split: OPMS methods
(x <- split(vaas_4))
## 1
## Class                 OPMD
## From file             ./E. coli DSM
##                       18039_vim10_12B__1_28_PMX_0_8#30#2010_E_12B_5.csv
## Hours measured        95.75
## Number of wells       1
## Plate type            Gen III
## Position              12-B
## Setup time            8/30/2010 1:19:11 PM
## Metadata              6
## Aggregated            TRUE
## Discretized           TRUE
## 
## 2
## Class                 OPMD
## From file             ./E. coli DSM
##                       18039_vim10_12B__1_28_PMX_0_8#30#2010_E_12B_5.csv
## Hours measured        95.75
## Number of wells       1
## Plate type            Gen III
## Position              12-B
## Setup time            8/30/2010 1:19:11 PM
## Metadata              6
## Aggregated            TRUE
## Discretized           TRUE
## 
## 3
## Class                 OPMD
## From file             ./E. coli DSM
##                       30083T_vim10_7B__1_28_PMX_0_8#30#2010_F_
##                       7B_5.csv
## Hours measured        95.75
## Number of wells       1
## Plate type            Gen III
## Position              7-B
## Setup time            8/30/2010 1:53:08 PM
## Metadata              6
## Aggregated            TRUE
## Discretized           TRUE
## 
## 4
## Class                 OPMD
## From file             ./E. coli DSM
##                       30083T_vim10_7B__1_28_PMX_0_8#30#2010_F_
##                       7B_5.csv
## Hours measured        95.75
## Number of wells       1
## Plate type            Gen III
## Position              7-B
## Setup time            8/30/2010 1:53:08 PM
## Metadata              6
## Aggregated            TRUE
## Discretized           TRUE
## 
## 5
## Class                 OPMD
## From file             ./P. aeruginosa DSM
##                       1707_vim10_17B__1_28_PMX_0_8#30#2010_D_17B_5.csv
## Hours measured        95.75
## Number of wells       1
## Plate type            Gen III
## Position              17-B
## Setup time            8/30/2010 12:31:46 PM
## Metadata              6
## Aggregated            TRUE
## Discretized           TRUE
## 
## 6
## Class                 OPMD
## From file             ./P. aeruginosa DSM
##                       1707_vim10_17B__1_28_PMX_0_8#30#2010_D_17B_5.csv
## Hours measured        95.75
## Number of wells       1
## Plate type            Gen III
## Position              17-B
## Setup time            8/30/2010 12:31:46 PM
## Metadata              6
## Aggregated            TRUE
## Discretized           TRUE
## 
## 7
## Class                 OPMD
## From file             ./P. aeruginosa St.
##                       429_vim10_22B__1_28_PMX_0_8#30#2010_C_22B_5.csv
## Hours measured        95.75
## Number of wells       1
## Plate type            Gen III
## Position              22-B
## Setup time            8/30/2010 11:28:54 AM
## Metadata              6
## Aggregated            TRUE
## Discretized           TRUE
## 
## 8
## Class                 OPMD
## From file             ./P. aeruginosa St.
##                       429_vim10_22B__1_28_PMX_0_8#30#2010_C_22B_5.csv
## Hours measured        95.75
## Number of wells       1
## Plate type            Gen III
## Position              22-B
## Setup time            8/30/2010 11:28:54 AM
## Metadata              6
## Aggregated            TRUE
## Discretized           TRUE
## 
## => OPMS object with 8 plates (8 aggregated, 8 discretized) of type 'Gen III', 1 well(s) and about 384 time point(s).
metadata(x, opm_opt("series.key"))
## [1] 1 2 1 2 1 2 1 2
stopifnot(is(x, "OPMS"), dim(x) == c(8, hours(vaas_4, "size")[1], 1))

(x <- split(vaas_4, "Species"))
##                        Length Plate.type Aggregated Discretized
## Escherichia.coli            2    Gen III          2           2
## Pseudomonas.aeruginosa      2    Gen III          2           2
## 
## => MOPMX object with 2 element(s), details are shown above.
##  Access the elements with [[ or $ to apply specific methods.
stopifnot(is(x, "MOPMX"), length(x) == 2)

# Split into list of OPMS objects with the same overall measurement hours
x <- split(vaas_4, as.factor(hours(vaas_4)))
stopifnot(is(x, "MOPMX"), length(x) == 1, class(x[[1]]) == "OPMS")
# ... because the running times were actually already identical, the list
# contains only a single element.

[Package opm version 1.3.63 Index]