{"id":60823,"date":"2024-09-12T15:02:01","date_gmt":"2024-09-12T07:02:01","guid":{"rendered":"http:\/\/www.biocloudservice.com\/wordpress\/?p=60823"},"modified":"2024-09-12T15:02:01","modified_gmt":"2024-09-12T07:02:01","slug":"%e7%a9%ba%e9%97%b4%e8%bd%ac%e5%bd%95%e7%bb%84%e5%ad%a6%e6%95%b0%e6%8d%ae%e5%a4%84%e7%90%86%e5%8f%aa%e4%be%9d%e8%b5%96r%e8%af%ad%e8%a8%80%ef%bc%9f%e8%ae%a9%e6%88%91%e4%bb%ac%e4%bb%8escanpy%e5%bc%80","status":"publish","type":"post","link":"http:\/\/www.biocloudservice.com\/wordpress\/?p=60823","title":{"rendered":"\u7a7a\u95f4\u8f6c\u5f55\u7ec4\u5b66\u6570\u636e\u5904\u7406\u53ea\u4f9d\u8d56R\u8bed\u8a00\uff1f\u8ba9\u6211\u4eec\u4ecescanpy\u5f00\u59cb\uff0c\u62e5\u62b1python\u5427\uff01"},"content":{"rendered":"\n<p><strong>\u524d\u8a00<\/strong><strong><\/strong><\/p>\n\n\n\n<p>\u7a7a\u95f4\u8f6c\u5f55\u7ec4\u5b66\u5206\u6790\uff0c\u662f\u8fd1\u51e0\u5e74\u7684\u4e00\u4e2a\u70ed\u70b9\u3002\u76f8\u4fe1\u5c0f\u4f19\u4f34\u4eec\u5bf9\u4e8eseurat\u518d\u719f\u6089\u4e0d\u8fc7\u4e86\uff01\u4f46\u662fseurat\u662f\u57fa\u4e8eR\u8bed\u8a00\u751f\u6001\u6765\u8fdb\u884c\u6570\u636e\u5904\u7406\u7684\uff0c\u6570\u636e\u5904\u7406\u8d77\u6765\u5b9e\u5728\u662f\u592a\u9ebb\u70e6\u4e86\uff01Python\u5728\u56fe\u50cf\u8bc6\u522b\u3001\u7a7a\u95f4\u5206\u5272\u548c\u53bb\u5377\u79ef\u7b49\u7b97\u6cd5\u9886\u57df\u62e5\u6709\u7edd\u5bf9\u7684\u4f18\u52bf\uff01Scanpy\u662f\u57fa\u4e8epython\u7684\u5355\u7ec6\u80de\u5206\u6790\u5de5\u5177\u5305\uff0c\u6c5f\u6e56\u5730\u4f4d\u76f8\u5f53\u4e8eR\u8bed\u8a00\u4e2d\u7684seurat\u3002\u91cd\u8981\u7a0b\u5ea6\u4e0d\u7528\u6211\u591a\u8bf4\u4e86\u5427\uff01\u6ca1\u63a5\u89e6\u8fc7python\u7684\u5c0f\u4f19\u4f34\u4eec\u4e5f\u4e0d\u8981\u5bb3\u6015\u54e6\uff01\u5b83\u4e0eseurat\u7684\u5206\u6790\u6d41\u7a0b\u57fa\u672c\u4e00\u81f4\uff0c\u90fd\u662f\u8d28\u63a7-\u9009\u62e9\u9ad8\u53d8\u57fa\u56e0-PCA\u964d\u7ef4-\u805a\u7c7b-UMAP(tSNE)\u964d\u7ef4\u8fd9\u4e9b\u6b65\u9aa4\u3002\u6ca1\u6709\u65f6\u95f4\u5b66\u4e60\u7684\u5c0f\u4f19\u4f34\u4eec\u4e5f\u4e0d\u8981\u7740\u6025\u54e6\uff01\u6709\u9700\u8981\u751f\u4fe1\u5206\u6790\u7684\u5c0f\u4f19\u4f34\u4eec\u4e5f\u53ef\u4ee5\u627e\u5c0f\u4e91\u54e6\uff01\u7ec3\u4e86\u5341\u5e74\u751f\u4fe1\u5206\u6790\u7684\u5c0f\u4e91\u5bf9\u4e8e\u751f\u4fe1\u5206\u6790\u77e5\u8bc6\u5df2\u7ecf\u5982\u9c7c\u5f97\u6c34\u4ece\u5206\u6790\u5230\u53ef\u89c6\u5316\u76f4\u5230\u4f60\u6ee1\u610f\u4e3a\u6b62\uff01<\/p>\n\n\n\n<p>\u751f\u4fe1\u6570\u636e\u5904\u7406\u8d77\u6765\u5360\u7528\u5185\u5b58\u5b9e\u5728\u592a\u5927\u4e86\uff0c\u653e\u8fc7\u81ea\u5df1\u7684\u7535\u8111\u5427\uff01\u5c0f\u4e91\u5728\u8fd9\u91cc\u7ed9\u5927\u5bb6\u9001\u4e0a\u798f\u5229\u4e86\uff0c\u6709\u9700\u8981\u670d\u52a1\u5668\u7684\u5c0f\u4f19\u4f34\u4eec\uff0c\u6b22\u8fce\u5927\u5bb6\u8054\u7cfb\u5c0f\u4e91\uff0c\u4fdd\u8bc1\u670d\u52a1\u5668\u7684\u6027\u4ef7\u6bd4\u6700\u9ad8\u54e6\uff01<\/p>\n\n\n\n<p><strong>\u4ee3\u7801\u6559\u7a0b<\/strong><strong><\/strong><\/p>\n\n\n\n<p><strong>1.\u5bfc\u5165\u76f8\u5173\u7684\u5e93<\/strong><strong><\/strong><\/p>\n\n\n\n<p>import scanpy as sc<\/p>\n\n\n\n<p>import pandas as pd<\/p>\n\n\n\n<p>import matplotlib.pyplot as plt<\/p>\n\n\n\n<p>import seaborn as sns<\/p>\n\n\n\n<p>sc.logging.print_versions()<\/p>\n\n\n\n<p>sc.set_figure_params(facecolor=&#8221;white&#8221;, figsize=(8, 8))<\/p>\n\n\n\n<p>sc.settings.verbosity = 3<\/p>\n\n\n\n<p><strong>2.\u8bfb\u53d6\u6570\u636e<\/strong><strong><\/strong><\/p>\n\n\n\n<p>\u6211\u4eec\u5c06\u4f7f\u7528\u4eba\u7c7b\u6dcb\u5df4\u7ed3\u7684&nbsp;Visium \u7a7a\u95f4\u8f6c\u5f55\u7ec4\u5b66\u6570\u636e\u96c6\u3002\u51fd\u6570&nbsp;datasets.visium_sge\uff08\uff09 \u4ece 10x Genomics \u4e0b\u8f7d\u6570\u636e\u96c6\u5e76\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u8ba1\u6570\u3001\u56fe\u50cf\u548c\u7a7a\u95f4\u5750\u6807\u7684\u5bf9\u8c61\u3002\u4f7f\u7528\u60a8\u81ea\u5df1\u7684&nbsp;Visium \u6570\u636e\u65f6\uff0c\u8bf7\u4f7f\u7528 sc.read_visium\uff08\uff09 \u51fd\u6570\u5bfc\u5165\u5b83\u3002<\/p>\n\n\n\n<p>adata = sc.datasets.visium_sge(sample_id=&#8221;V1_Human_Lymph_Node&#8221;)<\/p>\n\n\n\n<p>adata.var_names_make_unique()<\/p>\n\n\n\n<p>adata.var[&#8220;mt&#8221;] = adata.var_names.str.startswith(&#8220;MT-&#8220;)<\/p>\n\n\n\n<p>sc.pp.calculate_qc_metrics(adata, qc_vars=[&#8220;mt&#8221;], inplace=True)<\/p>\n\n\n\n<p>adata<\/p>\n\n\n\n<p><strong>3. \u8d28\u91cf\u63a7\u5236\u548c\u9884\u5904\u7406<\/strong><strong><\/strong><\/p>\n\n\n\n<p>\u6211\u4eec\u6839\u636e\u603b\u6570\u548c\u8868\u8fbe\u57fa\u56e0\u5bf9\u6837\u672c\u8fdb\u884c\u4e00\u4e9b\u57fa\u672c\u7684\u8fc7\u6ee4<\/p>\n\n\n\n<p>fig, axs = plt.subplots(1, 4, figsize=(15, 4))<\/p>\n\n\n\n<p>sns.histplot(adata.obs[&#8220;total_counts&#8221;], kde=False, ax=axs[0])<\/p>\n\n\n\n<p>sns.histplot(<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;adata.obs[&#8220;total_counts&#8221;][adata.obs[&#8220;total_counts&#8221;] &lt; 10000],<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;kde=False,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;bins=40,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;ax=axs[1],<\/p>\n\n\n\n<p>)<\/p>\n\n\n\n<p>sns.histplot(adata.obs[&#8220;n_genes_by_counts&#8221;], kde=False, bins=60, ax=axs[2])<\/p>\n\n\n\n<p>sns.histplot(<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;adata.obs[&#8220;n_genes_by_counts&#8221;][adata.obs[&#8220;n_genes_by_counts&#8221;] &lt; 4000],<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;kde=False,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;bins=60,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;ax=axs[3],<\/p>\n\n\n\n<p>)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"193\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72471-1.png?resize=640%2C193\" alt=\"\" class=\"wp-image-60824\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72471-1.png?resize=1024%2C308 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72471-1.png?resize=300%2C90 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72471-1.png?resize=768%2C231 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72471-1.png?resize=600%2C180 600w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72471-1.png?w=1295 1295w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>sc.pp.filter_cells(adata, min_counts=5000)<\/p>\n\n\n\n<p>sc.pp.filter_cells(adata, max_counts=35000)<\/p>\n\n\n\n<p>adata = adata[adata.obs[&#8220;pct_counts_mt&#8221;] &lt; 20].copy()<\/p>\n\n\n\n<p>print(f&#8221;#cells after MT filter: {adata.n_obs}&#8221;)<\/p>\n\n\n\n<p>sc.pp.filter_genes(adata, min_cells=10)<\/p>\n\n\n\n<p>\u6211\u4eec\u7ee7\u7eed\u4f7f\u7528&nbsp;Scanpy \u7684\u5185\u7f6e\u65b9\u6cd5\u5bf9 Visium \u8ba1\u6570\u6570\u636e\u8fdb\u884c\u5f52\u4e00\u5316\uff0c\u5e76\u68c0\u6d4b\u9ad8\u5ea6\u53ef\u53d8\u7684\u57fa\u56e0<\/p>\n\n\n\n<p>sc.pp.normalize_total(adata, inplace=True)<\/p>\n\n\n\n<p>sc.pp.log1p(adata)<\/p>\n\n\n\n<p>sc.pp.highly_variable_genes(adata, flavor=&#8221;seurat&#8221;, n_top_genes=2000)<\/p>\n\n\n\n<p><strong>4. \u57fa\u4e8e\u8f6c\u5f55\u76f8\u4f3c\u6027\u7684\u6d41\u5f62\u5d4c\u5165\u548c\u805a\u7c7b<\/strong><strong><\/strong><\/p>\n\n\n\n<p>sc.pp.pca(adata)<\/p>\n\n\n\n<p>sc.pp.neighbors(adata)<\/p>\n\n\n\n<p>sc.tl.umap(adata)<\/p>\n\n\n\n<p>sc.tl.leiden(<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;adata, key_added=&#8221;clusters&#8221;, flavor=&#8221;igraph&#8221;, directed=False, n_iterations=2<\/p>\n\n\n\n<p>)<\/p>\n\n\n\n<p>\u6211\u4eec\u7ed8\u5236\u4e86\u4e00\u4e9b\u534f\u53d8\u91cf\uff0c\u4ee5\u68c0\u67e5&nbsp;UMAP \u4e2d\u662f\u5426\u5b58\u5728\u4e0e\u603b\u6570\u548c\u68c0\u6d4b\u5230\u7684\u57fa\u56e0\u76f8\u5173\u7684\u4efb\u4f55\u7279\u5b9a\u7ed3\u6784\u3002<\/p>\n\n\n\n<p>plt.rcParams[&#8220;figure.figsize&#8221;] = (4, 4)<\/p>\n\n\n\n<p>sc.pl.umap(adata, color=[&#8220;total_counts&#8221;, &#8220;n_genes_by_counts&#8221;, &#8220;clusters&#8221;], wspace=0.4)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"171\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72473-1.png?resize=640%2C171\" alt=\"\" class=\"wp-image-60825\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72473-1.png?resize=1024%2C274 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72473-1.png?resize=300%2C80 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72473-1.png?resize=768%2C205 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72473-1.png?resize=600%2C160 600w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72473-1.png?w=1283 1283w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p><strong>5. \u7a7a\u95f4\u5750\u6807\u4e2d\u7684\u53ef\u89c6\u5316<\/strong><strong><\/strong><\/p>\n\n\n\n<p>plt.rcParams[&#8220;figure.figsize&#8221;] = (8, 8)<\/p>\n\n\n\n<p>sc.pl.spatial(adata, img_key=&#8221;hires&#8221;, color=[&#8220;total_counts&#8221;, &#8220;n_genes_by_counts&#8221;])<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"309\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72474.png?resize=640%2C309\" alt=\"\" class=\"wp-image-60826\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72474.png?resize=1024%2C494 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72474.png?resize=300%2C145 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72474.png?resize=768%2C371 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72474.png?resize=600%2C290 600w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72474.png?w=1274 1274w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>\u51fd\u6570&nbsp;sc.pl.spatial \u63a5\u53d7 4 \u4e2a\u9644\u52a0\u53c2\u6570\uff1a<\/p>\n\n\n\n<ul>\n<li>img_key\uff1a\u5176\u4e2d IMG \u5b58\u50a8\u5728\u5143\u7d20\u4e2dadata.uns<\/li>\n\n\n\n<li>crop_coord\uff1a\u7528\u4e8e\u88c1\u526a\u7684\u5750\u6807\uff08\u5de6\u3001\u53f3\u3001\u4e0a\u3001\u4e0b\uff09<\/li>\n\n\n\n<li>alpha_img\uff1a\u56fe\u50cf\u900f\u660e\u5ea6\u7684 alpha \u503c<\/li>\n\n\n\n<li>bw\uff1a\u6807\u5fd7\u5c06\u56fe\u50cf\u8f6c\u6362\u4e3a\u7070\u5ea6<\/li>\n<\/ul>\n\n\n\n<p>\u4e4b\u524d\uff0c\u6211\u4eec\u5728\u57fa\u56e0\u8868\u8fbe\u7a7a\u95f4\u4e2d\u8fdb\u884c\u4e86\u805a\u7c7b\uff0c\u5e76\u7528UMAP\u53ef\u89c6\u5316\u4e86\u7ed3\u679c\u3002\u901a\u8fc7\u5728\u7a7a\u95f4\u7ef4\u5ea6\u4e0a\u53ef\u89c6\u5316\u805a\u7c7b\u6837\u672c\uff0c\u6211\u4eec\u53ef\u4ee5\u6df1\u5165\u4e86\u89e3\u7ec4\u7ec7\u7ec4\u7ec7\uff0c\u5e76\u53ef\u80fd\u6df1\u5165\u4e86\u89e3\u7ec6\u80de\u95f4\u901a\u8baf\u3002<\/p>\n\n\n\n<p>sc.pl.spatial(adata, img_key=&#8221;hires&#8221;, color=&#8221;clusters&#8221;, size=1.5)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"688\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72475.png?resize=640%2C688\" alt=\"\" class=\"wp-image-60827\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72475.png?resize=953%2C1024 953w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72475.png?resize=279%2C300 279w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72475.png?resize=768%2C825 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72475.png?resize=600%2C645 600w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72475.png?w=1004 1004w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>\u57fa\u56e0\u8868\u8fbe\u7a7a\u95f4\u4e2d\u5c5e\u4e8e\u540c\u4e00\u7c07\u7684\u6591\u70b9\u901a\u5e38\u5728\u7a7a\u95f4\u7ef4\u5ea6\u4e0a\u5171\u73b0\u3002\u4f8b\u5982\uff0c\u5c5e\u4e8e\u805a\u7c7b&nbsp;5 \u7684\u6591\u70b9\u901a\u5e38\u88ab\u5c5e\u4e8e\u805a\u7c7b 0 \u7684\u70b9\u5305\u56f4\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u653e\u5927\u7279\u5b9a\u7684\u611f\u5174\u8da3\u533a\u57df\u4ee5\u83b7\u5f97\u5b9a\u6027\u89c1\u89e3\u3002\u6b64\u5916\uff0c\u901a\u8fc7\u6539\u53d8\u6591\u70b9\u7684&nbsp;alpha \u503c\uff0c\u6211\u4eec\u53ef\u4ee5\u4ece H&amp;E \u56fe\u50cf\u4e2d\u66f4\u597d\u5730\u53ef\u89c6\u5316\u4e0b\u9762\u7684\u7ec4\u7ec7\u5f62\u6001\u3002<\/p>\n\n\n\n<p>sc.pl.spatial(<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;adata,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;img_key=&#8221;hires&#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;color=&#8221;clusters&#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;groups=[&#8220;5&#8221;, &#8220;9&#8221;],<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;crop_coord=[7000, 10000, 0, 6000],<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;alpha=0.5,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;size=1.3,<\/p>\n\n\n\n<p>)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"625\" height=\"1024\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72476.png?resize=625%2C1024\" alt=\"\" class=\"wp-image-60828\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72476.png?resize=625%2C1024 625w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72476.png?resize=183%2C300 183w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72476.png?resize=600%2C982 600w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72476.png?w=659 659w\" sizes=\"(max-width: 625px) 100vw, 625px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p><strong>6. \u4e9a\u7fa4\u6807\u8bb0\u57fa\u56e0<\/strong><strong><\/strong><\/p>\n\n\n\n<p>\u8ba1\u7b97\u6807\u8bb0\u57fa\u56e0\u5e76\u7ed8\u5236\u70ed\u56fe\uff0c\u5176\u4e2d\u524d&nbsp;10 \u4e2a\u6807\u8bb0\u57fa\u56e0\u7684\u8868\u8fbe\u6c34\u5e73\u3002<\/p>\n\n\n\n<p>sc.tl.rank_genes_groups(adata, &#8220;clusters&#8221;, method=&#8221;t-test&#8221;)<\/p>\n\n\n\n<p>sc.pl.rank_genes_groups_heatmap(adata, groups=&#8221;9&#8243;, n_genes=10, groupby=&#8221;clusters&#8221;)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"911\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72477.png?resize=640%2C911\" alt=\"\" class=\"wp-image-60829\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72477.png?w=657 657w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72477.png?resize=211%2C300 211w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72477.png?resize=600%2C854 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>##\u6211\u4eec\u770b\u5230&nbsp;CR2 \u6982\u62ec\u4e86\u7a7a\u95f4\u7ed3\u6784\u3002<\/p>\n\n\n\n<p>sc.pl.spatial(adata, img_key=&#8221;hires&#8221;, color=[&#8220;clusters&#8221;, &#8220;CR2&#8221;])<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"305\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72478.png?resize=640%2C305\" alt=\"\" class=\"wp-image-60830\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72478.png?resize=1024%2C488 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72478.png?resize=300%2C143 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72478.png?resize=768%2C366 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72478.png?resize=600%2C286 600w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72478.png?w=1284 1284w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>sc.pl.spatial(adata, img_key=&#8221;hires&#8221;, color=[&#8220;COL1A2&#8221;, &#8220;SYPL1&#8221;], alpha=0.7)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"313\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72479.png?resize=640%2C313\" alt=\"\" class=\"wp-image-60831\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72479.png?resize=1024%2C500 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72479.png?resize=300%2C147 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72479.png?resize=768%2C375 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72479.png?resize=600%2C293 600w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u72479.png?w=1279 1279w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p><strong>7.<\/strong><strong>&nbsp;MERFISH\u793a\u4f8b<\/strong><strong><\/strong><\/p>\n\n\n\n<p>\u5982\u679c\u60a8\u4f7f\u7528\u57fa\u4e8e&nbsp;FISH \u7684\u6280\u672f\u751f\u6210\u7a7a\u95f4\u6570\u636e\uff0c\u53ea\u9700\u9605\u8bfb cordinate \u8868\u5e76\u5c06\u5176\u5206\u914d\u7ed9\u5143\u7d20\u5373\u53ef\u3002<\/p>\n\n\n\n<p># If needed:<\/p>\n\n\n\n<p># %pip install openpyxl<\/p>\n\n\n\n<p>coordinates = pd.read_excel(&#8220;.\/data\/pnas.1912459116.sd15.xlsx&#8221;, index_col=0)<\/p>\n\n\n\n<p>counts = sc.read_csv(&#8220;.\/data\/pnas.1912459116.sd12.csv&#8221;).transpose()<\/p>\n\n\n\n<p>adata_merfish = counts[coordinates.index, :].copy()<\/p>\n\n\n\n<p>adata_merfish.obsm[&#8220;spatial&#8221;] = coordinates.to_numpy()<\/p>\n\n\n\n<p>#\u9884\u5904\u7406\u548c\u964d\u7ef4<\/p>\n\n\n\n<p>sc.pp.normalize_per_cell(adata_merfish, counts_per_cell_after=1e6)<\/p>\n\n\n\n<p>sc.pp.log1p(adata_merfish)<\/p>\n\n\n\n<p>sc.pp.pca(adata_merfish, n_comps=15)<\/p>\n\n\n\n<p>sc.pp.neighbors(adata_merfish)<\/p>\n\n\n\n<p>sc.tl.umap(adata_merfish)<\/p>\n\n\n\n<p>sc.tl.leiden(<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;adata_merfish,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;key_added=&#8221;clusters&#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;resolution=0.5,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;n_iterations=2,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;flavor=&#8221;igraph&#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;directed=False,<\/p>\n\n\n\n<p>)<\/p>\n\n\n\n<p>adata_merfish<\/p>\n\n\n\n<p>sc.pl.umap(adata_merfish, color=&#8221;clusters&#8221;)<\/p>\n\n\n\n<p>sc.pl.embedding(adata_merfish, basis=&#8221;spatial&#8221;, color=&#8221;clusters&#8221;)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"602\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u724710.png?resize=640%2C602\" alt=\"\" class=\"wp-image-60832\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u724710.png?resize=1024%2C963 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u724710.png?resize=300%2C282 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u724710.png?resize=768%2C722 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u724710.png?resize=600%2C564 600w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u724710.png?w=1147 1147w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"602\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u724711.png?resize=640%2C602\" alt=\"\" class=\"wp-image-60833\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u724711.png?resize=1024%2C963 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u724711.png?resize=300%2C282 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u724711.png?resize=768%2C722 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u724711.png?resize=600%2C564 600w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/\u56fe\u724711.png?w=1147 1147w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p><strong>\u5c0f\u7ed3<\/strong><strong><\/strong><\/p>\n\n\n\n<p>\u597d\u5566\uff0c\u4eca\u5929\u7684\u5206\u4eab\u7ed3\u675f\u5566\uff01Scanpy\u662f\u4e0eseurat\u7684\u5206\u6790\u6d41\u7a0b\u57fa\u672c\u4e00\u81f4\uff0c\u90fd\u662f\u8d28\u63a7-\u9009\u62e9\u9ad8\u53d8\u57fa\u56e0-PCA\u964d\u7ef4-\u805a\u7c7b-UMAP(tSNE)\u964d\u7ef4\u8fd9\u4e9b\u6b65\u9aa4\u3002\u4f46\u662f\uff0cPython\u76f8\u6bd4R\u6709\u66f4\u597d\u7684\u5185\u5b58\u7ba1\u7406\uff0c\u66f4\u4e30\u5bcc\u7684\u4eba\u5de5\u667a\u80fd\u7b97\u6cd5\u8d44\u6e90\uff0c\u5e76\u4e14\u53ef\u4ee5\u8c03\u7528GPU\u52a0\u901f\u8ba1\u7b97\u3002Python\u5728\u56fe\u50cf\u8bc6\u522b\u3001\u7a7a\u95f4\u5206\u5272\u548c\u53bb\u5377\u79ef\u7b49\u7b97\u6cd5\u9886\u57df\u62e5\u6709\u66f4\u597d\u7684\u8d44\u6e90\uff0c\u56e0\u6b64\u5f88\u591a\u4f18\u79c0\u7684\u7a7a\u8f6c\u5206\u6790\u5de5\u5177\u90fd\u662fpython\u7f16\u5199\u7684\u3002\u505a\u597d\u7a7a\u8f6c\u6570\u636e\u7684\u5206\u6790\u4e0d\u80fd\u5c40\u9650\u4e8eR\u8bed\u8a00\u751f\u6001\uff0c\u8ba9\u6211\u4eec\u4ecescanpy\u5f00\u59cb\uff0c\u62e5\u62b1python\u3002\u6700\u540e\u5c0f\u4e91\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u4e00\u4e2a\u4e91\u5de5\u5177\uff01\u540c\u5b66\u4eec\u5982\u679c\u89c9\u5f97\u81ea\u5df1\u7684\u4ee3\u7801\u6c34\u5e73\u4e00\u822c\uff0c\u5bf9\u4e8e\u5f88\u591a\u7684\u53c2\u6570\u4e0d\u77e5\u9053\u600e\u4e48\u6539\uff0c\u53ef\u4ee5\u4f53\u9a8c\u4e00\u4e0b\u6211\u4eec\u7684\u4e91\u751f\u4fe1\u5c0f\u5de5\u5177\uff0c\u53ea\u9700\u8f93\u5165\u6570\u636e\uff0c\u5373\u53ef\u8f7b\u677e\u751f\u6210\u6240\u9700\u56fe\u8868\uff0c\u5b57\u4f53\u5927\u5c0f\u3001\u6807\u9898\u7b49\u4e5f\u53ef\u4e00\u952e\u66f4\u6539\u3002\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u53bb\u4e91\u751f\u4fe1\uff08http:\/\/www.biocloudservice.com\/home.html\uff09\u4f53\u9a8c\u4e00\u4e0b\u5427\uff01\u9700\u8981\u4ee3\u7801\u7684\u4e5f\u53ef\u4ee5\u8054\u7cfb\u6211\u5440\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/b83a70e861b85da4e5d054d57384bcfc-1.png?resize=640%2C285\" alt=\"\" class=\"wp-image-60834\" width=\"640\" height=\"285\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/b83a70e861b85da4e5d054d57384bcfc-1.png?w=553 553w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/09\/b83a70e861b85da4e5d054d57384bcfc-1.png?resize=300%2C133 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u7a7a\u95f4\u8f6c\u5f55\u7ec4\u5b66\u5206\u6790\uff0c\u662f\u8fd1\u51e0\u5e74\u7684\u4e00\u4e2a\u70ed\u70b9\u3002\u76f8\u4fe1\u5c0f\u4f19\u4f34\u4eec\u5bf9\u4e8eseurat\u518d\u719f\u6089\u4e0d\u8fc7\u4e86\uff01\u4f46\u662fseurat\u662f\u57fa\u4e8eR [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":""},"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/60823"}],"collection":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=60823"}],"version-history":[{"count":1,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/60823\/revisions"}],"predecessor-version":[{"id":60835,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/60823\/revisions\/60835"}],"wp:attachment":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=60823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=60823"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=60823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}