Complexheatmap::pheatmap画图字体设置

分享
手机游戏开发者 2024-9-7 06:10:46 5 0 来自 中国
ComplexHeatmap是一个很好用的绘制热图的R包。这篇文章紧张先容Complexheatmap::pheatmap画图字体设置。
在原函数中没有设置字体的参数。检察有关font的参数比力表如下:
表头为Arguments in pheatmap::pheatmap()和Identical settings/arguments in ComplexHeatmap::Heatmap()

1.png
实在我们通过上述比力表可以看出Complexheatmap::pheatmap中一些参数是调用Complexheatmap::Heatmap中的一些参数来调解画图参数的。
起首,我想到了测试了下直接传入Heatmap的参数到pheatmap,但是此中一些参数假如重新设置会体现辩说。
Error in (function (matrix, col, name, na_col = "grey", color_space = "LAB", :
正式参数"column_names_gp"有多个与之相对应的现实参数
清除了这种方式之外,我测试时发现另一种可行的方法!起首将画图函数生存到一个变量中,测试代码如下:
library("ComplexHeatmap")test = matrix(rnorm(200), 20, 10)test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4colnames(test) = paste("Test", 1:10, sep = "")rownames(test) = paste("Gene", 1:20, sep = "")annotation_col = data.frame(  CellType = factor(rep(c("CT1", "CT2"), 5)),  Time = 1:5)rownames(annotation_col) = paste("Test", 1:10, sep = "")annotation_row = data.frame(  GeneClass = factor(rep(c("ath1", "ath2", "ath3"), c(10, 4, 6))))rownames(annotation_row) = paste("Gene", 1:20, sep = "")# Specify colorsann_colors = list(  Time = c("white", "firebrick"),  CellType = c(CT1 = "#1B9E77", CT2 = "#D95F02"),  GeneClass = c(Path1 = "#7570B3", Path2 = "#E7298A", Path3 = "#66A61E"))p <- pheatmap(test,        annotation_col = annotation_col,         annotation_row = annotation_row,          annotation_colors = ann_colors,          color = colorRampPalette(c("#0000FF", "#FFFCC8", "#FF0000"))(100),         border_color = NA,          cellwidth =NA, cellheight = NA,         cluster_rows = TRUE,          cluster_cols = TRUE,          legend = TRUE,         main = "jsd diversity distance",         fontsize = 10,         fontsize_row = 8,          fontsize_col = 10,         display_numbers = FALSE, number_format = "%.1f", number_color="Black", fontsize_number=4,         # display_numbers = matrix(ifelse(test > 5, "*", ""), nrow(test))        angle_col = "90",  # options (0, 45, 90, 270 and 315)        # show_rownames = TRUE, show_colnames = TRUE        annotation_legend = TRUE)检察p可以看出是一个S4对象,我们可以找下此中可以设置字体的参数,可以根据参数的名称来找


这里我指定参数的代码如下
您需要登录后才可以回帖 登录 | 立即注册

Powered by CangBaoKu v1.0 小黑屋藏宝库It社区( 冀ICP备14008649号 )

GMT+8, 2024-10-19 14:38, Processed in 0.163833 second(s), 35 queries.© 2003-2025 cbk Team.

快速回复 返回顶部 返回列表