Previous changeset 2:243ed53cbc0d (2019-02-10) Next changeset 4:e11f91575af6 (2019-03-20) |
Commit message:
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/sr_bowtie_dataset_annotation commit 53e9bab2c20411f34ac09688de2f2cc8ae8c46a4 |
modified:
sr_bowtie_dataset_annotation.xml test-data/sample1_output.tab test-data/sample_output.tab |
added:
barplot.r test-data/sample1_output.pdf test-data/sample_output.pdf |
b |
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") |
b |
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 @@ -<tool id="sr_bowtie_dataset_annotation" name="Annotate smRNA dataset" version="2.0.2"> +<tool id="sr_bowtie_dataset_annotation" name="Annotate smRNA dataset" version="2.1.0"> <description>by iterative alignments with sRbowtie</description> <requirements> <requirement type="package" version="1.1.2">bowtie</requirement> + <requirement type="package" version="1.3.2">r-optparse</requirement> + <requirement type="package" version="2.2.1">r-ggplot2</requirement> + <requirement type="package" version="0.4.1">r-scales</requirement> </requirements> <command detect_errors="exit_code"><![CDATA[ #if $refGenomeSource1.genomeSource == "history": @@ -11,9 +14,9 @@ #else: #set index_path = $refGenomeSource1.index.fields.path #end if - #if $input.extension == "fasta": + #if $input.is_of_type('fasta'): #set format = "-f" - #elif $input.extension == "fastq": + #elif $input.is_of_type('fastq'): #set format = "-q" #end if #if $format == '-f': @@ -60,7 +63,8 @@ echo -e "$i.ownFile.name\t\${class_aligned}\n" >> $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 ]]></command> <inputs> <param name="input" type="data" format="fasta,fastq" label="Input file: reads clipped from their adapter" help="Only with clipped, raw fasta or fastq files"/> @@ -93,12 +97,13 @@ <!-- End of other bowtie index selections --> </inputs> <outputs> - <data format="tabular" name="output" label="Cascade Annotation Analysis"> - <actions> - <action name="column_names" type="metadata" default="Reference Index,Number of reads" /> - </actions> - </data> - </outputs> + <data format="tabular" name="output" label="Cascade Annotation Analysis"> + <actions> + <action name="column_names" type="metadata" default="Reference Index,Number of reads" /> + </actions> + </data> + <data name="barplot" format="pdf" label="barplot from ${on_string}" /> + </outputs> <tests> <test> <param name="input" value ="sample1.fa" ftype="fasta" /> @@ -107,6 +112,7 @@ <param name="AdditionalQueries_0|ownFile" value="dme_miR21_hairpin.fa" ftype="fasta" /> <param name="AdditionalQueries_1|ownFile" value="Ensembl_transposon_set.fa" ftype="fasta" /> <output name="output" ftype="tabular" file="sample1_output.tab" /> + <output name="barplot" ftype="pdf" file="sample1_output.pdf" /> </test> <test> <param name="input" value ="sample.fastq" ftype="fastq" /> @@ -115,6 +121,7 @@ <param name="AdditionalQueries_0|ownFile" value="dme_miR21_hairpin.fa" ftype="fasta" /> <param name="AdditionalQueries_1|ownFile" value="Ensembl_transposon_set.fa" ftype="fasta" /> <output name="output" ftype="tabular" file="sample_output.tab" /> + <output name="barplot" ftype="pdf" file="sample_output.pdf" /> </test> </tests> <help> |
b |
diff -r 243ed53cbc0d -r 008de522b3ea test-data/sample1_output.pdf |
b |
Binary file test-data/sample1_output.pdf has changed |
b |
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 |
b |
@@ -4,5 +4,5 @@ Ensembl_transposon_set.fa 2689 -Unmatched to previous indexes 265 +Not classified 265 |
b |
diff -r 243ed53cbc0d -r 008de522b3ea test-data/sample_output.pdf |
b |
Binary file test-data/sample_output.pdf has changed |
b |
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 |
b |
@@ -4,5 +4,5 @@ Ensembl_transposon_set.fa 560 -Unmatched to previous indexes 78 +Not classified 78 |