Tuesday, 19 September 2017

Extract Cluster Membership and Order From ComplexHeatmap::Heatmap

library(ComplexHeatmap)
require(circlize)

#make data
#set random seed
mat = matrix(rnorm(80, 2), 8, 10)
mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
rownames(mat) = letters[1:12]
colnames(mat) = letters[1:10]

#make Heatmap object
obj1=Heatmap(mat,km=2)

#set random seed for plotting
set.seed(1234)
obj1

#let us see whether we can get row cluster. It is empty
obj1@row_order_list

#now let us do preparation
set.seed(1234)

#set the same random seed
obj2=prepare(obj1)

#Now we can get row cluster.
obj2@row_order_list

No comments:

Post a Comment