Changing colour labels of samples with pheatmap

Bit of an R newbie here. I’m trying to generate a figure to see how RNA-seq samples are grouping via hierarchical clustering.

Using this code

rld<-vst(dds, blind=TRUE)
rld_mat<- assay(rld)
pheatmap(rld_cor,annotation = meta)
heat.colors<-brewer.pal(9, "Blues")
annotdf<-data.frame(row.names = rownames(rld_cor))
         annotation_colors = ColorCode,
         border_color = NA, 
         fontsize = 10, 
         fontsize_row = 10, 

enter image description here

But when I try to add this code in:

ColorCode<-c("#CDCDCD","#A5A5A5","#808080","#9AB3FF","#537EFF","#265DFF", "#FFD733","#DDB310", "#CC9900","#FB8ACA","#FB49B0","#E40081","#00FF89","#00B25D","#008042")

and then add this into the pheatmap function

         annotation_colors = ColorCode,

to try and change the colour labels for the samples to match other figures I keep getting this error

Error in annotation_colors[[names(annotation)[i]]] <- factor_colors[ind] : 

more elements supplied than there are to replace

I don’t really understand why as I have set up 15 colours and by samples are sorted into 15 categories. Does anyone know how to fix this? Thanks for any help

Read more here: Source link