{"id":68613,"date":"2026-12-03T09:09:22","date_gmt":"2026-12-03T01:09:22","guid":{"rendered":"https:\/\/www.biocloudservice.com\/wordpress\/?p=68613"},"modified":"2026-12-03T09:09:22","modified_gmt":"2026-12-03T01:09:22","slug":"r-guide-milor-practice","status":"publish","type":"post","link":"https:\/\/www.biocloudservice.com\/wordpress\/r-guide-milor-practice\/","title":{"rendered":"miloR \u770b\u89c1\u5c40\u90e8\u7ec6\u80de\u5bcc\u96c6\uff0c\u600e\u6837\u5224\u65ad\u662f\u4e0d\u662f\u4e00\u4e2a\u4f9b\u4f53\u6491\u8d77\u6765\u7684\uff1f"},"content":{"rendered":"<div class=\"ysx-r-practice\" id=\"ysx-r-milor\" 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\u5c40\u90e8\u90bb\u57df\u5728\u5904\u7406\u7ec4\u6709\u4e09\u5341\u4e2a\u7ec6\u80de\uff0c\u5bf9\u7167\u7ec4\u6709\u4e5d\u4e2a\u3002\u82e5\u5904\u7406\u7ec4\u5176\u4e2d\u4e8c\u5341\u4e94\u4e2a\u90fd\u6765\u81ea\u4e00\u4f4d\u4f9b\u4f53\uff0c\u89e3\u91ca\u5c31\u4e0e\u591a\u4f4d\u4f9b\u4f53\u4e00\u81f4\u589e\u52a0\u5927\u4e0d\u76f8\u540c\u3002Milo \u7528\u751f\u7269\u6837\u672c\u4f5c\u4e3a\u8ba1\u6570\u5217\uff0c\u540c\u65f6\u4fdd\u7559\u90bb\u57df\u4e4b\u95f4\u7684\u91cd\u53e0\u5173\u7cfb\u3002<\/p>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">miloR \u7684\u8f93\u5165\u548c\u5206\u6790\u5bf9\u8c61<\/h2>\n<p style=\"margin:.5em 0 1em\">m \u4e3a\u5df2\u7ecf\u5efa\u56fe\u5e76 makeNhoods \u7684 Milo \u5bf9\u8c61\u3002md \u7684\u884c\u540d\u4e3a\u7ec6\u80de\u4e14\u6709 sample_id\u3002design \u4e3a\u4ee5\u6837\u672c\u540d\u4f5c\u884c\u540d\u7684\u8bbe\u8ba1\u8868\u5e76\u542b condition\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5728\u4f7f\u7528 miloR \u8fdb\u884c\u7a7a\u95f4\u8f6c\u5f55\u7ec4\u5206\u6790\u65f6\uff0c\u5224\u65ad\u5c40\u90e8\u7ec6\u80de\u5bcc\u96c6\u662f\u5426\u7531\u5355\u4e00\u4f9b\u4f53\u6491\u8d77\u662f\u4e00\u4e2a\u6838\u5fc3\u95ee\u9898\u3002\u8fd9\u6d89\u53ca\u5bf9\u90bb\u57df\u5185\u7ec6\u80de\u6765\u6e90\u7684\u8ffd\u8e2a\uff0c\u4ee5\u53ca\u5bf9\u6f5c\u5728\u504f\u501a\u7684\u8bc6\u522b\u3002\u5f53\u4e00\u4e2a\u90bb\u57df\u4e2d\u7ec6\u80de\u7684\u5206\u5e03\u9ad8\u5ea6\u96c6\u4e2d\u4e8e\u67d0\u4e00\u4e2a\u4f9b\u4f53\u65f6\uff0c\u53ef\u80fd\u610f\u5473\u7740\u8be5\u90bb\u57df\u7684\u5bcc\u96c6\u5e76\u975e\u751f\u7269\u5b66\u5dee\u5f02\uff0c\u800c\u662f\u6837\u672c\u6765\u6e90\u7684\u504f\u5dee\u3002\u4e3a\u4e86\u51c6\u786e\u8bc6\u522b\u8fd9\u79cd\u73b0\u8c61\uff0c\u5fc5\u987b\u786e\u4fdd\u8bbe\u8ba1\u8868\u4e0e\u6837\u672c\u8ba1\u6570\u77e9\u9635\u7684\u5217\u540d\u4e00\u81f4\uff0c\u5e76\u5305\u542b\u72ec\u7acb\u7684\u751f\u7269\u5b66\u91cd\u590d\u3002\u8fd9\u79cd\u8bbe\u8ba1\u80fd\u591f\u652f\u6491\u5bf9\u4f9b\u4f53\u8d21\u732e\u7684\u91cf\u5316\u5206\u6790\uff0c\u4ece\u800c\u907f\u514d\u8bef\u5224\u5bcc\u96c6\u7684\u6765\u6e90\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5728\u8fdb\u884c\u5dee\u5f02\u4e30\u5ea6\u68c0\u9a8c\u524d\uff0c\u9700\u786e\u4fdd\u8bbe\u8ba1\u8868\u4e0e\u6837\u672c\u5217\u4e00\u81f4\u3002\u82e5\u8bbe\u8ba1\u8868\u4e2d\u6837\u672c\u540d\u4e0e\u8ba1\u6570\u77e9\u9635\u5217\u540d\u4e0d\u5339\u914d\uff0c\u5c06\u5bfc\u81f4\u68c0\u9a8c\u7ed3\u679c\u65e0\u6548\u3002\u5f53\u67d0\u4e00\u90bb\u57df\u4e2d\u7ec6\u80de\u8ba1\u6570\u9ad8\u5ea6\u96c6\u4e2d\u4e8e\u67d0\u4f9b\u4f53\u65f6\uff0c\u5e94\u68c0\u67e5\u8be5\u90bb\u57df\u662f\u5426\u7531\u8be5\u4f9b\u4f53\u4e3b\u5bfc\u3002\u82e5\u4f9b\u4f53\u8d21\u732e\u8d85\u8fc7 70%\uff0c\u5219\u8be5\u90bb\u57df\u53ef\u80fd\u4e0d\u5177\u4ee3\u8868\u6027\uff0c\u9700\u5728\u540e\u7eed\u5206\u6790\u4e2d\u6392\u9664\u3002\u8fd9\u79cd\u68c0\u67e5\u6709\u52a9\u4e8e\u907f\u514d\u56e0\u6837\u672c\u504f\u501a\u5bfc\u81f4\u7684\u5047\u9633\u6027\u7ed3\u679c\u3002\u901a\u8fc7\u7edf\u8ba1\u65b9\u6cd5\u5bf9\u4f9b\u4f53\u8d21\u732e\u6bd4\u4f8b\u8fdb\u884c\u91cf\u5316\uff0c\u53ef\u6709\u6548\u8bc6\u522b\u6f5c\u5728\u7684\u504f\u5dee\u6765\u6e90\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5728\u4f4e\u7ef4\u7a7a\u95f4\u5efa\u56fe\uff0c\u7528 <code>makeNhoods()<\/code> \u5b9a\u4e49\u90bb\u57df\uff0c<code>countCells()<\/code> \u6309\u751f\u7269\u5b66\u6837\u672c\u8ba1\u6570\uff0c\u518d\u7528 <code>testNhoods()<\/code> \u505a\u5dee\u5f02\u4e30\u5ea6\u68c0\u9a8c\u3002 <a href=\"https:\/\/bioconductor.org\/packages\/release\/bioc\/vignettes\/miloR\/inst\/doc\/milo_demo.html\" style=\"color:#185CB7;text-decoration:underline;\">miloR \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;\">m &lt;- miloR::countCells(m, meta.data = md, samples = \"sample_id\")\ndesign &lt;- design[colnames(miloR::nhoodCounts(m)), , drop = FALSE]\nres &lt;- miloR::testNhoods(m, design = ~condition, design.df = design)\n<\/code><\/pre>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">\u4e24\u4e2a\u6761\u4ef6\u5404\u4e09\u4e2a\u6837\u672c\u7684\u90bb\u57df\u8ba1\u6570<\/h2>\n<p style=\"margin:.5em 0 1em\">\u4e24\u7ec4\u5408\u8ba1\u4e5d\u4e0e\u4e09\u5341\uff0c\u5904\u7406\u7ec4\u4e8c\u5341\u4e94\u4e2a\u6765\u81ea\u540c\u4e00\u4f9b\u4f53\u3002\u5176\u4f59\u5904\u7406\u4f9b\u4f53\u5206\u522b\u4e8c\u548c\u4e09\u3002\u6309\u6355\u83b7\u603b\u6570\u5f52\u4e00\u5316\u3001\u68c0\u67e5\u5c40\u90e8\u56fe\u53ca\u4f9b\u4f53\u7559\u4e00\uff0c\u5e76\u8bf4\u660e\u7559\u4e00\u5728\u5c0f\u6837\u672c\u4e0b\u662f\u654f\u611f\u6027\u68c0\u67e5\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(sum(c(2,3,4)),sum(c(2,3,25)),25)\nnames(v) &lt;- c(\"\u5bf9\u7167\u5408\u8ba1\", \"\u5904\u7406\u5408\u8ba1\", \"\u5904\u7406\u6700\u5927\u4f9b\u4f53\")\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;\">\u5bf9\u7167\u5408\u8ba1<\/td>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">9<\/td>\n<\/tr>\n<tr>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">\u5904\u7406\u5408\u8ba1<\/td>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">30<\/td>\n<\/tr>\n<tr>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">\u5904\u7406\u6700\u5927\u4f9b\u4f53<\/td>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">25<\/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-milor-practice-4bce7e76.png?resize=1120%2C690&#038;ssl=1\" alt=\"\u4e24\u4e2a\u6761\u4ef6\u5404\u4e09\u4e2a\u6837\u672c\u7684\u90bb\u57df\u8ba1\u6570\u3002\u5bf9\u7167\u5408\u8ba1 9\uff0c\u5904\u7406\u5408\u8ba1 30\uff0c\u5904\u7406\u6700\u5927\u4f9b\u4f53 25\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;\">\u5220\u6389\u8d21\u732e\u6700\u5927\u7684\u6837\u672c\uff0c\u65b9\u5411\u8fd8\u770b\u5f97\u89c1\u5417\uff1f<\/h2>\n<p style=\"margin:.5em 0 1em\">\u6f14\u793a\u8ba1\u6570\u7684\u7ec4\u5747\u503c\u5dee\u539f\u4e3a\u4e03\uff0c\u6682\u65f6\u53bb\u6389\u5904\u7406\u7ec4\u6700\u540e\u4e00\u4eba\u540e\u53d8\u4e3a\u8d1f\u96f6\u70b9\u4e94\u3002\u6b64\u5904\u4ec5\u68c0\u67e5\u96c6\u4e2d\u7a0b\u5ea6\uff0c\u4e0d\u80fd\u636e\u6b64\u5220\u9664\u53d7\u8bd5\u8005\uff0c\u4e5f\u4e0d\u80fd\u62ff\u539f\u59cb\u90bb\u57df\u8ba1\u6570\u4ee3\u66ff\u542b\u6837\u672c\u89c4\u6a21\u548c\u8bbe\u8ba1\u77e9\u9635\u7684\u5dee\u5f02\u4e30\u5ea6\u6a21\u578b\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;\">ctl &lt;- c(2,3,4)\ntrt &lt;- c(2,3,25)\nc(all=mean(trt)-mean(ctl),remove_top=mean(head(trt,2))-mean(ctl))\n<\/code><\/pre>\n<p style=\"margin:.5em 0 1em\">\u5728\u5904\u7406\u90bb\u57df\u8ba1\u6570\u65f6\uff0c\u9700\u7279\u522b\u5173\u6ce8\u4f9b\u4f53\u8d21\u732e\u6bd4\u4f8b\u7684\u5206\u5e03\u3002\u82e5\u4f9b\u4f53\u8d21\u732e\u8d85\u8fc7 70%\uff0c\u5219\u8be5\u90bb\u57df\u53ef\u80fd\u4e0d\u5177\u4ee3\u8868\u6027\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5728\u8fdb\u884c\u5dee\u5f02\u4e30\u5ea6\u68c0\u9a8c\u65f6\uff0c\u9700\u7279\u522b\u6ce8\u610f\u90bb\u57df\u4e2d\u4f9b\u4f53\u7684\u8d21\u732e\u6bd4\u4f8b\u3002\u901a\u8fc7\u5bf9\u6bd4\u5206\u6790\uff0c\u53ef\u5224\u65ad\u5bcc\u96c6\u662f\u5426\u7531\u7279\u5b9a\u4f9b\u4f53\u9a71\u52a8\uff0c\u4ece\u800c\u63d0\u9ad8\u7ed3\u679c\u7684\u53ef\u9760\u6027\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5728\u5904\u7406\u90bb\u57df\u8ba1\u6570\u6570\u636e\u65f6\uff0c\u82e5\u8bbe\u8ba1\u8868\u672a\u4e0e\u6837\u672c\u5217\u4e25\u683c\u5bf9\u5e94\uff0c\u5c06\u5bfc\u81f4\u4f9b\u4f53\u8d21\u732e\u5206\u6790\u51fa\u73b0\u504f\u5dee\u3002\u4f8b\u5982\uff0c\u5f53\u6837\u672c\u5217\u540d\u4e0e\u8bbe\u8ba1\u8868\u884c\u540d\u4e0d\u4e00\u81f4\u65f6\uff0c\u7cfb\u7edf\u4f1a\u9519\u8bef\u5206\u914d\u7ec6\u80de\u5f52\u5c5e\uff0c\u4ece\u800c\u5f71\u54cd\u90bb\u57df\u4e2d\u4f9b\u4f53\u8d21\u732e\u6bd4\u4f8b\u7684\u8ba1\u7b97\u3002\u8fd9\u79cd\u9519\u8bef\u53ef\u80fd\u4f7f\u67d0\u4e00\u4f9b\u4f53\u5728\u90bb\u57df\u4e2d\u88ab\u9519\u8bef\u5730\u8bc6\u522b\u4e3a\u9ad8\u8d21\u732e\u8005\uff0c\u8fdb\u800c\u8bef\u5bfc\u5dee\u5f02\u4e30\u5ea6\u68c0\u9a8c\u7684\u7ed3\u679c\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5373\u4f7f\u90bb\u57df\u5bcc\u96c6\u5e76\u975e\u751f\u7269\u5b66\u5dee\u5f02\uff0c\u4e5f\u53ef\u80fd\u88ab\u8bef\u5224\u4e3a\u663e\u8457\u5bcc\u96c6\u3002\u56e0\u6b64\uff0c\u8bbe\u8ba1\u8868\u4e0e\u6837\u672c\u5217\u7684\u5339\u914d\u662f\u5224\u65ad\u4f9b\u4f53\u4e3b\u5bfc\u6027\u7684\u524d\u63d0\u6761\u4ef6\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\uff0c\u82e5\u8bbe\u8ba1\u8868\u4e2d\u6837\u672c\u540d\u4e0e\u8ba1\u6570\u77e9\u9635\u5217\u540d\u4e0d\u4e00\u81f4\uff0c\u5c06\u5bfc\u81f4\u8ba1\u6570\u7ed3\u679c\u65e0\u6cd5\u6b63\u786e\u6620\u5c04\u3002\u6b64\u65f6\uff0c\u5373\u4f7f\u90bb\u57df\u4e2d\u7ec6\u80de\u5206\u5e03\u7b26\u5408\u4f9b\u4f53\u4e3b\u5bfc\u7279\u5f81\uff0c\u7cfb\u7edf\u4ecd\u53ef\u80fd\u9519\u8bef\u5730\u5c06\u7ec6\u80de\u5f52\u5165\u5176\u4ed6\u6837\u672c\u3002\u8fd9\u79cd\u9519\u8bef\u4f1a\u4f7f\u5f97\u4f9b\u4f53\u8d21\u732e\u6bd4\u4f8b\u5931\u771f\uff0c\u4ece\u800c\u5f71\u54cd\u540e\u7eed\u7684\u5dee\u5f02\u4e30\u5ea6\u68c0\u9a8c\u3002\u4e3a\u907f\u514d\u6b64\u7c7b\u95ee\u9898\uff0c\u5e94\u9996\u5148\u68c0\u67e5\u8bbe\u8ba1\u8868\u7684\u884c\u540d\u662f\u5426\u4e0e\u8ba1\u6570\u77e9\u9635\u5217\u540d\u5b8c\u5168\u4e00\u81f4\u3002\u82e5\u53d1\u73b0\u4e0d\u4e00\u81f4\uff0c\u9700\u91cd\u65b0\u6574\u7406\u8bbe\u8ba1\u8868\uff0c\u786e\u4fdd\u6837\u672c\u4fe1\u606f\u7684\u51c6\u786e\u5bf9\u5e94\u3002<\/p>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">\u5728\u6a21\u62df\u7ec6\u80de\u4e0a\u5efa\u90bb\u57df\u5e76\u6309\u6837\u672c\u8ba1\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(18)\nx&lt;-matrix(rpois(60*80,3),60,80,dimnames=list(paste0(\"g\",1:60),paste0(\"c\",1:80)))\nsce&lt;-SingleCellExperiment::SingleCellExperiment(list(counts=x))\nSingleCellExperiment::reducedDim(sce,\"PCA\")&lt;-matrix(rnorm(80*5),80,5)\nsce$id&lt;-rep(paste0(\"s\",1:4),each=20)\nm&lt;-miloR::Milo(sce)\nm&lt;-miloR::buildGraph(m,k=8,d=5)\nm&lt;-miloR::makeNhoods(m,prop=.2,k=8,d=5,refined=TRUE)\nm&lt;-miloR::countCells(m,meta.data=as.data.frame(SummarizedExperiment::colData(sce)),sample=\"id\")\nv&lt;-miloR::nhoodCounts(m)\nc(ncol(sce),nrow(v),ncol(v))\n<\/code><\/pre>\n<p style=\"margin:.5em 0 1em\">\u5728 R 4.5.2\u3001miloR 2.6.0 \u4e2d\u8fd0\u884c\uff0c\u8f93\u51fa\u4f9d\u6b21\u4e3a\u8f93\u5165\u7ec6\u80de 80\uff0c\u90bb\u57df\u6570 10\uff0c\u6837\u672c\u5217\u6570 4\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\">\u8bbe\u8ba1\u8868\u8981\u4e0e\u8ba1\u6570\u77e9\u9635\u6837\u672c\u5217\u5bf9\u5e94\uff0c\u5e76\u4fdd\u6709\u72ec\u7acb\u751f\u7269\u5b66\u91cd\u590d\u3002\u68c0\u67e5\u5dee\u5f02\u90bb\u57df\u662f\u5426\u53ea\u7531\u67d0\u4e00\u4f4d\u4f9b\u4f53\u8d21\u732e\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u82e5\u67d0\u4e00\u90bb\u57df\u4e2d\u7ec6\u80de\u8ba1\u6570\u9ad8\u5ea6\u96c6\u4e2d\u4e8e\u67d0\u4e00\u4e2a\u4f9b\u4f53\uff0c\u800c\u8be5\u4f9b\u4f53\u5728\u6837\u672c\u4e2d\u4ec5\u5b58\u5728\u5c11\u91cf\u91cd\u590d\uff0c\u53ef\u80fd\u5f15\u53d1\u5bf9\u5bcc\u96c6\u6765\u6e90\u7684\u8bef\u5224\u3002\u4f8b\u5982\uff0c\u82e5\u67d0\u90bb\u57df\u4e2d25\u4e2a\u7ec6\u80de\u6765\u81ea\u5355\u4e00\u4f9b\u4f53\uff0c\u5176\u4f59\u4f9b\u4f53\u5404\u8d21\u732e2\u548c3\u4e2a\u7ec6\u80de\uff0c\u8fd9\u79cd\u5206\u5e03\u53ef\u80fd\u5728\u7edf\u8ba1\u4e0a\u663e\u793a\u51fa\u663e\u8457\u5bcc\u96c6\uff0c\u4f46\u5b9e\u9645\u53cd\u6620\u7684\u662f\u8be5\u4f9b\u4f53\u5728\u5c40\u90e8\u533a\u57df\u7684\u8868\u8fbe\u6c34\u5e73\u3002\u82e5\u672a\u8fdb\u884c\u7559\u4e00\u5206\u6790\uff0c\u53ef\u80fd\u5c06\u8fd9\u79cd\u5c40\u90e8\u8868\u8fbe\u5dee\u5f02\u8bef\u8ba4\u4e3a\u751f\u7269\u5b66\u5dee\u5f02\u3002\u8fd9\u79cd\u8bef\u5224\u5728\u5c0f\u6837\u672c\u60c5\u51b5\u4e0b\u5c24\u4e3a\u663e\u8457\uff0c\u56e0\u4e3a\u5355\u4e00\u4f9b\u4f53\u7684\u5fae\u5c0f\u53d8\u5316\u53ef\u80fd\u663e\u8457\u5f71\u54cd\u6574\u4f53\u8ba1\u6570\u6bd4\u4f8b\u3002\u56e0\u6b64\uff0c\u9700\u901a\u8fc7\u7559\u4e00\u5206\u6790\u9a8c\u8bc1\u5bcc\u96c6\u662f\u5426\u4f9d\u8d56\u4e8e\u7279\u5b9a\u4f9b\u4f53\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u82e5\u67d0\u4e00\u90bb\u57df\u4e2d\u7ec6\u80de\u6765\u6e90\u9ad8\u5ea6\u96c6\u4e2d\u4e8e\u67d0\u4e00\u4e2a\u4f9b\u4f53\uff0c\u5e94\u901a\u8fc7\u53ef\u89c6\u5316\u624b\u6bb5\u68c0\u67e5\u5176\u8ba1\u6570\u5206\u5e03\u3002\u6b64\u65f6\u5e94\u8fdb\u884c\u7559\u4e00\u5206\u6790\uff0c\u5254\u9664\u8be5\u4f9b\u4f53\u6837\u672c\u540e\u91cd\u65b0\u8ba1\u7b97\u90bb\u57df\u8ba1\u6570\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u82e5\u67d0\u4e00\u90bb\u57df\u4e2d\u7ec6\u80de\u5206\u5e03\u9ad8\u5ea6\u96c6\u4e2d\u4e8e\u67d0\u4f9b\u4f53\uff0c\u5e94\u901a\u8fc7\u6539\u53d8\u53c2\u6570\u8bbe\u7f6e\u8fdb\u884c\u654f\u611f\u6027\u5206\u6790\u3002\u4f8b\u5982\uff0c\u8c03\u6574 <code>makeNhoods()<\/code> \u4e2d\u7684 <code>k<\/code> \u548c <code>prop<\/code> \u53c2\u6570\uff0c\u91cd\u65b0\u5b9a\u4e49\u90bb\u57df\u7ed3\u6784\u3002\u82e5\u90bb\u57df\u7ed3\u6784\u6539\u53d8\u540e\uff0c\u8be5\u90bb\u57df\u7684\u4f9b\u4f53\u8d21\u732e\u6bd4\u4f8b\u53d1\u751f\u53d8\u5316\uff0c\u5219\u8bf4\u660e\u539f\u90bb\u57df\u5b9a\u4e49\u53ef\u80fd\u4e0d\u591f\u7a33\u5b9a\u3002\u901a\u8fc7\u5bf9\u6bd4\u4e0d\u540c\u53c2\u6570\u4e0b\u90bb\u57df\u8ba1\u6570\u7ed3\u679c\uff0c\u53ef\u8bc6\u522b\u51fa\u54ea\u4e9b\u90bb\u57df\u5bf9\u4f9b\u4f53\u5206\u5e03\u8f83\u4e3a\u654f\u611f\u3002\u5728\u5c0f\u6837\u672c\u60c5\u51b5\u4e0b\uff0c\u8fd9\u79cd\u654f\u611f\u6027\u68c0\u67e5\u5c24\u4e3a\u91cd\u8981\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\">\u53d6\u4e00\u4e2a\u663e\u793a\u6761\u4ef6\u5bcc\u96c6\u7684\u90bb\u57df\uff0c\u628a\u6bcf\u4e2a\u6837\u672c\u8d21\u732e\u7684\u7ec6\u80de\u6570\u6446\u6210\u4e00\u884c\uff0c\u518d\u63a5\u4e0a\u8fd9\u4e2a\u6837\u672c\u8fdb\u5165\u5206\u6790\u7684\u603b\u7ec6\u80de\u6570\u3002\u82e5\u5904\u7406\u7ec4\u7684\u603b\u8d21\u732e\u51e0\u4e4e\u5168\u90e8\u6765\u81ea\u5355\u4e2a\u60a3\u8005\uff0c\u5c31\u5e94\u56de\u5230\u8be5\u60a3\u8005\u7684\u6355\u83b7\u8d28\u91cf\u3001\u7ec6\u80de\u7ec4\u6210\u4e0e\u91c7\u6837\u7ec4\u7ec7\u5bfb\u627e\u89e3\u91ca\u3002\u76f8\u90bb\u90bb\u57df\u53ef\u80fd\u5171\u4eab\u5927\u91cf\u7ec6\u80de\uff0c\u53ef\u901a\u8fc7\u6761\u7801\u4ea4\u96c6\u8bc6\u522b\u4e00\u7247\u8fde\u7eed\u7684\u53d8\u5316\u3002\u62a5\u544a\u4e2d\u53ef\u4ee5\u63cf\u8ff0\u8fd9\u7247\u533a\u57df\uff0c\u663e\u8457\u90bb\u57df\u6570\u4e0d\u80fd\u76f4\u63a5\u6362\u7b97\u4e3a\u72ec\u7acb\u7ec6\u80de\u72b6\u6001\u6570\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u4ece\u51c6\u5907\u91cd\u70b9\u89e3\u91ca\u7684\u7c7b\u522b\u91cc\u9009\u4e09\u79cd\u4e0d\u540c\u4f4d\u7f6e\u7684\u89c2\u6d4b\u3002\u4e00\u79cd\u6700\u7b26\u5408\u8be5\u7c7b\u7279\u5f81\uff0c\u4e00\u79cd\u521a\u521a\u8de8\u8fc7\u5206\u7c7b\u6216\u7b5b\u9009\u8fb9\u754c\uff0c\u4e00\u79cd\u4e0e\u90bb\u8fd1\u7c7b\u578b\u5bb9\u6613\u6df7\u6dc6\u3002\u5206\u522b\u7559\u4e0b\u539f\u59cb\u8ba1\u6570\u6216\u539f\u59cb\u6d4b\u91cf\u3001\u6240\u5c5e\u6837\u672c\u3001\u51b3\u5b9a\u5b83\u5f52\u5c5e\u7684\u90a3\u6761\u8bc1\u636e\u3002\u5bf9\u8fb9\u754c\u5bf9\u8c61\uff0c\u518d\u9009\u4e00\u4e2a\u4f1a\u652f\u6301\u76f8\u53cd\u89e3\u91ca\u7684\u72ec\u7acb\u6807\u5fd7\u3002\u82e5\u8fd9\u4e2a\u6807\u5fd7\u53ea\u5728\u51e0\u6761\u4f4e\u8d28\u91cf\u8bb0\u5f55\u4e2d\u68c0\u51fa\uff0c\u4e0e\u5728\u591a\u4f4d\u4f9b\u4f53\u4e2d\u540c\u65f6\u68c0\u51fa\uff0c\u540e\u7eed\u8981\u67e5\u7684\u662f\u4e24\u4ef6\u4e0d\u540c\u7684\u4e8b\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u6b63\u5f0f\u62a5\u544a\u6837\u672c\u6784\u6210\u65f6\uff0c\u6bcf\u4f4d\u4f9b\u4f53\u5355\u5217\u4e00\u884c\uff0c\u540c\u65f6\u8bb0\u4e0b\u901a\u8fc7\u8d28\u63a7\u4e14\u80fd\u53c2\u4e0e\u8fd9\u4e00\u6b65\u7684\u603b\u6570\u3002\u5047\u5982\u9ad8\u5206\u5bf9\u8c61\u51e0\u4e4e\u90fd\u6765\u81ea\u4e00\u4f4d\u53d7\u8bd5\u8005\uff0c\u5e94\u628a\u8fd9\u4f4d\u53d7\u8bd5\u8005\u7684\u6587\u5e93\u6df1\u5ea6\u3001\u5904\u7406\u65e5\u671f\u548c\u7ec4\u7ec7\u6765\u6e90\u53d6\u51fa\u6765\uff0c\u4e0e\u5176\u4f59\u6837\u672c\u5e76\u5217\u6838\u5bf9\u3002\u82e5\u53e6\u4e00\u6279\u72ec\u7acb\u8d44\u6599\u4e2d\u7f3a\u5c11\u540c\u7c7b\u89c2\u6d4b\uff0c\u4fdd\u7559\u8fd9\u6b21\u53ef\u89c1\u7684\u8bc1\u636e\uff0c\u5e76\u628a\u63a8\u65ad\u8303\u56f4\u6536\u56de\u5230\u539f\u6765\u7684\u6837\u672c\u96c6\u5408\u3002\u8fd9\u6837\u7684\u8bb0\u5f55\u4e5f\u80fd\u5e2e\u52a9\u4e0b\u4e00\u4f4d\u5408\u4f5c\u8005\u6709\u9488\u5bf9\u6027\u5730\u8865\u505a\u67d3\u8272\u3001\u7a7a\u95f4\u5b9a\u4f4d\u6216\u989d\u5916\u53d6\u6837\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\/015-milor-code-236ab59a4465ab0e.zip\">\u4e0b\u8f7d\u672c\u7bc7 R \u4ee3\u7801\uff08ZIP\uff0c5.2 KiB\uff09<\/a> \u00b7 <a style=\"color:#1458a5;text-decoration:underline;\" href=\"https:\/\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/r-practice-labs\/015-milor-data-714140b886a9f219.zip\">\u4e0b\u8f7d\u914d\u5957\u793a\u4f8b\u6570\u636e\uff08ZIP\uff0c12.0 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;\">015-milor<\/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\u6a21\u62df\u7ec6\u80de\u4e0a\u5efa\u90bb\u57df\u5e76\u6309\u6837\u672c\u8ba1\u6570\u201d\u3002Linux x86_64\u3001R 4.5.2\u3001miloR 2.6.0 \u7684\u8f93\u51fa\u4e3a\u8f93\u5165\u7ec6\u80de 80\uff0c\u90bb\u57df\u6570 10\uff0c\u6837\u672c\u5217\u6570 4\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u4ece nhoodCounts \u53d6\u4e00\u4e2a\u90bb\u57df\uff0c\u5c06\u6bcf\u4f4d\u4f9b\u4f53\u7684\u7ec6\u80de\u6570\u9664\u4ee5\u884c\u548c\uff0c\u518d\u5bf9\u7167\u4f9b\u4f53\u81ea\u8eab\u7684\u603b\u7ec6\u80de\u6570\u3002\u5373\u4f7f\u4e24\u4e2a\u90bb\u57df\u884c\u548c\u76f8\u540c\uff0c\u4e5f\u53ef\u80fd\u5206\u522b\u7531\u4e00\u4f4d\u4f9b\u4f53\u548c\u591a\u4f4d\u4f9b\u4f53\u8d21\u732e\uff0c\u540e\u7eed\u5dee\u5f02\u68c0\u9a8c\u7684\u89e3\u91ca\u4f1a\u4e0d\u540c\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\">\u5b9e\u9645\u5efa\u56fe\u540e\uff0c\u516b\u5341\u4e2a\u7ec6\u80de\u5f62\u6210\u7684\u90bb\u57df\u6570\u4e0e\u56db\u4e2a\u751f\u7269\u6837\u672c\u662f\u4e24\u4e2a\u72ec\u7acb\u7ef4\u5ea6\u3002\u8fd9\u6b63\u662f\u68c0\u67e5 countCells \u7ed3\u679c\u7684\u5207\u5165\u53e3\uff0c\u5217\u5e94\u8be5\u5bf9\u5e94\u6837\u672c\uff0c\u884c\u5bf9\u5e94\u53ef\u80fd\u91cd\u53e0\u7684\u90bb\u57df\u3002\u82e5\u6700\u5927\u7684\u90a3\u4e2a\u90bb\u57df\u542b\u6709\u5f88\u591a\u7ec6\u80de\uff0c\u4e5f\u4e0d\u80fd\u628a\u8fd9\u4e9b\u7ec6\u80de\u5199\u6210\u540c\u7b49\u6570\u91cf\u7684\u72ec\u7acb\u91cd\u590d\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\u7ec4\u5408\u8ba1\u4e5d\u4e0e\u4e09\u5341\uff0c\u5904\u7406\u7ec4\u4e8c\u5341\u4e94\u4e2a\u6765\u81ea\u540c\u4e00\u4f9b\u4f53\u3002<\/p>\n","protected":false},"author":1,"featured_media":68612,"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":[1,71],"tags":[735,728,733],"class_list":["post-68613","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-part","category-single-cell","tag-milor","tag-r","tag-733"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2026\/11\/r-guide-milor-practice-4bce7e76.png?fit=1120%2C690&ssl=1","_links":{"self":[{"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/posts\/68613","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=68613"}],"version-history":[{"count":3,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/posts\/68613\/revisions"}],"predecessor-version":[{"id":70780,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/posts\/68613\/revisions\/70780"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/media\/68612"}],"wp:attachment":[{"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/media?parent=68613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/categories?post=68613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/tags?post=68613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}