{"id":438,"date":"2023-08-16T14:16:00","date_gmt":"2023-08-16T06:16:00","guid":{"rendered":"https:\/\/blog.ineuro.net\/?p=438"},"modified":"2023-09-08T13:26:33","modified_gmt":"2023-09-08T05:26:33","slug":"%e5%8d%95%e7%bb%86%e8%83%9e%e6%b5%8b%e5%ba%8f%ef%bc%88%e4%b8%89%ef%bc%89%ef%bc%9a%e5%af%bb%e6%89%be%e7%bb%86%e8%83%9e%e6%a0%87%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/blog.ineuro.net\/index.php\/2023\/08\/16\/438\/","title":{"rendered":"\u5355\u7ec6\u80de\u6d4b\u5e8f\uff08\u4e09\uff09\uff1a\u5bfb\u627e\u7ec6\u80de\u6807\u8bb0"},"content":{"rendered":"<h1>\u4e00\u3001\u4e9a\u7fa4\u6ce8\u91ca<\/h1>\n<p>\u660e\u786e\u7ec6\u80de\u7c7b\u578b\u3002<\/p>\n<p>1.\u8bc6\u522b\u6bcf\u4e2a\u7c7b\u7fa4\u7684\u6240\u6709\u6807\u8bb0\u7269\uff1b<\/p>\n<p>2.\u8bc6\u522b\u6bcf\u4e2a\u7c7b\u7fa4\u7684\u4fdd\u7559\u6807\u8bb0\uff1b<\/p>\n<p>3.\u7279\u5b9a\u7c7b\u7fa4\u7684\u6807\u8bb0\u8bc6\u522b\u3002<\/p>\n<h2>1. \u603b\u4f53\u4ee3\u7801<\/h2>\n<pre><code class=\"language-R\">markers &lt;- FindAllMarkers(object = scRNA_harmony, test.use=&quot;wilcox&quot; ,\n                          only.pos = TRUE,\n                          logfc.threshold = 0.25)   \n\nall_markers &lt;- markers %&gt;% dplyr::select(gene, everything()) %&gt;% subset(p_val&lt;0.05)\ntop10 = all_markers %&gt;% group_by(cluster) %&gt;% top_n(n = 10, wt = avg_log2FC)\nscRNA_harmony &lt;- RenameIdents(scRNA_harmony, &quot;12&quot; = &quot;Macrophage&quot;,&quot;0&quot;=&quot;Macrophage&quot;,&quot;2&quot;=&quot;MSc&quot;)\nDimPlot(scRNA_harmony,label = T,group.by = &quot;seurat_clusters&quot;)<\/code><\/pre>\n<h2>2. select()<\/h2>\n<p>\u4f7f\u7528select()\u51fd\u6570\u9009\u62e9\u5217<\/p>\n<p><code>select(\u6570\u636e\u6846\u540d\u79f0\uff0c\u7b5b\u9009\u7684\u5217)<\/code><\/p>\n<p>(1)\u9009\u62e9\u547d\u4e2d\u7684\u5217\uff1b\uff082\uff09\u9009\u62e9\u4e24\u8005\u4e4b\u95f4\u7684\u6240\u6709\u5217\uff1b\uff083\uff09\u9009\u62e9\u4e24\u8005\u4e4b\u5916\u7684\u6240\u6709\u5217<\/p>\n<p>\uff084\uff09\u642d\u914d\u4f7f\u7528\u51fd\u6570<\/p>\n<ul>\n<li>start_with(&quot;xxx&quot;) \u5339\u914d\u51fa\u5217\u540d\u79f0\u5f00\u5934\u662fxxx\u7684\u5217<\/li>\n<li>ends_with(&quot;xxx&quot;) \u5339\u914d\u51fa\u5217\u540d\u79f0\u672b\u5c3e\u662fxxx\u7684\u5217<\/li>\n<li>contains(&quot;xxx&quot;) \u5339\u914d\u51fa\u5217\u4e2d\u5305\u542bxxx\u7684\u5217<\/li>\n<li>matches(&quot;&quot;(.)\\1&quot;)&quot;) \u5339\u914d\u51fa\u5217\u540d\u79f0\u4e2d\u6709\u91cd\u590d\u5b57\u7b26\u7684\u53d8\u91cf<\/li>\n<li>num_range(&quot;xxx&quot;)<\/li>\n<li>everything() \u5c06\u9009\u4e2d\u7684\u5217\u79fb\u52a8\u5230\u6570\u636e\u6846\u5f00\u5934\u51e0\u5217<\/li>\n<\/ul>\n<p>Tidyverse \u9009\u62e9\u5b9e\u73b0\u4e86 R \u7684\u4e00\u79cd\u65b9\u8a00\uff0c\u5176\u4e2d\u7684\u8fd0\u7b97\u7b26\u53ef\u4ee5\u65b9\u4fbf\u5730\u9009\u62e9\u53d8\u91cf\uff1a<\/p>\n<p><code>: \u7528\u4e8e\u9009\u62e9\u4e00\u7cfb\u5217\u8fde\u7eed\u53d8\u91cf\u3002<\/code><\/p>\n<p><code>! \u7528\u4e8e\u53d6\u4e00\u7ec4\u53d8\u91cf\u7684\u8865\u96c6\u3002<\/code><\/p>\n<p><code>&amp; \u548c | \u7528\u4e8e\u9009\u62e9\u4e24\u7ec4\u53d8\u91cf\u7684\u4ea4\u96c6\u6216\u8054\u5408\u3002<\/code><\/p>\n<p><code>c() \u7528\u4e8e\u5408\u5e76\u9009\u62e9\u3002<\/code><\/p>\n<h2>3. top_n<\/h2>\n<p>top_n() \u5df2\u88ab slice_min()\/slice_max() \u6240\u53d6\u4ee3\u3002\u867d\u7136\u5728\u4e0d\u4e45\u7684\u5c06\u6765\u5b83\u4e0d\u4f1a\u88ab\u5f03\u7528\uff0c\u4f46\u5b83\u7684\u9000\u5f79\u610f\u5473\u7740\u6211\u4eec\u5c06\u53ea\u6267\u884c\u5173\u952e\u7684\u9519\u8bef\u4fee\u590d\uff0c\u56e0\u6b64\u5efa\u8bae\u4f7f\u7528\u8f83\u65b0\u7684\u66ff\u4ee3\u65b9\u6848\u3002top_n()\u4e4b\u6240\u4ee5\u88ab\u53d6\u4ee3\uff0c\u662f\u56e0\u4e3a\u5b83\u7684\u540d\u79f0\u5bb9\u6613\u5f15\u8d77\u6df7\u6dc6\uff0c\u56e0\u4e3a\u5b83\u8fd4\u56de\u7684\u662f\u4f60\u6709\u7406\u7531\u8ba4\u4e3a\u662f\u6700\u5e95\u5c42\u7684\u884c\u3002\u6b64\u5916\uff0cwt \u53d8\u91cf\u7684\u540d\u79f0\u548c\u9ed8\u8ba4\u503c\uff08\u6570\u636e\u5e27\u7684\u6700\u540e\u4e00\u5217\uff09\u4e5f\u4ee4\u4eba\u56f0\u60d1\u3002\u9057\u61be\u7684\u662f\uff0c\u5f00\u53d1\u8005\u65e0\u6cd5\u5728\u4e0d\u7834\u574f\u73b0\u6709\u4ee3\u7801\u7684\u60c5\u51b5\u4e0b\u4fee\u590d\u73b0\u6709\u7684 top_n()\u51fd\u6570\uff0c\u56e0\u6b64\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u7684\u66ff\u4ee3\u51fd\u6570\u3002<\/p>\n<p><code>top_n(x, n, wt)<\/code><\/p>\n<h2>4.group_by()<\/h2>\n<p>group_by()\u51fd\u6570\u5c5e\u4e8eR\u7f16\u7a0b\u8bed\u8a00\u4e2d\u7684dplyr\u5305\uff0c\u5b83\u5bf9\u6570\u636e\u5e27\u8fdb\u884c\u5206\u7ec4\u3002Group_by()\u51fd\u6570\u672c\u8eab\u4e0d\u4f1a\u4ea7\u751f\u4efb\u4f55\u8f93\u51fa\u3002<\/p>\n<p>\u8fdb\u884cgroup_by\u64cd\u4f5c\u4e4b\u540e\uff0c\u6574\u4e2a\u6570\u636e\u8868\u5c31\u5904\u4e8e\u4e00\u79cd\u5206\u7ec4\u7684\u72b6\u6001\uff0c\u6240\u6709\u7684\u64cd\u4f5c\u90fd\u662f\u57fa\u4e8e\u5206\u7ec4\u8fdb\u884c\uff0c\u4e5f\u5c31\u662f\u4f1a\u5206\u522b\u5bf9\u7ec4\u5185\u7684\u6570\u636e\u64cd\u4f5c\u3002\u8fdb\u884c\u5206\u7ec4\u8fd0\u7b97\u4ee5\u540e\uff0c\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u91cd\u65b0\u5206\u7ec4\uff0c\u6216\u8005\u5c31\u53ef\u4ee5\u76f4\u63a5\u53d6\u6d88\u5206\u7ec4\u505a\u5176\u4ed6\u64cd\u4f5c\u4e86\uff0c\u4f7f\u7528<code>ungroup()<\/code>\u51fd\u6570\u3002<\/p>\n<h1>\u4e8c\u3001FIndConservedMarkers<\/h1>\n<pre><code class=\"language-R\">install.packages(&#039;BiocManager&#039;)\nBiocManager::install(&#039;multtest&#039;)\ninstall.packages(&#039;metap&#039;)\n\nncolnames(scRNA_harmony@meta.data)\ntable(scRNA_harmony@meta.data$orig.ident)\n?FindConservedMarkers\nmarker_conserved = FindConservedMarkers(scRNA_harmony,\n                              ident.1 = &#039;Macrophage&#039;,\n                              grouping.var = &quot;orig.ident&quot;,\n                              only.pos = TRUE,\n                              min.diff.pct = 0.25,\n                              min.pct = 0.25,\n                              logfc.threshold = 0.25)\n\nDotPlot(scRNA_harmony, features = c(&quot;PECAM1&quot;,&quot;VWF&quot;))\nDimPlot(scRNA_harmony,label = T,group.by = &quot;celltype&quot;)<\/code><\/pre>\n<h2>\u4e09\u3001Dotplot\u6cd5<\/h2>\n<p><code>DotPlot(scRNA_harmony, features = c(&quot;PECAM1&quot;,&quot;VWF&quot;))<\/code><\/p>\n<p><img alt=\"\u56fe\u7247[1]-\u5403\u4e86\u5403\u4e86\" decoding=\"async\" src=\"https:\/\/cdn.ineuro.net\/cloudreve%2F2023%2F08%2F16%2FMDk9rwBp_Dimplot.png\"  \/><\/p>\n<p>\u53ef\u4ee5\u89c2\u5bdf\u5230Cluster 6\u4e24\u57fa\u56e0\u8868\u8fbe\u8f83\u9ad8\uff0c\u7ed3\u5408\u6587\u732e\uff0c\u53ef\u786e\u5b9aCluster 6\u4e3a\u5185\u76ae\u7ec6\u80de\u3002<\/p>\n<h2>\u56db\u3001\u62a5\u9519\u89e3\u51b3<\/h2>\n<p>\u5b89\u88c5<code>metap<\/code>\u65f6\uff0c\u63d0\u793a\uff1a<\/p>\n<p><code>fatal error: fftw3.h: No such file or directory    10 | #include &lt;fftw3.h&gt;<\/code><\/p>\n<p>\u8868\u660e\u7cfb\u7edf\u4e2d\u6240\u9700\u4f9d\u8d56\u7f3a\u5931\uff0c\u5728terminal\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4<\/p>\n<p><code>sudo apt-get install libfftw3-dev<\/code><\/p>\n<p>\u5b89\u88c5singleR\u65f6\uff0c\u63d0\u793a<\/p>\n<pre><code>ERROR: failed to lock directory \u2018\/home\/drqux\/R\/x86_64-pc-linux-gnu-library\/4.3\u2019 for modifying\nTry removing \u2018\/home\/drqux\/R\/x86_64-pc-linux-gnu-library\/4.3\/00LOCK-rsvd\u2019<\/code><\/pre>\n<p>\u8868\u660eR\u5305\u6240\u5b89\u88c5\u6587\u4ef6\u5939\u4e2d\u5b58\u5728\u4e34\u65f6\u6587\u4ef6\u593900LOCK-rsvd\uff0c\u624b\u52a8\u79fb\u9664\u76f8\u5173\u6587\u4ef6\u5939\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u4e9a\u7fa4\u6ce8\u91ca \u660e\u786e\u7ec6\u80de\u7c7b\u578b\u3002 1.\u8bc6\u522b\u6bcf\u4e2a\u7c7b\u7fa4\u7684\u6240\u6709\u6807\u8bb0\u7269\uff1b 2.\u8bc6\u522b\u6bcf\u4e2a\u7c7b\u7fa4\u7684\u4fdd\u7559\u6807\u8bb0\uff1b 3.\u7279\u5b9a\u7c7b\u7fa4\u7684\u6807\u8bb0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,24],"tags":[],"topics":[],"_links":{"self":[{"href":"https:\/\/blog.ineuro.net\/index.php\/wp-json\/wp\/v2\/posts\/438"}],"collection":[{"href":"https:\/\/blog.ineuro.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ineuro.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ineuro.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ineuro.net\/index.php\/wp-json\/wp\/v2\/comments?post=438"}],"version-history":[{"count":2,"href":"https:\/\/blog.ineuro.net\/index.php\/wp-json\/wp\/v2\/posts\/438\/revisions"}],"predecessor-version":[{"id":440,"href":"https:\/\/blog.ineuro.net\/index.php\/wp-json\/wp\/v2\/posts\/438\/revisions\/440"}],"wp:attachment":[{"href":"https:\/\/blog.ineuro.net\/index.php\/wp-json\/wp\/v2\/media?parent=438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ineuro.net\/index.php\/wp-json\/wp\/v2\/categories?post=438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ineuro.net\/index.php\/wp-json\/wp\/v2\/tags?post=438"},{"taxonomy":"topics","embeddable":true,"href":"https:\/\/blog.ineuro.net\/index.php\/wp-json\/wp\/v2\/topics?post=438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}