annotate ribowaltz.R @ 0:8e903cb3f919 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
author iuc
date Thu, 22 Sep 2022 20:30:20 +0000
parents
children e25d81465c23
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",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
24 "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
25 "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
26 "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
27 "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
28 "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
29 ), 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
30 opt <- getopt(spec)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
31
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
32 # 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
33 # 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
34 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
35 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
36 q(status = 1)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
37 }
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 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
40
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
41 library("riboWaltz")
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
42
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
43 # 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
44 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
45
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
46 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
47 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
48 sep <- NULL
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
49 }
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
50 # convert alignments in BAM files into list of data tables
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
51 reads_list <- bamtolist(bamfolder = opt$bamdir, annotation = annotation_dt, refseq_sep = sep)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
52
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
53 library("jsonlite")
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
54 # remove duplicate reads
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
55 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
56 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
57 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
58 data = reads_list,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
59 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
60 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
61 )
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 # 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
65 if (!is.null(opt$params_peridiocity_filterting)) {
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
66 json_peridiocity_filterting <- fromJSON(opt$params_peridiocity_filterting)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
67 reads_list <- length_filter(
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
68 data = reads_list,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
69 length_filter_mode = "periodicity",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
70 periodicity_threshold = json_peridiocity_filterting$periodicity_threshold
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
71 )
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
72 }
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
73 # 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
74 if (!is.null(opt$params_custom_filterting)) {
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
75 json_custom_filterting <- fromJSON(opt$params_custom_filterting)
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
76 reads_list <- length_filter(
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
77 data = reads_list,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
78 length_filter_mode = "custom",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
79 length_range = json_custom_filterting$length_range
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
80 )
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
81 }
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 # 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
84 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
85 psite_offset <- psite(
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
86 reads_list,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
87 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
88 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
89 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
90 plot = TRUE,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
91 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
92 plot_format = "pdf",
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
93 plot_dir = "plots"
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
94 )
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
95 psite_offset
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
96
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
97 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
98 reads_psite_list
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
99 # 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
100 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
101 write.table(
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
102 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
103 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
104 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
105 )
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
106 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
107 }
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 # 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
110 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
111 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
112 }
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 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
115 # codon coverage
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
116 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
117 reads_psite_list,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
118 annotation_dt,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
119 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
120 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
121 )
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
122 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
123
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
124 # CDS coverage
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
125 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
126 reads_psite_list,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
127 annotation_dt,
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
128 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
129 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
130 )
8e903cb3f919 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
131 write.table(cds_coverage_out, file = opt$cds_coverage_info, sep = "\t", row.names = FALSE, quote = FALSE)