geom_tile ggplot中的数据绘制错误

时间:2014-08-22 12:22:33

标签: r ggplot2 heatmap

请查看下面的数据示例和代码。我正在尝试使用geom_tile将此scaled矩阵绘制为热图。显然,情节似乎没有显示正确的内容和内容。你们有些人想检查一下吗?

miRNA     Group     0h_rep1        1h_rep1         4h_rep1          9h_rep1      15h_rep1        18h_rep1          21h_rep1        0h_rep2          1h_rep2         4h_rep2        9h_rep2      15h_rep2           18h_rep2         21h_rep2
hsa-miR-7705    G1  -0.5791601303   -0.2799399884   -0.1896145785   0.2137443595    0.5462122103    0.0546742825    0.0357391566    -0.8364257583   -0.0359128249   0.0357391566    0.3926289049    0.511077882 0.2026552482    -0.0714179196
hsa-miR-7-1-3p  G1  -0.2365412352   -0.276712928    0.050566601     0.0367194013    0.3796356901    0.1196670385    0.2062513311    -0.2935208321   -0.3420719883   -0.3243606254   0.050566601 0.3782237567    0.1771089921    0.0744681968
hsa-miR-381-3p  G2  -0.4223373638   -0.2716594911   0.2548068809    0.9238278212    0.4612359248    -0.1146808224   -0.3882829088   -0.242293132    -0.6773726941   0.1155544155    0.5506500983    0.2419740966    -0.1146808224   -0.3167420029
hsa-miR-411-5p  G2  -0.3406583024   -0.2678739252   0.4530401188    0.7580901648    0.0559456228    -0.1831301191   -0.4373072487   -0.336123987    -0.2159876198   0.3049452746    0.7131799981    0.0402389375    -0.1831301191   -0.3612287948

 data.m <- melt(data, id.vars=c("Group","miRNA"))
 head(data.m)

 p <- ggplot(data.m, aes(variable, miRNA))
 p  + geom_tile(aes(fill = value)) + facet_wrap(~Group,ncol=4) +
       scale_fill_gradient2(low=muted("blue"), high=muted("red")) +
       scale_x_discrete(labels=c("0h_rep2", "0h_rep1", "1h_rep2","1h_rep1","4h_rep2","4h_rep1","9h_rep2","9h_rep1", "15h_rep2", "15h_rep1","18h_rep2","18h_rep1","21h_rep2","21h_rep1")) + 
         theme_bw(base_size=20) + 
         theme(axis.text.x=element_text(angle=0, vjust=0.5, hjust=0, size=12), axis.text.y=element_text(size=12), strip.text.y=element_text(angle=0, vjust=0.5, hjust=0.5, size=12),
    strip.text.x=element_text(size=12)) + 
 labs(y="Genes", x="Time (h)", fill="")

0 个答案:

没有答案