Question: How to regroup columns in R using heatmap.2 or pheatmap ?
0
gravatar for Björn
2.4 years ago by
Björn40
Björn40 wrote:

Using following heatmap.2 command

heatmap.2(highly_variable_lcpm,labRow = y2$genes$genes, Rowv = TRUE, col=rev(morecols(20)),trace="none",tracecol = "black",main="Top 20 most variable genes across samples",cex.main=0.6, ColSideColors=group.col,scale="row",margins=c(10,9))

I got the following graph ![heatmap][1][1]: https://ibb.co/iiN257 The colors in column header indicate similar group which are 5 different colors (groups). How to make the samples in each group together so as to show group-wise variation (which is supervised clustering). Thanks

heatmap.2 edger pheatmap • 4.3k views
ADD COMMENTlink modified 2.4 years ago by h.mon30k • written 2.4 years ago by Björn40

If your input samples are in the correct order, use dendrogram="row" to turn off the column-wise clustering

ADD REPLYlink written 2.4 years ago by russhh5.5k

or, if your input matrix is ordered try Rowv=False

ADD REPLYlink written 2.4 years ago by Buffo1.8k

The row is not in order so adding

Colv=FALSE, dendrogram="row"

did not really help . E.g. my samples are as A A A B B B A A A C C C N N N. I need to find a way to bring all 6 "A" together.

ADD REPLYlink written 2.4 years ago by Björn40

Have you considered then reordering them

ADD REPLYlink written 2.4 years ago by russhh5.5k

That was my question , how ?

ADD REPLYlink written 2.4 years ago by Björn40

Re-order them in your actual data-matrix, i.e., before you even apply the heatmap.2 function, and then use Colv and dendrogram as per Buffo

Something like:

sample.order <- A A A B B B A A A C C C N N N *pseudocode
highly_variable_lcpm.ordered <- highly_variable_lcpm[,sample.order]

heatmap.2(highly_variable_lcpm.ordered, ...)
ADD REPLYlink written 2.4 years ago by Kevin Blighe63k
3
gravatar for h.mon
2.4 years ago by
h.mon30k
Brazil
h.mon30k wrote:

Reorder the matrix by column names:

data <- data[ , order( colnames( data ) ) ]

Then plot the heatmap with Colv=FALSE, dendrogram="row".

I wouldn't try to force the groupings, though, if your treatments are not clustering, this reflects the structure of the data and is important to the interpretation of the results.

ADD COMMENTlink written 2.4 years ago by h.mon30k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1291 users visited in the last hour