ludvigla / semla

Other
47 stars 6 forks source link

spatial data from Staffli to Seurat images slot #16

Closed VenomEvoDevo closed 9 months ago

VenomEvoDevo commented 9 months ago

Hello! I have a Seurat object created with the STutility InputFromTable command. The spatial information and images are stored as a Staffli object. I would like to use some of the Seurat command to analyse the data, for instance FindSpatiallyVariables. However, this requires the spatial data to be stored in the @images slot of Seurat. How can I convert the STutility/semla Staffli object to the Seurat images slot? I can only find the opposite, from Seurat images to Staffli.

Thank you,

Giulia

ludvigla commented 9 months ago

Hi Giulia,

This is not a feature we've implemented in semla, but we could absolutely do that. You could also achieve this using Read10X_Image from Seurat. It will collect image and spot related data and return an object that you can add to the images slot on the Seurat object.

/Ludvig

VenomEvoDevo commented 9 months ago

Thank you. The problem is that I cannot use the output from SpaceRanger as I have used the ST_pipeline to map my reads to a de novo transcriptome assembly to create the count matrix. This is why I used the STutility, as I could specify which count matrix and spotfile to use. I tried to use the Read10X_Image but then I couldn't find a way to convert that object into the Seurat @images slot.

ludvigla commented 9 months ago

I'm pretty sure you can use a transcriptome assembly in Space Ranger too. Unfortunately, we do not provide support for SST pipeline output files. You can check this tutorial showing how to create a Staffli object from scratch.

Here's how you could load and attach a "VisiumV1" object with Seurat and add it to the object:

# Load data from spaceranger output directory containing tissue_lores_image.png 
slice <- Seurat::Read10X_Image(image.dir = "path_to_image_dir", filter.matrix = TRUE)

# Assign the assay that you want to. associate the image with
DefaultAssay(slice) <- "Spatial"

# Add slice to Seurat object
se[["slice1"]] <- slice