Hi there,
I have almost done with my heatmap but I cannot figure out how to modify the command in order to see the label. Please, see below:
## Import dataset
data <- read.table("Genes_with_function.txt", header = TRUE, sep = "\t", dec = ".")
mat_data <- data.matrix(data[,2:ncol(data)])
# transform to Z-scale
mat <- t(scale(t(data.matrix(mat_data))))
# set colour
myCol <- colorRampPalette(c("#f03b20", "#fff7bc", "#2c7fb8"))(100)
myBreaks <- seq(-2, 3, length.out=100)
# For ID
ID <- read.table("ID.txt", header = TRUE, sep = "\t", dec = ".") ### a new .txt file with only the ID of the genes
# Do the plot
hmap <- pheatmap(mat,
cluster_rows = TRUE,
cluster_cols = TRUE,
scale = 'none',
breaks = myBreaks,
col = myCol,
show_colnames = TRUE,
labels_row = ID$ID)
Then I get this heatmap: https://ibb.co/nzMMy5t
As you can see the names of the genes (TRINITY blahblah) is imposible to see. Is there any way of specify that?
By the way the ID file looks like this:
Thank you in advance
You could modify the value of the
width
parameter that is passed topheatmap()
. Also, why not get rid of the 'TRINITY' prefix of the rownames? - it is not needed. You could also consider replacing the first_
with\n
via:Thank you much!
It worked with the commands
cellwidth cellheight
But still the legend is over the text:
https://ibb.co/wr3jjrL
Any idea how to move to the left (for instance)?
I am not sure why it is doing that. I use
cellwidth
and it comfortably positions the legend after the labels, no matter how long are the labels.Even without specifying width or cellwidth, my version of pheatmap correctly positions the colour bar:
Which version are you using? - I am using pheatmap_1.0.12 (R 3.5.3)
I am using the same version as you.
Maybe the problem is that I am using two different files and pheatmap does not recognize them?
luzglongoria ,did you try my solution?
I had assumed that s/he did try, but then I received a comment to my own comment (above). luzglongoria, can you confirm? - bioExplorer's solution should be good.