This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Heatmap column side bar error

I have created a heatmap with a column side bar showing the associated donor ID with respect to the sample number. The column color bar doesn't match with the donor ID legend or the sample number, and I can't figure out what I'm doing wrong. Would someone please inspect my code? Thanks very much.

> y$sample$donor
 [1] "Donor1" "Donor1" "Donor1" "Donor1" "Donor1" "Donor2" "Donor2" "Donor2" "Donor2"
[10] "Donor2" "Donor3" "Donor3" "Donor3" "Donor3" "Donor3" "Donor4" "Donor4" "Donor4"
[19] "Donor4" "Donor4" "Donor5" "Donor5" "Donor5" "Donor5" "Donor5" "Donor6" "Donor6"
[28] "Donor6" "Donor6" "Donor6"
    col.colors <- sample(c(rep("cyan",5),
                           rep("blue",5),
                           rep("green",5),
                           rep("pink",5),
                           rep("red",5),
                           rep("yellow",5)),length(y$samples$donor))
>    heatmap.2(logCPM, col=col.pan, ColSideColors = col.colors, trace = "none",
              dendrogram = "column", cexRow = 1, cexCol = 1, margin = c(8,6), 
              lhei = c(2,10), lwid = c(2,6))
>    legend("left",legend=c("Donor1","Donor2","Donor3","Donor4","Donor5","Donor6"),
           fill=col.colors, border=FALSE, bty="n", y.intersp = .9, cex=.9)
rna-seq heatmap

Although this is a question that should be fairly addressed in stackoverflow. But here are my 2 cents below.

Do not restrict yourself to only one package. Have you seen pheatmap(). It is pretty straigthforward to use annotation with them. Just create a dataframe with samples in rows and columns with the donor ID and parse them while using the pheatmap function in R. It should work.

Thanks - I will check out the documentation for pheatmap.

Wasn't sure if Biostars was the appropriate forum, but thought feedback would be worthwhile since my issue is related to analysis of RNA-seq data.

0 answers

No answers yet.

Log in to answer this question.