{"id":68806,"date":"2026-12-05T09:10:36","date_gmt":"2026-12-05T01:10:36","guid":{"rendered":"https:\/\/www.biocloudservice.com\/wordpress\/?p=68806"},"modified":"2026-12-05T09:10:36","modified_gmt":"2026-12-05T01:10:36","slug":"r-guide-diffcyt-practice","status":"publish","type":"post","link":"https:\/\/www.biocloudservice.com\/wordpress\/r-guide-diffcyt-practice\/","title":{"rendered":"diffcyt \u770b\u89c1\u6d41\u5f0f\u6807\u5fd7\u7269\u589e\u5f3a\uff0c\u600e\u6837\u5206\u6e05\u662f\u7ec6\u80de\u72b6\u6001\u53d8\u4e86\u8fd8\u662f\u7ec6\u80de\u7fa4\u53d8\u591a\uff1f"},"content":{"rendered":"<div class=\"ysx-r-practice\" id=\"ysx-r-diffcyt\" style=\"max-width:820px;margin:0 auto;color:#203449;font-size:17px;line-height:1.88;overflow-wrap:break-word;\">\n<p style=\"margin:.5em 0 1em\">\u4e00\u4e2a\u72b6\u6001\u6807\u5fd7\u7269\u7684\u5168\u6837\u672c\u5e73\u5747\u4e0a\u5347\uff0c\u53ef\u4ee5\u4ec5\u4ec5\u56e0\u4e3a\u9ad8\u8868\u8fbe\u7ec6\u80de\u7fa4\u589e\u591a\u3002\u8981\u8bc1\u660e\u540c\u7c7b\u7ec6\u80de\u5185\u90e8\u4fe1\u53f7\u53d8\u5f3a\uff0c\u5fc5\u987b\u5728\u76f8\u540c\u7ec6\u80de\u7fa4\u5185\u6309\u72ec\u7acb\u6837\u672c\u6c47\u603b\u3002\u628a\u72b6\u6001\u4e2d\u4f4d\u6570\u548c\u7c07\u5185\u4e8b\u4ef6\u6570\u540c\u65f6\u7559\u4e0b\uff0c\u624d\u80fd\u5206\u6e05\u4e24\u79cd\u53d8\u5316\u3002<\/p>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">diffcyt \u7684\u8f93\u5165\u548c\u5206\u6790\u5bf9\u8c61<\/h2>\n<p style=\"margin:.5em 0 1em\">counts \u548c medians \u5206\u522b\u4e3a diffcyt \u6d41\u7a0b\u5df2\u751f\u6210\u4e14\u5171\u540c\u5bf9\u9f50\u7684\u7c07\u4e8b\u4ef6\u6570\u5bf9\u8c61\u4e0e\u72b6\u6001\u6807\u5fd7\u4e2d\u4f4d\u8868\u8fbe\u5bf9\u8c61\uff0cdesign\u3001contrast \u4e0e\u6837\u672c\u987a\u5e8f\u76f8\u5bb9\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5728\u6d41\u5f0f\u7ec6\u80de\u672f\u6570\u636e\u5206\u6790\u4e2d\uff0c\u533a\u5206\u7ec6\u80de\u7fa4\u6570\u91cf\u53d8\u5316\u4e0e\u7ec6\u80de\u72b6\u6001\u53d8\u5316\u662f\u5224\u65ad\u751f\u7269\u6807\u5fd7\u7269\u8868\u8fbe\u5dee\u5f02\u7684\u5173\u952e\u3002\u5f53\u89c2\u5bdf\u5230\u67d0\u6807\u5fd7\u7269\u8868\u8fbe\u589e\u5f3a\u65f6\uff0c\u9700\u660e\u786e\u8be5\u589e\u5f3a\u662f\u7531\u4e8e\u7279\u5b9a\u7ec6\u80de\u7fa4\u6570\u91cf\u589e\u52a0\uff0c\u8fd8\u662f\u8be5\u7fa4\u7ec6\u80de\u72b6\u6001\u53d1\u751f\u4e86\u6539\u53d8\u3002\u6b64\u95ee\u9898\u5728\u591a\u6837\u672c\u3001\u591a\u6761\u4ef6\u8bbe\u8ba1\u4e2d\u5c24\u4e3a\u7a81\u51fa\u3002\u672c\u7814\u7a76\u8bbe\u5b9a\u4e2d\uff0c\u5c06\u6807\u5fd7\u7269\u5206\u4e3a\u5b9a\u4e49\u7ec6\u80de\u7c7b\u578b\u548c\u53cd\u6620\u7ec6\u80de\u72b6\u6001\u4e24\u7c7b\uff0c\u5206\u522b\u7528\u4e8e\u5206\u6790\u7ec6\u80de\u9891\u7387\u548c\u7ec6\u80de\u72b6\u6001\u8868\u8fbe\u3002\u8f93\u5165\u6570\u636e\u5305\u62ec\u4e24\u4e2a\u4e3b\u8981\u5bf9\u8c61\uff0c\u4e8b\u4ef6\u6570\u6c47\u603b\u7684 counts \u4e0e\u72b6\u6001\u6807\u5fd7\u4e2d\u4f4d\u8868\u8fbe\u7684 medians\u3002\u8fd9\u4e24\u4e2a\u5bf9\u8c61\u5747\u6765\u81ea diffcyt \u6d41\u7a0b\u7684\u4e2d\u95f4\u6b65\u9aa4\uff0c\u786e\u4fdd\u4e86\u7c07\u4e0e\u6837\u672c\u7684\u5bf9\u9f50\u3002counts \u5bf9\u8c61\u8bb0\u5f55\u6bcf\u4e2a\u6837\u672c\u4e2d\u6bcf\u4e2a\u7c07\u7684\u4e8b\u4ef6\u6570\u91cf\uff0c\u800c medians \u5bf9\u8c61\u5219\u8bb0\u5f55\u5404\u7c07\u4e2d\u72b6\u6001\u6807\u5fd7\u7684\u4e2d\u4f4d\u8868\u8fbe\u503c\u3002\u8bbe\u8ba1\u77e9\u9635 design \u4e0e\u5bf9\u6bd4\u77e9\u9635 contrast \u5b9a\u4e49\u4e86\u6837\u672c\u95f4\u7684\u5206\u7ec4\u4e0e\u6bd4\u8f83\u5173\u7cfb\uff0c\u786e\u4fdd\u5206\u6790\u7684\u903b\u8f91\u4e00\u81f4\u6027\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">diffcyt \u6d41\u7a0b\u4e2d\uff0ctestDS_limma() \u51fd\u6570\u7528\u4e8e\u5206\u6790\u7ec6\u80de\u72b6\u6001\u7684\u5dee\u5f02\uff0c\u5176\u8f93\u5165\u5bf9\u8c61\u5305\u62ec counts \u548c medians\uff0c\u4ee5\u53ca\u8bbe\u8ba1\u4e0e\u5bf9\u6bd4\u77e9\u9635\u3002\u51fd\u6570\u9996\u5148\u5c06 counts \u6309\u6837\u672c\u4e0e\u7c07\u8fdb\u884c\u6c47\u603b\uff0c\u4ee5\u4fdd\u7559\u6bcf\u4e2a\u7c07\u7684\u4e8b\u4ef6\u6570\u4fe1\u606f\u3002\u968f\u540e\uff0cmedians \u5bf9\u8c61\u63d0\u4f9b\u6bcf\u4e2a\u7c07\u4e2d\u72b6\u6001\u6807\u5fd7\u7684\u8868\u8fbe\u4e2d\u4f4d\u6570\u3002\u8fd9\u4e24\u4e2a\u4fe1\u606f\u5728 limma \u5305\u4e2d\u88ab\u6574\u5408\u4e3a\u8868\u8fbe\u77e9\u9635\uff0c\u7528\u4e8e\u62df\u5408\u7ebf\u6027\u6a21\u578b\u3002\u51fd\u6570\u4f1a\u68c0\u67e5\u6bcf\u4e2a\u7c07\u7684\u4e8b\u4ef6\u6570\u662f\u5426\u8db3\u591f\u7528\u4e8e\u7edf\u8ba1\u68c0\u9a8c\uff0c\u82e5\u4e8b\u4ef6\u6570\u8fc7\u4f4e\u5219\u53ef\u80fd\u5f15\u53d1 NA \u503c\u3002\u5728\u5206\u6790\u8fc7\u7a0b\u4e2d\uff0climma \u4f1a\u6839\u636e\u8bbe\u8ba1\u77e9\u9635\u62df\u5408\u7ec4\u95f4\u5dee\u5f02\uff0c\u5bf9\u6bd4\u77e9\u9635\u5219\u6307\u5b9a\u5177\u4f53\u6bd4\u8f83\u65b9\u5411\u3002\u5206\u6790\u7ed3\u679c\u5305\u542b\u6bcf\u4e2a\u7c07\u4e2d\u6807\u5fd7\u7269\u7684 p \u503c\u4e0e\u6821\u6b63\u540e p \u503c\uff0c\u7528\u4e8e\u5224\u65ad\u72b6\u6001\u8868\u8fbe\u662f\u5426\u5177\u6709\u7edf\u8ba1\u5b66\u610f\u4e49\u3002\u8f93\u51fa\u5bf9\u8c61 res \u4e3a SummarizedExperiment \u7c7b\u578b\uff0c\u5176\u4e2d rowData \u5305\u542b\u6bcf\u4e2a\u7c07\u7684\u6807\u5fd7\u7269\u4fe1\u606f\uff0c\u53ef\u8fdb\u4e00\u6b65\u63d0\u53d6\u5206\u6790\u7ed3\u679c\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u533a\u5206\u5b9a\u4e49\u7ec6\u80de\u7c7b\u578b\u548c\u53cd\u6620\u72b6\u6001\u7684\u6807\u5fd7\u7269\uff0c\u805a\u7c7b\u540e\u6309\u6837\u672c\u548c\u7c07\u6c47\u603b\u72b6\u6001\u6807\u5fd7\u7269\u8868\u8fbe\uff0c\u5411 <code>testDS_limma()<\/code> \u4f20\u5165\u6c47\u603b\u7ed3\u679c\u3001\u8bbe\u8ba1\u4e0e\u5bf9\u6bd4\u3002 <a href=\"https:\/\/bioconductor.org\/packages\/release\/bioc\/vignettes\/diffcyt\/inst\/doc\/diffcyt_workflow.html\" style=\"color:#185CB7;text-decoration:underline;\">diffcyt \u5b98\u65b9\u6559\u7a0b<\/a><\/p>\n<pre style=\"white-space:pre;overflow:auto;max-width:100%;padding:14px;background:#F0F7FF;border:1px solid #D1E7FF;border-radius:8px;color:#183551;font-size:14px;line-height:1.6;box-sizing:border-box;\"><code class=\"language-r\" style=\"font-family:Consolas,monospace;white-space:pre;overflow-wrap:normal;word-break:normal;\">res &lt;- diffcyt::testDS_limma(d_counts=counts,d_medians=medians,design=design,contrast=contrast)\nhead(as.data.frame(SummarizedExperiment::rowData(res)))\n<\/code><\/pre>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">\u7fa4\u5185\u8868\u8fbe\u56fa\u5b9a\u4e5f\u4f1a\u6539\u53d8\u5168\u4f53\u5e73\u5747<\/h2>\n<p style=\"margin:.5em 0 1em\">\u4e24\u7fa4\u5185\u8868\u8fbe\u56fa\u5b9a\u4e3a\u5341\u548c\u4e8c\uff0c\u82e5\u7532\u6bd4\u4f8b\u4ece\u56db\u5206\u4e4b\u4e00\u5347\u5230\u56db\u5206\u4e4b\u4e09\uff0c\u6df7\u5408\u5747\u503c\u4ece\u56db\u5347\u5230\u516b\u3002\u5168\u6837\u672c\u8868\u8fbe\u63d0\u9ad8\u4e0d\u4ee3\u8868\u7fa4\u5185\u72b6\u6001\u5fc5\u53d8\u3002\u7a00\u6709\u7c07\u8fd8\u5e94\u9010\u6837\u672c\u8bb0\u5f55\u4e8b\u4ef6\u6570\u4e0e\u7f3a\u5931\u3002<\/p>\n<pre style=\"white-space:pre;overflow:auto;max-width:100%;padding:14px;background:#F0F7FF;border:1px solid #D1E7FF;border-radius:8px;color:#183551;font-size:14px;line-height:1.6;box-sizing:border-box;\"><code class=\"language-r\" style=\"font-family:Consolas,monospace;white-space:pre;overflow-wrap:normal;word-break:normal;\">v &lt;- c(10,2,.75*10+.25*2)\nnames(v) &lt;- c(\"\u7fa4\u7532\u8868\u8fbe\", \"\u7fa4\u4e59\u8868\u8fbe\", \"\u7532\u6bd4\u4f8b\u5347\u9ad8\u540e\u7684\u5747\u503c\")\nprint(v)\n<\/code><\/pre>\n<table style=\"width:100%;border-collapse:collapse;margin:1em 0;font-size:15px\">\n<thead>\n<tr>\n<th style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#ECF6FF;\">\u8f93\u5165\u6216\u6bd4\u8f83\u9879<\/th>\n<th style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#ECF6FF;\">R \u8ba1\u7b97\u7ed3\u679c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">\u7fa4\u7532\u8868\u8fbe<\/td>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">10<\/td>\n<\/tr>\n<tr>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">\u7fa4\u4e59\u8868\u8fbe<\/td>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">2<\/td>\n<\/tr>\n<tr>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">\u7532\u6bd4\u4f8b\u5347\u9ad8\u540e\u7684\u5747\u503c<\/td>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<figure style=\"margin:1.5em 0;\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2026\/11\/r-guide-diffcyt-practice-89c16de0.png?resize=1120%2C690&#038;ssl=1\" alt=\"\u7fa4\u5185\u8868\u8fbe\u56fa\u5b9a\u4e5f\u4f1a\u6539\u53d8\u5168\u4f53\u5e73\u5747\u3002\u7fa4\u7532\u8868\u8fbe 10\uff0c\u7fa4\u4e59\u8868\u8fbe 2\uff0c\u7532\u6bd4\u4f8b\u5347\u9ad8\u540e\u7684\u5747\u503c 8\u3002\" width=\"1120\" height=\"690\" style=\"max-width:100%;width:100%;height:auto;display:block\"><figcaption style=\"font-size:14px;color:#455970;line-height:1.6;\">\u6559\u5b66\u7b97\u4f8b\uff0c\u6570\u636e\u4e0e\u8ba1\u7b97\u5f0f\u89c1\u56fe\u4e0a\u65b9\u3002<\/figcaption><\/figure>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">\u540c\u4e00\u4e2a\u7c07\u5185\u6709\u591a\u5c11\u4e8b\u4ef6\u6709\u8d44\u683c\u7b97\u72b6\u6001\uff1f<\/h2>\n<p style=\"margin:.5em 0 1em\">\u56db\u4e2a\u6837\u672c\u4e2d\u4e00\u4e2a\u6ca1\u6709\u8be5\u7c07\u4e8b\u4ef6\uff0c\u53e6\u4e00\u4e2a\u53ea\u6709\u4e24\u4e2a\u3002\u82e5\u4f8b\u793a\u8981\u6c42\u81f3\u5c11\u4e94\u4e2a\uff0c\u53ea\u6709\u4e24\u4efd\u80fd\u652f\u6301\u8be5\u7c07\u7684\u72b6\u6001\u6c47\u603b\u3002\u8fd9\u9879\u8fc7\u6ee4\u4f1a\u6539\u53d8\u6bd4\u8f83\u4e2d\u5b9e\u9645\u6709\u4fe1\u606f\u7684\u53d7\u8bd5\u8005\u6570\uff0c\u4e0d\u80fd\u628a\u7f3a\u5931\u7c07\u7684\u72b6\u6001\u4e2d\u4f4d\u8868\u8fbe\u586b\u96f6\u3002<\/p>\n<pre style=\"white-space:pre;overflow:auto;max-width:100%;padding:14px;background:#F0F7FF;border:1px solid #D1E7FF;border-radius:8px;color:#183551;font-size:14px;line-height:1.6;box-sizing:border-box;\"><code class=\"language-r\" style=\"font-family:Consolas,monospace;white-space:pre;overflow-wrap:normal;word-break:normal;\">events &lt;- c(0,2,60,70)\nok &lt;- events&gt;=5\nc(all_samples=length(events),eligible=sum(ok),none=sum(events==0))\n<\/code><\/pre>\n<p style=\"margin:.5em 0 1em\">\u4e3a\u9a8c\u8bc1\u5206\u6790\u7ed3\u679c\u7684\u7a33\u5065\u6027\uff0c\u53ef\u8fdb\u884c\u654f\u611f\u6027\u5bf9\u7167\u5b9e\u9a8c\u3002\u4f8b\u5982\uff0c\u5c06 counts \u4e0e medians \u5bf9\u8c61\u4e2d\u7684\u7c07\u4e8b\u4ef6\u6570\u8fdb\u884c\u4e0d\u540c\u9608\u503c\u7684\u7b5b\u9009\uff0c\u89c2\u5bdf\u7ed3\u679c\u662f\u5426\u4fdd\u6301\u4e00\u81f4\u3002\u82e5\u7ed3\u679c\u5728\u4e0d\u540c\u9608\u503c\u4e0b\u5747\u7a33\u5b9a\uff0c\u5219\u8bf4\u660e\u5206\u6790\u7ed3\u679c\u5177\u6709\u8f83\u5f3a\u9c81\u68d2\u6027\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u82e5\u67d0\u7c07\u4e8b\u4ef6\u6570\u6781\u4f4e\uff0c\u53ef\u80fd\u65e0\u6cd5\u8fdb\u884c\u7edf\u8ba1\u68c0\u9a8c\uff0c\u6b64\u65f6\u5e94\u8003\u8651\u5c06\u5176\u6392\u9664\u5728\u5206\u6790\u4e4b\u5916\u3002\u6b64\u5916\uff0c\u82e5\u67d0\u6807\u5fd7\u7269\u5728\u6240\u6709\u7c07\u4e2d\u8868\u8fbe\u5747\u4f4e\uff0c\u53ef\u80fd\u65e0\u6cd5\u63d0\u4f9b\u6709\u6548\u72b6\u6001\u4fe1\u606f\uff0c\u5e94\u5c06\u5176\u5254\u9664\u3002\u5206\u6790\u7ed3\u679c\u7684\u8fb9\u754c\u5e94\u660e\u786e\uff0c\u82e5\u67d0\u6807\u5fd7\u7269\u5728\u7279\u5b9a\u7c07\u4e2d\u8868\u8fbe\u663e\u8457\u5347\u9ad8\uff0c\u4f46\u4e8b\u4ef6\u6570\u8fc7\u4f4e\uff0c\u5219\u8be5\u7ed3\u679c\u53ef\u80fd\u4e0d\u53ef\u9760\u3002\u56e0\u6b64\uff0c\u5e94\u540c\u65f6\u62a5\u544a\u8868\u8fbe\u503c\u4e0e\u4e8b\u4ef6\u6570\uff0c\u4ee5\u4f9b\u5224\u65ad\u7ed3\u679c\u7684\u53ef\u4fe1\u5ea6\u3002\u5728\u6700\u7ec8\u7ed3\u679c\u4e2d\uff0c\u5e94\u4f18\u5148\u8003\u8651\u4e8b\u4ef6\u6570\u5145\u8db3\u4e14\u8868\u8fbe\u663e\u8457\u7684\u7c07\uff0c\u4ee5\u907f\u514d\u56e0\u4f4e\u9891\u8868\u8fbe\u5bfc\u81f4\u7684\u5047\u9633\u6027\u6216\u5047\u9634\u6027\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5f53\u5206\u6790\u4e2d\u51fa\u73b0\u5f02\u5e38\u663e\u8457\u6027\u7ed3\u679c\u65f6\uff0c\u5e94\u9996\u5148\u68c0\u67e5 counts \u5bf9\u8c61\u4e2d\u5bf9\u5e94\u7c07\u7684\u4e8b\u4ef6\u6570\u5206\u5e03\u3002\u82e5\u67d0\u7c07\u5728\u67d0\u6837\u672c\u4e2d\u4e8b\u4ef6\u6570\u7a81\u7136\u5347\u9ad8\uff0c\u53ef\u80fd\u7531\u4e8e\u8be5\u6837\u672c\u4e2d\u7279\u5b9a\u6761\u4ef6\u5bfc\u81f4\u7ec6\u80de\u805a\u96c6\uff0c\u800c\u975e\u6807\u5fd7\u7269\u72b6\u6001\u771f\u5b9e\u6539\u53d8\u3002\u6b64\u65f6\u5e94\u67e5\u770b\u8be5\u7c07\u5728\u4e0d\u540c\u6837\u672c\u4e2d\u7684\u4e8b\u4ef6\u6570\u53d8\u5316\u8d8b\u52bf\uff0c\u786e\u8ba4\u662f\u5426\u5b58\u5728\u6279\u6b21\u6216\u4f9b\u4f53\u6548\u5e94\u3002\u82e5\u4e8b\u4ef6\u6570\u5206\u5e03\u7a33\u5b9a\u4f46\u8868\u8fbe\u5347\u9ad8\uff0c\u5219\u5e94\u8fdb\u4e00\u6b65\u786e\u8ba4\u8be5\u6807\u5fd7\u7269\u662f\u5426\u4e3a\u72b6\u6001\u6807\u5fd7\u7269\u3002\u82e5\u4e3a\u7c7b\u578b\u6807\u5fd7\u7269\uff0c\u5219\u8868\u8fbe\u5347\u9ad8\u53ef\u80fd\u4ec5\u53cd\u6620\u7ec6\u80de\u7fa4\u9891\u7387\u53d8\u5316\uff0c\u800c\u975e\u72b6\u6001\u6539\u53d8\u3002\u901a\u8fc7\u9010\u6837\u672c\u68c0\u67e5\u4e8b\u4ef6\u6570\u4e0e\u8868\u8fbe\u503c\u7684\u5bf9\u5e94\u5173\u7cfb\uff0c\u53ef\u6709\u6548\u8bc6\u522b\u8bef\u5224\u6765\u6e90\u5e76\u4fee\u6b63\u5206\u6790\u903b\u8f91\u3002<\/p>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">\u5728\u6b63\u786e\u7684\u6837\u672c\u6620\u5c04\u4e0b\u5b9e\u9645\u6c47\u603b\u5404\u7c07\u72b6\u6001\u4e2d\u4f4d\u6570<\/h2>\n<pre style=\"white-space:pre;overflow:auto;max-width:100%;padding:14px;background:#F0F7FF;border:1px solid #D1E7FF;border-radius:8px;color:#183551;font-size:14px;line-height:1.6;box-sizing:border-box;\"><code class=\"language-r\" style=\"font-family:Consolas,monospace;white-space:pre;overflow-wrap:normal;word-break:normal;\">set.seed(12)\nm&lt;-matrix(rnorm(80*3),80,3,dimnames=list(NULL,c(\"M1\",\"M2\",\"S1\")))\ncell&lt;-S4Vectors::DataFrame(sample_id=factor(rep(paste0(\"s\",1:4),each=20)),cluster_id=factor(rep(c(\"A\",\"B\"),40)))\nmarker&lt;-S4Vectors::DataFrame(marker_name=colnames(m),marker_class=factor(c(\"type\",\"type\",\"state\"),levels=c(\"type\",\"state\",\"none\")))\nx&lt;-SummarizedExperiment::SummarizedExperiment(assays=list(exprs=m),rowData=cell,colData=marker,metadata=list(experiment_info=data.frame(sample_id=paste0(\"s\",1:4))))\nz&lt;-diffcyt::calcMedians(x)\nc(ncol(z),nrow(z),length(SummarizedExperiment::assays(z)))\n<\/code><\/pre>\n<p style=\"margin:.5em 0 1em\">\u5728 R 4.5.2\u3001diffcyt 1.30.0 \u4e2d\u8fd0\u884c\uff0c\u8f93\u51fa\u4f9d\u6b21\u4e3a\u6837\u672c\u5217 4\uff0c\u7c07\u884c 2\uff0c\u6807\u5fd7\u7269\u6c47\u603b\u77e9\u9635\u6570 3\u3002<\/p>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">\u9047\u5230\u5f02\u5e38\uff0c\u5148\u6838\u5bf9\u54ea\u4e00\u9879<\/h2>\n<p style=\"margin:.5em 0 1em\">\u5148\u770b\u6bcf\u4e2a\u6837\u672c\u5728\u8be5\u7c07\u6709\u591a\u5c11\u4e8b\u4ef6\uff0c\u518d\u68c0\u67e5\u6709\u65e0\u4f9b\u4f53\u6216\u6279\u6b21\u4e3b\u5bfc\u3002\u72b6\u6001\u68c0\u9a8c\u9700\u8981\u4fdd\u7559\u4f9b\u4f53\u5c42\u7684\u72ec\u7acb\u91cd\u590d\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5728\u5206\u6790\u8fc7\u7a0b\u4e2d\uff0c\u82e5\u51fa\u73b0\u90e8\u5206\u7c07\u7684 NA \u7cfb\u6570\u8b66\u544a\uff0c\u5e94\u9996\u5148\u68c0\u67e5 counts \u5bf9\u8c61\u4e2d\u5bf9\u5e94\u7c07\u7684\u4e8b\u4ef6\u6570\u662f\u5426\u8fc7\u4f4e\u3002\u82e5\u4e8b\u4ef6\u6570\u4e0d\u8db3\uff0c\u53ef\u8003\u8651\u5408\u5e76\u4f4e\u9891\u7c07\u6216\u8c03\u6574\u5206\u6790\u9608\u503c\u3002\u82e5\u4e8b\u4ef6\u6570\u5145\u8db3\uff0c\u5e94\u68c0\u67e5 medians \u5bf9\u8c61\u4e2d\u662f\u5426\u5b58\u5728\u7f3a\u5931\u503c\uff0c\u6216\u662f\u5426\u90e8\u5206\u6807\u5fd7\u7269\u5728\u7279\u5b9a\u7c07\u4e2d\u65e0\u8868\u8fbe\u3002\u6b64\u5916\uff0c\u8bbe\u8ba1\u77e9\u9635\u4e0e\u5bf9\u6bd4\u77e9\u9635\u7684\u8bbe\u5b9a\u9519\u8bef\u4e5f\u4f1a\u5bfc\u81f4\u5206\u6790\u5931\u8d25\u3002\u5e94\u9010\u4e00\u6838\u5bf9\u6837\u672c\u4e0e\u7c07\u7684\u5bf9\u5e94\u5173\u7cfb\uff0c\u786e\u8ba4\u8bbe\u8ba1\u77e9\u9635\u4e2d\u7684\u7ec4\u522b\u4e0e\u5bf9\u6bd4\u65b9\u5411\u662f\u5426\u6b63\u786e\u3002\u82e5\u5206\u6790\u7ed3\u679c\u51fa\u73b0\u5f02\u5e38\u663e\u8457\u6027\uff0c\u5e94\u68c0\u67e5\u662f\u5426\u56e0\u6837\u672c\u4e2d\u67d0\u7c07\u4e8b\u4ef6\u6570\u7a81\u7136\u589e\u52a0\uff0c\u5bfc\u81f4\u7edf\u8ba1\u6a21\u578b\u5931\u771f\u3002\u6b64\u65f6\u5e94\u67e5\u770b counts \u5bf9\u8c61\u4e2d\u5404\u7c07\u4e8b\u4ef6\u6570\u5206\u5e03\uff0c\u5224\u65ad\u662f\u5426\u5b58\u5728\u4f9b\u4f53\u6216\u6279\u6b21\u4e3b\u5bfc\u7684\u5f02\u5e38\u60c5\u51b5\u3002\u901a\u8fc7\u9010\u5c42\u6392\u67e5\uff0c\u53ef\u5b9a\u4f4d\u95ee\u9898\u5e76\u4fee\u6b63\u5206\u6790\u6d41\u7a0b\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5728 diffcyt \u7684\u5206\u6790\u6d41\u7a0b\u4e2d\uff0c\u4e8b\u4ef6\u6570\u4e0d\u8db3\u662f\u5bfc\u81f4\u7ed3\u679c\u4e0d\u53ef\u9760\u7684\u4e3b\u8981\u56e0\u7d20\u4e4b\u4e00\u3002\u82e5\u67d0\u7c07\u4e8b\u4ef6\u6570\u4f4e\u4e8e\u5206\u6790\u9608\u503c\uff0climma \u62df\u5408\u6a21\u578b\u65f6\u53ef\u80fd\u51fa\u73b0 NA \u7cfb\u6570\u8b66\u544a\uff0c\u5f71\u54cd\u7ed3\u679c\u7684\u53ef\u89e3\u91ca\u6027\u3002\u56e0\u6b64\uff0c\u5e94\u8bbe\u5b9a\u5408\u7406\u7684\u4e8b\u4ef6\u6570\u9608\u503c\uff0c\u786e\u4fdd\u6bcf\u4e2a\u7c07\u5728\u7edf\u8ba1\u5206\u6790\u4e2d\u5177\u5907\u8db3\u591f\u7684\u4fe1\u606f\u91cf\u3002\u82e5\u90e8\u5206\u7c07\u56e0\u4e8b\u4ef6\u6570\u8fc7\u4f4e\u88ab\u6392\u9664\uff0c\u9700\u8bc4\u4f30\u5176\u662f\u5426\u53ef\u80fd\u5f71\u54cd\u6574\u4f53\u5206\u6790\u7ed3\u8bba\u3002\u5728\u654f\u611f\u6027\u5206\u6790\u4e2d\uff0c\u53ef\u5c1d\u8bd5\u8c03\u6574\u8be5\u9608\u503c\uff0c\u89c2\u5bdf\u7ed3\u679c\u662f\u5426\u7a33\u5b9a\u3002\u82e5\u9608\u503c\u63d0\u9ad8\u540e\u7ed3\u679c\u4ecd\u663e\u8457\uff0c\u8bf4\u660e\u7ed3\u8bba\u5177\u6709\u7a33\u5065\u6027\u3002\u82e5\u7ed3\u679c\u968f\u9608\u503c\u53d8\u5316\u800c\u5267\u70c8\u6ce2\u52a8\uff0c\u5219\u9700\u8fdb\u4e00\u6b65\u6392\u67e5\u6570\u636e\u8d28\u91cf\u6216\u5206\u6790\u8bbe\u7f6e\u3002<\/p>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">\u5982\u4f55\u7528\u81ea\u5df1\u7684\u6570\u636e\u590d\u6838<\/h2>\n<p style=\"margin:.5em 0 1em\">\u6bcf\u4e2a\u5019\u9009\u7c07\u540c\u65f6\u7559\u4e24\u5f20\u4ee5\u751f\u7269\u6837\u672c\u4e3a\u5217\u7684\u5c0f\u8868\u3002\u4e00\u5f20\u662f\u8be5\u7c07\u4e8b\u4ef6\u6570\u53ca\u6837\u672c\u603b\u4e8b\u4ef6\u6570\uff0c\u4e00\u5f20\u662f\u7c07\u5185\u67d0\u72b6\u6001\u6807\u5fd7\u7684\u6c47\u603b\u5f3a\u5ea6\u3002\u6570\u91cf\u6539\u53d8\u4e0e\u7c07\u5185\u5f3a\u5ea6\u6539\u53d8\u53ef\u4ee5\u540c\u65f6\u53d1\u751f\uff0c\u4e5f\u53ef\u4ee5\u53ea\u6709\u5176\u4e2d\u4e4b\u4e00\u3002\u67d0\u7c92\u5ea6\u4e0b\u628a\u4e24\u4e2a\u72b6\u6001\u6df7\u6210\u4e00\u4e2a\u7c07\uff0c\u4f1a\u4f7f\u7c07\u5185\u5747\u503c\u968f\u7ec4\u6210\u79fb\u52a8\u3002\u6362\u4e00\u4e2a\u6709\u4f9d\u636e\u7684\u805a\u7c7b\u7c92\u5ea6\uff0c\u6309\u6807\u5fd7\u7279\u5f81\u5339\u914d\u76f8\u5e94\u7c07\uff0c\u518d\u770b\u60a3\u8005\u7ea7\u65b9\u5411\u662f\u5426\u53ef\u4ee5\u91cd\u73b0\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u53d6\u7ed3\u679c\u4e2d\u6700\u51c6\u5907\u89e3\u91ca\u7684\u4e00\u884c\uff0c\u628a\u6bcf\u4e2a\u72ec\u7acb\u6837\u672c\u7684\u539f\u59cb\u89c2\u6d4b\u3001\u6240\u5728\u6761\u4ef6\u4ee5\u53ca\u80fd\u591f\u652f\u6301\u8be5\u503c\u7684\u6d4b\u91cf\u6570\u6392\u5f00\u3002\u5148\u770b\u4e00\u4e2a\u6761\u4ef6\u5185\u90e8\u7684\u53d8\u5316\u8303\u56f4\uff0c\u518d\u770b\u4e24\u4e2a\u6761\u4ef6\u7684\u4e2d\u95f4\u4f4d\u7f6e\u3002\u82e5\u5dee\u5f02\u4e3b\u8981\u7531\u4e00\u4e2a\u6837\u672c\u8d21\u732e\uff0c\u67e5\u8be5\u6837\u672c\u540c\u6279\u5176\u4ed6\u6307\u6807\u662f\u5426\u4e5f\u504f\u79fb\uff0c\u7136\u540e\u4fdd\u7559\u5168\u6837\u672c\u548c\u6709\u4f9d\u636e\u7684\u654f\u611f\u6027\u5206\u6790\u4e24\u5957\u7ed3\u679c\u3002\u4ec5\u56e0\u67d0\u4e2a\u70b9\u4e0d\u7b26\u5408\u9884\u671f\u800c\u5220\u9664\uff0c\u4f1a\u540c\u65f6\u6539\u53d8\u6548\u5e94\u4f30\u8ba1\u548c\u4e0d\u786e\u5b9a\u6027\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u4ea4\u4ed8\u8868\u91cc\u6700\u597d\u4fdd\u7559\u4f30\u8ba1\u91cf\u7684\u65b9\u5411\u4ee5\u53ca\u54ea\u4e2a\u6761\u4ef6\u4f5c\u4e3a\u53c2\u7167\u3002\u7f3a\u6d4b\u548c\u6d4b\u51fa\u4e3a\u96f6\u8981\u5206\u522b\u7f16\u7801\uff0c\u67d0\u4f4d\u53d7\u8bd5\u8005\u6ca1\u6709\u8db3\u591f\u89c2\u6d4b\u65f6\uff0c\u5e94\u80fd\u4ece\u8868\u4e0a\u770b\u51fa\u4e3a\u4ec0\u4e48\u8fd9\u4e00\u6b21\u6ca1\u6709\u6570\u503c\u3002\u5bf9\u4e8e\u540c\u4e00\u4eba\u591a\u6b21\u6d4b\u91cf\u7684\u7814\u7a76\uff0c\u6309\u53d7\u8bd5\u8005\u8fde\u7ebf\u53ef\u8ba9\u65b9\u5411\u4e00\u81f4\u6027\u76f4\u63a5\u53ef\u89c1\u3002\u628a\u8fd9\u79cd\u6837\u672c\u5c42\u68c0\u67e5\u4e0e\u6a21\u578b\u7684\u591a\u91cd\u68c0\u9a8c\u7ed3\u679c\u914d\u5408\uff0c\u80fd\u533a\u5206\u201c\u91cd\u590d\u4e2d\u65b9\u5411\u4e00\u81f4\u4f46\u8bc1\u636e\u6709\u9650\u201d\u548c\u201c\u8868\u9762\u6548\u5e94\u5f88\u5927\u5374\u7531\u5355\u4e2a\u5bf9\u8c61\u63a8\u52a8\u201d\u3002<\/p>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">\u4e0b\u8f7d\u4ee3\u7801\u548c\u793a\u4f8b\u6570\u636e\uff0c\u5728 Linux \u4e0a\u590d\u73b0<\/h2>\n<p style=\"margin:.5em 0 1em\"><a style=\"color:#1458a5;text-decoration:underline;\" href=\"https:\/\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/r-practice-labs\/099-diffcyt-code-0a0f3ed2acac81dd.zip\">\u4e0b\u8f7d\u672c\u7bc7 R \u4ee3\u7801\uff08ZIP\uff0c5.6 KiB\uff09<\/a> \u00b7 <a style=\"color:#1458a5;text-decoration:underline;\" href=\"https:\/\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/r-practice-labs\/099-diffcyt-data-180e15952604e11b.zip\">\u4e0b\u8f7d\u914d\u5957\u793a\u4f8b\u6570\u636e\uff08ZIP\uff0c6.8 KiB\uff09<\/a><\/p>\n<p style=\"margin:.5em 0 1em\">\u5c06\u4e24\u4e2a ZIP \u89e3\u538b\u5230\u540c\u4e00\u4f4d\u7f6e\uff0c\u8fdb\u5165 <code style=\"background:#edf5fc;padding:.05em .25em;border-radius:3px;\">099-diffcyt<\/code> \u76ee\u5f55\uff0c\u8fd0\u884c <code style=\"background:#edf5fc;padding:.05em .25em;border-radius:3px;\">Rscript --vanilla run.R<\/code>\u3002\u6253\u5f00 <code style=\"background:#edf5fc;padding:.05em .25em;border-radius:3px;\">results\/metrics.tsv<\/code> \u67e5\u770b\u7ed3\u679c\uff0c\u4ee3\u7801\u5305\u4e2d\u7684 <code style=\"background:#edf5fc;padding:.05em .25em;border-radius:3px;\">expected\/metrics.tsv<\/code> \u53ef\u4f9b\u9010\u884c\u6838\u5bf9\u3002\u8981\u91cd\u505a\u6587\u4e2d\u7684\u4e24\u4e2a\u6570\u503c\u7ec3\u4e60\uff0c\u53ef\u7ee7\u7eed\u8fd0\u884c <code style=\"background:#edf5fc;padding:.05em .25em;border-radius:3px;\">Rscript --vanilla checks.R<\/code>\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u672c\u6b21\u4ece\u4e0b\u8f7d\u5305\u590d\u73b0\u7684\u6b65\u9aa4\u662f\u201c\u5728\u6b63\u786e\u7684\u6837\u672c\u6620\u5c04\u4e0b\u5b9e\u9645\u6c47\u603b\u5404\u7c07\u72b6\u6001\u4e2d\u4f4d\u6570\u201d\u3002Linux x86_64\u3001R 4.5.2\u3001diffcyt 1.30.0 \u7684\u8f93\u51fa\u4e3a\u6837\u672c\u5217 4\uff0c\u7c07\u884c 2\uff0c\u6807\u5fd7\u7269\u6c47\u603b\u77e9\u9635\u6570 3\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u9009\u5b9a\u4e00\u4e2a\u7c07\u3001\u6837\u672c\u548c\u6807\u5fd7\u7269\uff0c\u4ece\u539f\u59cb\u4e8b\u4ef6\u91cd\u7b97\u4e2d\u4f4d\u6570\uff0c\u4e0e calcMedians \u7684\u5bf9\u5e94\u5355\u5143\u683c\u5bf9\u7167\u3002\u82e5\u8be5\u7c07\u5728\u67d0\u4efd\u6837\u672c\u6ca1\u6709\u4e8b\u4ef6\uff0c\u4e2d\u4f4d\u6570\u6ca1\u6709\u5b9a\u4e49\uff0c\u4e0d\u5b9c\u7528\u6570\u503c\u96f6\u66ff\u4ee3\u3002<\/p>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">\u5b9e\u8dd1\u540e\u7684\u7ecf\u9a8c\u603b\u7ed3<\/h2>\n<p style=\"margin:.5em 0 1em\">\u6309\u6837\u672c\u7f16\u53f7\u91cd\u65b0\u5bf9\u9f50\u5b9e\u9a8c\u5143\u6570\u636e\u540e\uff0c\u624d\u80fd\u628a\u6bcf\u4e2a\u7c07\u548c\u6807\u5fd7\u7269\u7684\u4e2d\u4f4d\u6570\u653e\u56de\u6b63\u786e\u7684\u53d7\u8bd5\u8005\u5217\u3002\u6309\u7ec6\u80de\u753b\u7684\u6f02\u4eae\u7bb1\u7ebf\u56fe\u4f1a\u9690\u85cf\u8fd9\u91cc\u7684\u72ec\u7acb\u6837\u672c\u6570\u3002\u6311\u4e00\u4e2a\u7c07\u540c\u65f6\u5bfc\u51fa\u4e8b\u4ef6\u6570\u4e0e\u72b6\u6001\u4e2d\u4f4d\u6570\uff0c\u518d\u770b\u53d8\u5316\u662f\u5426\u6765\u81ea\u4e0d\u540c\u4f9b\u4f53\u7684\u540c\u5411\u6539\u53d8\u3002<\/p>\n<p style=\"border-top:1px solid #DAE6F2;margin-top:2em;padding-top:1em;\">\u5f53\u6570\u636e\u4e0e\u4ee3\u7801\u5df2\u7ecf\u5728\u5c0f\u89c4\u6a21\u8f93\u5165\u4e0a\u5bf9\u9f50\uff0c\u540e\u9762\u9700\u8981\u6309\u540c\u4e00\u53e3\u5f84\u5206\u6790\u6574\u6279\u9879\u76ee\u65f6\uff0c\u53ef\u4ee5\u6309\u5b9e\u9645\u4efb\u52a1\u4f7f\u7528<a href=\"https:\/\/www.biocloudservice.com\/wordpress\/compute-services\/\" style=\"color:#185CB7;text-decoration:underline;\" data-ysx-event=\"contact_click\">\u4e91\u751f\u4fe1\u751f\u7269\u4fe1\u606f\u5b66\u5206\u6790\u670d\u52a1\u5668<\/a>\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4e24\u7fa4\u5185\u8868\u8fbe\u56fa\u5b9a\u4e3a\u5341\u548c\u4e8c\uff0c\u82e5\u7532\u6bd4\u4f8b\u4ece\u56db\u5206\u4e4b\u4e00\u5347\u5230\u56db\u5206\u4e4b\u4e09\uff0c\u6df7\u5408\u5747\u503c\u4ece\u56db\u5347\u5230\u516b\u3002<\/p>\n","protected":false},"author":1,"featured_media":68805,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[47,1],"tags":[826,728,818],"class_list":["post-68806","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r","category-part","tag-diffcyt","tag-r","tag-818"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2026\/11\/r-guide-diffcyt-practice-89c16de0.png?fit=1120%2C690&ssl=1","_links":{"self":[{"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/posts\/68806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/comments?post=68806"}],"version-history":[{"count":3,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/posts\/68806\/revisions"}],"predecessor-version":[{"id":70942,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/posts\/68806\/revisions\/70942"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/media\/68805"}],"wp:attachment":[{"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/media?parent=68806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/categories?post=68806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/tags?post=68806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}