admin管理员组文章数量:1438937
mistyR:空间转录组共定位分析
今天学习一个空转的分析方法 mistyR,于2022年4月14号发表在 Genome Biology 杂志,文献标题为《Explainable multiview framework for dissecting spatial relationships from highly multiplexed data》。mistyR 是一个多视角细胞间空间建模框架(Multiview Intercellular SpaTial modeling framework,简称 MISTy),通过分析细胞内和细胞间的关系,帮助深入理解标记物之间的相互作用。
下图为 mistyR 软件的原理图,展示了四种视角类型:
- intrinsic (intraview):内部视角,基于单个spot内部的标记表达,relate the expression of other markers to a specifc marker of interest within the same location;
- local niche view (juxtaview):邻近视角,通过构建图并计算每个空间单元周围邻居的标记表达总和来定义,relates the expression from the immediate neighborhood of a cell to the observed expression within that cell;
- the broader, tissue view (paraview):旁观视角,通过加权总和计算所有空间单元的标记表达,权重可以根据距离函数(如高斯、指数、线性或常数)进行调整,relates the expression of markers measured in cells within a radius around a given cell;
- others:直接基于标记物的表达,或者从数据中推导出的细胞类型或功能特征,can ofer insight about relations coming not only as a function of space,For example, views can focus on interactions between diferent cell types, interactions within specifc regions of interest within a sample, or a higher-level functional organization。
Fig. 1 MISTy
软件地址:
mistyR 可以借助cell2location反卷积的细胞亚群关注共定位情况,可以提供:
①细胞和细胞之间的共定位;
②基于cellchat/其他细胞通讯算法的配受体同细胞之间的共定位热图;
③基于已知通路的通路和细胞之间的共定位热图。
0.软件安装
安装方式见网页:
包有两个来源可选一个就行:
代码语言:javascript代码运行次数:0运行复制# bash终端安装
# R CMD INSTALL -l /usr/local/software/miniconda3/envs/R4.4/lib/R/library mistyR-master.tar.gz
## 使用西湖大学的 Bioconductor镜像
options(BioC_mirror=";)
options("repos"=c(CRAN="/"))
# install.packages("BiocManager")
BiocManager::install("mistyR")
# install.packages("remotes")
# remotes::install_github("saezlab/mistyR")
# 加载R包
# MISTy
library(mistyR)
library(future)
#Seurat
library(Seurat)
library(SeuratObject)
# Data manipulation
library(tidyverse)
# Distances
library(distances)
1.示例数据
我们本次学习的内容参考:.html
背景了解:10 visum空转的数据 spot直径为 55 μm,点之间的圆心距是100μm
示例数据:10 visum 空间转录组数据,来源于2022年8月10号发表在Nature杂志上的一篇文献,标题为《Spatial multi-omic map of human myocardial infarction》,.1038/s41586-022-05060-x。
样本组织类型为:human myocardial infarction,人类心肌梗死组织
代码语言:javascript代码运行次数:0运行复制# 下载数据
download.file(".tar.gz?download=1",
destfile = "10X_Visium_ACH005.tar.gz", method = "curl")
# 解压
untar("10X_Visium_ACH005.tar.gz")
内容如下:
代码语言:javascript代码运行次数:0运行复制ls -1
filtered_feature_bc_matrix
spatial
spatial_ACH005_filtered_feature_bc_matrix.h5
spatial_ACH005_filtered_feature_bc_matrix.zip
spatial_ACH005_metrics_summary.csv
spatial_ACH005_molecule_info.h5
spatial_ACH005_raw_feature_bc_matrix.h5
spatial_ACH005_raw_feature_bc_matrix.zip
spatial_ACH005_spatial_enrichment.csv
spatial_ACH005_spatial.zip
输入数据为 空转反卷积注释结果 以及 空间坐标信息。
作者提供的Seurat对象包含了其他内容,例如切片上点的坐标以及通过cell2location估算的细胞组成。
加载数据并简单探索:
代码语言:javascript代码运行次数:0运行复制# 加载数据
# Load file into R
seurat_vs <- readRDS("ACH005/ACH005.rds")
seurat_vs
head(seurat_vs@meta.data)
table(seurat_vs$batch)
# Extract the cell composition c2l反卷积
composition <- as.data.frame(t(seurat_vs[["c2l_props"]]$data))
head(composition)
# Extract the location data
geometry <- GetTissueCoordinates(seurat_vs, cols = c("imagerow", "imagecol"), scale = NULL)
head(geometry)
c2l反卷积结果:每一行为一个spot,行和为1;每一列为一种细胞类型,值为某种细胞在spot中的相对比例
空间坐标如下:
可视化spots中的细胞比例
先看一下切片本身的结构:
代码语言:javascript代码运行次数:0运行复制# Tissue Slide
SpatialPlot(seurat_vs, keep.scale = NULL, alpha = 0)
再看看切片中某种细胞在每个spot的比例图:看一下 CM 细胞
代码语言:javascript代码运行次数:0运行复制# cell2location 反卷积结果
DefaultAssay(seurat_vs) <- "c2l_props"
# 细胞类型
rownames(seurat_vs)
# [1] "Adipo" "CM" "Endo" "Fib" "Lymphoid" "Mast" "Myeloid" "Neuronal" "PC" "prolif" "vSMCs"
# CM, cardiomyocytes 即心肌细胞
SpatialFeaturePlot(seurat_vs, keep.scale = NULL, features = "CM")
观察细胞的空间分布模式(绘制所有细胞类型结果):其中一些细胞类型广泛分布在整个载玻片上,而另一些则集中在特定区域。此外,还有一些细胞类型具有相似的分布模式。
2.运行 MISTy
定义 intraview 内部视角:captures the cell type proportions within a spot
定义 paraview 旁观视角:To capture the distribution of cell type proportions in the surrounding tissue
定义 the radius:the mean of the distance to the nearest neighbor plus the standard deviation
计算每个 spot 的权重:通过设置参数 family = gaussian
实现
距离计算:“distances” 构建了一组点的 Euclidean距离度量,公式如下:
# 运行mistyR
# Calculating the radius
head(geometry)
geom_dist <- as.matrix(distances(geometry))
geom_dist[1:5,1:4]
dim(geom_dist)
dist_nn <- apply(geom_dist, 1, function(x) (sort(x)[2]))
paraview_radius <- ceiling(mean(dist_nn+ sd(dist_nn)))
paraview_radius
# Create views
head(composition)
heart_views <- create_initial_view(composition) %>%
add_paraview(geometry, l= paraview_radius, family = "gaussian")
str(heart_views, max.level = 2)
# Run misty and collect results
run_misty(heart_views, "result/vignette_structural_pipeline")
misty_results <- collect_results("result/vignette_structural_pipeline")
返回的 geom_dist 是一个 3175 * 3175的矩阵,为任意两个spot间的距离。
misty 运行完后可以回答以下问题:
1.与内部视角(intraview)相比,周围组织中存在的细胞类型在多大程度上能够解释该spot的细胞类型组成?
这句话探讨的是周围组织的细胞类型与特定点(spot)的细胞类型组成之间的关联程度,以及这种关联与内部视角 intraview 结果的对比。它评估周围组织的细胞类型分布对特定点细胞组成的影响,以及这种影响是否与 intraview 结果一致。
查看两种不同的统计指标:multi.R2
表示多视角模型解释的总方差,gain.R2
则显示从单视角模型到多视角模型时可解释方差的增加量。
# `multi.R2` 表示多视角模型解释的总方差
plot_improvement_stats(misty_results,"multi.R2")
multi.R² 的值,即多视角模型相对于单视角模型的改进程度:高度越高,说明多视角模型对解释标记物表达变异的贡献越大
# `gain.R2` 则显示从单视角模型到多视角模型时可解释方差的增加量。
plot_improvement_stats(misty_results,"gain.R2")
旁观视角(paraview)在解释脂肪细胞 Adipo 和肥大细胞 Mast 的方差方面表现出显著优势。R²的显著提升表明,通过引入除内在视角之外( intrinsic view)的其他视角,能够更准确地解释标记物X的表达。
第二个问题:
代码语言:javascript代码运行次数:0运行复制2. 哪些具体的关系能够解释这些贡献?
# the intrinsic view:
plot_interaction_heatmap(misty_results, view = "intra", clean = TRUE)
该图展示在 内部视角(intra-view) 下细胞亚群之间的相互作用强度:
# the importance values
temp <- misty_results$importances.aggregated %>%
filter(view == "intra", Predictor == "CM") %>%
arrange(-Importance)
head(temp)
# view Predictor Target Importance nsamples
# <chr> <chr> <chr> <dbl> <int>
# 1 intra CM Fib 2.74 1
# 2 intra CM vSMCs 2.43 1
# 3 intra CM prolif 2.23 1
# 4 intra CM Myeloid 2.21 1
# 5 intra CM Endo 2.15 1
# 6 intra CM Mast 2.02 1
看看这些细胞类型在组织切片中的空间分布情况:
代码语言:javascript代码运行次数:0运行复制SpatialFeaturePlot(seurat_vs, keep.scale = NULL, features = c("Fib","CM"), image.alpha = 0)
我们可以观察到,心肌细胞比例较高的区域,成纤维细胞的比例较低,反之亦然:
包的版本:
代码语言:javascript代码运行次数:0运行复制packageVersion("mistyR")
# [1] ‘1.10.0’
Note
前面在 seurat v5 环境中绘图总有问题,可以这样读取数据并绘图:
代码语言:javascript代码运行次数:0运行复制## 绘图
data <- Read10X(data.dir = "ACH005/outs/filtered_feature_bc_matrix/")
dim(data)
data[1:5,1:5]
object <- CreateSeuratObject(counts = data, assay = "Spatial", min.cells = 1)
object
# 再读取
image <- Read10X_Image(image.dir = "ACH005/outs/spatial/",
image.name = "tissue_lowres_image.png",
filter.matrix = TRUE)
image
dim(image)
image <- image[Cells(x = object)]
DefaultAssay(object = image) <- "Spatial"
# 添加图片到object中
object[["SeuratProject"]] <- image
object@images[[1]]@scale.factors$lowres
object@images[[1]]@scale.factors$hires
head(object@meta.data)
SpatialFeaturePlot(object, keep.scale = NULL, features = "nCount_Spatial",pt.size.factor = 1.6)
object <- AddMetaData(object, metadata = composition)
head(object@meta.data)
SpatialFeaturePlot(object, features = "CM", keep.scale = NULL,pt.size.factor = 2,alpha = 1)
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。原始发表:2025-04-18,如有侵权请联系 cloudcommunity@tencent 删除objectspatial模型软件数据本文标签: mistyR空间转录组共定位分析
版权声明:本文标题:mistyR:空间转录组共定位分析 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/biancheng/1747611675a2729110.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论