Img<-,SpatialExperiment-method | R Documentation |
Modify or replace images stored in a SpatialExperiment
object. This is
different from addImg
which adds the image from files and can't
replace existing images, which is there to be consistent with
SpatialExperiment
. This setter here can replace existing images with
another object that inherits from VirtualSpatialImage
, including
SpatRasterImage
, BioFormatsImage
, and
ExtImage
.
## S4 replacement method for signature 'SpatialExperiment'
Img(x, sample_id = 1L, image_id, scale_fct = 1) <- value
x |
A |
sample_id |
Which sample the image is associated with. Use
|
image_id |
Image ID, such as "lowres" and "hires" for Visium data and "DAPI" and "PolyT" for Vizgen MERFISH data. |
scale_fct |
Scale factor to convert pixels in lower resolution to those
in the full resolution. Only relevant to image classes implemented in
|
value |
New version of image to add, must inherit from
|
SFE object with the new image added.
library(EBImage)
library(SFEData)
library(RBioFormats)
fp <- tempdir()
fn <- XeniumOutput("v2", file_path = file.path(fp, "xenium_test"))
# Weirdly the first time I get the null pointer error
try(sfe <- readXenium(fn))
sfe <- readXenium(fn)
img <- getImg(sfe) |> toExtImage(resolution = 1L)
img <- img[,,1] > 500
Img(sfe, image_id = "mask") <- img
imageIDs(sfe)
unlink(fn, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.