简体   繁体   中英

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.

A solution with ggplot2:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM