Spatially subset an object x using object y. Giotto spatial
subobjects respond to terra::crop. For giottoPoints
and giottoPolygon
,
an alternative faster crop operation is implemented through data.table
manipulation of the geometry information and are used by default. This mode
also only allows rectangular subsetting. Additionally, giottoPolygons
will
be cropped using their centroids so that the entire polygon is either present
or not instead of the default crop
behavior that would keep the portion of
the polygon that does fall within the selected crop region.
Set DT = FALSE
in order to use the default style of terra::crop behavior
that also allows usage of additional params through ...
Usage
# S4 method for class 'giottoLargeImage'
crop(x, y, ...)
# S4 method for class 'giottoAffineImage'
crop(x, y, ...)
# S4 method for class 'spatLocsObj'
crop(x, y, ...)
# S4 method for class 'spatialNetworkObj'
crop(x, y, ...)
# S4 method for class 'giottoPoints'
crop(x, y, DT = TRUE, xmin = NULL, xmax = NULL, ymin = NULL, ymax = NULL, ...)
# S4 method for class 'giottoPolygon'
crop(x, y, DT = TRUE, xmin = NULL, xmax = NULL, ymin = NULL, ymax = NULL, ...)
Examples
g <- GiottoData::loadGiottoMini("visium")
#> 1. read Giotto object
#> 2. read Giotto feature information
#> 3. read Giotto spatial information
#> 3.1 read Giotto spatial shape information
#> 3.2 read Giotto spatial centroid information
#> 3.3 read Giotto spatial overlap information
#> 4. read Giotto image information
#> python already initialized in this session
#> active environment : 'giotto_env'
#> python version : 3.10
#> checking default envname 'giotto_env'
#> a system default python environment was found
#> Using python path:
#> "/usr/share/miniconda/envs/giotto_env/bin/python"
g_image <- getGiottoImage(g, image_type = "largeImage")
crop(g_image, g_image)
#> An object of class giottoLargeImage : "alignment"
#> Image extent : 2364.5, 6522.5, -5425.25, -2620.75 (xmin, xmax, ymin, ymax)
#> Original image extent : 2364.5, 6522.5, -5425.25, -2620.75 (xmin, xmax, ymin, ymax)
#> Scale factor : 13.2420382165605, 13.2287735849057 (x, y)
#> Resolution : 0.0755170755170755, 0.0755927972900695 (x, y)
#> Layers : 4
#> Estimated max intensity : 174
#> Estimated min intensity : 0
#> Values : integers
#> File path : '/home/runner/work/_temp/Library/GiottoData/Mini_datasets/Visium/VisiumObject/Images/alignment_spatRaster'