Given a SpatialExperiment object, first as.Seurat() is run, which operates on SingleCellExperiment objects. The remaining components (images, spatial coordinates) are added manually. The actual appearance of images are buggy for now.

spe_to_seurat(spe, verbose = TRUE)

Arguments

spe

A SpatialExperiment with colData columns in_tissue, array_row_transformed, array_col_transformed, pxl_row_in_fullres_transformed, and pxl_col_in_fullres_transformed

verbose

A logical(1) vector. If true, print status updates about the conversion process

Value

A Seurat object

Author

Nicholas J. Eagles

Examples


## Grab an example SpatialExperiment and add dummy "transformed" versions of
## spatial coordinates, which are to be converted
spe <- if (!exists("spe")) {
    spatialLIBD::fetch_data(type = "spatialDLPFC_Visium_example_subset")
}
#> 2024-06-06 17:41:01.253161 loading file /github/home/.cache/R/BiocFileCache/6fb23c6a6be_spatialDLPFC_spe_subset_example.rds%3Fdl%3D1
spe$array_row_transformed <- spe$array_row
spe$array_col_transformed <- spe$array_col
spe$pxl_row_in_fullres_transformed <- SpatialExperiment::spatialCoords(spe)[, "pxl_row_in_fullres"]
spe$pxl_col_in_fullres_transformed <- SpatialExperiment::spatialCoords(spe)[, "pxl_col_in_fullres"]
colnames(spe) <- spe$key

## Convert from a SpatialExperiment to a Seurat object
seur <- spe_to_seurat(spe)
#> Running 'as.Seurat(spe)'...
#> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from pc. to pc_
#> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from tsne. to tsne_
#> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from umap. to umap_
#> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from PC to PC_
#> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from UMAP to UMAP_
#> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from TSNE_perplexity80_ to TSNEperplexity80_
#> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from UMAP to UMAP_
#> Warning: Key ‘UMAP_’ taken, using ‘umapharmony_’ instead
#> Adding spot coordinates and images for sample Br6432_ant...
#> Adding spot coordinates and images for sample Br6522_ant...
#> Adding spot coordinates and images for sample Br8667_mid...
#> Returning converted object...
seur
#> An object of class Seurat 
#> 28916 features across 12107 samples within 1 assay 
#> Active assay: originalexp (28916 features, 0 variable features)
#>  2 layers present: counts, data
#>  8 dimensional reductions calculated: X10x_pca, X10x_tsne, X10x_umap, PCA, UMAP, TSNE_perplexity80, HARMONY, UMAP.HARMONY
#>  3 images present: Br6432_ant, Br6522_ant, Br8667_mid