filter-methods {Cardinal} | R Documentation |
These methods provide analogs of data manipulation verbs from the dplyr
package, with appropriate semantics for imaging experiments. Due to the differences between imaging datasets and standard data frames, they do not always work identically.
See the descriptions below for details.
## S4 method for signature 'ImagingExperiment' filter(.data, ..., .id, .preserve=FALSE) ## S4 method for signature 'ImagingExperiment' select(.data, ..., .id) ## S4 method for signature 'ImagingExperiment' mutate(.data, ...) ## S4 method for signature 'SparseImagingExperiment' summarize(.data, ..., .by = c("feature", "pixel"), .stat = c("min", "max", "mean", "sum", "sd", "var"), .tform = identity, BPPARAM = bpparam())
.data |
An imaging dataset. |
... |
Conditions describing rows or columns to be retained, name-value pairs to be added as metadata columns, or name-value pairs of summary functions. See Details. |
.id |
Select rows (features) or columns (pixels) by index. |
.preserve |
Ignored, provided for compatibility with dplyr. |
.by |
Should the summarization be performed over pixels or features? |
.stat |
Summary statistics to be computed in an efficient manner. |
.tform |
How should each feature-vector of image-vector be transformed before summarization? |
BPPARAM |
An optional |
filter()
keeps only the rows (features) where the conditions are TRUE. Columns of featureData(.data)
can be referred to literally in the logical expressions.
select()
keeps only the columns (pixels) where the conditions are TRUE. Columns of pixelData(.data)
can be referred to literally in the logical expressions.
mutate()
adds new columns to the pixel metadata columns (pixelData(.data)
).
summarize()
calculates statistical summaries over either features or pixels using pixelApply()
or featureApply()
. Several statistical summaries can be chosen via the .stat
argument, which will be efficiently calculated according to the format of the data.
An ImagingExperiment
(or subclass) instance for filter()
, select()
, and mutate()
. An XDataFrame
(or subclass) instance for summarize()
.
Kylie A. Bemis
data <- matrix(c(NA, NA, 1, 1, NA, NA, NA, NA, NA, NA, 1, 1, NA, NA, NA, NA, NA, NA, NA, 0, 1, 1, NA, NA, NA, NA, NA, 1, 0, 0, 1, 1, NA, NA, NA, NA, NA, 0, 1, 1, 1, 1, NA, NA, NA, NA, 0, 1, 1, 1, 1, 1, NA, NA, NA, NA, 1, 1, 1, 1, 1, 1, 1, NA, NA, NA, 1, 1, NA, NA, NA, NA, NA, NA, 1, 1, NA, NA, NA, NA, NA), nrow=9, ncol=9) set.seed(1) msset <- generateImage(data, range=c(1000,5000), centers=c(3000,4000), resolution=100, as="MSImageSet") msset <- as(msset, "MSImagingExperiment") filter(msset, mz > 2000, mz < 3000) select(msset, x <= 4, y <= 4) sm1 <- summarize(msset, .stat="mean") sm2 <- summarize(msset, .stat=c(tic="sum"), .by="pixel") mutate(msset, tic=sm2$tic)