-
Notifications
You must be signed in to change notification settings - Fork 1
/
Seurat-analysis.r
71 lines (57 loc) · 2.36 KB
/
Seurat-analysis.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
library(Seurat)
library(Signac)
library(rtracklayer)
library(tidyverse)
library(patchwork)
library(dplyr)
library(BSgenome.Osativa.IRGSP.IRGSP1)
library(future)
options(future.globals.maxSize = 50*1024^3)
options(future.rng.onMisuse="ignore")
plan("multicore", workers = 4)
set.seed(1234)
scATAC <- readRDS("../../03-scATAC-Analysis/01-Clustering/scATAC-RAM-Cluster.rds")
# quantify gene activity
gene.activities <- GeneActivity(scATAC, extend.upstream = 1000)
# add gene activities as a new assay
scATAC[["ACTIVITY"]] <- CreateAssayObject(counts = gene.activities)
# normalize gene activities
DefaultAssay(scATAC) <- "ACTIVITY"
scATAC <- NormalizeData(scATAC)
scATAC <- ScaleData(scATAC, features = rownames(scATAC))
# 保存数据
saveRDS(scATAC, file = "scATAC-RAM-GeneActivity.rds")
library(Seurat)
library(Signac)
library(rtracklayer)
library(tidyverse)
library(patchwork)
library(dplyr)
library(BSgenome.Osativa.IRGSP.IRGSP1)
library(future)
options(future.globals.maxSize = 50*1024^3)
options(future.rng.onMisuse="ignore")
plan("multicore", workers = 4)
set.seed(1234)
#加载数据
scATAC <- readRDS("scATAC-RAM-GeneActivity.rds")
# Load the pre-processed scRNA-seq data
scRNA <- readRDS("../../04-scRNA-integrated/03-annotation/scRNA-RAM-annotation.rds")
scRNA_ <- subset(x = scRNA, subset = orig.ident == "scRNA-lib2")
cellinfo <- subset([email protected], select = c("orig.ident", "nCount_RNA", "nFeature_RNA", "cellType"))
scRNA <- CreateSeuratObject(scRNA_[["RNA"]]@counts, meta.data = cellinfo)
scRNA <- NormalizeData(scRNA)
scRNA <- FindVariableFeatures(scRNA)
scRNA <- ScaleData(scRNA, rownames(scRNA))
# Identify anchors
transfer.anchors <- FindTransferAnchors(reference = scRNA, query = scATAC,
features = VariableFeatures(object = scRNA),
reference.assay = "RNA", query.assay = "ACTIVITY",
normalization.method = "LogNormalize",
reduction = "cca", dims = 1:20)
celltype.predictions <- TransferData(anchorset = transfer.anchors, refdata = scRNA$cellType,
weight.reduction = scATAC[["lsi"]], dims = 2:20)
scATAC <- AddMetaData(scATAC, metadata = celltype.predictions)
table(scATAC$seurat_clusters, scATAC$predicted.id)
# 保存数据
saveRDS(scATAC, file = "RAM-rna-atac-Integrated.rds")