【问题标题】:Point pattern classification with spatstat: what am I doing wrong?使用 spatstat 进行点模式分类:我做错了什么?
【发布时间】:2021-07-21 16:45:52
【问题描述】:

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

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

  1. 我用sigma=80 计算了免疫细胞的核密度,因为这对我来说看起来“不错”。 Den<-density(split(cells)$"bcell",sigma=80,window= cells$window)(我应该改用sigma=bw.scott吗?)
  2. 然后我通过将密度范围分成 3 个部分创建了一个镶嵌图像(在这里,我再次尝试了中断以获得一些“好看的结果”)。
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

以下是带有癌细胞覆盖(白点)的镶嵌图的一些示例。左边的淋巴结有一个典型的均匀分布的免疫细胞“岛”,而右边的淋巴结只有几个密集的免疫细胞点,癌细胞并不局限于这些点:

heat map: immune cell kernel density, white dots: cancer cells

  1. 然后我测量了一些愚蠢的变量,这应该让我知道癌细胞是如何分布在镶嵌图块中的(计算代码很简单,所以我只发布了我的变量的描述):
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 软件包的可能性,我非常想用智能手机将钉子钉在墙上。

【问题讨论】:

  • 哇,这个问题真的很长,有很多部分,在我看来,这几乎是一个研究合作的邀请,而不是一个编程问题。我目前无法回答,但也许您在其他地方会遇到更好的运气。

标签: r statistics classification spatstat


【解决方案1】:

您似乎正在尝试量化癌细胞相对于免疫细胞的定位方式。你可以通过类似的方式来做到这一点

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 的值,然后使用经典判别分析(等)将幻灯片图像分类。

您可以使用免疫细胞的任何其他摘要来代替density(Immune)。 例如,D &lt;- distfun(Immune) 会给你到最近的免疫细胞的距离,然后f 会根据到最近的免疫细胞的距离来计算癌细胞的密度。以此类推。

【讨论】:

    猜你喜欢
    • 2021-09-24
    • 1970-01-01
    • 1970-01-01
    • 2021-03-24
    • 2023-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多