# HG changeset patch # User artbio # Date 1549841511 18000 # Node ID 008de522b3eaf66d61b37f40b4da1c2f7a2b5de4 # Parent 243ed53cbc0d860af93ab34ae6f481f223fe164e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/sr_bowtie_dataset_annotation commit 53e9bab2c20411f34ac09688de2f2cc8ae8c46a4 diff -r 243ed53cbc0d -r 008de522b3ea barplot.r --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/barplot.r Sun Feb 10 18:31:51 2019 -0500 @@ -0,0 +1,48 @@ +if (length(commandArgs(TRUE)) == 0) { + system("Rscript barplot.r -h", intern = F) + q("no") +} + + +# load packages that are provided in the conda env +options( show.error.messages=F, + error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) +loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") +warnings() +library(optparse) +library(ggplot2) +library(scales) + + + +#Arguments +option_list = list( + make_option( + c("-i", "--input"), + default = NA, + type = 'character', + help = "Input file that contains count data (no header)" + ), + make_option( + c("-o", "--barplot"), + default = NA, + type = 'character', + help = "PDF output file" + ) +) + +opt = parse_args(OptionParser(option_list = option_list), + args = commandArgs(trailingOnly = TRUE)) + + +## +annotations = read.delim(opt$input, header=F) +colnames(annotations) = c("class", "counts") +annotations = cbind(annotations, fraction=annotations$counts/annotations$counts[1]) +annotations = annotations[-1,] +# ggplot2 plotting +ggplot(annotations, aes(x="classes", y=fraction, fill=class)) + +geom_bar(width = .7, position=position_stack(), stat = "identity") + +geom_text(aes(label = percent(fraction)), position = position_stack(vjust = 0.5),size = 4) +ggtitle('Class proportions') +ggsave(file=opt$barplot, device="pdf") diff -r 243ed53cbc0d -r 008de522b3ea sr_bowtie_dataset_annotation.xml --- a/sr_bowtie_dataset_annotation.xml Sun Feb 10 14:07:12 2019 -0500 +++ b/sr_bowtie_dataset_annotation.xml Sun Feb 10 18:31:51 2019 -0500 @@ -1,7 +1,10 @@ - + by iterative alignments with sRbowtie bowtie + r-optparse + r-ggplot2 + r-scales > $output && #end for remaining=\$(( \$(wc -l < class_unmatched.fa)/2)) && - echo -e "Unmatched to previous indexes\t\${remaining}\n" >> $output + echo -e "Not classified\t\${remaining}\n" >> $output && + Rscript $__tool_directory__/barplot.r --input $output --barplot $barplot ]]> @@ -93,12 +97,13 @@ - - - - - - + + + + + + + @@ -107,6 +112,7 @@ + @@ -115,6 +121,7 @@ + diff -r 243ed53cbc0d -r 008de522b3ea test-data/sample1_output.pdf Binary file test-data/sample1_output.pdf has changed diff -r 243ed53cbc0d -r 008de522b3ea test-data/sample1_output.tab --- a/test-data/sample1_output.tab Sun Feb 10 14:07:12 2019 -0500 +++ b/test-data/sample1_output.tab Sun Feb 10 18:31:51 2019 -0500 @@ -4,5 +4,5 @@ Ensembl_transposon_set.fa 2689 -Unmatched to previous indexes 265 +Not classified 265 diff -r 243ed53cbc0d -r 008de522b3ea test-data/sample_output.pdf Binary file test-data/sample_output.pdf has changed diff -r 243ed53cbc0d -r 008de522b3ea test-data/sample_output.tab --- a/test-data/sample_output.tab Sun Feb 10 14:07:12 2019 -0500 +++ b/test-data/sample_output.tab Sun Feb 10 18:31:51 2019 -0500 @@ -4,5 +4,5 @@ Ensembl_transposon_set.fa 560 -Unmatched to previous indexes 78 +Not classified 78