{"id":254,"date":"2024-11-23T09:29:29","date_gmt":"2024-11-23T01:29:29","guid":{"rendered":"https:\/\/obagg.com\/index.php\/2024\/11\/23\/%e5%8d%95%e7%bb%86%e8%83%9e-%e7%a9%ba%e9%97%b4%e6%95%b4%e5%90%88%e5%8e%bb%e6%89%b9%e6%ac%a1%e6%96%b9%e6%b3%95%e6%af%94%e8%be%83%ef%bc%882%ef%bc%89\/"},"modified":"2024-11-23T09:29:29","modified_gmt":"2024-11-23T01:29:29","slug":"%e5%8d%95%e7%bb%86%e8%83%9e-%e7%a9%ba%e9%97%b4%e6%95%b4%e5%90%88%e5%8e%bb%e6%89%b9%e6%ac%a1%e6%96%b9%e6%b3%95%e6%af%94%e8%be%83%ef%bc%882%ef%bc%89","status":"publish","type":"post","link":"https:\/\/obagg.com\/index.php\/2024\/11\/23\/%e5%8d%95%e7%bb%86%e8%83%9e-%e7%a9%ba%e9%97%b4%e6%95%b4%e5%90%88%e5%8e%bb%e6%89%b9%e6%ac%a1%e6%96%b9%e6%b3%95%e6%af%94%e8%be%83%ef%bc%882%ef%bc%89\/","title":{"rendered":"\u5355\u7ec6\u80de  &amp;  \u7a7a\u95f4\u6574\u5408\u53bb\u6279\u6b21\u65b9\u6cd5\u6bd4\u8f83\uff082\uff09"},"content":{"rendered":"<h4>\u4f5c\u8005\uff0c\u8ffd\u98ce\u5c11\u5e74i<\/h4>\n<h4>\u5f00\u5934\u5148\u653e\u4e00\u5f20marker\u8868\uff0c\u4f9b\u5927\u5bb6\u53c2\u8003<\/h4>\n<div class=\"image-package\">\n<div class=\"image-container\" style=\"max-width: 700px; max-height: 581px;\">\n<div class=\"image-view\" data-width=\"1017\" data-height=\"844\"><img decoding=\"async\" src=\"https:\/\/obagg.com\/wp-content\/uploads\/2024\/11\/frc-7b79fcdd1cb322b266b3404de8d147ee.png\"><\/div>\n<\/div>\n<div class=\"image-caption\">marker list<\/div>\n<\/div>\n<h4>\u8fd9\u4e00\u7bc7\u5185\u5bb9\u5f88\u7b80\u5355<\/h4>\n<h4>\u63a5\u4e0a\u4e00\u7bc7\uff0c\u4e0a\u4e00\u7bc7\u6587\u7ae0\u5355\u7ec6\u80de &amp; \u7a7a\u95f4\u6574\u5408\u53bb\u6279\u6b21\u65b9\u6cd5\u6bd4\u8f83\u4ecb\u7ecd\u4e86\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u6574\u5408\u53bb\u6279\u6b21\u7684\u4ee3\u7801<\/h4>\n<ul>\n<li>CCA<\/li>\n<li>merge<\/li>\n<li>SCT<\/li>\n<li>merge &amp; SCT<\/li>\n<li>merge\u52a0harmony<\/li>\n<li>SCT &amp;&amp; harmony<\/li>\n<\/ul>\n<h4>\u5173\u4e8e\u4e0a\u8ff0\u65b9\u6cd5\u6211\u53ea\u5f3a\u8c03\u4e00\u70b9\uff0c\u5c31\u662fScaleData\u7684\u65f6\u5019vars.to.regress\u7684\u4f5c\u7528\uff0c\u8fd9\u4e2a\u8981\u5f15\u8d77\u5927\u5bb6\u7684\u91cd\u89c6\u3002<\/h4>\n<h4>\u8fd9\u4e00\u7bc7\u6211\u4eec\u8981\u8fdb\u884c\u8865\u5145\uff0c\u56e0\u4e3a\u4e0a\u8ff0\u7684\u65b9\u6cd5\u4ecd\u7136\u5b58\u5728\u4e00\u5b9a\u7684\u5c40\u9650\u6027\u3002\u9762\u5bf9\u5927\u6570\u636e\u96c6\uff0c\u51e0\u5341\u4e0a\u767e\u4e07\u7684\u7ec6\u80de\u91cf\uff0c\u4e0a\u8ff0\u65b9\u6cd5\u65e0\u80fd\u4e3a\u529b\uff0cR\u8bed\u8a00\u7684\u539f\u56e0\uff0c\u5904\u7406\u8d77\u6765\u5f88\u6162\u3002<\/h4>\n<ul>\n<li>\n<h2>\n<strong>rpca<\/strong>\u7684\u65b9\u6cd5\uff1a<\/h2>\n<\/li>\n<\/ul>\n<pre><code>ifnb.list <\/code><\/pre>\n<h4>\u8fd9\u91cc\u5927\u5bb6\u8981\u6ce8\u610frpca\u7684\u65b9\u6cd5\uff0c\u5173\u4e8erpca\uff0c\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003\u6587\u7ae010X\u5355\u7ec6\u80de\u6570\u636e\u6574\u5408\u5206\u6790Seurat\u4e4brpca\uff08large data\uff0c\u7ec6\u80de\u91cf\u8d85\u8fc720\u4e07\uff09\uff0c\u539f\u7406\u6211\u90fd\u5df2\u7ecf\u8bf4\u7684\u5f88\u6e05\u695a\u4e86\u3002<\/h4>\n<ul>\n<li>\n<h2>rpca +  reference<\/h2>\n<\/li>\n<\/ul>\n<pre><code>bm280k.list <\/code><\/pre>\n<h4>\u6ce8\u610f\u8fd9\u91cc\u7684reference\u5728\u6307\u5b9a\u7684\u65f6\u5019\u4e00\u822c\u6307\u5b9a\u4e3acontrol\u6837\u672c\uff0c\u6216\u8005\u9884\u540e\u597d\u7684\u6837\u672c\u3002<\/h4>\n<ul>\n<li>\n<h2>bbknn\uff08scanpy\uff0cpython\uff09\uff0c\u8fd9\u662f\u5f88\u591a\u9ad8\u5206\u6587\u7ae0\u91c7\u7528\u7684\u5927\u7ec6\u80de\u91cf\u6574\u5408\u65b9\u6cd5<\/h2>\n<\/li>\n<\/ul>\n<pre><code>import scanpy as sc\nimport pandas as pd\nimport seaborn as sns\n\nadata_ref = sc.datasets.pbmc3k_processed()  # this is an earlier version of the dataset from the pbmc3k tutorial\nadata = sc.datasets.pbmc68k_reduced()\n####\u6ce8\u610f\u8fd9\u91cc\u7684\u4e0d\u540c\uff0c\u9ad8\u53d8\u57fa\u56e0\u53d6\u4ea4\u96c6\nvar_names = adata_ref.var_names.intersection(adata.var_names)\nadata_ref = adata_ref[:, var_names]\nadata = adata[:, var_names]\n####ref\u6570\u636e\u9884\u5904\u7406\nsc.pp.pca(adata_ref)\nsc.pp.neighbors(adata_ref)\nsc.tl.umap(adata_ref)\n\nsc.tl.ingest(adata, adata_ref, obs='louvain')\nadata.uns['louvain_colors'] = adata_ref.uns['louvain_colors']  # fix colors\n\nadata_concat = adata_ref.concatenate(adata, batch_categories=['ref', 'new'])\nadata_concat.obs.louvain = adata_concat.obs.louvain.astype('category')\nadata_concat.obs.louvain.cat.reorder_categories(adata_ref.obs.louvain.cat.categories, inplace=True)  # fix category ordering\nadata_concat.uns['louvain_colors'] = adata_ref.uns['louvain_colors']  # fix category colors\n\n####\u91c7\u7528bbknn\u77eb\u6b63\u6279\u6b21\nsc.tl.pca(adata_concat)\nsc.external.pp.bbknn(adata_concat, batch_key='batch')\n####\u7136\u540e\u8fdb\u884c\u6807\u51c6\u8fc7\u7a0b\u5373\u53ef\uff0c\u591a\u6837\u672c\u5c31\u662f\u4e0d\u505c\u7684\u8fed\u4ee3\u8fd9\u4e2a\u8fc7\u7a0b\u3002\n<\/code><\/pre>\n<h4>python\u7248\u672c\u5927\u7ec6\u80de\u91cfharmony\u77eb\u6b63\u3002<\/h4>\n<pre><code>import scanpy as sc\nimport scanpy.external as sce\n####\u5927\u5bb6\u8bfb\u53d6\u81ea\u5df1\u7684\u6570\u636e\nadata = sc.datasets.pbmc3k()\nsc.pp.recipe_zheng17(adata)\nsc.tl.pca(adata)\n####\u77eb\u6b63\u6279\u6b21\nsce.pp.harmony_integrate(adata, 'sample')\nsc.pp.neighbors(adata)\nsc.tl.umap(adata)\n<\/code><\/pre>\n<p>\u5176\u4e2dsce.pp.harmony_integrate(adata, &#8216;sample&#8217;)\u8fd9\u53e5\u5176\u5b9e\u5c31\u662f\u4e0b\u9762\u8fd9\u4e2a\u8c03\u7528\u4e0b\u9762\u7684\u8bed\u53e5<\/p>\n<pre><code>import harmonypy\nharmony_out = harmonypy.run_harmony(adata.obsm[\"X_pca\"], adata.obs, 'batch')\nadata.obsm[adjusted_basis] = harmony_out.Z_corr.T ###obsm\u5c31\u662f\u964d\u7ef4\u7684\u6570\u636e\n<\/code><\/pre>\n<h4>\u5927\u6837\u672c\u91cf\u8fd8\u662f\u63a8\u8350scanpy\u505a\u5206\u6790\uff0cbbknn\u6216\u8005harmony\u77eb\u6b63\u3002<\/h4>\n<p><strong>\u751f\u6d3b\u5f88\u597d\uff0c\u6709\u4f60\u66f4\u597d<\/strong><\/p>\n<p>Please credit: <a href=\"https:\/\/obagg.com\">OBA Blog<\/a> &raquo; <a href=\"https:\/\/obagg.com\/index.php\/2024\/11\/23\/%e5%8d%95%e7%bb%86%e8%83%9e-%e7%a9%ba%e9%97%b4%e6%95%b4%e5%90%88%e5%8e%bb%e6%89%b9%e6%ac%a1%e6%96%b9%e6%b3%95%e6%af%94%e8%be%83%ef%bc%882%ef%bc%89\/\">\u5355\u7ec6\u80de  &amp;  \u7a7a\u95f4\u6574\u5408\u53bb\u6279\u6b21\u65b9\u6cd5\u6bd4\u8f83\uff082\uff09<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff0c\u8ffd\u98ce\u5c11\u5e74i \u5f00\u5934\u5148\u653e\u4e00\u5f20marker\u8868\uff0c\u4f9b\u5927\u5bb6\u53c2\u8003 marker list \u8fd9\u4e00\u7bc7\u5185\u5bb9\u5f88\u7b80\u5355 \u63a5\u4e0a\u4e00\u7bc7\uff0c\u4e0a\u4e00\u7bc7\u6587\u7ae0\u5355\u7ec6\u80de &amp; \u7a7a\u95f4\u6574\u5408\u53bb\u6279\u6b21\u65b9\u6cd5\u6bd4\u8f83\u4ecb\u7ecd\u4e86\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u6574\u5408\u53bb\u6279\u6b21\u7684\u4ee3\u7801 CCA merge SCT merge &amp; SCT merge\u52a0harmony SCT &amp;&amp; harmony \u5173\u4e8e\u4e0a\u8ff0\u65b9\u6cd5\u6211\u53ea\u5f3a\u8c03\u4e00\u70b9\uff0c\u5c31\u662fScaleData\u7684\u65f6\u5019vars.to.regress\u7684\u4f5c\u7528\uff0c\u8fd9\u4e2a\u8981\u5f15\u8d77\u5927\u5bb6\u7684\u91cd\u89c6\u3002 \u8fd9\u4e00\u7bc7\u6211\u4eec\u8981\u8fdb\u884c\u8865\u5145\uff0c\u56e0\u4e3a\u4e0a\u8ff0\u7684\u65b9\u6cd5\u4ecd\u7136\u5b58\u5728\u4e00\u5b9a\u7684\u5c40\u9650\u6027\u3002\u9762\u5bf9\u5927\u6570\u636e\u96c6\uff0c\u51e0\u5341\u4e0a\u767e\u4e07\u7684\u7ec6\u80de\u91cf\uff0c\u4e0a\u8ff0\u65b9\u6cd5\u65e0\u80fd\u4e3a\u529b\uff0cR\u8bed\u8a00\u7684\u539f\u56e0\uff0c\u5904\u7406\u8d77\u6765\u5f88\u6162\u3002 rpca\u7684\u65b9\u6cd5\uff1a ifnb.list \u8fd9\u91cc\u5927\u5bb6\u8981\u6ce8\u610frpca\u7684\u65b9\u6cd5\uff0c\u5173\u4e8erpca\uff0c\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003\u6587\u7ae010X\u5355\u7ec6\u80de\u6570\u636e\u6574\u5408\u5206\u6790Seurat\u4e4brpca\uff08large data\uff0c\u7ec6\u80de\u91cf\u8d85\u8fc720\u4e07\uff09\uff0c\u539f\u7406\u6211\u90fd\u5df2\u7ecf\u8bf4\u7684\u5f88\u6e05\u695a\u4e86\u3002 rpca + reference bm280k.list \u6ce8\u610f\u8fd9\u91cc\u7684reference\u5728\u6307\u5b9a\u7684\u65f6\u5019\u4e00\u822c\u6307\u5b9a\u4e3acontrol\u6837\u672c\uff0c\u6216\u8005\u9884\u540e\u597d\u7684\u6837\u672c\u3002 bbknn\uff08scanpy\uff0cpython\uff09\uff0c\u8fd9\u662f\u5f88\u591a\u9ad8\u5206\u6587\u7ae0\u91c7\u7528\u7684\u5927\u7ec6\u80de\u91cf\u6574\u5408\u65b9\u6cd5 import scanpy as sc import pandas as pd import seaborn as sns adata_ref = sc.datasets.pbmc3k_processed() # this is an earlier version of the dataset from the pbmc3k tutorial adata = sc.datasets.pbmc68k_reduced() ####\u6ce8\u610f\u8fd9\u91cc\u7684\u4e0d\u540c\uff0c\u9ad8\u53d8\u57fa\u56e0\u53d6\u4ea4\u96c6 var_names = adata_ref.var_names.intersection(adata.var_names) adata_ref = adata_ref[:, var_names] adata = adata[:, var_names] ####ref\u6570\u636e\u9884\u5904\u7406 sc.pp.pca(adata_ref) sc.pp.neighbors(adata_ref) sc.tl.umap(adata_ref) sc.tl.ingest(adata, adata_ref, obs=&#8217;louvain&#8217;) adata.uns[&#8216;louvain_colors&#8217;] = adata_ref.uns[&#8216;louvain_colors&#8217;] # fix colors adata_concat = adata_ref.concatenate(adata, batch_categories=[&#8216;ref&#8217;, &#8216;new&#8217;]) adata_concat.obs.louvain = adata_concat.obs.louvain.astype(&#8216;category&#8217;) adata_concat.obs.louvain.cat.reorder_categories(adata_ref.obs.louvain.cat.categories, inplace=True) # fix category ordering adata_concat.uns[&#8216;louvain_colors&#8217;] = adata_ref.uns[&#8216;louvain_colors&#8217;] # fix category colors ####\u91c7\u7528bbknn\u77eb\u6b63\u6279\u6b21 sc.tl.pca(adata_concat) sc.external.pp.bbknn(adata_concat, batch_key=&#8217;batch&#8217;) ####\u7136\u540e\u8fdb\u884c\u6807\u51c6\u8fc7\u7a0b\u5373\u53ef\uff0c\u591a\u6837\u672c\u5c31\u662f\u4e0d\u505c\u7684\u8fed\u4ee3\u8fd9\u4e2a\u8fc7\u7a0b\u3002 python\u7248\u672c\u5927\u7ec6\u80de\u91cfharmony\u77eb\u6b63\u3002 import scanpy as sc import scanpy.external as sce ####\u5927\u5bb6\u8bfb\u53d6\u81ea\u5df1\u7684\u6570\u636e adata = sc.datasets.pbmc3k() [&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],"tags":[],"class_list":["post-254","post","type-post","status-publish","format-standard","hentry","category-share"],"_links":{"self":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/posts\/254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/comments?post=254"}],"version-history":[{"count":0,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/posts\/254\/revisions"}],"wp:attachment":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/media?parent=254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/categories?post=254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/tags?post=254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}