R pheatmap行注释和标题字体大小问题

时间:2015-05-24 02:57:01

标签: heatmap pheatmap

我一直在尝试在由R中的pheatmap创建的热图中添加行注释。基本上我有一个csv文件,其中有一个特定列(Group)用于热图中的行注释。但是,我在使用以下代码时遇到问题。另外两个问题是:标题的字体大小显然太大但我找不到减少它的方法。我想将任何零的值设置为colorwhite的颜色,但我不确定它在输出文件中是否真的是白色。 The input csv file and output pdf files已关联。我坚持使用pheatmap,因为我发现它创建了比其他热图功能更适合我需要的热图。建议表示赞赏。

> library("pheatmap")

> data <- read.csv("/Users/neo/Test_BP_052215.csv", header = TRUE, row.names = 2, stringsAsFactors=F)

> head(data)

                                            Group           WT      KO1        KO2

GO:0018904 organic ether metabolic process Metabolism  12.17372951 0.000000 -15.006995

GO:0006641 triglyceride metabolic process  Metabolism  5.200847907 0.000000   0.000000

GO:0045444 fat cell differentiation        Metabolism  6.374521098 0.000000  -7.927192

GO:0006639 acylglycerol metabolic process  Metabolism  6.028616852 0.000000   0.000000

GO:0016125 sterol metabolic process        Metabolism  5.760678325 8.262778   0.000000

GO:0016126 sterol biosynthetic process     Metabolism -6.237114754 9.622373   0.000000



> heatdata <- data[,-1]

> head(heatdata)

                                                 WT      KO1        KO2

GO:0018904 organic ether metabolic process  12.17372951 0.000000 -15.006995

GO:0006641 triglyceride metabolic process   5.200847907 0.000000   0.000000

GO:0045444 fat cell differentiation         6.374521098 0.000000  -7.927192

GO:0006639 acylglycerol metabolic process   6.028616852 0.000000   0.000000

GO:0016125 sterol metabolic process         5.760678325 8.262778   0.000000

GO:0016126 sterol biosynthetic process     -6.237114754 9.622373   0.000000



> annotation_row <- data.frame(Group = data[,1])

> rownames(annotation_row) = paste("Group", 1:38, sep = "")

> ann_colors = list( Group = c(Metabolism="navy", Cellular="skyblue", Signal="steelblue", Transport="green", Cell="purple", Protein="yellow", Other="firebrick") ) 

> head(annotation_row)

        Group

Group1 Metabolism

Group2 Metabolism

Group3 Metabolism

Group4 Metabolism

Group5 Metabolism

Group6 Metabolism

> col_breaks = unique(c(seq(-16,-0.5,length=200), seq(-0.5,0.5,length=200), seq(0.5,20,length=200)))

> my_palette <- colorRampPalette(c("blue", "white", "red"))(n = 599)

> pheatmap(heatdata, main="Enrichment", color=my_palette, breaks=col_breaks, border_color = "grey20", cellwidth = 15, cellheight = 12, scale = "none",  annotation_row = annotation_row, annotation_colors = ann_colors, cluster_rows = F, cluster_cols=F, fontsize_row=10, filename="heatmap_BP_test.pdf")

0 个答案:

没有答案