This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Not getting annotated colours in the row annotation in pheatmap

Why am I not getting annotated colours in the row annotation box for respective genes?

I am extreme new to R. Can anyone suugest better way to do this?

I have used this code for my dataset to give row annotation and color.

I have converted the .csv file to matrix and then I used folllowing codes to give row annotation and colors

#convert from df to matrix
nitro_mat <- data.matrix(nitro)

annotation_row = data.frame(GeneClass = factor(rep(c("Path1", "Path2", "Path3"), c(20, 14, 15))))

ann_colors = list(GeneClass = c(Path1 = "#7570B3", Path2 = "#E7298A", Path3 = "#66A61E"))

pheatmap(nitro_mat, scale = "row", cellwidth = 10, cellheight = 8, cluster_cols = T, annotation_row = annotation_row, annotation_colors = ann_colors)

Finally I am getting this output, why?

pheatmap image

pheatmap r

I've cleaned up your post and title - in the future, please ensure your post doesn't have typos and your title is clear

If you're just starting on heatmap software, I'd recommend using ComplexHeatmap instead of pheatmap - CH has better (and more well-defined) features, and the guide is comprehensive.

Thanks sir for your valuable response, I will take care in the future

1 answer

Your annotation_row data frame has to have the same row identifiers as your data matrix. You could probably fix it with:

rownames(annotation_row) <- rownames(nitro_mat)

and the annotation_row data frame does not need to have factor() applied to the column.

Log in to answer this question.