I've made a heatmap including colors for annotating the rows using the script from here. Currently my script is this:
cols <- colorRampPalette(brewer.pal(9, "Paired"))
mycolors <- cols(length(unique(merged_DE_peaks_cut_annotation_type$V10)))
names(mycolors) <- unique(merged_DE_peaks_cut_annotation_type$V10)
mycolors <- list(mycolors = mycolors)
anno <- as.data.frame(merged_DE_peaks_cut_annotation_type$V10])
rownames(anno) <- rownames(merged_DE_peaks_cut_annotation_type)
colnames(anno) <- "Annotation"
pheatmap(merged_DE_peaks_cut_annotation_type[, c(3:6)],
color = colorRampPalette(rev(brewer.pal(n = 7, name = "RdYlBu")))(100),
annotation_row = anno,
annotation_colors = mycolors[1],
cluster_rows = TRUE,
cluster_cols = FALSE,
cellheight = 1,
cellwidth = 80,
border_color=NA,
show_rownames = F,
main="H3K27me3 log2(RPKM) at promoters of >1.5 FC downreg BA1 genes")
I don't get any errors, but the colours that are generated for row annotations aren't those specified in mycolors. They seem to just be the default option, whether I include annotation_colors = mycolors[1]
or not doesn't make a difference to the annotation colours on the plot. mycolors is as follows and the #'s codes change when I alter the palette, so it just seems to not get called properly during the pheatmap plot for some reason.
> mycolors[1]
$mycolors
None lncg contained in pcg antisense bidirectional antisense
"#A6CEE3" "#1F78B4" "#B2DF8A"
lncg contained in pcg sense head-head overlap antisense tail-tail overlap antisense
"#33A02C" "#FB9A99" "#E31A1C"
overlap sense pcg contained in lncg sense pcg contained in lncg antisense
"#FDBF6F" "#FF7F00" "#CAB2D6"
Any help really appreciated, thanks!