{"id":68631,"date":"2026-12-04T09:01:21","date_gmt":"2026-12-04T01:01:21","guid":{"rendered":"https:\/\/www.biocloudservice.com\/wordpress\/?p=68631"},"modified":"2026-12-04T09:01:21","modified_gmt":"2026-12-04T01:01:21","slug":"r-guide-spark-practice","status":"publish","type":"post","link":"https:\/\/www.biocloudservice.com\/wordpress\/r-guide-spark-practice\/","title":{"rendered":"SPARK-X \u7a7a\u95f4\u68c0\u9a8c\u524d\uff0c\u600e\u6837\u7528\u4e00\u4e2a\u57fa\u56e0\u6293\u51fa\u5750\u6807\u9519\u4f4d\uff1f"},"content":{"rendered":"<div class=\"ysx-r-practice\" id=\"ysx-r-spark\" 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\">\u7a7a\u95f4\u8868\u8fbe\u77e9\u9635\u4e0e\u5750\u6807\u8868\u884c\u6570\u5b8c\u5168\u76f8\u7b26\uff0c\u56fe\u6837\u4ecd\u53ef\u80fd\u6574\u5f20\u9519\u4f4d\u3002\u4e24\u5f20\u8868\u7ecf\u8fc7\u6392\u5e8f\u7684\u65b9\u5f0f\u4e0d\u540c\uff0c\u5c31\u8db3\u4ee5\u628a\u4e00\u4e2a\u4f4d\u70b9\u7684\u5206\u5b50\u8ba1\u6570\u8d34\u5230\u53e6\u4e00\u4e2a\u4f4d\u7f6e\u3002\u7528\u4e00\u4e2a\u6709\u65b9\u5411\u7684\u7b80\u5355\u68af\u5ea6\u68c0\u67e5\u987a\u5e8f\uff0c\u518d\u8fdb\u5165 SPARK-X \u7684\u7a7a\u95f4\u68c0\u9a8c\u3002<\/p>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">SPARK \u7684\u8f93\u5165\u548c\u5206\u6790\u5bf9\u8c61<\/h2>\n<p style=\"margin:.5em 0 1em\">counts \u4e3a\u57fa\u56e0\u00d7\u4f4d\u70b9\u8ba1\u6570\u77e9\u9635\u3002coords \u4e3a\u4ee5\u4f4d\u70b9\u4e3a\u884c\u540d\u7684\u4e24\u5217\u6570\u503c\u5750\u6807\uff0c\u884c\u540d\u65e0\u91cd\u590d\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">SPARK-X \u7a7a\u95f4\u68c0\u9a8c\u7684\u6838\u5fc3\u4efb\u52a1\u662f\u5224\u65ad\u57fa\u56e0\u8868\u8fbe\u7684\u7a7a\u95f4\u5206\u5e03\u662f\u5426\u5177\u6709\u663e\u8457\u7684\u7a7a\u95f4\u7ed3\u6784\u3002\u8be5\u65b9\u6cd5\u4f9d\u8d56\u4e8e\u57fa\u56e0\u8868\u8fbe\u77e9\u9635\u4e0e\u7a7a\u95f4\u5750\u6807\u7684\u5bf9\u5e94\u5173\u7cfb\uff0c\u56e0\u6b64\u8f93\u5165\u6570\u636e\u7684\u987a\u5e8f\u4e00\u81f4\u6027\u76f4\u63a5\u5f71\u54cd\u5206\u6790\u7ed3\u679c\u7684\u51c6\u786e\u6027\u3002\u5728\u4f7f\u7528 <code>sparkx<\/code> \u51fd\u6570\u524d\uff0c\u5fc5\u987b\u786e\u4fdd\u8ba1\u6570\u77e9\u9635\u7684\u5217\u540d\u4e0e\u5750\u6807\u77e9\u9635\u7684\u884c\u540d\u5b8c\u5168\u4e00\u81f4\u3002\u8fd9\u79cd\u4e00\u81f4\u6027\u4e0d\u4ec5\u4f53\u73b0\u5728\u6570\u91cf\u4e0a\uff0c\u66f4\u4f53\u73b0\u5728\u5bf9\u5e94\u5173\u7cfb\u4e0a\u3002\u5982\u679c\u5217\u540d\u987a\u5e8f\u4e0e\u884c\u540d\u987a\u5e8f\u4e0d\u4e00\u81f4\uff0c\u5373\u4f7f\u6570\u636e\u672c\u8eab\u65e0\u8bef\uff0c\u4e5f\u4f1a\u5bfc\u81f4\u7a7a\u95f4\u70b9\u4f4d\u4e0e\u57fa\u56e0\u8868\u8fbe\u9519\u914d\uff0c\u4ece\u800c\u4ea7\u751f\u9519\u8bef\u7684\u7a7a\u95f4\u6a21\u5f0f\u5224\u65ad\u3002\u56e0\u6b64\uff0c\u8f93\u5165\u6570\u636e\u7684\u9884\u5904\u7406\u6b65\u9aa4\u5fc5\u987b\u5305\u62ec\u5bf9\u5217\u540d\u4e0e\u884c\u540d\u7684\u6bd4\u5bf9\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u5728\u7a7a\u95f4\u7ef4\u5ea6\u4e0a\u7684\u5339\u914d\u6027\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u57fa\u56e0\u8868\u8fbe\u77e9\u9635 <code>counts<\/code> \u662f\u4e00\u4e2a\u57fa\u56e0\u5728\u4f4d\u70b9\u4e0a\u7684\u8868\u8fbe\u503c\u6784\u6210\u7684\u77e9\u9635\uff0c\u5176\u884c\u4ee3\u8868\u57fa\u56e0\uff0c\u5217\u4ee3\u8868\u4f4d\u70b9\u3002\u5750\u6807\u77e9\u9635 <code>coords<\/code> \u5219\u662f\u6bcf\u4e2a\u4f4d\u70b9\u5728\u7a7a\u95f4\u4e2d\u7684\u4e8c\u7ef4\u5750\u6807\uff0c\u5176\u884c\u540d\u5fc5\u987b\u4e0e <code>counts<\/code> \u7684\u5217\u540d\u4e00\u4e00\u5bf9\u5e94\u3002\u8fd9\u79cd\u5bf9\u5e94\u5173\u7cfb\u662f\u7a7a\u95f4\u5206\u6790\u7684\u57fa\u7840\uff0c\u4efb\u4f55\u987a\u5e8f\u4e0d\u4e00\u81f4\u90fd\u4f1a\u5bfc\u81f4\u7a7a\u95f4\u7ed3\u6784\u7684\u8bef\u5224\u3002\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\uff0c\u5e94\u4f7f\u7528 <code>setequal(colnames(counts), rownames(coords))<\/code> \u6765\u5224\u65ad\u5217\u540d\u4e0e\u884c\u540d\u662f\u5426\u4e00\u81f4\u3002\u5982\u679c\u8fd4\u56de\u503c\u4e3a <code>FALSE<\/code>\uff0c\u5219\u8bf4\u660e\u5b58\u5728\u987a\u5e8f\u95ee\u9898\uff0c\u9700\u8981\u8fdb\u4e00\u6b65\u6392\u67e5\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u7528 R \u5305 SPARK \u7684 <code>sparkx(counts, coords)<\/code>\uff0c\u6309\u4f5c\u8005\u793a\u4f8b\u5c06\u57fa\u56e0\u653e\u884c\u3001\u4f4d\u70b9\u653e\u5217\uff0c\u5750\u6807\u8868\u6bcf\u884c\u4e00\u4e2a\u4f4d\u70b9\uff0c\u8bfb\u53d6\u591a\u6838\u51fd\u6570\u68c0\u9a8c\u7684\u6821\u6b63\u7ed3\u679c\u3002 <a href=\"https:\/\/xzhoulab.github.io\/SPARK\/02_SPARK_Example\/\" style=\"color:#185CB7;text-decoration:underline;\">SPARK \u4f5c\u8005\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;\">stopifnot(setequal(colnames(counts),rownames(coords)), !anyDuplicated(rownames(coords)))\nxy &lt;- as.matrix(coords[colnames(counts), , drop=FALSE])\nfit &lt;- SPARK::sparkx(counts, xy)\nhead(fit$res_mtest)\n<\/code><\/pre>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">\u56db\u4e2a\u76f8\u90bb\u4f4d\u7f6e\u7684\u76f8\u90bb\u5dee\u603b\u91cf<\/h2>\n<p style=\"margin:.5em 0 1em\">\u4e00\u7ef4\u6559\u5b66\u4f8b\u6b63\u786e\u987a\u5e8f\u3001\u9519\u4f4d\u4e0e\u5168\u53cd\u8f6c\u7684\u90bb\u70b9\u7edd\u5bf9\u5dee\u548c\u4e3a\u4e09\u3001\u4e94\u3001\u4e09\u3002\u5b8c\u5168\u53cd\u8f6c\u4f1a\u4fdd\u7559\u5c40\u90e8\u7ed3\u6784\u4e14\u98a0\u5012\u89e3\u5256\u65b9\u5411\uff0c\u6240\u4ee5\u4e00\u9879\u7edf\u8ba1\u91cf\u4e0d\u80fd\u4fdd\u8bc1\u914d\u51c6\u6b63\u786e\u3002\u4e0d\u662f SPARK-X \u7684\u68c0\u9a8c\u7edf\u8ba1\u91cf\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;- vapply(list(c(0,1,2,3),c(0,2,1,3),c(3,2,1,0)),function(v)sum(abs(diff(v))),numeric(1))\nnames(v) &lt;- c(\"\u6b63\u786e\u914d\u5bf9\", \"\u4e2d\u95f4\u6362\u4f4d\", \"\u5b8c\u5168\u53cd\u5411\")\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;\">\u6b63\u786e\u914d\u5bf9<\/td>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">3<\/td>\n<\/tr>\n<tr>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">\u4e2d\u95f4\u6362\u4f4d<\/td>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">5<\/td>\n<\/tr>\n<tr>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">\u5b8c\u5168\u53cd\u5411<\/td>\n<td style=\"border-bottom:1px solid #CBDEEB;text-align:left;padding:8px;background:#FFF;\">3<\/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-spark-practice-414c1ed1.png?resize=1120%2C690&#038;ssl=1\" alt=\"\u56db\u4e2a\u76f8\u90bb\u4f4d\u7f6e\u7684\u76f8\u90bb\u5dee\u603b\u91cf\u3002\u6b63\u786e\u914d\u5bf9 3\uff0c\u4e2d\u95f4\u6362\u4f4d 5\uff0c\u5b8c\u5168\u53cd\u5411 3\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;\">\u600e\u6837\u628a\u771f\u6b63\u7684\u5750\u6807\u91cd\u65b0\u6392\u56de\u6765\uff1f<\/h2>\n<p style=\"margin:.5em 0 1em\">\u8ba1\u6570\u5217\u987a\u5e8f\u4e3a\u4e09\u3001\u4e00\u3001\u4e8c\u65f6\uff0c\u8ddf\u968f\u5b83\u7684\u5750\u6807\u5c31\u5e94\u4e3a\u516b\u3001\u96f6\u3001\u56db\u3002\u79bb\u6563\u7684\u7a7a\u4f4d\u6216\u91cd\u590d\u6761\u7801\u8981\u5148\u89e3\u51b3\u3002\u76f4\u63a5\u628a xy \u7684\u884c\u540d\u6539\u6210\u8ba1\u6570\u5217\u540d\u53ea\u662f\u6539\u6807\u7b7e\uff0c\u5b9e\u9645\u4e0a\u6ca1\u6709\u79fb\u52a8\u5bf9\u5e94\u5750\u6807\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;\">counts_id &lt;- c(\"s3\",\"s1\",\"s2\")\nxy &lt;- c(s1=0,s2=4,s3=8)\nunname(xy[counts_id])\n<\/code><\/pre>\n<p style=\"margin:.5em 0 1em\">\u8fd9\u79cd\u987a\u5e8f\u654f\u611f\u6027\u5728\u591a\u5207\u7247\u5206\u6790\u4e2d\u66f4\u52a0\u660e\u663e\u3002\u5728\u591a\u5207\u7247\u6570\u636e\u4e2d\uff0c\u4e0d\u540c\u5207\u7247\u7684\u5750\u6807\u987a\u5e8f\u53ef\u80fd\u4e0d\u4e00\u81f4\uff0c\u9700\u8981\u8fdb\u884c\u7edf\u4e00\u6821\u6b63\u3002\u5982\u679c\u672a\u8fdb\u884c\u6821\u6b63\uff0c\u4e0d\u540c\u5207\u7247\u7684\u8868\u8fbe\u6a21\u5f0f\u53ef\u80fd\u5728\u7a7a\u95f4\u4e0a\u51fa\u73b0\u9519\u4f4d\uff0c\u5bfc\u81f4\u6574\u4f53\u7a7a\u95f4\u7ed3\u6784\u7684\u8bef\u5224\u3002\u8fd9\u79cd\u4e00\u81f4\u6027\u4e0d\u4ec5\u4f53\u73b0\u5728\u6570\u636e\u7684\u987a\u5e8f\u4e0a\uff0c\u8fd8\u4f53\u73b0\u5728\u5750\u6807\u7cfb\u7edf\u7684\u7edf\u4e00\u6027\u4e0a\u3002\u901a\u8fc7\u5408\u7406\u7684\u6821\u6b63\u6b65\u9aa4\uff0c\u53ef\u4ee5\u6709\u6548\u907f\u514d\u56e0\u5750\u6807\u987a\u5e8f\u9519\u8bef\u5bfc\u81f4\u7684\u5206\u6790\u504f\u5dee\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5982\u679c\u987a\u5e8f\u6b63\u786e\u4f46\u5206\u6790\u7ed3\u679c\u4ecd\u7136\u5f02\u5e38\uff0c\u5e94\u8fdb\u4e00\u6b65\u68c0\u67e5\u5750\u6807\u77e9\u9635\u7684\u91cd\u590d\u884c\u540d\u3002anyDuplicated(rownames(coords))` \u53ef\u4ee5\u5224\u65ad\u5750\u6807\u77e9\u9635\u662f\u5426\u5b58\u5728\u91cd\u590d\u7684\u884c\u540d\u3002\u91cd\u590d\u7684\u884c\u540d\u4f1a\u5bfc\u81f4\u5206\u6790\u65f6\u51fa\u73b0\u9519\u8bef\u5339\u914d\uff0c\u4ece\u800c\u5f71\u54cd\u7ed3\u679c\u7684\u51c6\u786e\u6027\u3002\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\uff0c\u5e94\u786e\u4fdd\u6bcf\u4e2a\u4f4d\u70b9\u7684\u5750\u6807\u884c\u540d\u552f\u4e00\uff0c\u4ee5\u907f\u514d\u56e0\u91cd\u590d\u5bfc\u81f4\u7684\u5206\u6790\u9519\u8bef\u3002\u5982\u679c\u53d1\u73b0\u91cd\u590d\u884c\u540d\uff0c\u5e94\u901a\u8fc7\u6570\u636e\u6e05\u6d17\u6b65\u9aa4\u8fdb\u884c\u5904\u7406\uff0c\u4ee5\u786e\u4fdd\u5206\u6790\u7684\u987a\u5229\u8fdb\u884c\u3002<\/p>\n<h2 style=\"margin:2em 0 .6em;color:#205CAC;font-size:1.38em;line-height:1.5;\">\u4ece SPARK \u4f5c\u8005\u7684\u7a7a\u95f4\u8ba1\u6570\u5217\u540d\u6062\u590d\u4e8c\u7ef4\u5750\u6807<\/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;\">p&lt;-tempfile()\nutils::download.file(\"https:\/\/raw.githubusercontent.com\/xzhoulab\/SPARK\/a8b4bf27b804604dfda53da42992f100b8e4e727\/data\/Layer2_BC_Count.rds\",p,mode=\"wb\",quiet=TRUE)\ne&lt;-new.env()\nload(p,envir=e)\nm&lt;-e$rawcount\nxy&lt;-do.call(rbind,strsplit(colnames(m),\"x\",fixed=TRUE))\nstorage.mode(xy)&lt;-\"double\"\nstopifnot(nrow(xy)==ncol(m),ncol(xy)==2,all(is.finite(xy)))\nc(nrow(m),ncol(m),sum(duplicated(as.data.frame(xy))|duplicated(colnames(m))))\n<\/code><\/pre>\n<p style=\"margin:.5em 0 1em\">\u7528 R 4.5.2 \u8bfb\u53d6 SPARK \u4f5c\u8005\u63d0\u4f9b\u7684\u6559\u7a0b\u6570\u636e\uff08a8b4bf27\uff09\uff0c\u8f93\u51fa\u4f9d\u6b21\u4e3a\u57fa\u56e0 14,789\uff0c\u7a7a\u95f4\u4f4d\u70b9 251\uff0c\u5750\u6807\u6216\u540d\u79f0\u91cd\u590d\u7684\u4f4d\u70b9 0\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\">\u5373\u4f7f\u884c\u6570\u76f8\u540c\uff0c\u5750\u6807\u987a\u5e8f\u9519\u4f4d\u4e5f\u4f1a\u6539\u53d8\u6574\u4e2a\u7a7a\u95f4\u56fe\u6837\u3002\u8fd0\u884c\u524d\u6838\u5bf9 <code>identical(colnames(counts), rownames(coords))<\/code> \u5e76\u753b\u4e00\u4e2a\u6807\u5fd7\u57fa\u56e0\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5728\u7a7a\u95f4\u5206\u6790\u4e2d\uff0c\u987a\u5e8f\u7684\u6b63\u786e\u6027\u5bf9\u7ed3\u679c\u7684\u5f71\u54cd\u662f\u663e\u8457\u7684\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5750\u6807\u987a\u5e8f\u9519\u8bef\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u7a7a\u95f4\u8868\u8fbe\u6a21\u5f0f\u7684\u955c\u50cf\u53cd\u8f6c\uff0c\u4ece\u800c\u5f71\u54cd\u5bf9\u8868\u8fbe\u7ed3\u6784\u7684\u5224\u65ad\u3002\u8fd9\u79cd\u53cd\u8f6c\u53ef\u80fd\u5728\u56fe\u50cf\u4e0a\u8868\u73b0\u4e3a\u8868\u8fbe\u6a21\u5f0f\u7684\u5de6\u53f3\u98a0\u5012\uff0c\u800c\u5728\u7edf\u8ba1\u4e0a\u5219\u8868\u73b0\u4e3a\u7a7a\u95f4\u76f8\u5173\u6027\u7684\u65b9\u5411\u9519\u8bef\u3002\u56e0\u6b64\uff0c\u901a\u8fc7\u8ba1\u7b97\u76f8\u90bb\u5143\u7d20\u7684\u7edd\u5bf9\u5dee\u4e4b\u548c\uff0c\u53ef\u4ee5\u5feb\u901f\u5224\u65ad\u5750\u6807\u987a\u5e8f\u662f\u5426\u6b63\u786e\u3002\u8fd9\u79cd\u5224\u65ad\u65b9\u6cd5\u7b80\u5355\u6709\u6548\uff0c\u9002\u7528\u4e8e\u521d\u6b65\u7b5b\u67e5\u987a\u5e8f\u9519\u8bef\u7684\u60c5\u51b5\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5728\u4f7f\u7528 <code>sparkx<\/code> \u51fd\u6570\u65f6\uff0c\u5982\u679c\u53d1\u73b0\u5206\u6790\u7ed3\u679c\u4e0e\u9884\u671f\u4e0d\u7b26\uff0c\u9996\u5148\u5e94\u68c0\u67e5\u8f93\u5165\u6570\u636e\u7684\u987a\u5e8f\u662f\u5426\u6b63\u786e\u3002\u901a\u8fc7 <code>identical(colnames(counts), rownames(coords))<\/code> \u53ef\u4ee5\u5feb\u901f\u5224\u65ad\u5217\u540d\u4e0e\u884c\u540d\u662f\u5426\u4e00\u81f4\u3002\u5982\u679c\u8fd4\u56de\u503c\u4e3a <code>FALSE<\/code>\uff0c\u5219\u8bf4\u660e\u5750\u6807\u987a\u5e8f\u5b58\u5728\u9519\u8bef\uff0c\u9700\u8981\u91cd\u65b0\u6392\u5e8f\u3002\u8fd9\u79cd\u9519\u8bef\u53ef\u80fd\u7531\u6570\u636e\u5bfc\u5165\u65f6\u7684\u5904\u7406\u4e0d\u5f53\u5f15\u8d77\uff0c\u4e5f\u53ef\u80fd\u7531\u624b\u52a8\u64cd\u4f5c\u4e2d\u7684\u758f\u5ffd\u9020\u6210\u3002\u5728\u6392\u67e5\u8fc7\u7a0b\u4e2d\uff0c\u5e94\u9010\u4e00\u68c0\u67e5\u6570\u636e\u7684\u5bfc\u5165\u8fc7\u7a0b\uff0c\u786e\u4fdd\u5750\u6807\u4e0e\u8868\u8fbe\u6570\u636e\u7684\u5bf9\u5e94\u5173\u7cfb\u65e0\u8bef\u3002\u8fd9\u79cd\u68c0\u67e5\u662f\u5206\u6790\u524d\u7684\u5fc5\u8981\u6b65\u9aa4\uff0c\u6709\u52a9\u4e8e\u907f\u514d\u56e0\u987a\u5e8f\u9519\u8bef\u5bfc\u81f4\u7684\u5206\u6790\u504f\u5dee\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5982\u679c\u4e0a\u8ff0\u6b65\u9aa4\u5747\u65e0\u8bef\uff0c\u4f46\u4ecd\u51fa\u73b0\u5f02\u5e38\u7ed3\u679c\uff0c\u5e94\u68c0\u67e5 <code>sparkx<\/code> \u51fd\u6570\u7684\u53c2\u6570\u8bbe\u7f6e\u3002\u4f8b\u5982\uff0c<code>option<\/code> \u53c2\u6570\u51b3\u5b9a\u4e86\u68c0\u9a8c\u7684\u6838\u51fd\u6570\u7c7b\u578b\uff0c<code>numCores<\/code> \u53c2\u6570\u5f71\u54cd\u8ba1\u7b97\u7684\u5e76\u884c\u7a0b\u5ea6\u3002\u5982\u679c\u53c2\u6570\u8bbe\u7f6e\u4e0d\u5f53\uff0c\u53ef\u80fd\u5bfc\u81f4\u68c0\u9a8c\u7ed3\u679c\u7684\u504f\u5dee\u3002\u5982\u679c\u7ed3\u679c\u5f02\u5e38\uff0c\u5e94\u901a\u8fc7\u9010\u6b65\u8c03\u8bd5\u6765\u6392\u67e5\u95ee\u9898\u6240\u5728\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5728\u591a\u5207\u7247\u5206\u6790\u4e2d\uff0c\u4e0d\u540c\u5207\u7247\u7684\u5750\u6807\u987a\u5e8f\u53ef\u80fd\u4e0d\u4e00\u81f4\uff0c\u8fd9\u79cd\u4e0d\u4e00\u81f4\u4f1a\u76f4\u63a5\u5f71\u54cd\u6574\u4f53\u7a7a\u95f4\u7ed3\u6784\u7684\u8bc6\u522b\u3002\u901a\u8fc7\u5c06\u6240\u6709\u5207\u7247\u7684\u5750\u6807\u7edf\u4e00\u6821\u6b63\uff0c\u53ef\u4ee5\u6709\u6548\u907f\u514d\u56e0\u987a\u5e8f\u4e0d\u4e00\u81f4\u5bfc\u81f4\u7684\u5206\u6790\u504f\u5dee\u3002\u8fd9\u79cd\u6821\u6b63\u8fc7\u7a0b\u9700\u8981\u786e\u4fdd\u6240\u6709\u5207\u7247\u7684\u5750\u6807\u7cfb\u7edf\u4e00\u81f4\uff0c\u4ee5\u4fdd\u8bc1\u7a7a\u95f4\u8868\u8fbe\u6a21\u5f0f\u7684\u6b63\u786e\u8bc6\u522b\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\">\u62ff\u4e00\u4e2a\u80fd\u4ece\u539f\u56fe\u627e\u5230\u9ad8\u8868\u8fbe\u533a\u57df\u7684\u57fa\u56e0\uff0c\u5148\u6309\u6761\u7801\u5c06\u8868\u8fbe\u5217\u4e0e\u5750\u6807\u884c\u8fde\u63a5\uff0c\u518d\u6545\u610f\u6253\u4e71\u5750\u6807\u4f5c\u8d1f\u5bf9\u7167\u3002\u82e5\u4e24\u5e45\u56fe\u51e0\u4e4e\u4e0d\u53d8\uff0c\u68c0\u67e5\u989c\u8272\u662f\u5426\u771f\u7684\u53d6\u81ea\u8be5\u57fa\u56e0\u3001\u7a0b\u5e8f\u662f\u5426\u6309\u540d\u79f0\u5bf9\u9f50\uff0c\u4ee5\u53ca\u663e\u793a\u5207\u7247\u65f6\u5750\u6807\u8f74\u662f\u5426\u88ab\u7ffb\u8f6c\u3002\u82e5\u771f\u5b9e\u5207\u7247\u6709\u6570\u5757\u76f8\u4e92\u5206\u79bb\u7684\u7ec4\u7ec7\uff0c\u5750\u6807\u4e0a\u7684\u8fd1\u8ddd\u79bb\u4e5f\u53ef\u80fd\u8de8\u8d8a\u7a7a\u767d\u8fb9\u754c\uff0c\u89e3\u91ca\u7a7a\u95f4\u68c0\u9a8c\u524d\u8981\u80fd\u6307\u51fa\u4fe1\u53f7\u6765\u81ea\u54ea\u4e00\u4e2a\u7ec4\u7ec7\u533a\u57df\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u628a\u5019\u9009\u533a\u57df\u7684\u539f\u59cb\u6807\u8bc6\u3001\u53c2\u8003\u7248\u672c\u3001\u8d77\u70b9\u548c\u7ec8\u70b9\u5199\u5728\u540c\u4e00\u884c\uff0c\u518d\u4ece\u4e00\u4e2a\u5177\u4f53\u5bf9\u8c61\u53cd\u67e5\u5b83\u5982\u4f55\u843d\u8fdb\u8be5\u533a\u57df\u3002\u82e5\u9700\u8981\u8f6c\u6362\u540d\u79f0\u6216\u5750\u6807\uff0c\u4fdd\u7559\u8f6c\u6362\u524d\u540e\u4e24\u4e2a\u503c\u4ee5\u53ca\u65e0\u6cd5\u5339\u914d\u7684\u6761\u76ee\u3002\u591a\u4e2a\u5bf9\u8c61\u5408\u5728\u4e00\u8d77\u4ee5\u540e\uff0c\u540d\u5b57\u76f8\u540c\u4e0d\u4ee3\u8868\u6765\u81ea\u540c\u4e00\u6ce8\u91ca\u7248\u672c\u3002\u6700\u7701\u4e8b\u7684\u9a8c\u7b97\u662f\u540c\u65f6\u67e5\u4e00\u6761\u660e\u786e\u5e94\u5f53\u547d\u4e2d\u7684\u8bb0\u5f55\u548c\u4e00\u6761\u6070\u5728\u8fb9\u754c\u5916\u7684\u8bb0\u5f55\uff0c\u540e\u8005\u80fd\u53d1\u73b0\u5355\u9760\u9633\u6027\u4f8b\u5b50\u770b\u4e0d\u51fa\u7684\u7aef\u70b9\u9519\u8bef\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u5bf9\u4e8e\u7ed3\u679c\u8868\u7684\u4e00\u884c\uff0c\u518d\u95ee\u5b83\u80fd\u4e0d\u80fd\u56de\u5230\u539f\u59cb\u8bb0\u5f55\u3002\u82e5\u4e00\u884c\u4ee3\u8868\u805a\u5408\u540e\u7684\u533a\u57df\uff0c\u8981\u8ba9\u8bfb\u8005\u67e5\u5f97\u5230\u6709\u54ea\u4e9b\u6210\u5458\u88ab\u5408\u5e76\uff0c\u91cd\u590d\u6620\u5c04\u7684\u6210\u5458\u6309\u4ec0\u4e48\u89c4\u5219\u8ba1\u7b97\u3002\u82e5\u6362\u7528\u53e6\u4e00\u4e2a\u6ce8\u91ca\u7248\u672c\uff0c\u5148\u5217\u51fa\u6d88\u5931\u3001\u65b0\u589e\u548c\u8eab\u4efd\u53ef\u5bf9\u5e94\u7684\u533a\u57df\uff0c\u533a\u57df\u8eab\u4efd\u4e0d\u540c\u7684\u884c\u4e0d\u8981\u53ea\u6309\u6392\u5e8f\u53f7\u6a2a\u5411\u62fc\u5728\u4e00\u8d77\u3002\u8fd9\u6837\u5373\u4f7f\u6700\u7ec8\u6570\u5b57\u4e0d\u540c\uff0c\u4e5f\u80fd\u786e\u5b9a\u662f\u5019\u9009\u8303\u56f4\u53d8\u4e86\uff0c\u8fd8\u662f\u540c\u4e00\u8303\u56f4\u5185\u7684\u6d4b\u91cf\u786e\u5b9e\u4e0d\u540c\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\/024-spark-code-b0e85c2a3550c9cd.zip\">\u4e0b\u8f7d\u672c\u7bc7 R \u4ee3\u7801\uff08ZIP\uff0c3.5 KiB\uff09<\/a> \u00b7 <a style=\"color:#1458a5;text-decoration:underline;\" href=\"https:\/\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/r-practice-labs\/024-spark-data-953eb0fb76129533.zip\">\u4e0b\u8f7d\u914d\u5957\u793a\u4f8b\u6570\u636e\uff08ZIP\uff0c655.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;\">024-spark<\/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\u4ece SPARK \u4f5c\u8005\u7684\u7a7a\u95f4\u8ba1\u6570\u5217\u540d\u6062\u590d\u4e8c\u7ef4\u5750\u6807\u201d\u3002Linux x86_64\u3001R 4.3.3 \u7684\u8f93\u51fa\u4e3a\u57fa\u56e0 14789\uff0c\u7a7a\u95f4\u4f4d\u70b9 251\uff0c\u5750\u6807\u6216\u540d\u79f0\u91cd\u590d\u7684\u4f4d\u70b9 0\u3002<\/p>\n<p style=\"margin:.5em 0 1em\">\u4fdd\u7559\u539f\u4f4d\u70b9\u540d\u5e76\u89e3\u6790\u51fa\u4e24\u5217\u5750\u6807\uff0c\u5c06\u4e8c\u7ef4\u5750\u6807\u91cd\u590d\u4e0e\u5b57\u7b26\u4e32\u91cd\u590d\u5206\u522b\u8ba1\u6570\u3002\u683c\u5f0f\u4e0d\u540c\u7684\u4f4d\u70b9\u540d\u4e5f\u53ef\u80fd\u4ee3\u8868\u540c\u4e00\u5bf9\u6570\u503c\u5750\u6807\u3002\u8fd9\u4e2a\u68c0\u67e5\u9002\u5408\u653e\u5728\u7a7a\u95f4\u53d8\u5f02\u6a21\u578b\u62df\u5408\u4e4b\u524d\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\">\u4f5c\u8005\u793a\u4f8b\u7528\u6a2a\u7eb5\u5750\u6807\u7f16\u7801\u8ba1\u6570\u77e9\u9635\u7684\u5217\u540d\u3002\u62c6\u5206\u8fd9\u4e9b\u5217\u540d\u5e76\u8f6c\u6362\u4e3a\u4e24\u5217\u6570\u503c\u540e\uff0c\u53ef\u4ee5\u76f4\u63a5\u6838\u5bf9\u8868\u8fbe\u91cf\u4e0e\u4f4d\u7f6e\u662f\u5426\u540c\u5e8f\u3001\u5750\u6807\u6709\u65e0\u91cd\u590d\u3002\u8fd9\u4e2a\u5b9a\u4f4d\u7ec3\u4e60\u6ca1\u6709\u5728\u6574\u5f20\u5207\u7247\u4e0a\u8fd0\u884c\u7a7a\u95f4\u57fa\u56e0\u68c0\u9a8c\u3002\u6362\u8fdb\u53e6\u4e00\u4e2a\u5e73\u53f0\u7684\u6570\u636e\u65f6\uff0c\u5e94\u8bc6\u522b\u5176\u81ea\u5df1\u7684\u6761\u7801\u6620\u5c04\uff0c\u5c24\u5176\u4e0d\u80fd\u5bf9\u4e24\u4e2a\u5bf9\u8c61\u5206\u522b\u6309\u5b57\u7b26\u6392\u5e8f\u540e\u5c31\u8ba4\u5b9a\u5b83\u4eec\u5df2\u5bf9\u9f50\u3002<\/p>\n<p style=\"border-top:1px solid #DAE6F2;margin-top:2em;padding-top:1em;\">\u5c0f\u6837\u672c\u7684\u8ba1\u6570\u548c\u5224\u65ad\u6807\u51c6\u6838\u5bf9\u6e05\u695a\u540e\uff0c\u82e5\u8981\u628a\u540c\u4e00\u6d41\u7a0b\u7528\u4e8e\u6574\u6279\u6837\u672c\uff0c\u53ef\u4ee5\u5e26\u4e0a\u8f93\u5165\u89c4\u6a21\u548c\u5df2\u7ecf\u8dd1\u901a\u7684 R \u811a\u672c\uff0c\u6309\u9879\u76ee\u5468\u671f\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>\u4e00\u7ef4\u6559\u5b66\u4f8b\u6b63\u786e\u987a\u5e8f\u3001\u9519\u4f4d\u4e0e\u5168\u53cd\u8f6c\u7684\u90bb\u70b9\u7edd\u5bf9\u5dee\u548c\u4e3a\u4e09\u3001\u4e94\u3001\u4e09\u3002<\/p>\n","protected":false},"author":1,"featured_media":68630,"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":[728,744,741],"class_list":["post-68631","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-part","category-single-cell","tag-r","tag-spark","tag-741"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2026\/11\/r-guide-spark-practice-414c1ed1.png?fit=1120%2C690&ssl=1","_links":{"self":[{"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/posts\/68631","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=68631"}],"version-history":[{"count":3,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/posts\/68631\/revisions"}],"predecessor-version":[{"id":70794,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/posts\/68631\/revisions\/70794"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/media\/68630"}],"wp:attachment":[{"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/media?parent=68631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/categories?post=68631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.biocloudservice.com\/wordpress\/wp-json\/wp\/v2\/tags?post=68631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}