Mercurial > repos > gaelcge > r_signac_galaxy
comparison signac-add_gene_annotations.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 | |
13 option_list = list( | |
14 make_option( | |
15 c("--signac-object"), | |
16 action = "store", | |
17 default = NA, | |
18 type = 'character', | |
19 help = "Filtered peak BC matrix file in h5 format." | |
20 ), | |
21 make_option( | |
22 c("--ens-db-genome"), | |
23 action = "store", | |
24 default = NA, | |
25 type = 'character', | |
26 help = "Metadata file." | |
27 ), | |
28 make_option( | |
29 c("--annotations"), | |
30 action = "store", | |
31 default = NA, | |
32 type = 'character', | |
33 help = "Genome version." | |
34 ), | |
35 make_option( | |
36 c("--output-object-file"), | |
37 action = "store", | |
38 default = NA, | |
39 type = 'character', | |
40 help = "File name in which to store serialized R matrix object." | |
41 ) | |
42 ) | |
43 | |
44 opt <- wsc_parse_args(option_list) | |
45 | |
46 suppressPackageStartupMessages(require(Seurat)) | |
47 suppressPackageStartupMessages(require(Signac)) | |
48 suppressPackageStartupMessages(require(GenomeInfoDb)) | |
49 suppressPackageStartupMessages(require(EnsDb.Hsapiens.v75)) | |
50 suppressPackageStartupMessages(require(EnsDb.Mmusculus.v79)) | |
51 | |
52 set.seed(1234) | |
53 | |
54 # extract gene annotations from EnsDb | |
55 signac_object <- readRDS(file = opt$signac_object) | |
56 | |
57 annotations <- GetGRangesFromEnsDb(ensdb = EnsDb.Hsapiens.v75) | |
58 print(annotations) | |
59 | |
60 # change to UCSC style since the data was mapped to hg19 | |
61 seqlevelsStyle(annotations) <- "UCSC" | |
62 genome(annotations) <- opt$annotations | |
63 | |
64 # add the gene information to the object | |
65 Annotation(signac_object) <- annotations | |
66 | |
67 print(signac_object) | |
68 | |
69 # Output to a serialized R object | |
70 saveRDS(signac_object, file = opt$output_object_file) |