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

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