R-how to create single column table heatmap

最后都变了- 提交于 2019-12-11 06:38:45

问题


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.


回答1:


A solution with ggplot2:

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


来源:https://stackoverflow.com/questions/26244408/r-how-to-create-single-column-table-heatmap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!