satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.24k stars 902 forks source link

Some questions in spatial transcriptome analysis #6691

Closed ghost closed 2 months ago

ghost commented 1 year ago

Hello everyone, I have encountered a problem when analyzing spatial transcriptome data with the protocol in (https://satijalab.org/seurat/articles/spatial_vignette.html). When I use SpatialPlot() functions, it produces this plot.

0e4f2aa651860224b6dba3fcc60847c

A part should have been in the left part of the picture, but it is in the right side. However, there seems no problem in the coordinate information since the shape of the plot draw by the plot() function is intact.

9aef583cf11e41648fcfa4325ae7f6a

Also, I use the LinkedDimPlot() function to see the coordinates, and when I point to this part the horizontal coordinate also shows it should have been in the left part of the picture.

d511b28791d34f601b63d87f2065dc5

My code is as follows, along with my expression matrix and coordinate information. Thanks a lot for helping me solve the problem.

library(Seurat)
library(ggplot2)
library(patchwork)
library(dplyr)
library(SeuratData)
setwd("~/dbitseq/stpipline_res/10d_50um_rna_rep1/")

Sys.setenv(LANGUAGE = "en")
options(stringsAsFactors = FALSE)
rm(list=ls())

# creat Seurat object
expr = data.table::fread(
  input = "10d_50um_rna_rep1.tsv",
  sep = "\t",
  data.table = F
)
rownames(expr) = expr[, 1]
expr = t(expr[, -1])
expr = na.omit(expr)
stdata = CreateSeuratObject(
  counts = expr,
  project = "dbitseq",
  assay = "spatial"
)

# load coordinate information
barcode = colnames(expr)
coord = strsplit(barcode, 'x', fixed = T)
xcoord = sapply(coord, function(x){ x[2]})
ycoord = sapply(coord, function(x){ x[1]})
total_counts = colSums(expr, na.rm = T)
positions = data.frame(xcoord, ycoord, barcode, total_counts)
rownames(positions) = positions$barcode
positions = positions[, 1:2]
stdata[["image"]] = new(
  Class = 'SlideSeq',
  assay = 'spatial',
  coordinates = positions
)
plot(positions$ycoord, positions$xcoord)
SpatialPlot(stdata, pt.size.factor = 5)

# UMI count
plot1 <- VlnPlot(stdata, features = "nCount_spatial", pt.size = 1, log = TRUE) + NoLegend()
stdata$log_nCount_Spatial <- log(stdata$nCount_spatial)
plot2 <- SpatialFeaturePlot(stdata, features = "nCount_spatial", pt.size.factor = 5) + theme(legend.position = "right")
wrap_plots(plot1, plot2)

# Normalization, dimension reduction and clustering
stdata <- SCTransform(stdata, assay = "spatial", ncells = 1754, verbose = FALSE)
stdata <- RunPCA(stdata)
stdata <- RunUMAP(stdata, dims = 1:30)
stdata <- FindNeighbors(stdata, dims = 1:30)
stdata <- FindClusters(stdata, resolution = 0.3, verbose = FALSE)

# Visualization
plot1 <- DimPlot(stdata, reduction = "umap", label = TRUE)
plot2 <- SpatialDimPlot(stdata, stroke = 0, pt.size.factor = 5)
plot1 + plot2
ddfe37b0951657119a0b2fe22b9792b 61174c3901f7bbe6ceeee8a51fac163
dcollins15 commented 2 months ago

Thanks for using Seurat!

It appears that this issue has gone stale. In an effort to keep our Issues board from getting more unruly than it already is, we’re going to begin closing out issues that haven’t had any activity since the release of v4.4.0.

If this issue is still relevant we strongly encourage you to reopen or repost it, especially if you didn’t initially receive a response from us.