收入即学习

10X单细胞转录组下游流程-1-整合多个cellranger结果

2019-11-08  本文已影响0人  大吉岭猹

1. 写在前面

2. 读取数据

| SRR7722939 | PBMC Pre |

| SRR7722940 | PBMC Disc Early |

| SRR7722941 | PBMC Disc Resp |

| SRR7722942 | PBMC Disc AR |

library(Seurat)
sce.10x <- Read10X(data.dir = './cellranger/four-PBMC-mtx/SRR7722939/')
sce1 <- CreateSeuratObject(counts = sce.10x,
                           min.cells = 60,
                           min.features = 200,
                           project = "SRR7722939")
sce1
sce.10x <- Read10X(data.dir = './cellranger/four-PBMC-mtx/SRR7722940/')
sce2 <- CreateSeuratObject(counts = sce.10x,
                           min.cells = 60,
                           min.features = 200,
                           project = "SRR7722940")
sce2
sce.10x <- Read10X(data.dir = './cellranger/four-PBMC-mtx/SRR7722941/')
sce3 <- CreateSeuratObject(counts = sce.10x,
                           min.cells = 60,
                           min.features = 200,
                           project = "SRR7722941")
sce3
sce.10x <- Read10X(data.dir = './cellranger/four-PBMC-mtx/SRR7722942/')
sce4 <- CreateSeuratObject(counts = sce.10x,
                           min.cells = 60,
                           min.features = 200,
                           project = "SRR7722942")
sce4
> sce1;sce2;sce3;sce4
An object of class Seurat
6163 features across 2047 samples within 1 assay
Active assay: RNA (6163 features)
An object of class Seurat
4267 features across 1074 samples within 1 assay
Active assay: RNA (4267 features)
An object of class Seurat
5480 features across 4311 samples within 1 assay
Active assay: RNA (5480 features)
An object of class Seurat
6429 features across 4028 samples within 1 assay
Active assay: RNA (6429 features)

3. 添加分组信息

sce1@meta.data$group <- "PBMC_Pre"
sce2@meta.data$group <- "PBMC_EarlyD27"
sce3@meta.data$group <- "PBMC_RespD376"
sce4@meta.data$group <- "PBMC_ARD614"

4. 添加分组信息至细胞名

> str(sce1@assays)
List of 1
#后面还有一大堆
#既然是个列表,我们就取它第一项看看
> str(sce1@assays[[1]])
Formal class 'Assay' [package "Seurat"] with 7 slots
head(colnames(sce1@assays[[1]]@data))
colnames(sce1@assays[[1]]@data) <- paste0("PBMC_Pre.",colnames(sce1@assays[[1]]@data))
head(colnames(sce1@assays[[1]]@data))
colnames(sce1@assays[[1]]@data) <- paste0("PBMC_Pre.",colnames(sce1@assays[[1]]@data))
colnames(sce1@assays[[1]]@data) <- paste0("PBMC_Pre.",colnames(sce1@assays[[1]]@data))
colnames(sce1@assays[[1]]@data) <- paste0("PBMC_Pre.",colnames(sce1@assays[[1]]@data))

5. 归一化+标准化

sce1 <- NormalizeData(sce1)
sce1 <- ScaleData(sce1, display.progress = F)
sce2 <- NormalizeData(sce2)
sce2 <- ScaleData(sce2, display.progress = F)
sce3 <- NormalizeData(sce3)
sce3 <- ScaleData(sce3, display.progress = F)
sce4 <- NormalizeData(sce4)
sce4 <- ScaleData(sce4, display.progress = F)

6. 整合

sce1@meta.data$orig.ident <- "PBMC_Pre"
sce2@meta.data$orig.ident <- "PBMC_EarlyD27"
sce3@meta.data$orig.ident <- "PBMC_RespD376"
sce4@meta.data$orig.ident <- "PBMC_ARD614"

sce.big <- merge(sce1,
                 y = c(sce2,sce3,sce4),
                 add.cell.ids = c("PBMC_Pre.","PBMC_EarlyD27.","PBMC_RespD376.","PBMC_ARD614."),
                 project = "p1-PBMC")

table(sce.big$orig.ident)
sce.big <- SCTransform(sce.big, verbose = FALSE)
sce.big <- RunPCA(sce.big, verbose = FALSE)
sce.big <- RunTSNE(sce.big, verbose = FALSE)
DimPlot(object = sce.big,
        reduction = "tsne",group.by = 'orig.ident')
sce.big <- FindNeighbors(sce.big, dims = 1:20)
sce.big <- FindClusters(sce.big, resolution = 0.2)
DimPlot(object = sce.big, reduction = "tsne",
        group.by = 'SCT_snn_res.0.2')#这里的SCT_snn_res.0.2就是分群信息
> table(sce.big$SCT_snn_res.0.2,sce.big$orig.ident)

     PBMC_ARD614 PBMC_EarlyD27 PBMC_Pre PBMC_RespD376
  0         1175           347       22          1555
  1          987           152      137          1103
  2          862            35       24           488
  3          396            43       14           471
  4            0             2      862             1
  5          294             0      160           330
  6           26           272        6           261
  7            0             1      361             1
  8            1            43      228             2
  9          112           130        1            15
  10           0             0      205             5
  11         134            29        4            29
  12          41            20       23            50
上一篇下一篇

猜你喜欢

热点阅读