{"id":28656,"date":"2024-02-18T15:41:15","date_gmt":"2024-02-18T07:41:15","guid":{"rendered":"http:\/\/www.biocloudservice.com\/wordpress\/?p=28656"},"modified":"2024-02-18T15:41:17","modified_gmt":"2024-02-18T07:41:17","slug":"%e7%bb%98%e5%88%b6%e5%8d%95%e7%bb%86%e8%83%9e%e5%88%86%e6%9e%90%e7%bb%84%e7%bb%87%e4%b8%ad%e7%bb%86%e8%83%9e%e6%95%b0%e9%87%8f%e5%92%8c%e7%bb%86%e8%83%9e%e6%af%94%e4%be%8b%e6%9f%b1%e7%8a%b6%e5%9b%be","status":"publish","type":"post","link":"http:\/\/www.biocloudservice.com\/wordpress\/?p=28656","title":{"rendered":"\u7ed8\u5236\u5355\u7ec6\u80de\u5206\u6790\u7ec4\u7ec7\u4e2d\u7ec6\u80de\u6570\u91cf\u548c\u7ec6\u80de\u6bd4\u4f8b\u67f1\u72b6\u56fe"},"content":{"rendered":"<p>\u4eca\u5929\u7ed8\u5236\u4e00\u4e0b\u5355\u7ec6\u80de\u5206\u6790\u7ed3\u679c\u7ec4\u7ec7\u4e2d\u7ec6\u80de\u6570\u91cf\u548c\u7ec6\u80de\u6bd4\u4f8b\u67f1\u72b6\u56fe\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u5b89\u88c5\u9700\u8981\u7684R\u5305<\/li>\n<\/ol>\n<p>install.packages(\u201cSeurat\u201d)<\/p>\n<p>install.packages(\u201cpatchwork\u201d)<\/p>\n<p>install.packages(\u201creshape2\u201d)<\/p>\n<p>install.packages(\u201cRcolorBrewer\u201d)<\/p>\n<p>install.packages(\u201cscales\u201d)<\/p>\n<p>install.packages(\u201cggplot2\u201d)<\/p>\n<p>install.packages(\u201ctidyverse\u201d)<\/p>\n<ol>\n<li>\u5bfc\u5165\u6240\u9700\u8981\u7684R\u5305<\/li>\n<\/ol>\n<p>library(Seurat)<\/p>\n<p>library(patchwork)<\/p>\n<p>library(reshape2)<\/p>\n<p>library(RcolorBrewer)<\/p>\n<p>library(ggplot2)<\/p>\n<p>library(tidyverse)<\/p>\n<p>library(scales)<\/p>\n<ol>\n<li>\u4ee3\u7801\u5c55\u793a<\/li>\n<\/ol>\n<p>\u6570\u636e\u4e0b\u8f7d<\/p>\n<p>wget <a href=\"https:\/\/cf.10xgenomics.com\/samples\/cell\/pbmc3k\/pbmc3k_filtered_gene_bc_matrices.tar.gz\">https:\/\/cf.10xgenomics.com\/samples\/cell\/pbmc3k\/pbmc3k_filtered_gene_bc_matrices.tar.gz<\/a><\/p>\n<p>tar -zxvf pbmc3k_filtered_gene_bc_matrices.tar.gz<\/p>\n<p>#\u5206\u6790\u6240\u9700\u8981\u7684\u6587\u4ef6\u4e09\u4e2a\u5728filtered_gene_bc_matrices\/hg19\/<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"95\" class=\"wp-image-28657\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230115121454.jpeg?resize=640%2C95\" alt=\"Dingtalk_20230115121454\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230115121454.jpeg?w=741 741w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230115121454.jpeg?resize=300%2C45 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230115121454.jpeg?resize=600%2C89 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>pbmc.data &lt;- Read10X(data.dir = &#8220;filtered_gene_bc_matrices\/hg19\/&#8221;)<\/p>\n<p># Initialize the Seurat object with the raw (non-normalized data).<\/p>\n<p>pbmc &lt;- CreateSeuratObject(counts = pbmc.data, project = &#8220;pbmc3k&#8221;, min.cells = 3, min.features = 200)<\/p>\n<p># Normalizing the data<\/p>\n<p>pbmc &lt;- NormalizeData(pbmc, normalization.method = &#8220;LogNormalize&#8221;, scale.factor = 10000)<\/p>\n<p>#Identification of highly variable features<\/p>\n<p>pbmc &lt;- FindVariableFeatures(pbmc, selection.method = &#8220;vst&#8221;, nfeatures = 2000)<\/p>\n<p>all.genes &lt;- rownames(pbmc)<\/p>\n<p>pbmc &lt;- ScaleData(pbmc, features = all.genes)<\/p>\n<p>#Run non-linear dimensional reduction (UMAP\/tSNE)<\/p>\n<p>pbmc &lt;- RunUMAP(pbmc, dims = 1:10)<\/p>\n<p>#\u5f00\u59cb\u7ed8\u56fe<\/p>\n<p>colourCount = length(unique(pbmc@meta.data$celltype))<\/p>\n<p>getPalette = colorRampPalette(brewer.pal(9, &#8220;Set1&#8221;))<\/p>\n<p>celltype_colors &lt;- getPalette(colourCount)<\/p>\n<p>#\u63d0\u53d6\u6837\u672c\u548c\u7ec6\u80de\u6570\u636e\uff0c\u5e76\u4e14\u8fdb\u884c\u957f\u5bbd\u6570\u636e\u8f6c\u6362<\/p>\n<p>plotC &lt;- table(pbmc@meta.data$sample, pbmc@meta.data$celltype) %&gt;% melt()<\/p>\n<p>colnames(plotC) &lt;- c(&#8220;Sample&#8221;, &#8220;CellType&#8221;,&#8221;Number&#8221;)<\/p>\n<p>#\u7ed8\u5236\u6bcf\u4e2a\u7ec4\u7ec7\u4e2d\u7ec6\u80de\u6570\u76ee\u67f1\u72b6\u56fe<\/p>\n<p>pC1 &lt;- ggplot(data = data_plotC, aes(x = Sample, y = Number, fill = CellType)) +<\/p>\n<p>geom_bar(stat = &#8220;identity&#8221;, width=0.8,aes(group=CellType),position=&#8221;stack&#8221;)+<\/p>\n<p>scale_fill_manual(values=celltype_colors) +<\/p>\n<p>theme_bw()+<\/p>\n<p>theme(panel.grid =element_blank()) +<\/p>\n<p>labs(x=&#8221;&#8221;,y=&#8221;Average number&#8221;)+<\/p>\n<p>theme(axis.text = element_text(size=12, colour = &#8220;black&#8221;))+<\/p>\n<p>theme(axis.title.y = element_text(size=12, colour = &#8220;black&#8221;))+<\/p>\n<p>theme(panel.border = element_rect(size = 1, linetype = &#8220;solid&#8221;, colour = &#8220;black&#8221;))+<\/p>\n<p>theme(axis.text.x = element_text(angle = 45,hjust = 0.8, vjust = 0.6))<\/p>\n<p>#\u7ed8\u5236\u6bcf\u4e2a\u7ec4\u7ec7\u4e2d\u7ec6\u80de\u6bd4\u4f8b\u67f1\u72b6\u56fe<\/p>\n<p>pC2 &lt;- ggplot(data = plotC, aes(x = Sample, y = Number, fill = CellType)) +<\/p>\n<p>geom_bar(stat = &#8220;identity&#8221;, width=0.8,aes(group=CellType),position=&#8221;fill&#8221;)+<\/p>\n<p>scale_fill_manual(values=celltype_colors) +<\/p>\n<p>theme_bw()+<\/p>\n<p>theme(panel.grid =element_blank()) +<\/p>\n<p>labs(x=&#8221;&#8221;,y=&#8221;Cell proportion&#8221;)+<\/p>\n<p>scale_y_continuous(labels = percent)+ ####\u7528\u6765\u5c06y\u8f74\u79fb\u52a8\u4f4d\u7f6e<\/p>\n<p>theme(axis.text = element_text(size=12, colour = &#8220;black&#8221;))+<\/p>\n<p>theme(axis.title.y = element_text(size=12, colour = &#8220;black&#8221;))+<\/p>\n<p>theme(panel.border = element_rect(size = 1, linetype = &#8220;solid&#8221;, colour = &#8220;black&#8221;))+<\/p>\n<p>theme(axis.text.x = element_text(angle = 45,hjust = 0.8, vjust = 0.6))#\u8ba9\u6a2a\u8f74\u4e0a\u7684\u6807\u7b7e\u503e\u659c45\u5ea6<\/p>\n<p>#\u4e24\u4e2a\u56fe\u7247\u8fdb\u884c\u62fc\u56fe<\/p>\n<p>pC &lt;- pC1 + pC2 + plot_layout(ncol = 2, widths = c(1,1),guides = &#8216;collect&#8217;)<\/p>\n<p>#\u4fdd\u5b58\u56fe\u7247<\/p>\n<p>ggsave(pC,file=&#8221;plotC.pdf&#8221;,width = 7, height = 5)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"460\" class=\"wp-image-28658\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230115125005.jpeg?resize=640%2C460\" alt=\"Dingtalk_20230115125005\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230115125005.jpeg?w=805 805w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230115125005.jpeg?resize=300%2C215 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230115125005.jpeg?resize=768%2C551 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230115125005.jpeg?resize=600%2C431 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u7ed8\u5236\u4e00\u4e0b\u5355\u7ec6\u80de\u5206\u6790\u7ed3\u679c\u7ec4\u7ec7\u4e2d\u7ec6\u80de\u6570\u91cf\u548c\u7ec6\u80de\u6bd4\u4f8b\u67f1\u72b6\u56fe\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a \u5b89\u88c5\u9700\u8981\u7684R\u5305 install.pack [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","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\/28656"}],"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=28656"}],"version-history":[{"count":1,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/28656\/revisions"}],"predecessor-version":[{"id":28659,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/28656\/revisions\/28659"}],"wp:attachment":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=28656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=28656"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=28656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}