基础信息: 二元属性-取值为0或者1的属性
有些课题用于聚类的数据只包含是01值的矩阵,这种情况下,许多聚类方法和测度明显不适合用于聚类。
上网查阅,这种类型的数据比较适合使用Jaccard距离,然而Jaccard 并不是一致性聚类包ConsensusClusterPlus的内置距离参数,所以这时你需要自定义距离函数:myDistFunc=function(x){vegan::vegdist(x, "jaccard")}
mut_path:是示例数据:它是一个只包含01矩阵
setwd("/pub3/xuyanjun/team/hanjw_students/zbt/ConsensusClusterPlus20190711_job6")
load("mut_pathjob6.rda")
mut_path<-mut_pathjob6
library(ConsensusClusterPlus)
library(vegan)
#myDistFunc = function(x){dist(x, method = "Jaccard")}
myDistFunc=function(x){vegan::vegdist(x, "jaccard")}
t_mut_path<-t(mut_path)
res<-ConsensusClusterPlus(t_mut_path,maxK=40,reps=100,pItem=0.8,pFeature=1,title="consensusclusterplus_jaccard",distance="myDistFunc",clusterAlg="kmdist",plot="png", writeTable=T)
参数细节:distance="myDistFunc"
,clusterAlg="kmdist"
聚类方法也可以是clusterAlg="hc"
等
运行上方代码:输出的结果,和前一篇“ConsensusClusterPlus①一致性聚类Consensus Clustering”的结果类似,输出delta图、聚类图、分组表。
网友评论