{"rsdb":{"rid":"377747","subhead":"","postdate":"0","aid":"264294","fid":"91","uid":"1","topic":"1","content":"
\n
# 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