基礎(chǔ)信息: 二元屬性-取值為0或者1的屬性
有些課題用于聚類的數(shù)據(jù)只包含是01值的矩陣,這種情況下,許多聚類方法和測(cè)度明顯不適合用于聚類。
上網(wǎng)查閱,這種類型的數(shù)據(jù)比較適合使用Jaccard距離,然而Jaccard 并不是一致性聚類包ConsensusClusterPlus的內(nèi)置距離參數(shù),所以這時(shí)你需要自定義距離函數(shù):myDistFunc=function(x){vegan::vegdist(x, "jaccard")}
mut_path:是示例數(shù)據(jù):它是一個(gè)只包含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)
參數(shù)細(xì)節(jié):distance="myDistFunc",clusterAlg="kmdist"聚類方法也可以是clusterAlg="hc"等
運(yùn)行上方代碼:輸出的結(jié)果,和前一篇“ConsensusClusterPlus①一致性聚類Consensus Clustering”的結(jié)果類似,輸出delta圖、聚類圖、分組表。