-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.R
53 lines (45 loc) · 2.24 KB
/
example.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
## ----library and source---------------------------------------------------------------------------
library(Seurat)
library(SeuratData)
library(Azimuth)
library(patchwork)
library(tidyverse)
library(sctransform)
library(Matrix)
setwd('/home/rstudio/autoimmune_10x')
source('/screfmapping/ref_mapping_seuratobj.R')
source('/screfmapping/utils_seurat.R')
## ----Load reference---------------------------------------------------------------------------
# Reference for CD4T cells are included in Docker repo. No need to modify this section for CD4T analysis.
# Azimuth
reference <- LoadReference(path = "/screfmapping/data/Azimuth/human_pbmc_v1.0.0")
# Symphony
load("/screfmapping/data/ref_Reference_Mapping_20220525.RData")
file.copy(from = '/screfmapping/data/cache_symphony_sct.uwot',
to = '/home/rstudio/autoimmune_10x/cache_symphony_sct.uwot')
## ----parameter setting (change here)---------------------------------------------------------------
project.name <- "example"
prefix <- paste0("./output/", project.name, "/", project.name)
dir.create(paste0("./output/", project.name), recursive = T)
## ----reading data (change here)--------------------------------------------------------------------
# Load the PBMC dataset
pbmc.data <- Read10X(data.dir = "/filtered_gene_bc_matrices/hg19/")
q <- CreateSeuratObject(counts = pbmc.data,
project = project.name,
assay = "RNA",
min.cells = 3,
min.features = 200)
## ----extraction of CD4T-----------------------------------------------------------------------------
# if your seurat object contains only CD4T, skip this step
extract_cells_seuratobj(q, reference, prefix)
# load extracted CD4T
query_obj <- readRDS(paste0(prefix, "_CD4T_AssayData.rds"))
query_obj <- CreateSeuratObject(counts = query_obj,
project = project.name,
assay = "RNA",
min.cells = 3,
min.features = 200)
## ----run Symphony-----------------------------------------------------------------------------
reference_mapping_seuratobj(ref, query_obj, prefix)
## ----sessionInfo----------------------------------------------------------------------------------
sessionInfo()