# HG changeset patch
# User iuc
# Date 1663878620 0
# Node ID 8e903cb3f91925708a15360d48b4e75f8ca19ce8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
diff -r 000000000000 -r 8e903cb3f919 macros.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/macros.xml Thu Sep 22 20:30:20 2022 +0000
@@ -0,0 +1,28 @@
+
+
+
+ ribowaltz
+ r-getopt
+
+
+ 1.2.0
+ 21.05
+
+
+ topic_4027
+
+
+ operation_0439
+
+
+
+
+ 10.1371/journal.pcbi.1006169
+
+
+
+
+ riboWaltz
+
+
+
diff -r 000000000000 -r 8e903cb3f919 ribowaltz.R
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ribowaltz.R Thu Sep 22 20:30:20 2022 +0000
@@ -0,0 +1,131 @@
+# setup R error handling to go to stderr
+options(show.error.messages = FALSE, error = function() {
+ cat(geterrmessage(), file = stderr())
+ q("no", 1, FALSE)
+})
+
+# we need that to not crash galaxy with an UTF8 error on German LC settings.
+loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
+library("getopt")
+options(stringAsFactors = FALSE, useFancyQuotes = FALSE)
+args <- commandArgs(trailingOnly = TRUE)
+
+# get options, using the spec as defined by the enclosed list.
+# we read the options from the default: commandArgs(TRUE).
+spec <- matrix(c(
+ "quiet", "q", 0, "logical",
+ "help", "h", 0, "logical",
+ "bamdir", "b", 1, "character",
+ "gtffile", "g", 1, "character",
+ "codon_coverage_info", "Y", 1, "character",
+ "cds_coverage_info", "Z", 1, "character",
+ "psite_info_rdata", "O", 0, "character",
+ "refseq_sep", "s", 0, "character",
+ "params_duplicate_filterting", "d", 0, "character",
+ "params_peridiocity_filterting", "l", 0, "character",
+ "params_custom_filterting", "c", 0, "character",
+ "params_psite_additional", "p", 0, "character",
+ "params_coverage_additional", "C", 0, "character"
+), byrow = TRUE, ncol = 4)
+opt <- getopt(spec)
+
+# if help was asked for print a friendly message
+# and exit with a non-zero error code
+if (!is.null(opt$help)) {
+ cat(getopt(spec, usage = TRUE))
+ q(status = 1)
+}
+
+verbose <- is.null(opt$quiet)
+
+library("riboWaltz")
+
+# create annotation data table
+annotation_dt <- create_annotation(opt$gtffile)
+
+sep <- opt$refseq_sep
+if (opt$refseq_sep == "") {
+ sep <- NULL
+}
+# convert alignments in BAM files into list of data tables
+reads_list <- bamtolist(bamfolder = opt$bamdir, annotation = annotation_dt, refseq_sep = sep)
+
+library("jsonlite")
+# remove duplicate reads
+if (!is.null(opt$params_duplicate_filterting)) {
+ json_duplicate_filterting <- fromJSON(opt$params_duplicate_filterting)
+ reads_list <- duplicates_filter(
+ data = reads_list,
+ extremity = json_duplicate_filterting$extremity,
+ keep = json_duplicate_filterting$keep
+ )
+}
+
+# selection of read lengths - periodicity filtering
+if (!is.null(opt$params_peridiocity_filterting)) {
+ json_peridiocity_filterting <- fromJSON(opt$params_peridiocity_filterting)
+ reads_list <- length_filter(
+ data = reads_list,
+ length_filter_mode = "periodicity",
+ periodicity_threshold = json_peridiocity_filterting$periodicity_threshold
+ )
+}
+# selection of read lengths - length range filtering
+if (!is.null(opt$params_custom_filterting)) {
+ json_custom_filterting <- fromJSON(opt$params_custom_filterting)
+ reads_list <- length_filter(
+ data = reads_list,
+ length_filter_mode = "custom",
+ length_range = json_custom_filterting$length_range
+ )
+}
+
+# compute P-site offset
+json_psite_additional <- fromJSON(opt$params_psite_additional)
+psite_offset <- psite(
+ reads_list,
+ start = json_psite_additional$use_start,
+ flanking = json_psite_additional$flanking,
+ extremity = json_psite_additional$psite_extrimity,
+ plot = TRUE,
+ cl = json_psite_additional$cl,
+ plot_format = "pdf",
+ plot_dir = "plots"
+)
+psite_offset
+
+reads_psite_list <- psite_info(reads_list, psite_offset)
+reads_psite_list
+# write a separate P-site offset info table for each sample
+for (sample in names(reads_psite_list)) {
+ write.table(
+ reads_psite_list[[sample]],
+ file = paste(sample, "psite_info.tsv", sep = "_"),
+ sep = "\t", row.names = FALSE, quote = FALSE
+ )
+ print(paste(sample, "psite_info.tsv", sep = "_"))
+}
+
+# write R object to a file
+if (!is.null(opt$psite_info_rdata)) {
+ save(reads_psite_list, annotation_dt, file = opt$psite_info_rdata)
+}
+
+json_coverage_additional <- fromJSON(opt$params_coverage_additional)
+# codon coverage
+codon_coverage_out <- codon_coverage(
+ reads_psite_list,
+ annotation_dt,
+ psite = json_coverage_additional$psites_per_region,
+ min_overlap = json_coverage_additional$min_overlap
+)
+write.table(codon_coverage_out, file = opt$codon_coverage_info, sep = "\t", row.names = FALSE, quote = FALSE)
+
+# CDS coverage
+cds_coverage_out <- cds_coverage(
+ reads_psite_list,
+ annotation_dt,
+ start_nts = json_coverage_additional$start_nts,
+ stop_nts = json_coverage_additional$stop_nts
+)
+write.table(cds_coverage_out, file = opt$cds_coverage_info, sep = "\t", row.names = FALSE, quote = FALSE)
diff -r 000000000000 -r 8e903cb3f919 ribowaltz_plot.R
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ribowaltz_plot.R Thu Sep 22 20:30:20 2022 +0000
@@ -0,0 +1,152 @@
+# setup R error handling to go to stderr
+options(show.error.messages = FALSE, error = function() {
+ cat(geterrmessage(), file = stderr())
+ q("no", 1, FALSE)
+})
+
+# we need that to not crash galaxy with an UTF8 error on German LC settings.
+loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
+library("getopt")
+options(stringAsFactors = FALSE, useFancyQuotes = FALSE)
+args <- commandArgs(trailingOnly = TRUE)
+
+# get options, using the spec as defined by the enclosed list.
+# we read the options from the default: commandArgs(TRUE).
+spec <- matrix(c(
+ "quiet", "q", 0, "logical",
+ "help", "h", 0, "logical",
+ "input_rdata", "i", 1, "character",
+ "params_rlength_distr", "r", 0, "character",
+ "params_rends_heat", "e", 0, "character",
+ "region_psite_plot", "R", 0, "logical",
+ "params_trint_periodicity", "t", 0, "character",
+ "params_metaplots", "m", 0, "character",
+ "params_codon_usage_psite", "u", 0, "character"
+), byrow = TRUE, ncol = 4)
+opt <- getopt(spec)
+
+# if help was asked for print a friendly message
+# and exit with a non-zero error code
+if (!is.null(opt$help)) {
+ cat(getopt(spec, usage = TRUE))
+ q(status = 1)
+}
+
+verbose <- is.null(opt$quiet)
+
+library("riboWaltz")
+library("jsonlite")
+
+load(opt$input_rdata)
+
+if (!is.null(opt$params_rlength_distr)) {
+ pdf("read_lengths.pdf")
+ json_rlength_distr <- fromJSON(opt$params_rlength_distr)
+ length_dist <- rlength_distr(
+ reads_psite_list,
+ sample = names(reads_psite_list),
+ cl = json_rlength_distr$cl,
+ multisamples = json_rlength_distr$multisamples,
+ plot_style = json_rlength_distr$plot_style
+ )
+ print(length_dist)
+ dev.off()
+}
+
+if (!is.null(opt$params_rends_heat)) {
+ pdf("read_ends_heatmap.pdf", height = 5 * length(reads_psite_list), width = 15)
+ json_rends_heat <- fromJSON(opt$params_rends_heat)
+ for (sample_name in names(reads_psite_list)) {
+ ends_heatmap <- rends_heat(
+ reads_psite_list,
+ annotation_dt,
+ sample = sample_name,
+ cl = json_rends_heat$cl,
+ utr5l = json_rends_heat$utr5l,
+ cdsl = json_rends_heat$cdsl,
+ utr3l = json_rends_heat$utr3l
+ )
+ print(ends_heatmap[["plot"]])
+ }
+ dev.off()
+}
+
+if (!is.null(opt$region_psite_plot)) {
+ pdf("psites_per_region.pdf", height = 12, width = 7 * length(reads_psite_list))
+ psite_region <- region_psite(reads_psite_list, annotation_dt, sample = names(reads_psite_list))
+ print(psite_region[["plot"]])
+ dev.off()
+}
+
+if (!is.null(opt$params_trint_periodicity)) {
+ pdf("trinucleotide_periodicity.pdf", height = 6 * length(reads_psite_list), width = 10)
+ json_trint_periodicity <- fromJSON(opt$params_trint_periodicity)
+ frames_stratified <- frame_psite_length(
+ reads_psite_list,
+ sample = names(reads_psite_list),
+ cl = json_trint_periodicity$cl,
+ region = json_trint_periodicity$region,
+ length_range = json_trint_periodicity$length_range
+ )
+ frames_stratified[["plot"]]
+ frames <- frame_psite_length(
+ reads_psite_list,
+ sample = names(reads_psite_list),
+ region = json_trint_periodicity$region,
+ length_range = json_trint_periodicity$length_range
+ )
+ print(frames[["plot"]])
+ dev.off()
+}
+
+if (!is.null(opt$params_metaplots)) {
+ pdf("metaplots.pdf", height = 5 * length(reads_psite_list), width = 24)
+ json_metaplots <- fromJSON(opt$params_metaplots)
+ metaprofile <- metaprofile_psite(
+ reads_psite_list,
+ annotation_dt,
+ sample = names(reads_psite_list),
+ multisamples = json_metaplots$multisamples,
+ plot_style = json_metaplots$plot_style,
+ length_range = json_metaplots$length_range,
+ frequency = json_metaplots$frequency,
+ utr5l = json_metaplots$utr5l,
+ cdsl = json_metaplots$cdsl,
+ utr3l = json_metaplots$utr3l,
+ plot_title = "sample.transcript.length_range"
+ )
+ print(metaprofile)
+ sample_list <- list()
+ for (sample_name in names(reads_psite_list)) {
+ sample_list[[sample_name]] <- c(sample_name)
+ }
+ metaheatmap <- metaheatmap_psite(
+ reads_psite_list,
+ annotation_dt,
+ sample = sample_list,
+ length_range = json_metaplots$length_range,
+ utr5l = json_metaplots$utr5l,
+ cdsl = json_metaplots$cdsl,
+ utr3l = json_metaplots$utr3l,
+ plot_title = "Comparison metaheatmap"
+ )
+ print(metaheatmap[["plot"]])
+ dev.off()
+}
+
+if (!is.null(opt$params_codon_usage_psite)) {
+ pdf("codon_usage.pdf", height = 6, width = 16)
+ json_codon_usage_psite <- fromJSON(opt$params_codon_usage_psite)
+ for (sample_name in names(reads_psite_list)) {
+ cu_barplot <- codon_usage_psite(
+ reads_psite_list,
+ annotation_dt,
+ sample = sample_name,
+ fastapath = json_codon_usage_psite$fastapath,
+ fasta_genome = FALSE,
+ frequency_normalization = json_codon_usage_psite$frequency
+ )
+ print(cu_barplot[["plot"]])
+ }
+ dev.off()
+}
diff -r 000000000000 -r 8e903cb3f919 ribowaltz_plot.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ribowaltz_plot.xml Thu Sep 22 20:30:20 2022 +0000
@@ -0,0 +1,253 @@
+
+ visual inspection of ribosome profiling data
+
+ macros.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 000000000000 -r 8e903cb3f919 test-data/rep1.bam
Binary file test-data/rep1.bam has changed
diff -r 000000000000 -r 8e903cb3f919 test-data/rep1.rdata
Binary file test-data/rep1.rdata has changed
diff -r 000000000000 -r 8e903cb3f919 test-data/rep1_annot.gtf.gz
Binary file test-data/rep1_annot.gtf.gz has changed