{"id":345,"date":"2025-08-25T17:58:12","date_gmt":"2025-08-25T09:58:12","guid":{"rendered":"http:\/\/106.52.213.145:21080\/?p=345"},"modified":"2025-08-25T17:58:12","modified_gmt":"2025-08-25T09:58:12","slug":"shiyong-docker-bushu-r-yu-cellchatconglingkaishidewanzhengjiaocheng","status":"publish","type":"post","link":"https:\/\/apifj.com\/index.php\/2025\/08\/25\/shiyong-docker-bushu-r-yu-cellchatconglingkaishidewanzhengjiaocheng\/","title":{"rendered":"\u4f7f\u7528 Docker \u90e8\u7f72 R \u4e0e CellChat\uff1a\u4ece\u96f6\u5f00\u59cb\u7684\u5b8c\u6574\u6559\u7a0b"},"content":{"rendered":"<h1>\u4f7f\u7528 Docker \u90e8\u7f72 R \u4e0e CellChat\uff1a\u4ece\u96f6\u5f00\u59cb\u7684\u5b8c\u6574\u6559\u7a0b<\/h1>\n<p>\u5728\u5355\u7ec6\u80de\u6570\u636e\u5206\u6790\u9886\u57df\uff0c<strong>CellChat<\/strong> \u662f\u4e00\u4e2a\u5f3a\u5927\u7684 R \u5305\uff0c\u7528\u4e8e\u63a8\u65ad\u548c\u53ef\u89c6\u5316\u7ec6\u80de\u95f4\u901a\u8baf\u7f51\u7edc\u3002\u7136\u800c\uff0c\u7531\u4e8e\u5176\u4f9d\u8d56\u4f17\u591a\uff08\u5305\u62ec Bioconductor \u5305\u3001GitHub \u7b2c\u4e09\u65b9\u5305\u548c\u7cfb\u7edf\u7ea7\u5e93\uff09\uff0c\u5728\u672c\u5730\u73af\u5883\u4e2d\u5b89\u88c5\u5e38\u5e38\u4f1a\u9047\u5230\u5404\u79cd\u4f9d\u8d56\u51b2\u7a81\u6216\u7f3a\u5931\u95ee\u9898\u3002<\/p>\n<p>\u672c\u6587\u5c06\u5e26\u4f60\u4f7f\u7528 <strong>Docker<\/strong> \u6280\u672f\uff0c\u4ece\u96f6\u5f00\u59cb\u6784\u5efa\u4e00\u4e2a\u7eaf\u51c0\u3001\u53ef\u590d\u73b0\u7684 R \u73af\u5883\uff0c\u5e76\u6210\u529f\u5b89\u88c5\u548c\u8fd0\u884c <code>CellChat<\/code>\u3002\u6574\u4e2a\u8fc7\u7a0b\u65e0\u9700\u6c61\u67d3\u672c\u5730\u7cfb\u7edf\uff0c\u9002\u5408\u79d1\u7814\u3001\u5f00\u53d1\u548c\u56e2\u961f\u534f\u4f5c\u3002<\/p>\n<hr \/>\n<h2>\u2705 \u4e3a\u4ec0\u4e48\u9009\u62e9 Docker\uff1f<\/h2>\n<ul>\n<li><strong>\u73af\u5883\u9694\u79bb<\/strong>\uff1a\u907f\u514d\u6c61\u67d3\u672c\u5730 R \u73af\u5883<\/li>\n<li><strong>\u53ef\u590d\u73b0\u6027<\/strong>\uff1a\u4efb\u4f55\u4eba\u8fd0\u884c\u76f8\u540c\u955c\u50cf\u90fd\u80fd\u5f97\u5230\u4e00\u81f4\u7ed3\u679c<\/li>\n<li><strong>\u8de8\u5e73\u53f0\u517c\u5bb9<\/strong>\uff1aWindows\u3001macOS\u3001Linux \u901a\u7528<\/li>\n<li><strong>\u6613\u4e8e\u5206\u4eab<\/strong>\uff1a\u53ea\u9700\u5206\u4eab <code>Dockerfile<\/code> \u5373\u53ef\u91cd\u5efa\u73af\u5883<\/li>\n<\/ul>\n<hr \/>\n<h2>\ud83d\udc33 \u7b2c\u4e00\u6b65\uff1a\u9009\u62e9\u5408\u9002\u7684 R Docker \u955c\u50cf<\/h2>\n<p>Rocker \u9879\u76ee\uff08<a href=\"https:\/\/www.rocker-project.org\/\">Rocker Project<\/a>\uff09\u63d0\u4f9b\u4e86\u5b98\u65b9\u7ef4\u62a4\u7684 R \u955c\u50cf\u7cfb\u5217\u3002\u6211\u4eec\u6709\u4ee5\u4e0b\u4e24\u4e2a\u63a8\u8350\u9009\u9879\uff1a<\/p>\n<h3>\u2705 \u63a8\u8350 1\uff1a<code>rocker\/r-ver<\/code>\uff08\u7eaf\u51c0\u57fa\u7840\u955c\u50cf\uff09<\/h3>\n<ul>\n<li>\u4f18\u70b9\uff1a\u6700\u5c0f\u5316 R \u73af\u5883\uff0c\u9002\u5408\u81ea\u5b9a\u4e49\u6784\u5efa<\/li>\n<li>\u7f3a\u70b9\uff1a\u65e0\u9884\u88c5\u4f9d\u8d56\uff0c\u9700\u624b\u52a8\u5b89\u88c5\u6240\u6709\u7cfb\u7edf\u5e93<\/li>\n<\/ul>\n<h3>\u2705 \u63a8\u8350 2\uff1a<code>rocker\/tidyverse<\/code>\uff08\u5f3a\u70c8\u63a8\u8350\uff01\uff09<\/h3>\n<ul>\n<li>\u955c\u50cf\uff1a<code>rocker\/tidyverse:4.4<\/code><\/li>\n<li>\u4f18\u70b9\uff1a\n<ul>\n<li>\u5305\u542b <code>r-base<\/code> \u548c\u5e38\u7528 <code>tidyverse<\/code> \u5305<\/li>\n<li>\u9884\u88c5\u4e86 <code>libcurl<\/code>\u3001<code>libxml2<\/code>\u3001<code>openssl<\/code>\u3001<code>gcc<\/code> \u7b49\u5e38\u7528\u7cfb\u7edf\u4f9d\u8d56<\/li>\n<li>\u7279\u522b\u9002\u5408\u9700\u8981 <code>devtools::install_github()<\/code> \u7684\u573a\u666f<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\ud83d\udc49 <strong>\u672c\u6587\u9009\u62e9 <code>rocker\/tidyverse:4.4<\/code> \u4f5c\u4e3a\u57fa\u7840\u955c\u50cf\u3002<\/strong><\/p>\n<hr \/>\n<h2>\ud83d\udee0 \u7b2c\u4e8c\u6b65\uff1a\u542f\u52a8\u5bb9\u5668\u5e76\u8fdb\u5165\u4ea4\u4e92\u73af\u5883<\/h2>\n<pre><code class=\"language-bash\">docker run -it --name r-cellchat rocker\/tidyverse:4.4 \/bin\/bash<\/code><\/pre>\n<ul>\n<li><code>-it<\/code>\uff1a\u5f00\u542f\u4ea4\u4e92\u5f0f\u7ec8\u7aef<\/li>\n<li><code>--name r-cellchat<\/code>\uff1a\u4e3a\u5bb9\u5668\u547d\u540d\uff0c\u4fbf\u4e8e\u540e\u7eed\u64cd\u4f5c<\/li>\n<li><code>\/bin\/bash<\/code>\uff1a\u76f4\u63a5\u8fdb\u5165 bash \u800c\u975e\u9ed8\u8ba4\u7684 R \u73af\u5883<\/li>\n<\/ul>\n<hr \/>\n<h2>\ud83d\udd27 \u7b2c\u4e09\u6b65\uff1a\u5b89\u88c5\u7cfb\u7edf\u4f9d\u8d56<\/h2>\n<p>\u867d\u7136 <code>tidyverse<\/code> \u955c\u50cf\u5df2\u5305\u542b\u8bb8\u591a\u4f9d\u8d56\uff0c\u4f46\u4e3a\u4e86\u5b89\u88c5 <code>CellChat<\/code>\uff0c\u6211\u4eec\u4ecd\u9700\u8865\u5145\u4e00\u4e9b\u5173\u952e\u7cfb\u7edf\u5e93\uff1a<\/p>\n<pre><code class=\"language-bash\">apt-get update\n\napt-get install -y \\\n    libgit2-dev \\\n    libssh2-1-dev \\\n    libcurl4-openssl-dev \\\n    libssl-dev \\\n    libxml2-dev \\\n    libfontconfig1-dev \\\n    libharfbuzz-dev \\\n    libfribidi-dev \\\n    libglpk-dev  # \u5173\u952e\uff01\u89e3\u51b3 igraph \u7684 libglpk.so.40 \u95ee\u9898<\/code><\/pre>\n<blockquote>\n<p>\u26a0\ufe0f \u6ce8\u610f\uff1a<code>libglpk-dev<\/code> \u662f <code>igraph<\/code> \u7684\u5e95\u5c42\u4f9d\u8d56\uff0c\u7f3a\u5931\u4f1a\u5bfc\u81f4\u540e\u7eed\u52a0\u8f7d\u5931\u8d25\u3002<\/p>\n<\/blockquote>\n<hr \/>\n<h2>\ud83d\udce6 \u7b2c\u56db\u6b65\uff1a\u5728 R \u4e2d\u5b89\u88c5 R \u5305<\/h2>\n<p>\u8fdb\u5165 R \u73af\u5883\uff1a<\/p>\n<pre><code class=\"language-bash\">R<\/code><\/pre>\n<p>\u7136\u540e\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<h3>1. \u5b89\u88c5 <code>devtools<\/code> \u548c <code>remotes<\/code><\/h3>\n<pre><code class=\"language-r\">install.packages(c(&quot;devtools&quot;, &quot;remotes&quot;), repos = &quot;https:\/\/cloud.r-project.org&quot;)<\/code><\/pre>\n<h3>2. \u5b89\u88c5 <code>BiocManager<\/code>\uff08\u7528\u4e8e Bioconductor \u5305\uff09<\/h3>\n<pre><code class=\"language-r\">if (!require(&quot;BiocManager&quot;, quietly = TRUE)) {\n    install.packages(&quot;BiocManager&quot;, repos = &quot;https:\/\/cloud.r-project.org&quot;)\n}<\/code><\/pre>\n<h3>3. \u5b89\u88c5 CellChat \u6240\u9700\u7684 Bioconductor \u4f9d\u8d56\u5305<\/h3>\n<pre><code class=\"language-r\">BiocManager::install(c(\n    &quot;BiocBase&quot;, \n    &quot;BiocNeighbors&quot;, \n    &quot;BiocGenerics&quot;, \n    &quot;ComplexHeatmap&quot;, \n    &quot;SingleCellExperiment&quot;, \n    &quot;SummarizedExperiment&quot;\n))<\/code><\/pre>\n<blockquote>\n<p>\ud83d\udca1 \u63d0\u793a\uff1a<code>CellChat<\/code> \u4f9d\u8d56\u591a\u4e2a Bioconductor \u5305\uff0c\u5fc5\u987b\u901a\u8fc7 <code>BiocManager::install()<\/code> \u5b89\u88c5\u3002<\/p>\n<\/blockquote>\n<hr \/>\n<h2>\ud83d\udea8 \u7b2c\u4e94\u6b65\uff1a\u89e3\u51b3\u5e38\u89c1\u5b89\u88c5\u9519\u8bef<\/h2>\n<h3>\u274c \u9519\u8bef 1\uff1a<code>ERROR: dependencies \u2018ComplexHeatmap\u2019, \u2018BiocNeighbors\u2019 are not available<\/code><\/h3>\n<p><strong>\u539f\u56e0<\/strong>\uff1a\u672a\u63d0\u524d\u5b89\u88c5 Bioconductor \u4f9d\u8d56\u5305\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong>\uff1a\u5982\u4e0a\u4e00\u6b65\u6240\u793a\uff0c\u5148\u7528 <code>BiocManager::install()<\/code> \u5b89\u88c5\u6240\u6709\u4f9d\u8d56\u3002<\/p>\n<hr \/>\n<h3>\u274c \u9519\u8bef 2\uff1a<code>unable to load shared object &#039;igraph.so&#039;: libglpk.so.40: cannot open shared object file<\/code><\/h3>\n<p><strong>\u539f\u56e0<\/strong>\uff1a\u7cfb\u7edf\u7f3a\u5c11 <code>GLPK<\/code> \u7ebf\u6027\u89c4\u5212\u5e93\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong>\uff1a\u5728\u5bb9\u5668\u4e2d\u8fd0\u884c\uff1a<\/p>\n<pre><code class=\"language-bash\">apt-get install -y libglpk-dev<\/code><\/pre>\n<p>\u7136\u540e\u91cd\u65b0\u5c1d\u8bd5\u5b89\u88c5 <code>CellChat<\/code>\u3002<\/p>\n<hr \/>\n<h2>\u2705 \u7b2c\u516d\u6b65\uff1a\u6210\u529f\u5b89\u88c5 CellChat<\/h2>\n<p>\u786e\u8ba4\u6240\u6709\u4f9d\u8d56\u5df2\u5b89\u88c5\u540e\uff0c\u6267\u884c\uff1a<\/p>\n<pre><code class=\"language-r\">devtools::install_github(&quot;sqjin\/CellChat&quot;)<\/code><\/pre>\n<blockquote>\n<p>\u2705 \u5982\u679c\u4f60\u5728\u56fd\u5185\u7f51\u7edc\u73af\u5883\uff0c\u5efa\u8bae\u4f7f\u7528\u4ee3\u7406\u6216 <code>remotes::install_github()<\/code> \u914d\u5408\u955c\u50cf\u6e90\u3002<\/p>\n<\/blockquote>\n<hr \/>\n<h2>\ud83e\uddea \u7b2c\u4e03\u6b65\uff1a\u9a8c\u8bc1 CellChat \u662f\u5426\u6b63\u5e38\u5de5\u4f5c<\/h2>\n<pre><code class=\"language-r\">library(CellChat)\n\n# \u67e5\u770b CellChat \u63d0\u4f9b\u7684\u6570\u636e\u96c6\ndata(package = &quot;CellChat&quot;)\n\n# \u624b\u52a8\u4e0b\u8f7d\u793a\u4f8b\u6570\u636e\uff08\u5982\u679c\u5185\u7f6e\u6570\u636e\u7f3a\u5931\uff09\ndownload.file(\n  &quot;https:\/\/github.com\/sqjin\/CellChat\/raw\/main\/data\/pbmc.cellchat.rda&quot;,\n  destfile = &quot;\/tmp\/pbmc.cellchat.rda&quot;\n)\nload(&quot;\/tmp\/pbmc.cellchat.rda&quot;)\n\n# \u8fd0\u884c\u5b8c\u6574\u5206\u6790\u6d41\u7a0b\npbmc.cellchat &lt;- subsetCellChat(pbmc.cellchat)\npbmc.cellchat &lt;- createCellChat(object = pbmc.cellchat, group.by = &quot;idents&quot;)\npbmc.cellchat &lt;- computeCommunProb(pbmc.cellchat)\nplot(pbmc.cellchat)<\/code><\/pre>\n<p>\u5982\u679c\u56fe\u5f62\u6210\u529f\u7ed8\u5236\uff0c\u606d\u559c\u4f60\uff01\ud83c\udf89<br \/>\n\ud83d\udc49 <strong>CellChat \u5df2\u5728 Docker \u73af\u5883\u4e2d\u5b8c\u5168\u6b63\u5e38\u8fd0\u884c\uff01<\/strong><\/p>\n<hr \/>\n<h2>\ud83d\udce6 \u9644\u5f55\uff1a\u63a8\u8350\u7684 Dockerfile\uff08\u81ea\u52a8\u5316\u6784\u5efa\uff09<\/h2>\n<pre><code class=\"language-Dockerfile\">FROM rocker\/tidyverse:4.4\n\nRUN apt-get update &amp;&amp; \\\n    apt-get install -y --no-install-recommends \\\n        libgit2-dev \\\n        libssh2-1-dev \\\n        libcurl4-openssl-dev \\\n        libssl-dev \\\n        libxml2-dev \\\n        libfontconfig1-dev \\\n        libharfbuzz-dev \\\n        libfribidi-dev \\\n        libglpk-dev &amp;&amp; \\\n    rm -rf \/var\/lib\/apt\/lists\/*\n\nRUN R -e &quot; \\\n    install.packages(c(&#039;devtools&#039;, &#039;remotes&#039;), repos = &#039;https:\/\/cloud.r-project.org&#039;); \\\n    if (!require(&#039;BiocManager&#039;, quietly = TRUE)) install.packages(&#039;BiocManager&#039;); \\\n    BiocManager::install(c(&#039;BiocBase&#039;, &#039;BiocNeighbors&#039;, &#039;BiocGenerics&#039;, &#039;ComplexHeatmap&#039;, &#039;SingleCellExperiment&#039;, &#039;SummarizedExperiment&#039;)); \\\n    devtools::install_github(&#039;sqjin\/CellChat&#039;); \\\n    &quot;<\/code><\/pre>\n<p>\u6784\u5efa\u955c\u50cf\uff1a<\/p>\n<pre><code class=\"language-bash\">docker build -t cellchat-env .<\/code><\/pre>\n<p>\u8fd0\u884c\u5bb9\u5668\uff1a<\/p>\n<pre><code class=\"language-bash\">docker run -it cellchat-env R<\/code><\/pre>\n<hr \/>\n<h2>\ud83c\udfaf \u603b\u7ed3<\/h2>\n<table>\n<thead>\n<tr>\n<th>\u6b65\u9aa4<\/th>\n<th>\u5173\u952e\u70b9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u9009\u62e9\u955c\u50cf<\/td>\n<td><code>rocker\/tidyverse:4.4<\/code> \u6700\u9002\u5408\u5f00\u53d1<\/td>\n<\/tr>\n<tr>\n<td>\u7cfb\u7edf\u4f9d\u8d56<\/td>\n<td>\u5fc5\u987b\u5b89\u88c5 <code>libglpk-dev<\/code><\/td>\n<\/tr>\n<tr>\n<td>R \u5305\u5b89\u88c5<\/td>\n<td>\u5148\u88c5 <code>BiocManager<\/code> \u4f9d\u8d56\uff0c\u518d\u88c5 <code>CellChat<\/code><\/td>\n<\/tr>\n<tr>\n<td>\u9a8c\u8bc1\u5b89\u88c5<\/td>\n<td>\u4f7f\u7528\u793a\u4f8b\u6570\u636e\u6216\u624b\u52a8\u4e0b\u8f7d\u6d4b\u8bd5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 Docker \u90e8\u7f72 R \u4e0e CellChat\uff1a\u4ece\u96f6\u5f00\u59cb\u7684\u5b8c\u6574\u6559\u7a0b \u5728\u5355\u7ec6\u80de\u6570\u636e\u5206\u6790\u9886\u57df\uff0cCellChat&#8230; &raquo; <a class=\"read-more-link\" href=\"https:\/\/apifj.com\/index.php\/2025\/08\/25\/shiyong-docker-bushu-r-yu-cellchatconglingkaishidewanzhengjiaocheng\/\">\u9605\u8bfb\u5168\u6587<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-345","post","type-post","status-publish","format-standard","hentry","category-dl"],"_links":{"self":[{"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/posts\/345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/comments?post=345"}],"version-history":[{"count":1,"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/posts\/345\/revisions"}],"predecessor-version":[{"id":346,"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/posts\/345\/revisions\/346"}],"wp:attachment":[{"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/media?parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/categories?post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/tags?post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}