prabhakarlab / Banksy

BANKSY: spatial clustering
https://prabhakarlab.github.io/Banksy
Other
74 stars 12 forks source link

How to change a BanksyObject to seurat object ? #3

Closed hzongyao closed 2 years ago

hzongyao commented 2 years ago

How to change a BanksyObject to seurat object ? Thank you !

jleechung commented 2 years ago

Hi @hzongyao

You can convert a BanksyObject to a SeuratObject as follows:

library(Banksy)
library(Seurat)

# Use the hippocampus data attached with Banksy as an example
data(hippocampus)

# Construct BanksyObject
bank <- BanksyObject(own.expr = hippocampus$expression,
                     cell.locs = hippocampus$locations)

# Count normalize cells
bank <- NormalizeBanksy(bank)

# Compute the neighbour matrix with inverse radial kernel and 10 neighbors
bank <- ComputeBanksy(bank, spatialMode = 'kNN_r', k_geom = 10)

# Extract the BANKSY matrix and cell locations
out <- getBanksyMatrix(bank, lambda = 0.3)
counts <- out$expr
locs <- out$locs

# Create SeuratObject with BANKSY matrix counts and cell locations
seu <- CreateSeuratObject(counts = counts, 
                          meta.data = locs)

We also implemented a wrapper for running BANKSY with SeuratWrappers, but this is still undergoing review. You can view this markdown and install our fork of SeuratWrappers with remotes::install_github('jleechung/seurat-wrappers'). You'll most likely also have to install Seurat v4 and above for this to work.

hzongyao commented 2 years ago

Thank you !