{"id":802,"date":"2024-10-21T17:15:48","date_gmt":"2024-10-21T09:15:48","guid":{"rendered":"https:\/\/yunshangtulv.com.cn\/?p=802"},"modified":"2024-10-21T17:15:48","modified_gmt":"2024-10-21T09:15:48","slug":"%e7%83%ad%e5%9b%be","status":"publish","type":"post","link":"https:\/\/yunshangtulv.com.cn\/?p=802","title":{"rendered":"\u70ed\u56fe"},"content":{"rendered":"<h3><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-809\" src=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2024\/10\/Rplot.png\" alt=\"\" width=\"612\" height=\"573\" srcset=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2024\/10\/Rplot.png 1132w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2024\/10\/Rplot-600x562.png 600w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\" \/>1.\u89e3\u91ca\u56fe\u7247\u7279\u70b9<\/h3>\n<h4>\u8fd9\u5f20\u56fe\u662f\u4e00\u4e2a\u70ed\u56fe\uff08Heatmap\uff09\uff0c\u7528\u4e8e\u5c55\u793a\u4e0d\u540c\u6837\u672c\u4e4b\u95f4\u7684\u57fa\u56e0\u8868\u8fbe\u91cf\u7684\u5dee\u5f02\u3002\u8be5\u56fe\u7684\u7279\u70b9\u5982\u4e0b\uff1a<\/h4>\n<p>\u6570\u636e\u5206\u7ec4\uff1a\u6837\u672c\u88ab\u5206\u4e3a\u4e24\u4e2a\u7ec4\uff08A \u548c B\uff09\uff0c\u6bcf\u7ec4\u7684\u6837\u672c\u901a\u8fc7\u4e0d\u540c\u7684\u989c\u8272\u6761\u6807\u8bb0\uff0c\u5206\u522b\u4e3a\u9752\u8272\u548c\u7c89\u8272\uff0c\u663e\u793a\u5728\u56fe\u7684\u9876\u90e8\u3002<br \/>\n\u57fa\u56e0\u540d\u79f0\uff1a\u53f3\u4fa7\u7684\u6807\u7b7e\u5217\u663e\u793a\u4e86\u6bcf\u4e2a\u57fa\u56e0\u7684\u540d\u79f0\u3002<br \/>\n\u989c\u8272\u68af\u5ea6\uff1a\u56fe\u4e2d\u4f7f\u7528\u4e86\u4ece\u84dd\u8272\u5230\u7ea2\u8272\u7684\u989c\u8272\u68af\u5ea6\u8868\u793a\u57fa\u56e0\u8868\u8fbe\u91cf\u7684\u53d8\u5316\uff0c\u84dd\u8272\u4ee3\u8868\u8f83\u4f4e\u8868\u8fbe\uff08-1.5\u4ee5\u4e0b\uff09\uff0c\u7ea2\u8272\u4ee3\u8868\u8f83\u9ad8\u8868\u8fbe\uff081.5\u4ee5\u4e0a\uff09\uff0c\u989c\u8272\u7684\u5f3a\u5ea6\u8868\u793a\u57fa\u56e0\u8868\u8fbe\u7684\u6c34\u5e73\u3002<br \/>\n\u805a\u7c7b\u6811\uff1a\u5728\u884c\u548c\u5217\u7684\u4e24\u4fa7\u90fd\u6709\u805a\u7c7b\u6811\uff0c\u8868\u793a\u57fa\u56e0\u548c\u6837\u672c\u4e4b\u95f4\u7684\u76f8\u4f3c\u6027\u3002<br \/>\n\u56fe\u4f8b\uff1a\u53f3\u4fa7\u5305\u542b\u989c\u8272\u68af\u5ea6\u7684\u56fe\u4f8b\uff0c\u8868\u793a\u6570\u636e\u7684\u8303\u56f4\u548c\u4e24\u4e2a\u5206\u7ec4\u7684\u540d\u79f0\u3002<\/p>\n<h3>2.\u6570\u636e\u8981\u6c42<\/h3>\n<h4>\u4e3a\u4e86\u751f\u6210\u7c7b\u4f3c\u7684\u70ed\u56fe\uff0c\u6570\u636e\u9700\u8981\u6ee1\u8db3\u4ee5\u4e0b\u8981\u6c42\uff1a<\/h4>\n<p>\u6570\u636e\u77e9\u9635\uff1a\u4e00\u4e2a\u5305\u542b\u591a\u4e2a\u57fa\u56e0\uff08\u884c\uff09\u548c\u591a\u4e2a\u6837\u672c\uff08\u5217\uff09\u7684\u77e9\u9635\u3002\u6bcf\u4e2a\u5355\u5143\u683c\u8868\u793a\u57fa\u56e0\u5728\u67d0\u4e2a\u6837\u672c\u4e2d\u7684\u8868\u8fbe\u91cf\u3002<br \/>\n\u6837\u672c\u5206\u7ec4\u4fe1\u606f\uff1a\u6837\u672c\u88ab\u5206\u4e3a\u4e24\u4e2a\u6216\u591a\u4e2a\u7ec4\uff0c\u9700\u4e3a\u6bcf\u4e2a\u6837\u672c\u6807\u8bb0\u5176\u6240\u5c5e\u7684\u7ec4\uff08\u5982\u7ec4A\u3001\u7ec4B\uff09\u3002<br \/>\n\u6570\u503c\u8303\u56f4\uff1a\u57fa\u56e0\u8868\u8fbe\u91cf\u5e94\u8be5\u662f\u8fde\u7eed\u6570\u636e\uff0c\u8303\u56f4\u5e94\u8986\u76d6\u6b63\u8d1f\u503c\uff08\u4ee5\u7a81\u51fa\u9ad8\u8868\u8fbe\u548c\u4f4e\u8868\u8fbe\u4e4b\u95f4\u7684\u5dee\u5f02\uff09\u3002<br \/>\n\u805a\u7c7b\u5206\u6790\uff1a\u7528\u4e8e\u884c\u548c\u5217\u7684\u805a\u7c7b\uff0c\u5c55\u793a\u57fa\u56e0\u548c\u6837\u672c\u4e4b\u95f4\u7684\u76f8\u4f3c\u6027\u3002<\/p>\n<h3>3.\u7528R\u4ee3\u7801\u751f\u6210\u865a\u62df\u6570\u636e\u5e76\u7ed8\u5236\u70ed\u56fe<\/h3>\n<pre class=\"corepress-code-pre\"><code># \u751f\u6210\u865a\u62df\u6570\u636e\r\nset.seed(123)\r\ngene_names &lt;- c(\"SLC7A2\", \"PLXND1\", \"MTMR7\", \"ARF5\", \"SARM1\", \"POLDIP2\", \"NDUFAF7\", \r\n                \"ICA1\", \"CFLAR\", \"ALS2\", \"TFPI\", \"CASP10\", \"DBNDD1\", \"RBM5\")\r\nsample_names &lt;- c(\"A-1\", \"A-2\", \"A-3\", \"B-1\", \"B-2\")\r\ngroup &lt;- c(\"A\", \"A\", \"A\", \"B\", \"B\")\r\n\r\ndata_matrix &lt;- matrix(rnorm(14 * 5, mean = 0, sd = 1), nrow = 14, ncol = 5, dimnames = list(gene_names, sample_names))\r\ndata_frame &lt;- as.data.frame(data_matrix)\r\n\r\n# \u6dfb\u52a0\u5206\u7ec4\u4fe1\u606f\u5230\u5217\u6ce8\u91ca\u6570\u636e\u6846\r\ngroup_info &lt;- data.frame(Group = group)\r\nrownames(group_info) &lt;- sample_names\r\n\r\n# \u4fdd\u5b58\u4e3aCSV\u6587\u4ef6\r\nwrite.csv(data_frame, file = \"heatmap_data.csv\", row.names = TRUE)\r\nwrite.csv(group_info, file = \"group_info.csv\", row.names = TRUE)\r\n\r\n# \u8bfb\u53d6CSV\u6587\u4ef6\r\nheatmap_data &lt;- read.csv(\"heatmap_data.csv\", row.names = 1)\r\ngroup_info &lt;- read.csv(\"group_info.csv\", row.names = 1)\r\n\r\ngroup_info &lt;- group_info\r\nheatmap_data &lt;- data_frame\r\n\r\n# \u4f7f\u7528pheatmap\u7ed8\u5236\u70ed\u56fe\r\nif (!require(\"pheatmap\")) install.packages(\"pheatmap\")\r\nlibrary(pheatmap)\r\n\r\nlibrary(RColorBrewer)\r\n# \u5206\u79bb\u57fa\u56e0\u8868\u8fbe\u6570\u636e\u548c\u5206\u7ec4\u4fe1\u606f\r\nexpression_data &lt;- heatmap_data[, -ncol(heatmap_data)]\r\n\r\n# \u8bbe\u7f6e\u989c\u8272\r\nann_colors &lt;- list(Group = c(A = \"#66c2a5\", B = \"#fc8d62\"))\r\n\r\n# \u6309\u5217\u805a\u7c7b\r\npheatmap(heatmap_data, \r\n         cluster_rows = TRUE, \r\n         cluster_cols = TRUE, \r\n         annotation_col = group_info,\r\n         annotation_colors = list(Group = c(A = \"#00BFC4\", B = \"#F8766D\")),\r\n         color = colorRampPalette(c(\"blue\", \"white\", \"red\"))(50),\r\n         scale = \"row\",\r\n         fontsize_row = 12,\r\n         fontsize_col = 12,\r\n         legend_breaks = seq(-1.5, 1.5, by = 0.5),\r\n         legend_labels = seq(-1.5, 1.5, by = 0.5),\r\n         annotation_legend = TRUE,\r\n         main = \"Heatmap of Gene Expression\",\r\n         border_color = NA,\r\n         cellwidth = 20, \r\n         cellheight = 15)\r\n\r\n# \u5206\u7ec4\u5c55\u793a\r\npheatmap(heatmap_data, \r\n         cluster_rows = TRUE, \r\n         cluster_cols = FALSE, \r\n         annotation_col = group_info,\r\n         annotation_colors = list(Group = c(A = \"#00BFC4\", B = \"#F8766D\")),\r\n         color = colorRampPalette(c(\"blue\", \"white\", \"red\"))(50),\r\n         scale = \"row\",\r\n         fontsize_row = 12,\r\n         fontsize_col = 12,\r\n         legend_breaks = seq(-1.5, 1.5, by = 0.5),\r\n         legend_labels = seq(-1.5, 1.5, by = 0.5),\r\n         annotation_legend = TRUE,\r\n         main = \"Heatmap of Gene Expression\",\r\n         border_color = NA,\r\n         cellwidth = 20, \r\n         cellheight = 15,\r\n         clustering_distance_cols = \"euclidean\",\r\n         clustering_method = \"ward.D2\",\r\n         gaps_col = c(3))<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-810\" src=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2024\/10\/Rplot06.png\" alt=\"\" width=\"648\" height=\"466\" srcset=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2024\/10\/Rplot06.png 1132w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2024\/10\/Rplot06-600x431.png 600w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u89e3\u91ca\u56fe\u7247\u7279\u70b9 \u8fd9\u5f20\u56fe\u662f\u4e00\u4e2a\u70ed\u56fe\uff08Heatmap\uff09\uff0c\u7528\u4e8e\u5c55\u793a\u4e0d\u540c\u6837\u672c\u4e4b\u95f4\u7684\u57fa\u56e0\u8868\u8fbe\u91cf\u7684\u5dee\u5f02\u3002\u8be5\u56fe\u7684\u7279\u70b9\u5982\u4e0b\uff1a [&hellip;]<\/p>\n","protected":false},"author":104,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-802","post","type-post","status-publish","format-standard","hentry","category-r"],"_links":{"self":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/users\/104"}],"replies":[{"embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=802"}],"version-history":[{"count":0,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/802\/revisions"}],"wp:attachment":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}