Mercurial > repos > moheydarian > ggplot_histogram
changeset 29:68a008225c51 draft
Deleted selected files
| author | moheydarian |
|---|---|
| date | Tue, 11 Apr 2017 19:14:54 -0400 |
| parents | 1d1518b029d1 |
| children | 240d9329bf4b |
| files | ggplot_histogram.xml ggplotscripthistogram.R |
| diffstat | 2 files changed, 0 insertions(+), 327 deletions(-) [+] |
line wrap: on
line diff
--- a/ggplot_histogram.xml Tue Apr 11 18:35:55 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,192 +0,0 @@ -<tool id="ggplot_histogram" name="Histogram w ggplot2" version="0.1.3"> - <requirements> - <requirement type="package">r-getopt</requirement> - <requirement type="package">r-ggplot2</requirement> - <requirement type="package">r-reshape2</requirement> - </requirements> - <stdio> - <exit_code range="1:" /> - </stdio> - <command><![CDATA[ - Rscript ${__tool_directory__}/ggplotscripthistogram.R --input "$input1" --title "$title" - --xlab "$xlab" --ylab "$ylab" --transform "$transformation.transform" --scaling "$scaling.Plot_scaling" --density "$distribution.density" - --colorscheme "$coloring.colorscheme" --dim "$dimensions.plotdim" --facet "$group.facet" - --size "$size" --binwidth "$binwidth" --legend "$showlegend.legend" --output "Rplot.pdf" - #if str( $coloring.colorscheme ) == "Defined": - --colors ${coloring.colors} - --colororder ${coloring.colororder} - #else: - --colors=irrelevant - --colororder=1 - #end if - - #if str( $scaling.Plot_scaling ) == "Defined": - --xaxismin=${scaling.xaxismin} - --xaxismax=${scaling.xaxismax} - --yaxismin=${scaling.yaxismin} - --yaxismax=${scaling.yaxismax} - #else: - --xaxismin=0 - --xaxismax=1 - --yaxismin=2 - --yaxismax=3 - #end if - - #if str( $dimensions.plotdim ) == "Defined": - --woutputdim ${dimensions.woutputdim} - --houtputdim ${dimensions.houtputdim} - #else: - --woutputdim=7 - --houtputdim=7 - #end if - - ]]></command> - <inputs> - <param name="input1" type="data" format="tabular" label="Input should have column headers - these will be the columns that are plotted"/> - <param name="title" size="30" type="text" format="txt"/> - <param name="xlab" size="30" type="text" value="title of x-axis" label="Label for x-axis"/> - <param name="ylab" size="30" type="text" value="title of y-axis" label="Label for y-axis"/> - <param name="size" size="4" type="float" value="1" label="relative line width" /> - <param name="binwidth" size="4" type="float" value="0.5" label="Bin width for plotting"/> - <conditional name="transformation"> - <param name="transform" type="select" label="Advanced - log transformation"> - <option value="none">Plot the data as it is</option> - <option value="log2">Log2(value) transform my data</option> - <option value="log2plus1">Log2(value+1) transform my data</option> - <option value="log10">Log10(value) transform my data</option> - <option value="log10plus1">Log10(value+1) transform my data</option> - </param> - </conditional> - <conditional name="distribution"> - <param name="density" type="select" label="Advanced - plot counts or density"> - <option value="counts">Plot counts on the y-axis</option> - <option value="freq">Plot frequency on the y-axis</option> - <option value="nfreq">Plot normalized frequency on the y-axis</option> - </param> - </conditional> - <conditional name="group"> - <param name="facet" type="select" label="Advanced - faceting"> - <option value="none">Plot my groups on one plot</option> - <option value="facet">Plot my groups on individual plots</option> - </param> - </conditional> - <conditional name="coloring"> - <param name="colorscheme" type="select" label="Advanced - coloring groups" > - <option value="Default" selected="True">No thanks - just use the default scheme to color code my groups (columns)</option> - <option value="Defined">I want to use defined color palettes to differentiate my groups (columns) </option> - </param> - <when value="Default"> - </when> - <when value="Defined"> - <param name="colors" type="select" label="Color schemes to differentiate your groups" > - <option value="Default">Default color scheme</option> - <option value="YlOrRd">Yellow to orange to red (discrete, max=9 colors)</option> - <option value="YlOrBr">Yellow to orange to brown (discrete, max=9 colors)</option> - <option value="YlGnBu">Yellow to green to blue (discrete, max=9 colors)</option> - <option value="YlGn">Yellow to green (discrete, max=9 colors)</option> - <option value="Reds">Shades of red from light to dark (discrete, max=9 colors)</option> - <option value="RdPu">Red to purple (discrete, max=9 colors)</option> - <option value="Purples">Shades of purple from light to dark (discrete, max=9 colors)</option> - <option value="PuRd">Purple to red (discrete, max=9 colors)</option> - <option value="PuBuGn">Purple to blue to green (discrete, max=9 colors)</option> - <option value="PuBu">Purple to blue(discrete, max=9 colors)</option> - <option value="OrRd">Orange to red (discrete, max=9 colors)</option> - <option value="Oranges">Shades of orange from light to dark (discrete, max=9 colors)</option> - <option value="Greys">Shades of grey from light to dark (discrete, max=9 colors)</option> - <option value="Greens">Shades of greens from light to dark (discrete, max=9 colors)</option> - <option value="GnBu">Green to blue (discrete, max=9 colors)</option> - <option value="BuPu">Blue to purple (discrete, max=9 colors)</option> - <option value="BuGn">Blue to green (discrete, max=9 colors)</option> - <option value="Blues">Shades of blue from light to dark (discrete, max=9 colors)</option> - <option value="Set1">Set 1 - predefined color pallete (discrete, max=9 colors)</option> - <option value="Set2">Set 2 - predefined color pallete (discrete, max=8 colors)</option> - <option value="Set3">Set 3 - predefined color pallete (discrete, max=12 colors)</option> - <option value="Pastel1">Pastel 1 - predefined pastel color pallete (discrete, max=9 colors)</option> - <option value="Pastel2">Pastel 2 - predefined pastel color pallete (discrete, max=8 colors)</option> - <option value="Paired">Paired - predefined color pallete (discrete, max=12 colors)</option> - <option value="Dark2">Dark 2 - predefined color pallete (discrete, max=12 colors)</option> - <option value="Accent">Accent - predefined color pallete (discrete, max=12 colors)</option> - <option value="Spectral">Spectral - Red to yellow to purple (discrete, max=11 colors)</option> - <option value="RdYlGn">Red to yellow to green (discrete, max=11 colors)</option> - <option value="RdYlBu">Red to yellow to blue (discrete, max=11 colors)</option> - <option value="RdGy">Red to grey (discrete, max=11 colors)</option> - <option value="RdBu">Red to blue (discrete, max=11 colors)</option> - <option value="PuOr">Purple to orange (discrete, max=11 colors)</option> - <option value="PRGn">Purple to green (discrete, max=11 colors)</option> - <option value="BrBG">Brown to teal (discrete, max=11 colors)</option> - </param> - <param name="colororder" type="select" label="Reverse color scheme" > - <option value="1">Default order of color scheme</option> - <option value="-1">Reverse the order of my color scheme</option> - </param> - </when> - </conditional> - <conditional name="scaling"> - <param name="Plot_scaling" type="select" label="Advanced - Axis scaling"> - <option value="Automatic" selected="True">Automatic axis scaling</option> - <option value="Defined">User deined axis scales</option> - </param> - <when value="Automatic"> - <!--Do nothing here --> - </when> - <when value="Defined"> - <param name="xaxismin" size="4" type="integer" value="0" label="minimal range of x-axis" /> - <param name="xaxismax" size="4" type="integer" value="3" label="maximal range of x-axis" /> - <param name="yaxismin" size="4" type="integer" value="0" label="minimal range of y-axis" /> - <param name="yaxismax" size="4" type="integer" value="3" label="maximal range of y-axis" /> - </when> - </conditional> - <conditional name="dimensions"> - <param name="plotdim" type="select" label="Advanced - output dimensions"> - <option value="Default" selected="True">Default</option> - <option value="Defined">User deined output dimensions</option> - </param> - <when value="Default"> - <!--Do nothing here --> - </when> - <when value="Defined"> - <param name="woutputdim" size="4" type="float" value="7" label="width of output (inches)" /> - <param name="houtputdim" size="4" type="float" value="7" label="height of output (inches)" /> - </when> - </conditional> - <conditional name="showlegend"> - <param name="legend" type="select" label="Legend options"> - <option value="yes">Include legend on plot</option> - <option value="no">Hide legend</option> - </param> - </conditional> - </inputs> - <outputs> - <!-- <data name="output1" format="png" from_work_dir="Rplot.png"/> --> - <data name="output1" format="pdf" from_work_dir="Rplot.pdf"/> - </outputs> - <tests> - <test> - <param name="input1" value="input.txt"/> - <output name="output1" file="Rplot.pdf"/> - </test> - </tests> - <help><![CDATA[ - -This tool will generate a histogram representing the distrinutions of each numerical column. Each column should have a descriptive header with no spaces, which will be used in the plot legend to represent the corresponding column (group). - -Input data example: -ID Cond_A Cond_B -gene_A 10 15 -gene_B 8 12 -gene_C 10 15 -gene_D 6 9 -gene_E 9 13.5 -gene_F 8 12 - - ]]></help> - <citations> - <citation type="bibtex"> -@misc{renameTODO, - author = {TODO, FirstTODO}, - year = {TODO}, - title = {TODO}, - url = {under construction}, -}</citation> - </citations> -</tool>
--- a/ggplotscripthistogram.R Tue Apr 11 18:35:55 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -# Setup R error handling to go to stderr -options(show.error.messages=F, error=function(){cat(geterrmessage(),file=stderr());q("no",1,F)}) - -# We need to not crash galaxy with an UTF8 error on German LC settings. -loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") - - -# Import library -library("getopt") -library("reshape2") -library("ggplot2") -options(stringAsfactors = FALSE, useFancyQuotes = FALSE) -# Take in trailing command line arguments -args <- commandArgs(trailingOnly = TRUE) - - -# get options, using the spec as defined by the enclosed list. -# we read the options from the default: commandArgs(TRUE). -option_specification = matrix(c( - 'input', 'i', 2, 'character', - 'title', 't',2, 'character', - 'size', 's', 2, 'double', - 'xlab', 'x', 2, 'character', - 'ylab', 'y', 2, 'character', - 'binwidth', 'b', 2, 'double', - 'xaxismin', 'e', 2, 'integer', - 'xaxismax', 'f', 2, 'integer', - 'yaxismin', 'g', 2, 'integer', - 'yaxismax', 'h', 2, 'integer', - 'colors', 'q', 2, 'character', - 'colorscheme', 'z', 2, 'character', - 'colororder', 'r', 2, 'integer', - 'facet', 'a', 2, 'character', - 'transform', 'c', 2, 'character', - 'woutputdim', 'w', 2, 'integer', - 'houtputdim', 'd', 2, 'integer', - 'dim', 'k', 2, 'character', - 'scaling', 'j', 2, 'character', - 'legend', 'l', 2, 'character', - 'density', 'm', 2, 'character', - 'output', 'o', 2, 'character' - ), byrow=TRUE, ncol=4); - -# Parse options -options = getopt(option_specification); - - - -# Print options to see what is going on -cat("\n input: ",options$input) -cat("\n title: ",options$title) -cat("\n size: ",options$size) -cat("\n transform: ",options$alpha) -cat("\n xlab: ",options$xlab) -cat("\n xlab: ",options$xlab) -cat("\n binwidth: ",options$binwidth) -cat("\n output: ",options$output) - -integrated <- read.csv(options$input,sep='\t',header=TRUE) -input <- melt(integrated) - -#Show/hide legend -if(options$legend == "yes"){ - gg_legend = NULL -} else { - gg_legend = theme(legend.position="none") -} - -#density -if(options$density == "counts"){ - gg_density = ggplot(input,aes(value, color=variable)) - gg_freq = NULL -} else if(options$density == "nfreq"){ - gg_density = ggplot(input,aes(value, ..ncount.., color=variable)) - gg_freq = NULL -} else if(options$density == "freq"){ - gg_density = ggplot(input,aes(value, color=variable)) - gg_freq = aes(y=..count../sum(..count..)) -} else { - -} - -#Choose between automatically scaled x and y axis or user defined -if(options$scaling == "Automatic"){ - gg_scalex = NULL - gg_scaley = NULL -} else { - gg_scalex = xlim(options$xaxismin,options$xaxismax) - gg_scaley = ylim(options$yaxismin,options$yaxismax) - cat("\n xaxismin: ",options$xaxismin) - cat("\n xaxismax: ",options$xaxismax) - cat("\n yaxismin: ",options$yaxismin) - cat("\n yaxismax: ",options$yaxismax) -} - -#Choose dimensions of output pdf -if(options$dim == "Default"){ - gg_width = 7 - gg_height = 7 -} else { - gg_width = options$woutputdim - gg_height = options$houtputdim -} - - -if(options$transform == "log2"){ - input["value"] <- log2(input["value"]) -}else if(options$transform == "log2plus1"){ - input["value"] <- log2(input["value"]+1) -}else if(options$transform == "log10"){ - input["value"] <- log10(input["value"]) -}else if(options$transform == "log10plus1"){ - input["value"] <- log10(input["value"]+1) - }else{ -} - - -if(options$facet == "facet"){ - gg_facet = facet_wrap(~ variable) - } else { - gg_facet = NULL - } - -if(options$colorscheme == "Default"){ - gg_colorscale = NULL - } else { - gg_colorscale = scale_color_brewer(palette=options$colors, direction=options$colororder) - } - -gg_density + -geom_freqpoly(gg_freq,binwidth=options$binwidth,size=options$size)+gg_facet+gg_colorscale+ -gg_scalex+gg_scaley+theme_bw()+xlab(options$xlab)+ylab(options$ylab)+gg_legend+ -ggtitle(options$title) - -ggsave(file=options$output)
