sessmurda
sessmurda

Reputation: 167

R-how to create single column table heatmap

I have a working solution but am. I've been using the mtcars data set and trying to color by the "disp" variable as my reproducible example.

    > library(gplots)
    > m<-cbind(mtcars[,3],mtcars[,3])
    > rownames(m)<-rownames(mtcars)
    > heatmap.2(x=m,dendrogram="none",trace="none",Colv=FALSE,Rowv=FALSE,cellnote=cbind(rownames(m),rownames(m)),notecol="black")

I can always cut out the extra row of the pdf, replace with a representation of the p-value in my actual data set (plotting ratios and p-value is fisher's exact difference from whole population), however that would add a large amount of processing on the full table of 500 values (right now just printing a giant length pdf). I may color the p-value column separately and paste them together for the final figure but assuming this will look sloppy. Suggestions at any step are appreciated.

Upvotes: 1

Views: 967

Answers (1)

ddiez
ddiez

Reputation: 1127

A solution with ggplot2:

d=as.data.frame.table(m[,1,drop=FALSE])
ggplot(d,aes(x=Var2,y=Var1,fill=Freq)) + geom_tile()

Upvotes: 1

Related Questions