filterSpataObject.Rd
This function filters a SPATA2 object based on specified logical expressions,
retaining only the observations that meet the criteria. It has the same effect as
the function subsetSpataObject()
has, but it provides more convenient input options.
Note the .
prefix before the arguments.
filterSpataObject(
object,
...,
.normalize = FALSE,
.spatial_proc = TRUE,
.verbose = TRUE
)
An object of class SPATA2
or, in case of S4 generics,
objects of classes for which a method has been defined.
<data-masking
> Expressions that
return a logical value, and are defined in terms of the variables in
.data
. If multiple expressions are included, they are combined with the
&
operator. Only rows for which all conditions evaluate to TRUE
are
kept.
Logical value indicating whether numeric variables should be
scaled to 0-1 before filtering. Default is FALSE
.
Logical value. Indicates whether the new sub-object is
processed spatially. If TRUE
, a new tissue outline is identified based
on the remaining observations via identifyTissueOutline()
. Then,
spatial annotations are tested on being located on either of the remaining
tissue sections. If they are not, they are removed.
If FALSE
, these processing steps are skipped. Generally speaking, this is
not recommended. Only set to FALSE
, if you know what you're doing.
Logical. If TRUE
, informative messages regarding the
computational process will be printed.
(Warning messages will always be printed.)
The updated input object, containing the added, removed or computed results.
The function filters the input SPATA2
object based on the logical expressions provided in ...
.
If no expressions are provided, the function returns the input object with a warning.
The variables used in the expressions are extracted and joined with the SPATA2
object's data frame.
The observations that meet the criteria specified by the logical expressions are retained.
library(SPATA2)
library(patchwork)
object <- loadExampleObject("UKF269T", process = TRUE, meta = TRUE)
orig_frame <- ggpLayerFrameByCoords(object)
# exemplifies the effect of the 'normalize'
# note the value range
plotSurface(object, color_by = "SNAP25", normalize = TRUE)
plotSurface(object, color_by = "SNAP25", normalize = FALSE)
# another grouping variable for this example
plotSurface(object, color_by = "bayes_space")
# example 1: normalize = TRUE
object_sub1 <- filterSpataObject(object, SNAP25 > 0.5, .normalize = TRUE)
plotSurface(object_sub1) +
(plotSurface(object_sub1) + orig_frame)
# example 2: normalize = FALSE
object_sub2 <- filterSpataObject(object, SNAP25 > 0.5, .normalize = FALSE)
plotSurface(object_sub2, color_by = "SNAP25") +
(plotSurface(object_sub1) + orig_frame)
# example 3: logical tests can be more complex
object_sub3 <- filterSpataObject(object, GFAP > 0.5 | bayes_space %in% c("1", "3"), .normalize = TRUE)
plotSurface(object_sub3, color_by = "SNAP25") +
plotSurface(object_sub3, color_by = "bayes_space")