Skip to content

Workflow to incorporate H&E image (post-Xenium) info SFE? #78

@dpcook

Description

@dpcook

Hi there,

I'm wondering if you have any advice on incorporating H&E images into SpatialFeatureExperiments objects--specifically images with an alignment matrix as exported by Xenium Explorer, where pixel/micron conversion and to deal with flipped y-axis coordinates.

I managed to get the aligned image in:

bbox1 <- c(xmin = 7500, xmax = 8500, ymin = -5500, ymax = -4500)

bboxes_sf <- st_as_sfc(st_bbox(bbox1))
p1 <- plotImage(sfe, image_id = "morphology_focus", channel = 3:1, show_axes = TRUE,
          dark = TRUE, normalize_channels = TRUE) +
    geom_sf(data = bboxes_sf, fill = NA, color = "white", linewidth = 0.5)

p2 <- plotImage(sfe, image_id = "HE", channel = 1:3, show_axes = TRUE,
          normalize_channels = TRUE) +
    geom_sf(data = bboxes_sf, fill = NA, color = "white", linewidth = 0.5)

cowplot::plot_grid(p1, p2, align="h")
Image

But any functions that use a bbox to view a subset of the image fail.

> plotImage(sfe, image_id = "HE", channel = 1:3,
+           bbox = bbox1, normalize_channels = TRUE)
Error in .jcall("RBioFormats", "Ljava/lang/Object;", "readPixels", i,  : 
  java.lang.IllegalArgumentException: Invalid array size: 0 x 0 x 1 x 3

Though standard Xenium bundle images work fine:

plotImage(sfe, image_id = "morphology_focus", channel = 3:1,
          bbox = bbox1, normalize_channels = TRUE)
Image

If you have a workflow that has worked for you, it would be greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions