-
-
Save decodebiology/e3d0d9e200311cec7f1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#The X axis is -3 kb to 3 kb around TSS. | |
#It turns out that the heatmap.2 function use default hclust ( Hierachical Clustering) to cluster the #matrix. | |
#alternatively, we can use K-means clustering to cluster the data and to see what's the pattern look like. | |
km<- kmeans(m1,2) # determine how many cluster you want, I specify 2 here | |
m1.kmeans<- cbind(m1, km$cluster) # combine the cluster with the matrix | |
dim(m1.kmeans) | |
# [1] 903 602 | |
# the last column is 602 | |
o<- order(m1.kmeans[,602]) # order the last column | |
m1.keans<- m1.kmeans[o,] # order the matrix according to the order of the last column | |
pheatmap( m1.kmeans[,1:601], cluster_rows = F, cluster_cols = F, col= hmcols, breaks = bk, legend=FALSE, show_rownames=FALSE, show_colnames=FALSE) | |
# no need to cluster by pheatmap, so I set cluster_rows and cluster_cols to FALSE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment