This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Add gene name in ComplexHeatmap

Hi, I am a beginner in R and I would like to add gene name in my heatmap generated. I imported a txt file from a normalized transcriptomic data with row = gene and colum = cell Only numerical value can be used for generating the heatmap, so I remove the first colum with all gene names. How can I add the gene name stored in the data frame "gene_info" in the heatmap ? Thanks a lot for your help, Best, Jessica

> library(ComplexHeatmap)
> filename<-"Dataset-APM.txt"
> my_data <- read.table(filename, sep="\t", quote="", stringsAsFactors=FALSE,header=TRUE)
> my_matrix <- as.matrix(my_data[  ,c(2:32)])
> gene_info <- data.frame(gene=my_data$Gene) 
> my_matrix <- t(my_matrix)
> Heatmap(my_matrix, cluster_columns=FALSE)
> Heatmap(my_matrix,
    cluster_columns=FALSE,
    row_names_side = "left",
    row_hclust_side = "right",
    row_names_gp=gpar(cex=0.8),
    row_hclust_width = unit(3, "cm"),
    clustering_distance_rows ="maximum",
    clustering_method_rows = "ward.D")
r complexheatmap

2 answers

Set genes names as rownames in the matrix.

I tried this :

rownames(my_matrix) = my_data$Gene

It's working ! :) Thanks !

add the argument row_labels = my_data$Gene in the function Heatmap.

Log in to answer this question.