Closed rbutleriii closed 4 months ago
Thanks for reporting. The plotting issue shown here should be fixed in GiottoVisuals v0.1.4 #60 I am now getting this:
library(Giotto)
x <- GiottoData::loadGiottoMini("cosmx")
spatInSituPlotPoints(x,
feats = list("COL1A1", "IGHG1", "KITLG", "ITK", "TPSB2"),
point_size = 1,
polygon_line_size = 0.1,
show_polygon = TRUE,
polygon_color = 'white',
show_image = TRUE,
largeImage_name = names(x@largeImages),
show_legend = TRUE
)
Some additional details: The mini objects do attempt automatic image reconnections on load. It looks like there were some issues with the image saving during the creation of the mini object that resulted in the high values being treated as NA values. The object in GiottoData will have to be updated to rectify this.
y <- array(x@largeImages$`fov002-composite`@raster_object)
sum(is.na(test))
[1] 4332
That was causing this error message when converting to an annotation raster for ggplot to use
Error in rgb(t(x[, , 1L]), t(x[, , 2L]), t(x[, , 3L]), maxColorValue = max) :
color intensity NA, not in [0,1]
Giotto is now treating NA values in the images as 0 when using the plotting functions.
For the reconnection issue with the giottoImage
objects, we are working on a solution.
I would need to take a closer look, but my guess is that the problem is because of issues with our older giottoImage
class that we are in the process of deprecating in favor of the newer giottoLargeImage
.
Before we can fully do that, we need to remove them in favor of just giottoLargeImage
creation from the convenience functions for Visium (#850) and CosMx (in progress).
With the CosMx convenience function, we convert the composite giottoLargeImage
to giottoImage
, intending it as a way of caching it to be faster to load, but that means they do not actually exist on disk. This behavior will also be removed pending the convenience function update mentioned above.
The workaround for the moment is to use the giottoLargeImage
versions of the composite images for visualizations.
If a giottoLargeImage
needs to be made, then that can be done by checking the giottoImage
for spatial bounds information
a <- x@images$`fov002-image`
a
relevant portion of the return is below:
Boundaries are:
Image x-axis max boundary: 5966.444
Image x-axis min boundary: 5294.444
Image y-axis max boundary: -156585.3
Image y-axis min boundary: -157233.3
a giottoLargeImage can then be created and the spatial extent can be set based on these values before being set back into the giotto object
library(GiottoClass)
im_path <- system.file("Mini_datasets/CosMx/Raw/CellComposite/CellComposite_F002.jpg", package = "GiottoData")
b <- createGiottoLargeImage(im_path)
ext(b) <- c(5294.444, 5966.444, -157233.3,-156585.3) # xmin, xmax, ymin, ymax
plot(b)
Yep, updating to GiottoVisuals
0.1.4 and updating terra
to 1.7-65 fixed the plotting error for me. Can probably close this or link it to the reconnection issue #
Describe the Error
Looking through the
GiottoData
package, I can locate images that look like the ones for the mini cosmx dataset inloadGiottoMini
. But when I try toreconnectGiottoImage
so I can plot the images, I get a strange errorTo Reproduce
If I try to manually specify them I get an issue still with plotting:
Expected behavior
Ideally the mini object would load without needing reconnection, but per #541 that is perhaps a longer solve. In the interim, am I pointing at the right images in the
GiottoData
object?System Information