首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >点模式分类与spatstat:我做错了什么?

点模式分类与spatstat:我做错了什么?
EN

Stack Overflow用户
提问于 2021-04-28 10:19:48
回答 1查看 157关注 0票数 1

我试图使用spatstat将二元点模式分类成组。这些模式是从淋巴结与癌症的整体幻灯片图像中得出的。我训练了一个神经网络来识别三种类型的细胞(癌症“LP”,免疫细胞“bcell”和所有其他细胞)。我不想分析所有其他细胞,而是用它们来构造一个具有淋巴结形状的多边形窗口。因此,需要分析的模式是多角形窗口中的免疫细胞和癌细胞。每个模式可以有几个10k癌细胞和多达2mio免疫细胞。这种模式属于“小世界模式”,因为不可能在窗口外放置点。

我的分类应该基于癌细胞相对于免疫细胞的位置。例如,大多数癌细胞位于免疫细胞的“岛屿”上,但在某些情况下,癌细胞(似乎)均匀分布,只有少数免疫细胞。此外,在整个节点上,模式并不总是一致的。由于我对空间统计相当陌生,所以我开发了一种简单而粗糙的方法来对模式进行分类。这里简单地说:

  1. 我用sigma=80计算了免疫细胞的核心密度,因为这对我来说“不错”。Den<-density(split(cells)$"bcell",sigma=80,window= cells$window) (我应该使用例如sigma=bw.scott吗?)
  2. 然后,通过将密度范围划分为3个部分,创建了一个镶嵌图像(在这里,我再次尝试了这些间隔,以获得一些“好看的结果”)。
代码语言:javascript
运行
复制
rangesDenMax<-2*range(Den)[2]/3
rangesDenMin<-range(Den)[2]/3
map.breaks<-c(-Inf,rangesDenMin,rangesDenMax,Inf)
map.cuts <- cut(Den, breaks = map.breaks, labels = c("Low B-cell density","Medium B-cell density", "High B-cell density"))
map.quartile <- tess(image = map.cuts,window=cells$window)
tessImage<-map.quartile

这里是一些例子的图解与癌症细胞覆盖(白点)。左边的淋巴结有典型的均匀分布的免疫细胞“岛”,而右边的淋巴结只有几个密集的免疫细胞和癌细胞,不限于这些部位:

热图:免疫细胞核密度,白点:癌细胞

  1. 然后,我测量了一些愚蠢的变量,这应该给我一个关于癌细胞如何分布在镶嵌块上的线索(计算代码很简单,所以我只发布了我的变量的描述):
代码语言:javascript
运行
复制
LPlwB<-c() # proportion of cancer cells in low-b-cell-area 
LPmdB<-c() # proportion of cancer cells in medium-b-cell-area 
LPhiB<-c() # proportion of cancer cells in high-b-cell-area
AlwB<-c()  # proportion of the low-b-cell area
AmdB<-c()  # proportion of the medium-b-cell area
AhiB<-c()  # proportion of the high-b-cell area
LPm1<-c()  # mean distance to the 1st neighbour
LPm2<-c()  # mean distance to the 2nd neighbour
LPm3<-c()  # mean distance to the 3d neighbour
LPsd1<-c() # standard deviation of the mean distance to the 1st neighbour
LPsd2<-c() # standard deviation of the mean distance to the 2nd neighbour
LPsd3<-c() # standard deviation of the mean distance to the 3d neighbour
meanQ<-c() # mean quadratcount (I visually chose the quadrat size to be not too large and not too small)
sdevQ<-c() # standard deviation of the mean quadratcount
hiSAT<-c() # realised cancer cells saturation in high b-cell-area (number of cells observed divided by a number of cells, which could be fitted into the area considering the observed min distance between the cells)
mdSAT<-c() # realised cancer cells saturation in medium b-cell-area 
lwSAT<-c() # realised cancer cells saturation in low b-cell-area 
ll<-c() # Proportion LP neighbours of LP (contingency table count divided by total points) 
lb<-c() # Proportion b-cell neighbours of LP
bl<-c() # Proportion b-cell neighbours of b-cells
bb<-c() # Proportion LP neighbours of b-cells
  1. 我对变量进行z缩放,在PCA图上检查它们(向量指向不同的方向,如海胆针),并进行了层次聚类分析。我通过计算fviz_nbclust(scaled_variables, hcut, method = "silhouette")来选择k。在将树状图划分成k个簇并检查簇的稳定性后,我得到了我的组,这似乎是有意义的,因为有“岛”的情况是从“更分散的”情况中分离出来的。

然而,考虑到spatstat包的可能性,我强烈地想用智能手机把钉子钉在墙上。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-29 09:21:45

你似乎在尝试量化癌细胞相对于免疫细胞的定位方式。你可以这样做

代码语言:javascript
运行
复制
Cancer <- split(cells)[["LP"]]
Immune <- split(cells)[["bcell"]]
Dimmune <- density(Immune, sigma=80)
f <- rhohat(Cancer, Dimmune)
plot(f)

然后,f是一个函数,它指示癌细胞的强度(单位面积的数量)作为免疫细胞密度的函数。图中显示的是垂直轴上的癌细胞密度,而水平轴上的免疫细胞密度。

如果这个函数的图形是平的,就意味着癌细胞没有注意到免疫细胞的密度。如果图表急剧下降,就意味着癌细胞倾向于避开免疫细胞。

我建议您首先查看一些示例数据集的f图,以确定f是否有能力区分您认为应该被归类为不同的空间排列。如果是这样的话,那么您可以使用as.data.frame提取f的值,然后使用经典的判别分析(etc)将幻灯片图像分类为组。

而不是density(Immune),您可以使用任何其他的免疫细胞摘要。例如,D <- distfun(Immune)将给出与最近的免疫细胞的距离,然后f将计算癌细胞的密度,作为与最近的免疫细胞的距离的函数。诸若此类。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67298342

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档