简体   繁体   中英

Reorder columns in heatmap, keep topology

I've generated the following heatmap in R

在此处输入图片说明

using the following code.

heatmap(data.matrix(data), col=colorRampPalette(c("yellow", "blue"))(64), labRow=NA, Rowv=NA)

I would like to plot the heatmap with a different column ordering. This column ordering maintains the topology of the dendrogram, so I would like to continue to plot the dendrogram as well. The R help for the heatmap function mentions row and column reordering, and I have tried providing the desired column order as a vector to heatmap 's Colv argument, but this did not work. Any suggestions?

The arguments to Colv need to be an ordering passed to the reorder.dendrogram function. It will NOT produce an arbitrary ordering but will impose constraints by virtue of the column dendrogram structure. This should produce a different ordering.

nc <- dim(data.matrix(data)}[2]
heatmap(data.matrix(data), Colv = sample(1:nc),
        col=colorRampPalette(c("yellow", "blue"))(64), 
        labRow=NA, Rowv=NA)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM