annotate scripts/seurat-scale-data.R @ 0:b9424c715a0d draft default tip

planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
author ebi-gxa
date Sat, 02 Mar 2024 10:40:43 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
1 #!/usr/bin/env Rscript
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
2
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
3 # Load optparse we need to check inputs
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
4
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
5 suppressPackageStartupMessages(require(optparse))
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
6
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
7 # Load common functions
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
8
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
9 suppressPackageStartupMessages(require(workflowscriptscommon))
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
10
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
11 # parse options
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
12
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
13 option_list = list(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
14 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
15 c("-i", "--input-object-file"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
16 action = "store",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
17 default = NA,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
18 type = 'character',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
19 help = "File name in which a serialized R matrix object may be found."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
20 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
21 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
22 c("--input-format"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
23 action = "store",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
24 default = "seurat",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
25 type = 'character',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
26 help = "Either loom, seurat, anndata or singlecellexperiment for the input format to read."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
27 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
28 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
29 c("--output-format"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
30 action = "store",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
31 default = "seurat",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
32 type = 'character',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
33 help = "Either loom, seurat, anndata or singlecellexperiment for the output format."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
34 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
35 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
36 c("-e", "--genes-use"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
37 action = "store",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
38 default = NULL,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
39 type = 'character',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
40 help = "File with gene names to scale/center (one gene per line). Default is all genes in object@data."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
41 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
42 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
43 c("-v", "--vars-to-regress"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
44 action = "store",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
45 default = NULL,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
46 type = 'character',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
47 help = "Comma-separated list of variables to regress out (previously latent.vars in RegressOut). For example, nUMI, or percent.mito."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
48 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
49 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
50 c("-m", "--model-use"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
51 action = "store",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
52 default = 'linear',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
53 type = 'character',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
54 help = "Use a linear model or generalized linear model (poisson, negative binomial) for the regression. Options are 'linear' (default), 'poisson', and 'negbinom'."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
55 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
56 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
57 c("-u", "--use-umi"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
58 action = "store",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
59 default = FALSE,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
60 type = 'logical',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
61 help = "Regress on UMI count data. Default is FALSE for linear modeling, but automatically set to TRUE if model.use is 'negbinom' or 'poisson'."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
62 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
63 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
64 c("-s", "--do-not-scale"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
65 action = "store_true",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
66 default = FALSE,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
67 type = 'logical',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
68 help = "Skip the data scale."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
69 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
70 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
71 c("-c", "--do-not-center"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
72 action = "store_true",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
73 default = FALSE,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
74 type = 'logical',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
75 help = "Skip data centering."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
76 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
77 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
78 c("-x", "--scale-max"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
79 action = "store",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
80 default = 10,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
81 type = 'double',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
82 help = "Max value to return for scaled data. The default is 10. Setting this can help reduce the effects of genes that are only expressed in a very small number of cells. If regressing out latent variables and using a non-linear model, the default is 50."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
83 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
84 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
85 c("-b", "--block-size"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
86 action = "store",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
87 default = 1000,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
88 type = 'integer',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
89 help = "Default size for number of genes to scale at in a single computation. Increasing block.size may speed up calculations but at an additional memory cost."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
90 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
91 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
92 c("-d", "--min-cells-to-block"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
93 action = "store",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
94 default = 1000,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
95 type = 'integer',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
96 help = "If object contains fewer than this number of cells, don't block for scaling calculations."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
97 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
98 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
99 c("-n", "--check-for-norm"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
100 action = "store",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
101 default = TRUE,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
102 type = 'logical',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
103 help = "Check to see if data has been normalized, if not, output a warning (TRUE by default)."
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
104 ),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
105 make_option(
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
106 c("-o", "--output-object-file"),
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
107 action = "store",
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
108 default = NA,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
109 type = 'character',
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
110 help = "File name in which to store serialized R object of type 'Seurat'.'"
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
111 )
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
112 )
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
113
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
114 opt <- wsc_parse_args(option_list, mandatory = c('input_object_file', 'output_object_file'))
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
115
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
116 # Check parameter values
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
117
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
118 if ( ! file.exists(opt$input_object_file)){
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
119 stop((paste('File', opt$input_object_file, 'does not exist')))
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
120 }
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
121
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
122 if (! is.null(opt$genes_use)){
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
123 if (! file.exists(opt$genes_use)){
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
124 stop((paste('Supplied genes file', opt$genes_use, 'does not exist')))
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
125 }else{
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
126 genes_use <- readLines(opt$genes_use)
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
127 }
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
128 }else{
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
129 genes_use <- NULL
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
130 }
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
131
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
132 # break up opt$vars_to_regress into a list if it has commas
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
133 opt$vars_to_regress <- unlist(strsplit(opt$vars_to_regress, ","))
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
134
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
135 # Now we're hapy with the arguments, load Seurat and do the work
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
136
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
137 suppressPackageStartupMessages(require(Seurat))
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
138 if(opt$input_format == "loom" | opt$output_format == "loom") {
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
139 suppressPackageStartupMessages(require(SeuratDisk))
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
140 } else if(opt$input_format == "singlecellexperiment" | opt$output_format == "singlecellexperiment") {
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
141 suppressPackageStartupMessages(require(scater))
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
142 }
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
143
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
144 # Input from serialized R object
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
145
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
146 seurat_object <- read_seurat4_object(input_path = opt$input_object_file, format = opt$input_format)
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
147 # https://stackoverflow.com/questions/9129673/passing-list-of-named-parameters-to-function
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
148 # might be useful
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
149 scaled_seurat_object <- ScaleData(seurat_object,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
150 features = genes_use,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
151 vars.to.regress = opt$vars_to_regress,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
152 model.use = opt$model_use,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
153 use.umi = opt$use_umi,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
154 do.scale = !opt$do_not_scale,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
155 do.center = !opt$do_not_center,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
156 scale.max = opt$scale_max,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
157 block.size = opt$block_size,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
158 min.cells.to.block = opt$min_cells_to_block,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
159 verbose = FALSE)
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
160
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
161
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
162 # Output to a serialized R object
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
163 write_seurat4_object(seurat_object = scaled_seurat_object,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
164 output_path = opt$output_object_file,
b9424c715a0d planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
165 format = opt$output_format)