Closed alikhuseynov closed 1 year ago
Many Thanks! I can confirm that it works now for the whole image.
However it won't work with the bbox_use
, any suggestions?
bbox_use <- c(xmin = 8300, xmax = 8000, ymin = -8300, ymax = -8000)
plotSpatialFeature(sfe, features = "LAMA2", bbox = bbox_use,
size = 4, colGeometryName = "cellSeg",
image_id = "DAPI" #
) & DarkTheme()
Error: [ext] invalid extent
Traceback:
1. plotSpatialFeature(sfe, features = "LAMA2", bbox = bbox_use,
. size = 4, colGeometryName = "cellSeg", image_id = "DAPI")
2. .plotSpatialFeature(sfe, values, colGeometryName, sample_id,
. ncol, ncol_sample, annotGeometryName, annot_aes, annot_fixed,
. bbox, image_id, aes_use, divergent, diverge_center, annot_divergent,
. annot_diverge_center, size, shape, linewidth, linetype, alpha,
. color, fill, scattermore, pointsize, bins, summary_fun, hex,
. maxcell, dark, ...)
3. .get_img_df(sfe, sample_id, image_id, bbox)
4. lapply(sample_id, function(s) {
. img_data <- img_df$data[img_df$sample_id == s]
. bbox_use <- ext(bbox[c("xmin", "xmax", "ymin", "ymax"), s])
. bb <- as.vector(bbox_use)
. lapply(img_data, function(img) {
. img_cropped <- terra::crop(imgRaster(img), bbox_use,
. snap = "out")
. img_cropped <- terra::shift(img_cropped, dx = -bb["xmin"],
. dy = -bb["ymin"])
. new("SpatRasterImage", image = img_cropped)
. })
. })
5. FUN(X[[i]], ...)
6. ext(bbox[c("xmin", "xmax", "ymin", "ymax"), s])
7. ext(bbox[c("xmin", "xmax", "ymin", "ymax"), s])
8. .local(x, ...)
9. error("ext", "invalid extent")
10. stop("[", f, "] ", emsg, ..., call. = FALSE)
The bbox is unrelated to the maximum value in the image. Using a bounding box would still work with my 16 bit test image. Your bbox is
bbox_use <- c(xmin = 8300, xmax = 8000, ymin = -8300, ymax = -8000)
xmax is smaller than xmin, and that's the reason why it's invalid extent.
Plus there's an argument in plotSpatialFeature
for dark theme: dark = TRUE
; it uses different default palettes from light theme so lighter color stands for higher value and stand out from the dark background.
ahh I see, Thanks! it works now. The confusion came from flip
in ReadVizgen()
since I was trying different combinations. By default plotSpatialFeature()
doesn't show the axes, so I was adding Seurat::DarkTheme()
which does the trick with less code. dark = TRUE
is awesome 👍
is it easy to implement multiple overlapping images (eg, terra::aggregate()
) to show, say image_id = ("DAPI", "Cellbound1")
together?
I could take a look at some point as well.
That's a good point. I can implement that. Doesn't seem difficult.
Thanks, especially, if one could use > 2
images, like image_id = ("DAPI", "Cellbound1", "Cellbound2")
This error happen when using
image_id
. Something to do withmax_col_value
inVoyager:::geom_spi_rgb(., max_col_value = 255)
any suggestions? Thanks