annotate ribowaltz.R @ 1:e25d81465c23 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
author iuc
date Mon, 23 Oct 2023 12:10:37 +0000
parents 8e903cb3f919
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
1 # setup R error handling to go to stderr
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
2 options(show.error.messages = FALSE, error = function() {
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
3 cat(geterrmessage(), file = stderr())
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
4 q("no", 1, FALSE)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
5 })
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
6
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
7 # we need that to not crash galaxy with an UTF8 error on German LC settings.
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
8 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
9 library("getopt")
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
10 options(stringAsFactors = FALSE, useFancyQuotes = FALSE)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
11 args <- commandArgs(trailingOnly = TRUE)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
12
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
13 # get options, using the spec as defined by the enclosed list.
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
14 # we read the options from the default: commandArgs(TRUE).
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
15 spec <- matrix(c(
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
16 "quiet", "q", 0, "logical",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
17 "help", "h", 0, "logical",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
18 "bamdir", "b", 1, "character",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
19 "gtffile", "g", 1, "character",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
20 "codon_coverage_info", "Y", 1, "character",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
21 "cds_coverage_info", "Z", 1, "character",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
22 "psite_info_rdata", "O", 0, "character",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
23 "refseq_sep", "s", 0, "character",
1
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
24 "indel_threshold", "t", 0, "integer",
0
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
25 "params_duplicate_filterting", "d", 0, "character",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
26 "params_peridiocity_filterting", "l", 0, "character",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
27 "params_custom_filterting", "c", 0, "character",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
28 "params_psite_additional", "p", 0, "character",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
29 "params_coverage_additional", "C", 0, "character"
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
30 ), byrow = TRUE, ncol = 4)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
31 opt <- getopt(spec)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
32
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
33 # if help was asked for print a friendly message
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
34 # and exit with a non-zero error code
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
35 if (!is.null(opt$help)) {
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
36 cat(getopt(spec, usage = TRUE))
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
37 q(status = 1)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
38 }
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
39
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
40 verbose <- is.null(opt$quiet)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
41
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
42 library("riboWaltz")
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
43
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
44 # create annotation data table
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
45 annotation_dt <- create_annotation(opt$gtffile)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
46
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
47 sep <- opt$refseq_sep
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
48 if (opt$refseq_sep == "") {
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
49 sep <- NULL
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
50 }
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
51 # convert alignments in BAM files into list of data tables
1
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
52 reads_list <- bamtolist(bamfolder = opt$bamdir, annotation = annotation_dt, refseq_sep = sep, indel_threshold = opt$indel_threshold)
0
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
53
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
54 library("jsonlite")
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
55 # remove duplicate reads
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
56 if (!is.null(opt$params_duplicate_filterting)) {
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
57 json_duplicate_filterting <- fromJSON(opt$params_duplicate_filterting)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
58 reads_list <- duplicates_filter(
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
59 data = reads_list,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
60 extremity = json_duplicate_filterting$extremity,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
61 keep = json_duplicate_filterting$keep
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
62 )
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
63 }
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
64
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
65 # selection of read lengths - periodicity filtering
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
66 if (!is.null(opt$params_peridiocity_filterting)) {
1
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
67 json_peridiocity_filterting <- fromJSON(opt$params_peridiocity_filterting)
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
68 reads_list <- length_filter(
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
69 data = reads_list,
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
70 length_filter_mode = "periodicity",
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
71 periodicity_threshold = json_peridiocity_filterting$periodicity_threshold
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
72 )
0
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
73 }
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
74 # selection of read lengths - length range filtering
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
75 if (!is.null(opt$params_custom_filterting)) {
1
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
76 json_custom_filterting <- fromJSON(opt$params_custom_filterting)
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
77 reads_list <- length_filter(
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
78 data = reads_list,
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
79 length_filter_mode = "custom",
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
80 length_range = json_custom_filterting$length_range
e25d81465c23 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit 416063685092b818a398e00d5027f7fe742230f1
iuc
parents: 0
diff changeset
81 )
0
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
82 }
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
83
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
84 # compute P-site offset
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
85 json_psite_additional <- fromJSON(opt$params_psite_additional)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
86 psite_offset <- psite(
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
87 reads_list,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
88 start = json_psite_additional$use_start,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
89 flanking = json_psite_additional$flanking,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
90 extremity = json_psite_additional$psite_extrimity,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
91 plot = TRUE,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
92 cl = json_psite_additional$cl,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
93 plot_format = "pdf",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
94 plot_dir = "plots"
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
95 )
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
96 psite_offset
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
97
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
98 reads_psite_list <- psite_info(reads_list, psite_offset)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
99 reads_psite_list
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
100 # write a separate P-site offset info table for each sample
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
101 for (sample in names(reads_psite_list)) {
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
102 write.table(
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
103 reads_psite_list[[sample]],
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
104 file = paste(sample, "psite_info.tsv", sep = "_"),
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
105 sep = "\t", row.names = FALSE, quote = FALSE
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
106 )
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
107 print(paste(sample, "psite_info.tsv", sep = "_"))
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
108 }
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
109
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
110 # write R object to a file
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
111 if (!is.null(opt$psite_info_rdata)) {
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
112 save(reads_psite_list, annotation_dt, file = opt$psite_info_rdata)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
113 }
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
114
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
115 json_coverage_additional <- fromJSON(opt$params_coverage_additional)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
116 # codon coverage
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
117 codon_coverage_out <- codon_coverage(
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
118 reads_psite_list,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
119 annotation_dt,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
120 psite = json_coverage_additional$psites_per_region,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
121 min_overlap = json_coverage_additional$min_overlap
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
122 )
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
123 write.table(codon_coverage_out, file = opt$codon_coverage_info, sep = "\t", row.names = FALSE, quote = FALSE)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
124
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
125 # CDS coverage
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
126 cds_coverage_out <- cds_coverage(
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
127 reads_psite_list,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
128 annotation_dt,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
129 start_nts = json_coverage_additional$start_nts,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
130 stop_nts = json_coverage_additional$stop_nts
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
131 )
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
132 write.table(cds_coverage_out, file = opt$cds_coverage_info, sep = "\t", row.names = FALSE, quote = FALSE)