data=read.table("data.txt", sep=";",head=T) summary(data) ## elimination des NA data.all.na=na.omit(data[data$type == "FAP" |data$type == "control" ,c(-2,-3,-7)]) summary(data.all.na$type) data.all.na=t(data.all.na[, -1]) ## les libraries library(pvclust) library(ade4) ## distance et hclust data.all.na.d=dist(data.all.na) cl=hclust(data.all.na.d, method="single") ## options de plot plot(cl) plot(cl,hang=-1) ## object hclust str(cl) cl$merge cl$height ## determiner k plot(1:length(cl$height),cl$height, xlab="cluster #", ylab="height") ## obtenir les classes cutree(cl, h=40) plot(cl,hang=-1) abline(h=40, col="red") cutree(cl, k=2) cutree(cl, k=3) cutree(cl, k=35) ## encadrer certains clusters plot(cl,hang=-1) rect.hclust(cl, h=60, which=c(1,3)) ## une méthode - un dendogramme par(mfrow=c(3,2)) cl=hclust(data.all.na.d, method="single") plot(cl,hang=-1) cl=hclust(data.all.na.d, method="complete") plot(cl,hang=-1) cl=hclust(data.all.na.d, method="average") plot(cl,hang=-1) cl=hclust(data.all.na.d, method="ward") plot(cl,hang=-1) cl=hclust(data.all.na.d, method="median") plot(cl,hang=-1) cl=hclust(data.all.na.d, method="centroid") plot(cl,hang=-1) ##pvclust data.all.na.t=t(data.all.na) pvcl <- pvclust(data.all.na.t, method.hclust="ward", method.dist="correlation", nboot=100) plot(pvcl, hang=-1) pvcl <- pvclust(data.all.na.t, method.hclust="ward", method.dist="correlation", nboot=100, r=1) plot(pvcl, hang=-1) pvrect(pvcl, alpha=0.50, pv="bp") ## data.all.na.r=data.all.na B=1000 N=dim(data.all.na.r)[1] P=dim(data.all.na.r)[2] for (ii in 1:B) { n1=sample(1:N,1) p1=sample(1:P,1) n2=sample(1:N,1) p2=sample(1:P,1) tmp=data.all.na.r[n1,p1] data.all.na.r[n1,p1]=data.all.na.r[n2,p2] data.all.na.r[n2,p2]=tmp } data.all.na.r.d=dist(data.all.na.r) cl.r=hclust(data.all.na.r.d, method="single") cl=hclust(data.all.na.d, method="single") par(mfrow=c(1,2)) plot(cl, hang=-1) plot(cl.r, hang=-1) data.all.na.r.t=t(data.all.na.r) data.all.na.t=t(data.all.na) pvcl.r <- pvclust(data.all.na.r.t, method.hclust="ward", method.dist="correlation", nboot=100) pvcl <- pvclust(data.all.na.t, method.hclust="ward", method.dist="correlation", nboot=100) par(mfrow=c(1,2)) plot(pvcl, hang=-1) plot(pvcl.r, hang=-1) heatmap(data.all.na) heatmap(data.all.na.r) dd=as.dendrogram(cl) plot(dd, type="triangle") plot(cut(dd, h=30)$upper, hang=-1)