I m using heatmap.2 function from gplots package of R to plot the heatmap of DEGs.
I have total 22 samples (10 normal and 12 treated). I have the heatmap (master heatmap) of all these samples, but the samples of interest are treated one (12 samples), so the genes which are upregulated in those 12 samples i want to extract from the master heatmap.
I have clustered the genes and samples using hierarchical clustring (hclust).
Now i want to extract the subclusters (up regulated in 12 samples) from the hclust object and for this i have used cutree function.
I have used this link to obtain the subcluster How To Get The Subclusters From The Object Of Hclust() Using Cutree() According To The Order On The Map Produced By Heatmap.2? But i want this subcluster in the form of matrix and so then i can plot this subcluster matrix again as a hetamap.
I have refered to the heatmap.2 healp page and found the subclustering code. the code is as follows,
## plot a sub-cluster using the same color coding as for the full heatmap
full <- heatmap.2(x)
heatmap.2(x, Colv=full$colDendrogram[], breaks=full$breaks) # column subset
heatmap.2(x, Rowv=full$rowDendrogram[], breaks=full$breaks) # row subset
Rowv=full$rowDendrogram[], breaks=full$breaks) # both
My question is ,
- How to extract that subcluster matrix? using R code.Can anyone provide such sample R code.
- If i plot this subcluster matrix using heatmap.2, will the pattern i have obtained in the master heatmap change in this subcluster one? if it changes then why does it change? please someone help me with this, i'm not understanding this.