【发布时间】:2021-09-24 20:05:35
【问题描述】:
我仍在努力寻找对二元点模式进行分类的最佳方法:
Point pattern classification with spatstat: what am I doing wrong?
我现在使用@Adrian 的建议和sigma=bw.diggle 分析了我的数据集的 110 个样本(因为我想要一个自动带宽选择)。 f 是一个“资源选择函数”(RSF),它描述了 Cancer 点过程的强度和协变量(这里是 Immune 的核密度)之间的关系:
Cancer <- split(cells)[["tumor"]]
Immune <- split(cells)[["bcell"]]
Dimmune <- density(Immune,sigma=bw.diggle)
f <- rhohat(Cancer, Dimmune)
我对我得到的一些结果表示怀疑。十几个 rho 函数看起来很奇怪(中断,单峰)。更改为默认 sigma=NULL 或 sigma=bw.scott(更平滑)后,功能变得“更好”(参见下面的示例)。我还尝试了以下操作:
cells # bivariate point pattern with marks "tumor" and "bcell"
o.marks<-cells$marks # original marks
#A) randomly re-assign original marks
a.marks <- sample(cells$marks)
#B) replace marks randomly with a 50/50 proportion
b.marks<-as.factor(sample(c("tumor","bcell"), replace=TRUE, size=length(o.marks)))
#C) random (homogenious?) pattern with the original number of points
randt<-runifpoint(npoints(subset(cells,marks=="tumor")),win=cells$window)
randb<-runifpoint(npoints(subset(cells,marks=="bcell")),win=cells$window)
cells<-superimpose(tumor=randt,bcell=randb)
#D) tumor points are associated with bcell points (is "clustered" a right term?)
Cancer<-rpoint(npoints(subset(cells,marks=="tumor")),Dimmune,win=cells$window)
#E) tumor points are segregated from bcell points
reversedD<-Dimmune
density.scale.v<-sort(unique((as.vector(Dimmune$v)[!is.na(as.vector(Dimmune$v))]))) # density scale
density.scale.v.rev<-rev(density.scale.v)# reversed density scale
new.image.v<-Dimmune$v
# Loop over matrix
for(row in 1:nrow(Dimmune$v)) {
for(col in 1:ncol(Dimmune$v)) {
if (is.na(Dimmune$v[row, col])==TRUE){next}
number<-which(density.scale.v==Dimmune$v[row, col])
new.image.v[row, col]<-density.scale.v.rev[number]}
}
reversedD$v<-new.image.v # reversed density
Cancer<-rpoint(npoints(subset(cells,marks=="tumor")),reversedD,win=cells$window)
@Adrian 在下面的帖子中给出了生成逆密度热图的更好方法。
我无法为bw.diggle 密度生成rpoint 模式,因为它产生了负数。因此我替换了负数Dimmune$v[which(Dimmune$v<0)]<-0,然后可以运行rpoint。正如@Adrian 在下面的帖子中解释的那样,这是正常的,可以通过使用density.ppp 选项positive=TRUE 更轻松地解决。
我第一次使用bw.diggle,因为hopskel.test 为我的所有模式表示“聚类”。现在我将使用bw.scott 进行分析,但这个决定是否合理?除了“RSF 函数看起来很奇怪”之外,还有更好的方法吗?
一些例子:
【问题讨论】:
标签: r classification gis kernel-density spatstat