Question: Sorted hetamap using R

0

#### •

**190**wrote:I want to generate the sorted heatmaps based on the expression, what function I have to use to get the sorted heatmap based on expression, here is the script I wrote to generate the heatmap:

```
library(gplots) a <- read.csv("heatmap_input.csv",sep=",")
row.names(a) <- a$Gene
a <- a[,2:6]
a_matrix <- data.matrix(a)
cR=c(0.85)
cols= colorpanel(20,'blue','black','yellow')
a_heatmap <- heatmap.2(a_matrix,col=cols,dendrogram='row',Colv=NA,key=TRUE,keysize =
1.0, main = 'ctrl vs treated', density.info="none",trace="none",cexRow=cR,scale="row", margins=c(5,5))
```

I think you need to order the data yourself before making the heatmap. Also, sorted based on expression is unclear.

2.1kLook at the parameters Rowv and Colv of heatmap.2().

18kColv shall help me , but its ordering all the columns , but lets say I want sample group wise lets say unregulated on the top or down regulated at the bottom or viceversa

190I think you can give a vector of indices to Colv so you generate the ordering you want and pass this as Colv argument. Alternatively, reorder your data matrix and use Colv = FALSE.

18k