0

I generated heapmap using glpots like this.

head(TEST)
#             GO.0000041  GO.0001505 ...
#GO:0002479      0.053      0.061  ...
...

heatmap.2(TEST, trace="none", density.info="none", col=colfunc(15))

What I want to do is take the elements of x and y label as clustered on the heatmap and save it as text file. That is, GO:0042164..... Many thanks for your help!

enter image description here

user2913161
  • 1,115
  • 2
  • 13
  • 15

1 Answers1

1

First of all, when you post a question involving plotting, it's extremely helpful if you provide a minimal, reproducible example. Otherwise it's difficult to give specific coding suggestions or you just make the person answering your question do unnecessary work. I'll try to saved time by taking an example from the ?heatmap.2 help page

data(mtcars)
x  <- as.matrix(mtcars)
library(gplots)
xx <- heatmap.2(x)

Here we make sure to save the results of the plotting command to a variable. This stores the dendrograms for the rows and columns. You can get at the labels with

head(finalrownames<-labels(xx$rowDendrogram))
# [1] "Maserati Bora"       "Chrysler Imperial"   "Lincoln Continental"
# [4] "Cadillac Fleetwood"  "Hornet Sportabout"   "Pontiac Firebird"   

head(finalcolnames<-labels(xx$colDendrogram))
# [1] "cyl"  "am"   "vs"   "carb" "wt"   "drat"

here i took the head() just to keep the output to a minimal length.

Community
  • 1
  • 1
MrFlick
  • 195,160
  • 17
  • 277
  • 295