# Create test matrix\uff08\u9020\u6570\u636e\uff09\nset.seed(6)\ntest = matrix(rnorm(200), 20, 10)\ntest[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3\ntest[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2\ntest[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4\ncolnames(test) = paste("Test", 1:10, sep = "")\nrownames(test) = paste("Gene", 1:20, sep = "")\n<\/code><\/pre> \n \u6b63\u6587\u4ece\u8fd9\u91cc\u5f00\u59cb<\/em><\/h2> \n # Show text within cells\npheatmap(test, display_numbers = TRUE)\npheatmap(test, display_numbers = TRUE, number_format = "\\\\%.1e")\npheatmap(test, display_numbers = TRUE, display_numbers = matrix(ifelse(test > 5, "*", ""), nrow(test)))\n<\/code><\/pre> \n \n -
display_numbers = T \u5373Show text within cells<\/p> <\/li> \n
-
number_format \u53ef\u4ee5\u683c\u5f0f\u8f93\u51fadisplay_number<\/p> <\/li> \n
-
\u6216\u8005\u5e72\u8106\u81ea\u5b9a\u4e49\u4e00\u4e2amatrix\u901a\u8fc7display_numbers\u53c2\u6570\u8fdb\u884cdisplay<\/p> <\/li> \n <\/ul> \n
# legend\uff08\u56fe\u4f8b\uff09\u7684\u8bbe\u7f6e\u9009\u9879\npheatmap(test) # p1\npheatmap(test, legend_breaks = -1:7) # p2\npheatmap(test, legend_breaks = 1:6, legend_labels = c("6","6", "6", "6", "6", "6")) # p3\npheatmap(test, legend_breaks = 9:14, legend_labels = c("6","6", "6", "6", "6", "6")) # p4\n<\/code><\/pre> \n \n -
pheatmap\u51fd\u6570\u4f1a\u5728\u5185\u90e8\u7b97\u51falegend\u7684\u6570\u503c\u8303\u56f4\uff0c\u672c\u4f8b\u4e2d\u5927\u6982\u662f -1:7<\/p> <\/li> \n
-
\u5728\u6570\u503c\u8303\u56f4\u5185\uff0c\u6211\u4eec\u53ef\u4ee5\u8bbe\u5b9alegend_breaks\uff0c\u4ee5\u53ca\u5bf9legend_breaks\u8fd9\u4e2alabel\u7684\u6587\u672c\u5c55\u793a<\/p> <\/li> \n
-
legend_breaks\u548clegend_labels\u662f\u6709\u4e00\u4e2a\u5bf9\u5e94\u5173\u7cfb\u7684\uff0c\u5426\u5219\u62a5\u9519\u5982\u4e0b<\/p>
Error in pheatmap(test, legend_breaks = 1:6, legend_labels =
c(\u201c6\u201d, \u201c6\u201d, : Lengths of legend_breaks and legend_labels must be
the same<\/p> <\/li> \n
-
\u5047\u5982\u6211\u4eec\u7684\u8bbe\u5b9a\u8303\u56f4\u8d85\u51fa\uff0c\u5c31\u5982p4\u6240\u793a<\/p> <\/li> \n <\/ul> \n
<\/p> \n
# Fix cell sizes and save to file with correct size\npheatmap(test, cellwidth = 15, cellheight = 12, main = "Example heatmap") # the title of the plot\npheatmap(test, cellwidth = 15, cellheight = 12, fontsize = 8, filename = "test.pdf") # save to pdf\n\n# Change angle of text in the columns (0, 45, 90, 270 and 315)\npheatmap(test, angle_col = "45")\npheatmap(test, angle_col = "0")\n<\/code><\/pre> \n \u6709\u5173annotation<\/em><\/h3> \n # Generate annotations for rows and columns\uff08\u5148\u9020\u6570\u636e\uff09\nannotation_col = data.frame(\n CellType = factor(rep(c("CT1", "CT2"), 5)), \n Time = 1:5\n )\nrownames(annotation_col) = paste("Test", 1:10, sep = "")\n\nannotation_row = data.frame(\n GeneClass = factor(rep(c("Path1", "Path2", "Path3"), c(10, 4, 6)))\n )\nrownames(annotation_row) = paste("Gene", 1:20, sep = "")\n\n# Display row and color annotations\npheatmap(test, annotation_col = annotation_col, cluster_cols = F)\n\npheatmap(test, annotation_col = annotation_col, annotation_legend = FALSE, cluster_cols = F)\n\npheatmap(test, annotation_row = annotation_row, cluster_rows = F)\n<\/code><\/pre> \n <\/p> \n
\n -
annotation\u6570\u636e\u9996\u5148\u8981\u7ec4\u7ec7\u6210dataframe\uff0cdataframe\u4e2d\u7684rownames\u8981\u548c\u6ce8\u91ca\u9879\u8fdb\u884c\u5bf9\u5e94\uff0c
\u800ccolumn\u5c31\u662f\u8981\u5c55\u793a\u7684\u6ce8\u91ca\u6761\uff0c\u6bcf\u4e2acolumn\u90fd\u4f1a\u751f\u6210\u4e00\u4e2a\u6ce8\u91ca\u6761\u6765\u663e\u793a<\/p> <\/li> \n
-
annotation_col\/row \u9ed8\u8ba4\u4f1a\u6709legend\u914d\u5408\u5c55\u793a\uff0cannotation_legend = FALSE\u53ef\u4ee5\u53bb\u6389legend<\/p> <\/li> \n <\/ul> \n
# Specify colors \uff08\u81ea\u5b9a\u4e49\u6ce8\u91ca\u6761\u989c\u8272\uff09\nann_colors = list(\n Time = c("white", "firebrick"),\n CellType = c(CT1 = "#1B9E77", CT2 = "#D95F02"),\n GeneClass = c(Path1 = "#7570B3", Path2 = "#E7298A", Path3 = "#66A61E")\n)\n\npheatmap(test, annotation_col = annotation_col, annotation_colors = ann_colors)\n\npheatmap(test, annotation_col = annotation_col, annotation_row = annotation_row, annotation_colors = ann_colors)\n<\/code><\/pre> \n <\/p> \n
\n - \u6ce8\u91ca\u6761\u989c\u8272\u6570\u636e\u8981\u7ec4\u7ec7\u6210list\uff08list\u7684\u7075\u6d3b\u6027\u5c31\u5728\u6b64\u5904\u51f8\u663e\u51fa\u6765\u4e86\uff09\uff0c
list\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u540d\u4f5c\u4e3a\u5bf9\u5e94\u9879\uff08\u5bf9\u5e94\u524d\u8ff0datafra","orderid":"0","title":"pheatmap\u5b9e\u7528\u53c2\u6570\uff08\u4e8c\uff09(\u4e00)","smalltitle":"","mid":"0","fname":"R\u8bed\u8a00","special_id":"0","bak_id":"0","info":"0","hits":"402","pages":"2","comments":"0","posttime":"2023-07-23 13:24:50","list":"1690089890","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"pheatmap<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"119.59.235.169","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"pheatmap\u5b9e\u7528\u53c2\u6570\uff08\u4e8c\uff09","lastview":"1716081044","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}