find_substrate: Identify substrates or positions

Description Usage Arguments Details Value See Also Examples

Description

Identify the names of substrates as used in the stored plate annotations, or identify the positions of substrates, i.e. the plate(s) and well(s) in which they occur. Exact or error-tolerant matching can be used, as well as globbing and regular-expression matching.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
  ## S4 method for signature 'MOPMX'
find_positions(object, ...) 
  ## S4 method for signature 'OPM'
find_positions(object, type = NULL, ...) 
  ## S4 method for signature 'OPMS'
find_positions(object, ...) 
  ## S4 method for signature 'character'
find_positions(object, type = NULL, ...) 
  ## S4 method for signature 'factor'
find_positions(object, ...) 
  ## S4 method for signature 'list'
find_positions(object, ...) 
  ## S4 method for signature 'substrate_match'
find_positions(object, ...) 

  ## S4 method for signature 'character'
find_substrate(object,
    search = c("exact", "glob", "approx", "regex", "pmatch"), max.dev = 0.2) 
  ## S4 method for signature 'factor'
find_substrate(object, ...) 

Arguments

object

Query character vector or factor, when searching for positions alternatively a list, an S3 object of class ‘substrate_match’, an OPM or an OPMS object.

type

Ignored if empty or FALSE. Otherwise, passed to plate_type for normalisation and then used to restrict the positions to those in that plate. Changes the output object to a vector; see below for details. In the case of OPMX objects, this can be set to TRUE, causing the use of the plate of object.

search

Character scalar indicating the search mode.

exact

Query names must exactly match (parts of) the well annotations.

glob

Shell globbing is used. See glob_to_regex for a description of globbing patterns.

approx

Approximate matching is used; the number or proportion of errors allowed is set using max.dev, and neither globbing or regular-expression matching is done in that case.

regex

Regular-expression matching is used.

pmatch

Uses pmatch from the base package.

All matching is case-insensitive except for the exact and pmatch search modes.

max.dev

Numeric scalar indicating the maximum allowed deviation. If < 1, the proportion of characters that might deviate, otherwise their absolute number. It can also be a list; see the ‘max.distance’ argument of agrep in the base package for details. Has an effect only if ‘approx’ is chosen as search mode (see the search argument).

...

Optional arguments passed between the methods.

Details

When searching for positions, the query names must be written exactly as used in the stored plate annotations. To determine their spelling, use find_substrate. This spelling is not guaranteed to be stable between distinct opm releases.

Value

find_substrate returns an S3 object of class ‘substrate_match’; basically a list of character vectors (empty if nothing was found), with duplicates removed and the rest sorted. The names of the list correspond to names.

The find_positions character method returns a list of character matrices (empty if nothing was found), with one row per position found, the plate name in the first column and the well name in the second. The names of this list correspond to names. The OPM and OPMS methods do the same, using their own substrates. The list and ‘substrate_match’ methods return lists of such lists.

See Also

base::grep base::agrep

Other naming-functions: gen_iii, listing, opm_files, plate_type, register_plate, select_colors, substrate_info, wells

Examples

 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
## find_substrate()

# Note that 'exact' search matches parts of the names, whereas globbing
# matches entire strings if there are no wildcards (which wouldn't make much
# sense)
(x <- find_substrate("D-Glucose", search = "exact"))
(y <- find_substrate("D-Glucose", search = "glob"))
stopifnot(length(x[[1]]) > length(y[[1]]))

# 'pmatch' matching matches partially at the beginning and returns at most
# one match (the first one)
(y <- find_substrate("D-Glucose", search = "pmatch"))
stopifnot(length(x[[1]]) > length(y[[1]]))

# Now allowing mismatches
(z <- find_substrate("D-Glucose", search = "approx"))
stopifnot(length(z[[1]]) > length(x[[1]]))

# Factor method
(zz <- find_substrate(as.factor("D-Glucose"), search = "approx"))
stopifnot(identical(z, zz))

## find_positions()

# Character method; compare correct and misspelled substrate name
(x <- find_positions(c("D-Glucose", "D-Gloucose")))
stopifnot(length(x[[1]]) > length(x[[2]]))

# Factor method
(y <- find_positions(as.factor(c("D-Glucose", "D-Gloucose"))))
stopifnot(identical(y, x))

# Restrict to  a certain plate
(x <- find_positions(c("D-Glucose", "D-Gloucose"), type = "Gen III"))
stopifnot(is.character(x), anyNA(x), !all(is.na(x)))

# List method
x <- find_positions(find_substrate(c("D-Glucose", "D-Gloucose")))
x[[1]][1:3]
x[[2]]
stopifnot(length(x[[1]]) > length(x[[2]]))

opm documentation built on May 2, 2019, 6:08 p.m.