Cluster data in heat map in R ggplot

后端 未结 3 1082
予麋鹿
予麋鹿 2020-12-29 10:06

Please see my plot below: \"enter

my code:

 > head(data)
                  


        
3条回答
  •  梦谈多话
    2020-12-29 10:37

    I don't think ggplot supports this out of the box, but you can use heatmap:

     heatmap(
       as.matrix(dat), Rowv=NA,
       Colv=as.dendrogram(hclust(dist(t(as.matrix(dat)))))
     )
    

    enter image description here

    Note this won't look like yours because I'm just using the head of your data, not the whole thing.

    Here we specify the clustering manually with a dendogram derived from your hclust with the Colv argument. You can specify the clustering manually too through the Colv argument if the one used by default doesn't line up with what you want.

提交回复
热议问题