I have this vector of colours in R:
"#88FF00" "#54FF00" "#FFFF00" "#13FF00" "#50FF00" "#87FF00" "#FDFB02" "#B8FF00" "#6DFF00"
"#ECFF00" "#CBFF00" "#EDFF00" "#39FF00" "#B7FF00" "#75FF00" "#65FF00" "#C2FF00" "#25FF00"
"#9AFF00" "#E6FF00" "#58FF00" "#E5CA1A" "#DEFF00" "#9AFF00" "#21FF00" "#35FF00" "#3AFF00"
"#D0912F" "#FF0000" "#F7EF08" "#40FF00" "#DA7325" "#D8B027" "#DAFF00" "#55FF00" "#F8F007"
"#46FF00" "#69FF00" "#B8FF00" "#37FF00" "#32FF00" "#60FF00" "#7CFF00" "#00FF00" "#50FF00"
"#F3E60C" "#DFBE20" "#7FFF00" "#F7EF08" "#99FF00" "#13FF00" "#DA7325" "#13FF00"
And I want to plot them in this order, something such as a heatmap. I had been toying with the image function but the colours are reordered and even modified by the image function.
The code that I tried is the following, when cols is the vector of colors mentioned above:
image(1:nrow(expressionOrdered), 1:ncol(expressionOrdered), as.matrix(expressionOrdered), col= cols,xlab="",ylab="")
How about just a bunch of rectangles?
COL = c("#88FF00", "#54FF00", "#FFFF00", "#13FF00",
"#50FF00", "#87FF00", "#FDFB02", "#B8FF00", "#6DFF00",
"#ECFF00", "#CBFF00", "#EDFF00", "#39FF00", "#B7FF00",
"#75FF00", "#65FF00", "#C2FF00", "#25FF00", "#9AFF00",
"#E6FF00", "#58FF00", "#E5CA1A", "#DEFF00", "#9AFF00",
"#21FF00", "#35FF00", "#3AFF00", "#D0912F", "#FF0000",
"#F7EF08", "#40FF00", "#DA7325", "#D8B027", "#DAFF00",
"#55FF00", "#F8F007", "#46FF00", "#69FF00", "#B8FF00",
"#37FF00", "#32FF00", "#60FF00", "#7CFF00", "#00FF00",
"#50FF00", "#F3E60C", "#DFBE20", "#7FFF00", "#F7EF08",
"#99FF00", "#13FF00", "#DA7325", "#13FF00")
plot(NULL, xlim=c(0,length(COL)), ylim=c(0,1),
xlab="", ylab="", xaxt="n", yaxt="n")
rect(0:(length(COL)-1), 0, 1:length(COL), 1, col=COL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With