-
Notifications
You must be signed in to change notification settings - Fork 0
/
1. Read10x_CreateSeurat.R
41 lines (24 loc) · 1.16 KB
/
1. Read10x_CreateSeurat.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
# Read10x_CreateSeurat ----
## Specify a path of the directory of the Cell Ranger filtered_feature_bc_matrix
## output and it will return a list all of the respective Seurat objects
## Note: Name the filtered_feature_bc_matrix directories accordingly to have nicely named Seurat objects that represent the biology of each sample
Read10x_CreateSeurat <- function(dir_path) {
set.seed(1993)
require(Seurat)
objects <- as.list(list.dirs(dir_path, full.names = FALSE, recursive=F))
seurat_list <- list()
for (object in objects) {
print(object)
seurat_data <- Read10X(data.dir = paste0(dir_path, object))
seurat_obj <- CreateSeuratObject(counts = seurat_data,
min.features = 0,
min.cells = 0,
project = object)
seurat_list[[object]] <- seurat_obj
remove(seurat_data, seurat_obj)
}
return(seurat_list)
}
##eg.how to use function
data_path <- "C:/Users/Fotini/Documents/Meduoa_research/scrna_seq/data/test/"
samples <- Read10x_CreateSeurat(data_path)