欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

Scillus:一个 R 软件包解决了单细胞数据分析的所有难题

最编程 2024-07-13 08:34:39
...

说在前面

单细胞数据分析发展到现在越来越平民化了,如今对于很多小伙伴来说,入门单细胞数据分析要比几年前简单多了,这主要得利于很多轻便而且一站式的单细胞数据分析软件的使用,其中最有名的就是基于R语言的Seurat和基于Python的Scanpy了。

今天小编介绍的这款Scillus软件就是Seurat的一个wrapper,使用它可以做到和Seurat无缝衔接,并且也有自己独特的分析函数,可谓是单细胞数据分析的必备神器!而且,最重要的是使用这个软件可以轻松克服没有办法在一个图中添加更多组条来为不同的数据着色的问题,而且出图十分美观。

下面我们来使用代码进行实操演示。。。


代码实现

devtools::install_github("xmc811/Scillus", ref = "development")
library(Scillus)
library(tidyverse)
library(Seurat)
library(magrittr)
library(tidyverse)
library('magrittr')
library(R.utils)
a <- list.files("GSE128531_RAW", full.names = TRUE)

m <- tibble(file = a,
            sample = stringr::str_remove(basename(a), ".csv.gz"),
            group = rep(c("CTCL", "Normal"), each = 3))


pal <- tibble(var = c("sample", "group","seurat_clusters"),
              pal = c("Set2","Set1","Paired")) #配色

scRNA <- load_scfile(m)

读取完数据,下面进行数据质控。。。

plot_qc(scRNA, metrics = "percent.mt")
plot_qc(scRNA, metrics = "nFeature_RNA")
plot_qc(scRNA, metrics = "nCount_RNA")
plot_qc(scRNA, metrics = "nCount_RNA", plot_type = "density") + scale_x_log10()
plot_qc(scRNA, metrics = "percent.mt", group_by = "group", pal_setup = c("purple","yellow"))
scRNA_f <- filter_scdata(scRNA, subset = nFeature_RNA > 500 & percent.mt < 10)

scRNA_f %<>%
  purrr::map(.f = NormalizeData) %>%
  purrr::map(.f = FindVariableFeatures) %>%
  purrr::map(.f = CellCycleScoring,
             s.features = cc.genes$s.genes,
             g2m.features = cc.genes$g2m.genes)


scRNA_int <- IntegrateData(anchorset = FindIntegrationAnchors(object.list = scRNA_f, dims = 1:30, k.filter = 50), dims = 1:30)
scRNA_int %<>%
  ScaleData(vars.to.regress = c("nCount_RNA", "percent.mt", "S.Score", "G2M.Score"))

scRNA_int %<>%
  RunPCA(npcs = 50, verbose = TRUE)
scRNA_int %<>%
  RunUMAP(reduction = "pca", dims = 1:20, n.neighbors = 30) %>%
  FindNeighbors(reduction = "pca", dims = 1:20) %>%
  FindClusters(resolution = 0.3)

m %<>%mutate(group = factor(group, levels = c("Normal", "CTCL")))
scRNA_int %<>%refactor_seurat(metadata = m)
plot_scdata(scRNA_int, pal_setup = pal)
plot_scdata(scRNA_int, color_by = "group", pal_setup = pal)
plot_scdata(scRNA_int, split_by = "sample", pal_setup = pal)
plot_scdata(scRNA_int, pal_setup = "Dark2")

plot_stat(scRNA_int, plot_type = "prop_multi", pal_setup = "Set3")
image.png
image.png
image.png
image.png

Seurat做出的热图其实是很丑的,而用Scillus就很好的解决了这个问题,美美哒。

markers <- FindAllMarkers(scRNA_int, logfc.threshold = 0.1, min.pct = 0, only.pos = T)

plot_heatmap(dataset = scRNA_int,
             markers = markers,
             sort_var = c("seurat_clusters","sample"),
             anno_var = c("seurat_clusters","sample","percent.mt","S.Score","G2M.Score"),
             anno_colors = list("Set2",                                             # RColorBrewer palette
                                c("red","orange","yellow","purple","blue","green"), # color vector
                                "Reds",
                                c("blue","white","red"),                            # Three-color gradient
                                "Greens"))

image.png

Scillus最有特色的一点是可以一站式进行功能分析,包括ORA和GSEA.

plot_all_cluster_go(markers, org = "human", ont = "CC")

de <- find_diff_genes(dataset = scRNA_int,
clusters = as.character(0:7),
comparison = c("group", "CTCL", "Normal"),
logfc.threshold = 0,   # threshold of 0 is used for GSEA
min.cells.group = 1)   # To include clusters with only 1 cell
gsea_res <- test_GSEA(de,
pathway = pathways.hallmark)
plot_GSEA(gsea_res, p_cutoff = 0.1, colors = c("#0570b0", "grey", "#d7301f"))
image.png
image.png

小结

Scillus的功能其实是很多的,也能画很多图,这里Immugent只介绍了一部分,大家可以进官网进行系统学习(Scillus https://scillus.netlify.app/)。

不过Immugent一直没搞明白这个包好像没有自己的函数,都是调用的别的软件,因此也没有发表相应的文章。Whatever,好用就行,小伙伴赶紧用起来哇!


推荐阅读