Hello All
I want to change the labels of my heatmap from ENSDAR_IDs to Gene Names. The Heatmap I initially produce with ENSDAR_IDs can be seen in (Fig.1). I have a list of gene names List_Gene_Names, Which I want to use as labels instead of the ENSDAR_IDs so that my Heatmap will look as in (Fig. 2). However, when I use my List_Gene_Names in the following code Code_To_Change_Labels my new Gene_Name labels become randomly located on the heatmap as can be seen in (Fig. 3)
Question: How can I add my List_Gene_Names in the correct order to my Heatmap?
Note: Fig. 2 is made with the following code: Code_For_(Fig. 2). However, this code is not. Feasible for heatmaps with 200+ labels, as I manually typed it in.
> List_Gene_Names
[1] "FO704772.2" "FO704772.1" "atp5pd" "ndufa4l" "CR383676.2" "nme2b.2" "cox7c" "RPL37A" "hspa5"
[10] "zgc:162730" "sorbs1" "hspb7"
# Code_To_Change_Labels
p4 <- DoHeatmap(zf_AR, features = top2$gene)
p4 + theme(legend.position="right", text = element_text(size = 10))
p4 + scale_y_discrete(labels = **List_Gene_Names**)
# Code_For_(Fig. 2)
p4 + scale_y_discrete(labels = c("ENSDARG00000116076" = "FO704772.2", "ENSDARG00000114910" = "FO704772.1", "ENSDARG00000098355" = "atp5pd",
"ENSDARG00000099499" = "ndufa4l", "ENSDARG00000099970" = "CR383676.2", "ENSDARG00000099420" = "nme2b.2",
"ENSDARG00000104537" = "cox7c", "ENSDARG00000115271" = "RPL37A", "ENSDARG00000103846" = "hspa5",
"ENSDARG00000103720" = "zgc:162730", "ENSDARG00000103435" = "sorbs1", "ENSDARG00000104441" = "hspb7") )
Best Regards
Kristian Andersen
Without knowing what
DoHeatmap
actually does, it's difficult to give a precise answer, but I would recommend to change the names in thezf_AR
object already. Can you post the result ofhead(zf_AR)
andstr(zf_AR)
here?Hello Friederike
Here are the head(zf_AR) and some of str(zf_AR) result. Let me know if you need more information, I'm quite new at working with R and scRNAseq analysis.
Best Regards Kristian Andersen
It doesn't look like the order is random, but reversed from what you wanted. Try
List_Gene_Names <- rev(List_Gene_Names)
.