| sort {opm} | R Documentation |
Sort an OPMS object based on one to several
metadata or CSV data entries, or sort elements
of a MOPMX object based on plate type,
length, or a metadata entry. Alternatively, remove
duplicated elements from a OPMS or
MOPMX object, or revert the order of plates
within an OPMS object, or, repeat
OPMS or OPM objects zero
times, once, or several times.
## S4 method for signature 'OPM'
rep(x, ...)
## S4 method for signature 'OPMS'
rep(x, ...)
## S4 method for signature 'OPM'
rev(x)
## S4 method for signature 'OPMS'
rev(x)
## S4 method for signature 'MOPMX,ANY'
sort(x, decreasing,
by = c("plate.type", "length"), exact = TRUE, strict = TRUE,
na.last = TRUE, ...)
## S4 method for signature 'MOPMX,missing'
sort(x, decreasing, ...)
## S4 method for signature 'OPM,ANY'
sort(x, decreasing, ...)
## S4 method for signature 'OPM,missing'
sort(x, decreasing, ...)
## S4 method for signature 'OPMS,ANY'
sort(x, decreasing, by = "setup_time",
parse = identical(by, "setup_time"), exact = TRUE, strict = TRUE,
na.last = TRUE)
## S4 method for signature 'OPMS,missing'
sort(x, decreasing, ...)
## S4 method for signature 'MOPMX,ANY'
unique(x, incomparables, ...)
## S4 method for signature 'MOPMX,missing'
unique(x, incomparables, ...)
## S4 method for signature 'OPM,ANY'
unique(x, incomparables, ...)
## S4 method for signature 'OPM,missing'
unique(x, incomparables, ...)
## S4 method for signature 'OPMS,ANY'
unique(x, incomparables, ...)
## S4 method for signature 'OPMS,missing'
unique(x, incomparables, ...)
x |
|
decreasing |
Logical scalar. Passed to |
by |
List or character vector. For
For |
parse |
Logical scalar. Convert the
|
exact |
Logical scalar. Passed to
|
strict |
Logical scalar. Is it an error if metadata
keys are not found? If |
na.last |
Logical scalar. Also passed to
|
incomparables |
Vector passed to
|
... |
Optional arguments passed between the methods
or to |
The sort OPM method just returns the
input data to avoid destructive effects due to the way
the default sort interacts with OPM
indexing.
rev should be slightly more efficient than calling
the default rev method. There is also an
OPM method which just returns the input
data (to avoid destructive effects due to the way the
default rev interacts with OPM
indexing).
The OPM method of unique also
returns the passed object.
rev yields an OPMS object with
another number of plates, or an OPM object,
or NULL.
OPMS object with not necessarily the same
order of plates than before, or OPM object.
base::order base::sort base::strptime base::unique base::rev
base::rep
Other conversion-functions: as.data.frame,
extract, extract_columns,
flatten, merge,
oapply, opmx,
plates, split,
to_yaml
## 'OPMS' methods
# Existing keys
stopifnot(is.unsorted(metadata(vaas_4, "Strain")))
x <- sort(vaas_4, by = list("Strain"))
stopifnot(is(x, "OPMS"), !is.unsorted(metadata(x, "Strain")))
x <- sort(vaas_4, by = list("Strain"), decreasing = TRUE)
stopifnot(is(x, "OPMS"), is.unsorted(metadata(x, "Strain")))
# Non-existing keys
x <- try(sort(vaas_4, by = list("Not there", "Missing"), strict = TRUE))
stopifnot(inherits(x, "try-error")) # yields error
x <- try(sort(vaas_4, by = list("Not there", "Missing"), strict = FALSE))
stopifnot(identical(x, vaas_4)) # no error, but no new order
# CSV-data based
copy <- sort(vaas_4) # default: by setup time
csv_data(vaas_4, what = "setup_time")
## [1] "8/30/2010 1:19:11 PM" "8/30/2010 1:53:08 PM" "8/30/2010 12:31:46 PM"
## [4] "8/30/2010 11:28:54 AM"
csv_data(copy, what = "setup_time")
## [1] "8/30/2010 11:28:54 AM" "8/30/2010 12:31:46 PM" "8/30/2010 1:19:11 PM"
## [4] "8/30/2010 1:53:08 PM"
stopifnot(!identical(copy, vaas_4))
copy <- sort(vaas_4, by = c("Position", "Setup Time"))
csv_data(vaas_4, what = "position")
## [1] "12-B" " 7-B" "17-B" "22-B"
csv_data(copy, what = "position")
## [1] " 7-B" "12-B" "17-B" "22-B"
stopifnot(!is.unsorted(csv_data(copy, what = "position")))
stopifnot(is.unsorted(csv_data(vaas_4, what = "position")))
# sorting accoring to overall measurement duration
stopifnot(identical(sort(vaas_4, TRUE, "hours"), vaas_4))
# (uniform measurements durations in this object)
# making OPMS objects unique
dim(x <- unique(vaas_4))
## [1] 4 384 96
stopifnot(identical(x, vaas_4))
dim(x <- unique(c(vaas_4, vaas_4)))
## [1] 4 384 96
stopifnot(identical(x, vaas_4))
dim(x <- unique(vaas_4, what = "Species")) # species are not unique
## [1] 2 384 96
stopifnot(dim(x)[1L] < dim(vaas_4)[1L])
dim(x <- unique(vaas_4, what = list("Species", "Strain")))
## [1] 4 384 96
stopifnot(identical(x, vaas_4)) # organisms are unique
# reverting an OPMS object
dim(x <- rev(vaas_4))
## [1] 4 384 96
stopifnot(dim(x) == dim(vaas_4), !identical(x, vaas_4))
stopifnot(identical(rev(x), vaas_4))
# repeating an OPMS object
dim(x <- rep(vaas_4))
## [1] 4 384 96
stopifnot(identical(x, vaas_4))
dim(x <- rep(vaas_4, times = 2))
## [1] 8 384 96
stopifnot(length(x) == length(vaas_4) * 2)
dim(y <- rep(vaas_4, each = 2))
## [1] 8 384 96
stopifnot(length(y) == length(vaas_4) * 2, !identical(x, y))
stopifnot(is.null(rep(vaas_4, 0)))
## 'OPM' methods
summary(x <- sort(vaas_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 96
## Plate type Gen III
## Position 7-B
## Setup time 8/30/2010 1:53:08 PM
## Metadata 5
## Aggregated TRUE
## Discretized TRUE
stopifnot(identical(x, vaas_1))
dim(x <- unique(vaas_1)) # trivial
## [1] 384 96
stopifnot(identical(x, vaas_1))
dim(x <- unique(vaas_1, what = list("Species", "Strain")))
## [1] 384 96
stopifnot(identical(x, vaas_1))
dim(x <- rev(vaas_1)) # trivial
## [1] 384 96
stopifnot(identical(x, vaas_1))
dim(x <- rep(vaas_1, 1))
## [1] 384 96
stopifnot(identical(x, vaas_1))
dim(x <- rep(vaas_1, 2)) # conversion to OPMS if > 1 element
## [1] 2 384 96
stopifnot(length(x) == 2, is(x, "OPMS"))
stopifnot(is.null(rep(vaas_4, 0)))