Question: Extract gene names from a particular cluster from pheatmap
0
gravatar for grant.hovhannisyan
18 months ago by
grant.hovhannisyan1.7k wrote:

Hi Biostars,

My question might seem very redundant, but I havn't come across a solution for my particular case (I guess I miss a small detail).

So, with pheatmap I have generated a heapmap of ca 7.5k genes. The code is

heat<-pheatmap(LFC_human, annotation_col=human_conditions,cluster_rows=TRUE, show_rownames=FALSE,cluster_cols=TRUE, 
         border_color = NA, scale = "row",
         color=greenred(75),main="Title")

Here is the heatmap

human heatmap LFC overlap genes reordered biostars

My question is - how I can get gene names of a specific cluster (highlighted in blue)?

I know I can use

hc <-heat$tree_row
lbl <- cutree(hc, 5) # split gene dendrogram in 5 groups
which(lbl==1) # grab genes of first group

but how do I know to which clusters this 5 groups correspond to on my dendrogram? And since there are a lot of genes, any visual inspection is problematic. Maybe I should use a different package for heatmaps?

Thanks

pheatmap R cluster • 2.1k views
ADD COMMENTlink modified 18 months ago • written 18 months ago by grant.hovhannisyan1.7k

I believe we do have clustering gurus in Biostars:)

ADD REPLYlink modified 18 months ago • written 18 months ago by grant.hovhannisyan1.7k

I hope @Kevin_Blighe will hear me :)

ADD REPLYlink written 18 months ago by grant.hovhannisyan1.7k
1

Not unless you tag him: Kevin Blighe

ADD REPLYlink written 18 months ago by genomax72k

Ah, thanks @genomax, wan't aware about this functionality.

ADD REPLYlink written 18 months ago by grant.hovhannisyan1.7k
1

I embedded the image you had linked in original post. For future reference: How to add images to a post

ADD REPLYlink written 18 months ago by genomax72k

Thanks! For some reason only cubeupload works for me.

ADD REPLYlink written 18 months ago by grant.hovhannisyan1.7k

A very dirty way is to print the graph as a PDF with the gene IDs on the right of the Heat map. You can then highlight the geneID of your choice and paste them in your favorite text editor....

ADD REPLYlink written 14 months ago by RemiToAmigo0
4
gravatar for Kevin Blighe
18 months ago by
Kevin Blighe49k
Kevin Blighe49k wrote:

Did you look at this previous answer? - A: extract dendrogram cluster from pheatmap

Specifically search for the text "#Re-order original data (genes) to match ordering in heatmap (top-to-bottom)" in that thread.

By knowing the exact order of the genes in your dendrogram/heatmap, you should be able to combine that information with the output of cutree and, thus, creating a 2-column data-frame of the sample-to-cluster assignment.

I do prefer ComplexHeatmap, as it gives greater flexibility all round!

ADD COMMENTlink written 18 months ago by Kevin Blighe49k

Hi Kevin, Thanks for reply! Yes I have seen that post before, but as far as I understand at some point you should do some manual inspection to see where the cutree cuts the tree and whether it corresponds to the cluster I need (and since there are a lot of genes I thought it might be problematic). But I will try anyway. Ideally I wanted something similar to the picture below (with assigned clusters on the left)enter image description here

ADD REPLYlink modified 18 months ago • written 18 months ago by grant.hovhannisyan1.7k

I believe that cutree assigns the clusters based on the tree merge height, i.e., the height at which two samples or sample groups merge, which is useful to know. When there are many genes, it can indeed be difficult.

I still prefer ComplexHeatmap, though. The tutorial on the Bioconductor website is great, and I have also put code on BIostars as answers in various threads. Inparticular, you may be interested in how the heat map is segregated into different clusters, as you can see here:

That is done by PAM or means clustering, or you can first use cutree and then assign the sample-to-cluster output from cutter to the ComplexHeatmap Heatmap() function (via the split parameter) in order to split the heat map based on how cutree has identified the groupings.

ADD REPLYlink modified 18 months ago • written 18 months ago by Kevin Blighe49k
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: 1283 users visited in the last hour