咱们生信妙技树的单细胞月更群内部等闲看到小伙伴建议的图片好意思化需求母狗 调教,这就来望望单细胞umap好意思化用具吧!
第一种:SCP 包(这个包特地的出色)对于SCP,咱们前边也有一个成心的专辑对其进行了大篇幅的先容,不知说念全球用起来了没呢?
端到端的单细胞管说念SCP-整合历程端到端的单细胞管说念SCP-细胞质控端到端的单细胞管说念SCP-步资格程端到端的单细胞管说念SCP-快速开动SCP—为单细胞分析揣度打算的端到端管理决议端到端的单细胞管说念SCP-安设其学习的官网地址为:https://zhanghao-njmu.github.io/SCP/index.html
莫得安设的,此次就不要再错过啦:
# 安设devtools::install_github("zhanghao-njmu/SCP")
本次,咱们使用的数据为来自 GSE128531 数据精后光的seurat对象,你我方用的技艺不错使用任何一个经过了精后光的seurat对象。
rm(list=ls())library(COSG)library(harmony)library(ggsci)library(dplyr) library(future)library(Seurat)library(clustree)library(cowplot)library(data.table)library(dplyr)library(ggplot2)library(patchwork)library(stringr)library(qs)# 导入数据sce.all.int <- readRDS('2-harmony/sce.all_int.rds')sp <- 'human'head(sce.all.int@meta.data)load("phe.Rdata")head(phe)sce.all.int <- AddMetaData(sce.all.int, metadata = phe)Idents(sce.all.int) <- "celltype"table(Idents(sce.all.int))
图片
看一下它对UMAP可视化的蛮横之处!
1、先看默许主题一键出图:################## umap1library(SCP)head(sce.all.int@meta.data)CellDimPlot(sce.all.int, group.by = "celltype", reduction = "UMAP")
这个配色特地CNS,且图中展示了总细胞数,每个亚群的细胞数这些信息:
图片
2、坐标改成 左下小箭头,亦然全球非通常见的需求!# 左下小箭头CellDimPlot(sce.all.int, group.by = "celltype", reduction = "UMAP", theme_use = "theme_blank")
图片
3、只露出X、Y轴还不错一键休养全体字体大小:
CellDimPlot(sce.all.int, group.by = "celltype", reduction = "UMAP", theme_use = ggplot2::theme_classic, theme_args = list(base_size = 16))
图片
上头三个是我最可爱的ump立场,还有许多其他,总有你的一款:
图片
第二种:Nebulosa(r包)Nebulosa 是一个基于核密度揣度可视化单细胞数据的 R 包,主要通过结合细胞之间的通常性来规复丢失特征中的信号,从而杀青细胞特征的“卷积”。
学习官网:https://bioconductor.org/packages/devel/bioc/vignettes/Nebulosa/inst/doc/nebulosa_seurat.html
Nebulosa 的主邀功能是 plot_density,让咱们按照以下形势绘制 一些marker基因 的核密度揣度图,展示的marker基因抒发水平上下:
# 安设一下options(BioC_mirror="https://mirrors.westlake.edu.cn/bioconductor")options("repos"=c(CRAN="https://mirrors.westlake.edu.cn/CRAN/"))BiocManager::install("Nebulosa")library(Nebulosa)1、 绘制一个基因PTPRC
这种图亦然在许多CNS级别的著述中出现的:
# 绘制一个基因PTPRCp1 <- plot_density(sce.all.int,卡通动漫 c("PTPRC"),size = 0.3)p1
图片
2、绘制多个基因# 同期绘制多个基因p3 <- plot_density(sce.all.int, c("CD3D","CD4","CD8A","CD68"),size = 0.3)p3
成果如下:
图片
3、绘制基因共抒发这里不错同期展示两个基因皆抒发的场合:
# combine = FALSE 只保留两个基因皆抒发的区域p4 <- plot_density(sce.all.int, c("CD8A", "CCR7"), joint = TRUE,combine = FALSE) p4
图片
第三种:scCustomize(r包)学习官网:https://samuel-marsh.github.io/scCustomize/index.html
# 安设# Base Rinstall.packages("scCustomize")
画图:不错绘制一个marker,也不错展示多个marker:
################## umap4:scCustomizelibrary(viridis)library(Seurat)library(scCustomize)FeaturePlot_scCustom(seurat_object = sce.all.int, features = c("VWF","CD3E"), order = F)
这种立场很像早期的椒盐画图立场:你看这个着色点是不是很像洒在鸡腿上头的椒盐!(椒盐立场这个词我在一篇单细胞文件中遭遇过,当今找不见了,其时还成心在群里问了来着哈哈哈哈)
图片
还不错任性地修改配色:
# 修改情怀# Set color palettepal <- viridis(n = 10, option = "D")FeaturePlot_scCustom(seurat_object = sce.all.int, features = c("VWF","CD3E"), colors_use = pal, order = T,pt.size = 0.3)
图片
第四种:ggplot2绘制细胞密度umap图在seurat包中有东说念主建议一个画图需求:https://github.com/satijalab/seurat/issues/6962
图片
这种图主要用来处理数据点重迭问题时特地有效,使用 MASS::kde2d() 进行二维核密度揣度,并通过等高线露出成果,geom_density_2d() 绘制等高线,而 geom_density_2d_filled() 绘制填充的等高线带。
连结:https://ggplot2.tidyverse.org/reference/geom_density_2d.html
library(cetcolor)library(Seurat)library(ggplot2)# 建造情怀scale.col <- cet_pal(16, name = "fire")# generate UMAP plotpl1 <- UMAPPlot(sce.all.int, combine = FALSE) # returns full ggplot objectpl1# make plotpl1[[1]] & stat_density_2d(aes_string(x = "umap_1", y = "umap_2", fill = "after_stat(level)"), linewidth = 0.2, geom = "density_2d_filled", colour = "ivory", alpha = 0.4, n = 150, h = c(1.2, 1.2)) & scale_fill_gradientn(colours = scale.col) & DarkTheme()
这种立场很专有:
图片
第五种:ggpointdensity(r包)在二维坐标系中可视化数据点有几种要领:要是你有多数的数据点重迭在沿路,geom_point() 无法为你提供重迭点的数目揣度。
刚刚上头先容的geom_density2d() 和 geom_bin2d() 不错管理这个问题,但它们使得无法探问个别特地点,而这些特地点可能具有斟酌价值。
geom_pointdensity() 旨在通过结合两者的优点来管理这个问题:各个点阐发相近点的数目进行着色。这使得你既能看到全体散播,也能看到个别点。
学习官网:https://github.com/LKremer/ggpointdensity
细胞密度图:
# 安设install.packages("ggpointdensity")library(ggpointdensity)# 提真金不怕火umap坐标数据dat <- Embeddings(sce.all.int, reduction = "umap")head(dat)# umap_1 umap_2# SC67mf2_AAACCTGAGAGTAATC -3.541568 5.127461# SC67mf2_AAACCTGAGCGCTTAT -6.623588 -3.025122# SC67mf2_AAACCTGAGGACACCA -4.586405 1.513219ggplot(data = dat, mapping = aes(x = umap_1, y = umap_2)) + geom_pointdensity() + scale_color_viridis()
图片
刘涛李晨车震虽然,它还不错展示marker特征基因抒发:
# 提真金不怕火umap坐标以及特征基因抒发df <- FetchData(object =sce.all.int, vars = c("umap_1", "umap_2", "CD3D"), layer = "data")head(df)# umap_1 umap_2 CD3D# SC67mf2_AAACCTGAGAGTAATC -3.541568 5.127461 0.000000# SC67mf2_AAACCTGAGCGCTTAT -6.623588 -3.025122 1.430228# SC67mf2_AAACCTGAGGACACCA -4.586405 1.513219 0.000000p <- ggplot(df, aes(x= umap_1, y= umap_2 )) + geom_point(data = df %>% filter(CD3D == 0), color = "#440154FF", size = 0.6) + ggpointdensity::geom_pointdensity(data = df %>% filter(CD3D > 0), size = 0.6) + viridis::scale_color_viridis() + theme_classic(base_size = 14) + labs(color= "CD3D")p
成果如下:
图片
上头哪一款是你的菜?不错在挑剔区高声说出来(爱就要勇敢说出来!)。
友情宣传:
生信初学&数据挖掘线上直播课2025年1月班
时隔5年,咱们的生信妙技树VIP学徒不绝招生啦
心仪你生信分析筹划需求的廉价管理决议母狗 调教
本站仅提供存储工作,悉数试验均由用户发布,如发现存害或侵权试验,请点击举报。