annotate scripts/seurat-scale-data.R @ 6:07fc9f4841b3 draft default tip

planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
author ebi-gxa
date Sat, 02 Mar 2024 10:42:01 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
1 #!/usr/bin/env Rscript
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
2
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
3 # Load optparse we need to check inputs
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
4
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
5 suppressPackageStartupMessages(require(optparse))
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
6
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
7 # Load common functions
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
8
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
9 suppressPackageStartupMessages(require(workflowscriptscommon))
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
10
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
11 # parse options
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
12
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
13 option_list = list(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
14 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
15 c("-i", "--input-object-file"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
16 action = "store",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
17 default = NA,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
18 type = 'character',
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
19 help = "File name in which a serialized R matrix object may be found."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
20 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
21 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
22 c("--input-format"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
23 action = "store",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
24 default = "seurat",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
25 type = 'character',
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
26 help = "Either loom, seurat, anndata or singlecellexperiment for the input format to read."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
27 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
28 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
29 c("--output-format"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
30 action = "store",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
31 default = "seurat",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
32 type = 'character',
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
33 help = "Either loom, seurat, anndata or singlecellexperiment for the output format."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
34 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
35 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
36 c("-e", "--genes-use"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
37 action = "store",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
38 default = NULL,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
39 type = 'character',
07fc9f4841b3 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."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
41 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
42 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
43 c("-v", "--vars-to-regress"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
44 action = "store",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
45 default = NULL,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
46 type = 'character',
07fc9f4841b3 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."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
48 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
49 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
50 c("-m", "--model-use"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
51 action = "store",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
52 default = 'linear',
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
53 type = 'character',
07fc9f4841b3 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'."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
55 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
56 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
57 c("-u", "--use-umi"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
58 action = "store",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
59 default = FALSE,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
60 type = 'logical',
07fc9f4841b3 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'."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
62 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
63 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
64 c("-s", "--do-not-scale"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
65 action = "store_true",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
66 default = FALSE,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
67 type = 'logical',
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
68 help = "Skip the data scale."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
69 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
70 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
71 c("-c", "--do-not-center"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
72 action = "store_true",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
73 default = FALSE,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
74 type = 'logical',
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
75 help = "Skip data centering."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
76 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
77 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
78 c("-x", "--scale-max"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
79 action = "store",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
80 default = 10,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
81 type = 'double',
07fc9f4841b3 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."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
83 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
84 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
85 c("-b", "--block-size"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
86 action = "store",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
87 default = 1000,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
88 type = 'integer',
07fc9f4841b3 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."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
90 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
91 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
92 c("-d", "--min-cells-to-block"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
93 action = "store",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
94 default = 1000,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
95 type = 'integer',
07fc9f4841b3 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."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
97 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
98 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
99 c("-n", "--check-for-norm"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
100 action = "store",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
101 default = TRUE,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
102 type = 'logical',
07fc9f4841b3 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)."
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
104 ),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
105 make_option(
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
106 c("-o", "--output-object-file"),
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
107 action = "store",
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
108 default = NA,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
109 type = 'character',
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
110 help = "File name in which to store serialized R object of type 'Seurat'.'"
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
111 )
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
112 )
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
113
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
114 opt <- wsc_parse_args(option_list, mandatory = c('input_object_file', 'output_object_file'))
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
115
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
116 # Check parameter values
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
117
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
118 if ( ! file.exists(opt$input_object_file)){
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
119 stop((paste('File', opt$input_object_file, 'does not exist')))
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
120 }
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
121
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
122 if (! is.null(opt$genes_use)){
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
123 if (! file.exists(opt$genes_use)){
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
124 stop((paste('Supplied genes file', opt$genes_use, 'does not exist')))
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
125 }else{
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
126 genes_use <- readLines(opt$genes_use)
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
127 }
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
128 }else{
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
129 genes_use <- NULL
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
130 }
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
131
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
132 # break up opt$vars_to_regress into a list if it has commas
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
133 opt$vars_to_regress <- unlist(strsplit(opt$vars_to_regress, ","))
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
134
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
135 # Now we're hapy with the arguments, load Seurat and do the work
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
136
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
137 suppressPackageStartupMessages(require(Seurat))
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
138 if(opt$input_format == "loom" | opt$output_format == "loom") {
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
139 suppressPackageStartupMessages(require(SeuratDisk))
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
140 } else if(opt$input_format == "singlecellexperiment" | opt$output_format == "singlecellexperiment") {
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
141 suppressPackageStartupMessages(require(scater))
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
142 }
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
143
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
144 # Input from serialized R object
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
145
07fc9f4841b3 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)
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
147 # https://stackoverflow.com/questions/9129673/passing-list-of-named-parameters-to-function
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
148 # might be useful
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
149 scaled_seurat_object <- ScaleData(seurat_object,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
150 features = genes_use,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
151 vars.to.regress = opt$vars_to_regress,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
152 model.use = opt$model_use,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
153 use.umi = opt$use_umi,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
154 do.scale = !opt$do_not_scale,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
155 do.center = !opt$do_not_center,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
156 scale.max = opt$scale_max,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
157 block.size = opt$block_size,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
158 min.cells.to.block = opt$min_cells_to_block,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
159 verbose = FALSE)
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
160
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
161
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
162 # Output to a serialized R object
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
163 write_seurat4_object(seurat_object = scaled_seurat_object,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
164 output_path = opt$output_object_file,
07fc9f4841b3 planemo upload commit 0264c359f1d638bbbbab515a3502231f679cdcf6
ebi-gxa
parents:
diff changeset
165 format = opt$output_format)