comparison signac-geneactivity.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("--fragment-file"),
22 action = "store",
23 default = NA,
24 type = 'character',
25 help = "Fragments file."
26 ),
27 make_option(
28 c("--assay"),
29 action = "store",
30 default = NULL,
31 type = 'character',
32 help = "Assay."
33 ),
34 make_option(
35 c("--features"),
36 action = "store",
37 default = NA,
38 type = 'character',
39 help = "Features."
40 ),
41 make_option(
42 c("--extend-upstream"),
43 action = "store",
44 default = NA,
45 type = 'numeric',
46 help = "Number of bases to extend upstream of the TSS."
47 ),
48 make_option(
49 c("--extend-downstream"),
50 action = "store",
51 default = NA,
52 type = 'numeric',
53 help = "Number of bases to extend downstream of the TSS."
54 ),
55 make_option(
56 c("--biotypes"),
57 action = "store",
58 default = NA,
59 type = 'character',
60 help = "Gene biotypes to include. If NULL, use all biotypes in the gene annotation."
61 ),
62 make_option(
63 c("--max-width"),
64 action = "store",
65 default = NA,
66 type = 'numeric',
67 help = "Maximum allowed gene width for a gene to be quantified."
68 ),
69 make_option(
70 c("--output-object-file"),
71 action = "store",
72 default = NA,
73 type = 'character',
74 help = "File name in which to store serialized R matrix object."
75 )
76 )
77
78 opt <- wsc_parse_args(option_list)
79
80 suppressPackageStartupMessages(require(Seurat))
81 suppressPackageStartupMessages(require(Signac))
82
83 set.seed(1234)
84
85 if (! file.exists(opt$signac_object)){
86 stop((paste('File', opt$signac_object, 'does not exist')))
87 }
88
89 signac_object <- readRDS(file = opt$signac_object)
90
91 signac_object@assays$peaks@fragments[[1]]@path <- opt$fragment_file
92
93 # Check features
94 features <- NULL
95 if (! is.null(opt$features) && opt$features != 'NULL'){
96 if (file.exists(opt$features)){
97 features <- readLines(opt$features)
98 }
99 }
100
101 # Check assay
102 assay <- NULL
103 if (! is.null(opt$assay) && opt$assay != 'NULL'){
104 assay <- opt$assay
105 }
106
107 saveRDS(GeneActivity(object = signac_object, assay = assay, features = features, extend.upstream = opt$extend_upstream, extend.downstream = opt$extend_downstream, biotypes = opt$biotypes, max.width = opt$max_width), file = opt$output_object_file)