comparison signac-createAssayObject.R @ 0:6e0b320d8b6a draft default tip

"planemo upload commit dc808171975d0012e25bd7b32adc7a5a5c56a145-dirty"
author gaelcge
date Tue, 02 Aug 2022 19:11:27 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:6e0b320d8b6a
1 #!/usr/bin/env Rscript
2
3 # Load optparse we need to check inputs
4
5 suppressPackageStartupMessages(require(optparse))
6
7 # Load common functions
8
9 suppressPackageStartupMessages(require(workflowscriptscommon))
10
11 # parse options
12 option_list = list(
13 make_option(
14 c("--signac-object"),
15 action = "store",
16 default = NA,
17 type = 'character',
18 help = "A Seurat object."
19 ),
20 make_option(
21 c("--counts"),
22 action = "store",
23 default = NA,
24 type = 'character',
25 help = "Counts Matrix."
26 ),
27 make_option(
28 c("--name"),
29 action = "store",
30 default = NA,
31 type = 'character',
32 help = "Assay Name."
33 ),
34 make_option(
35 c("--min-cells"),
36 action = "store",
37 default = NA,
38 type = 'numeric',
39 help = "Min Cells."
40 ),
41 make_option(
42 c("--min-features"),
43 action = "store",
44 default = NA,
45 type = 'numeric',
46 help = "Min Features."
47 ),
48 make_option(
49 c("--method"),
50 action = "store",
51 default = NA,
52 type = 'character',
53 help = "Method for normalization."
54 ),
55 make_option(
56 c("--scale-factor"),
57 action = "store",
58 default = 10000,
59 type = 'numeric',
60 help = "Sets the scale factor for cell-level normalization."
61 ),
62 make_option(
63 c("--margin"),
64 action = "store",
65 default = NA,
66 type = 'character',
67 help = "If performing CLR normalization, normalize across features (1) or cells (2)."
68 ),
69 make_option(
70 c("--output-object-file"),
71 action = "store",
72 default = NA,
73 type = 'numeric',
74 help = "File name in which to store serialized R matrix object."
75 )
76 )
77 opt <- wsc_parse_args(option_list)
78
79 suppressPackageStartupMessages(require(Seurat))
80 suppressPackageStartupMessages(require(Signac))
81
82 set.seed(1234)
83
84 if (! file.exists(opt$signac_object)){
85 stop((paste('File', opt$signac_object, 'does not exist')))
86 }
87 if (! file.exists(opt$counts)){
88 stop((paste('File', opt$counts, 'does not exist')))
89 }
90
91 signac_object <- readRDS(file = opt$signac_object)
92 counts <- readRDS(opt$counts)
93
94 signac_object[[opt$name]] <- CreateAssayObject(counts = counts)#, min.cells = opt$min_cells, min.features = opt$min_features)
95
96 signac_object <- NormalizeData(object = signac_object, normalization.method = opt$method, scale.factor = opt$scale_factor, margin = opt$margin, assay = opt$name)
97
98 saveRDS(signac_object, file = opt$output_object_file)