removeSpatialOutliers.Rd
Removes data points that were identified as spatial outliers and all their related data. If no spatial outliers exist, the input object is returned as is.
removeSpatialOutliers(
object,
spatial_proc = TRUE,
rm_var = TRUE,
verbose = NULL
)
An object of class SPATA2
or, in case of S4 generics,
objects of classes for which a method has been defined.
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.
Only relevant, if barcodes
is not NULL
.
Logical value. If TRUE
, the variable sp_outlier is removed
since it only contains FALSE
after this function call and is of no value
any longer.
Logical. If TRUE
, informative messages regarding
the computational progress will be printed.
(Warning messages will always be printed.)
The updated input object, containing the added, removed or computed results.
identifyTissueOutline()
, identifySpatialOutliers()
, containsSpatialOutliers()
,
subsetSpataObject()
is the working horse behind the removal.
library(SPATA2)
data("example_data")
object <- example_data$object_UKF269T_diet
# spatial outliers have not been labeled histologically (= NA)
plotSurface(object, color_by = "histology")
object <- identifyTissueOutline(object) # step 1
plotSurface(object, color_by = "tissue_section")
object <- identifySpatialOutliers(object) # step 2
plotSurface(object, color_by = "sp_outlier")
nObs(object) # before removal
object <- removeSpatialOutliers(object) # step 3
plotSurface(object, color_by = "histology")
nObs(object) # after removal