-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrnaseq_run_azimuth_231128.r
66 lines (49 loc) · 2.09 KB
/
scrnaseq_run_azimuth_231128.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
# clear workspace
rm(list = ls())
gc()
args <- commandArgs(TRUE) # to access command line arguments
print(args)
############################################################################################################################################################
work_dir <- args[1] ### WORKING/OUTPUT DIRECTORY
input_filename <- "nsclc_2023_11_27_08_03_25.rds" ### INPUT FILENAME
output_filename <- paste('scrnaseq_run_azimuth_231128', system("date '+_%Y_%m_%d_%H_%M_%S'", intern=TRUE), '.rds', sep = '') ### OUTPUT FILENAME
# load packages
library(BPCells)
library(Seurat)
library(SeuratObject)
library(SeuratDisk)
library(Azimuth)
library(SeuratData)
library(future)
library(dplyr)
options(future.globals.maxSize = 16e+09) # 16G
# change the current plan to access parallelization
plan("multisession", workers = availableCores())
plan()
# load data
cat(paste('\n', system("date", intern=TRUE), '---> loading data...', '\n'))
setwd(work_dir)
nsclc <- readRDS(input_filename)
cat(paste('\n', system("date", intern=TRUE), '---> loading data COMPLETE.', '\n'))
# annotate with Azimuth
cat(paste('\n', system("date", intern=TRUE), '---> starting annotate with Azimuth...', '\n'))
options(timeout = 1200)
nsclc <- RunAzimuth(nsclc, reference = "lungref")
cat(paste('\n', system("date", intern=TRUE), '---> annotate with Azimuth COMPLETE.', '\n'))
# save objects
cat(paste('\n', system("date", intern=TRUE), '---> saving output...', '\n'))
saveRDS(nsclc, file = output_filename)
cat(paste('\n', system("date", intern=TRUE), '---> save objects COMPLETE.', '\n'))
# cleanup
rm(nsclc)
gc()
# Explicitly close multisession workers by switching plan
plan(sequential)
plan()
############################################################################################################################################################
## print session info ##
cat("\nSession Info below: \n")
sessionInfo()
# clear workspace
rm(list = ls())
gc()