作者,Evil Genius
低谷期怎么过?自己不放弃自己,一切都还有希望。
今天我们分享方法论。
Kasumi,一种用于识别跨样本和条件持续存在的细胞内和细胞间关系的空间局部化邻域模式的方法。
组织的显微解剖结构与其功能之间的联系是公认的。
空间组学数据的分析框架中,常用的数据表示方法有两种:聚类(表型)和邻域(生态位)分析。
聚类为测量的空间分布分配标签,通常对应于细胞(亚)类型或功能状态。
邻域(生态位)识别和分析,虽然与聚类有关,但更进一步。通常从聚类结果开始,旨在通过识别聚类之间相互作用的保守模式来捕获组织的高阶表示。邻域分析的方法采用不同的方法。一些,如histoCAT,Giotto和Cellular Spatial Enrichment Analysis(CSEA),关注细胞类型或功能状态对之间的直接邻近和相互作用的数量。
通过与从细胞位置排列得到的相互作用的零分布进行比较,计算紧邻区域内共现的显著性,来识别相互作用的细胞类型对。另一组方法,包括诸如iNiche、Spatial-LDA和Coordinated Cellular Neighborhood(CCN)的方法,通过首先用其邻域内的细胞类型组成表示每个细胞,然后再次对该表示进行聚类以推断更高阶的基序,来识别邻域.
第三组方法,如SPACE-GM 20和STELLAR,旨在监督端到端GNN(图神经网络)的基于细胞表示的学习,所述细胞表示基于如由样品的细胞图22定义的它们的细胞邻域。从空间分布或初始聚类开始,这组方法依赖于额外的近似解释或学习的嵌入与其他邻近分析方法的组合。
最后,包括BANKSY、CellCharter和UTAG等的一组较新的相关方法将空间分布作为与细胞类型标签相反的输入。通过明确考虑每个细胞周围的空间邻域,它们执行空间聚类,其中标签不一定对应于不同的细胞类型,而是对应于许多不同空间邻域中的membership。因此,这样的方法,由于其结果表示的解释,通常也被认为是邻域分析方法。
从高度复用的数据(misty)中剖析空间关系。 MISTy是一个从空间组学数据中提取全球关系的通用框架,其产出是一套来自不同空间背景的稳健关系,这些关系存在于整个样本中。
结果1、Kasumi识别persistent local patterns(windows策略)
结果2、Kasumi提取与临床特征相关的稳健模式
邻域组成和局部关系模式。
结果3、Kasumi提供全面的解释
library(kasumi)
library(tidyverse)
library(readxl)
if(!file.exists("CTCL.xlsx")){
download.file("https://static-content.springer.com/esm/art%3A10.1038%2Fs41467-021-26974-6/MediaObjects/41467_2021_26974_MOESM3_ESM.xlsx", "CTCL.xlsx")
}
ctcl <- read_xlsx("CTCL.xlsx", skip=2)
spots <- ctcl %>%
filter(Groups %in% c(1, 2)) %>%
pull(Spots) %>%
unique()
outcome <- ctcl %>%
filter(Groups %in% c(1, 2)) %>%
group_by(Spots, Patients) %>%
summarize(Groups = Groups[1], .groups = "drop")
cts <- ctcl %>%
pull(ClusterName) %>%
unique()
all.cells.ctcl <- spots %>% map(\(id){
ctcl %>%
filter(Spots == id) %>%
pull(ClusterName) %>%
map(~ .x == cts) %>%
rlist::list.rbind() %>%
`colnames<-`(make.names(cts)) %>%
as_tibble(.name_repair = "unique")
})
names(all.cells.ctcl) <- spots
all.positions.ctcl <- spots %>% map(\(id){
ctcl %>%
filter(Spots == id) %>%
select(X, Y) %>%
`colnames<-`(c("x", "y"))
})
names(all.positions.ctcl) <- spots
panel <- colnames(ctcl)[10:68][-c(53,56,58)]
all.cells.ctcl <- spots %>% map(\(id){
ctcl %>%
filter(Spots == id) %>%
select(all_of(panel)) %>%
rename_with(make.names)
})
# future::plan(future::multisession, workers = 8)
if(!file.exists("CTCLct400.sqm")){
as.character(spots) %>% walk(\(id){
ct <- all.cells.ctcl[[id]]
pos <- all.positions.ctcl[[id]]
kasumi.views <- create_initial_view(ct) %>% add_paraview(pos, 10, family = "constant", prefix="p.")
suppressWarnings(
run_kasumi(kasumi.views, pos, window=400, overlap=50, id, "CTCLct400.sqm", minu=20, bypass.intra=TRUE, sqlite_timeout = 250)
)
})
}
seq_along(spots) %>% walk(\(id){
expr <- all.cells.ctcl[[id]]
pos <- all.positions.ctcl[[id]]
kasumi.views <- create_initial_view(expr) %>% add_paraview(pos, 100, family = "gaussian")
suppressWarnings(
run_kasumi(kasumi.views, pos, window=400, overlap=50, id, "CTCLexpr400.sqm", minu=20)
)
})
# future::plan(future::multisession, workers = 8)
kasumi.results <- collect_results("CTCLct400.sqm")
# First representation - relationships
kasumi.representation <- extract_representation(kasumi.results)
# Second representation - clusters
kasumi.clusters <- extract_clusters(kasumi.representation, "leiden", 0.4, 0.9)
# Cluster composition
kasumi.agg <- aggregate_clusters(kasumi.clusters)
# Third representation - persistent cluster composition -
# clusters that are present in at least 5 samples
persistent.clusters <- persistent_clusters(kasumi.agg, 5)
kasumi.persistent <- kasumi.agg %>% select(id, all_of(persistent.clusters))
target <- kasumi.persistent %>% mutate(id = str_remove(id, "sample")) %>%
left_join(outcome %>% mutate(Spots = as.character(Spots)), by = c("id" = "Spots")) %>% pull(Groups)
kasumi.pca <-prcomp(kasumi.persistent %>% select(-id), scale. = TRUE)
to.plot <- data.frame(kasumi.pca$x[,c(1,2)]) %>% mutate(Condition = as.factor(target))
ggplot(to.plot, aes(x = PC1, y = PC2, color = Condition)) + geom_point() + theme_classic()
kasumi.roc <- downstream_classify(kasumi.persistent, make.names(target))
sMR(kasumi.persistent, as.factor(make.names(target)))
cluster.23 <- collect_kasumi_cluster(kasumi.clusters, "23", "CTCLct400.sqm")
plot_improvement_stats(cluster.23, trim = 1)
plot_interaction_heatmap(cluster.23, "paraview.10", trim = 1, cutoff = 0.5, clean = TRUE)
plot_interaction_heatmap(cluster.23, "paraview.10", trim = 1, cutoff = 0.5, clean = TRUE, correlation = TRUE)
生活很好,有你更好
网友评论