Previous changeset 0:c5846258c458 (2017-06-08) Next changeset 2:2c8e564adede (2017-08-01) |
Commit message:
Uploaded |
modified:
ks_distribution.R ks_distribution.xml macros.xml |
added:
test-data/components.ptkscmp test-data/kaks_input1.tabular test-data/output.pdf |
removed:
components.tabular kaks_input1.tabular output.pdf |
b |
diff -r c5846258c458 -r 56f42cc1dd58 components.tabular --- a/components.tabular Thu Jun 08 12:55:49 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
b |
@@ -1,2 +0,0 @@ -species n number_comp lnL AIC BIC mean variance porportion -species1 3 1 -3.4750 6.95 6.95 3.1183 5.7732 1.00 |
b |
diff -r c5846258c458 -r 56f42cc1dd58 kaks_input1.tabular --- a/kaks_input1.tabular Thu Jun 08 12:55:49 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
b |
@@ -1,4 +0,0 @@ -SEQ1 SEQ2 Ka Ks Ka\Ks -contig_241; contig_241 1.5312 7.1619 0.2138 -contig_300 contig_300; 0.8653 3.7872 0.2285 -contig_586 contig_586; 1.7791 1.1181 1.5912 |
b |
diff -r c5846258c458 -r 56f42cc1dd58 ks_distribution.R --- a/ks_distribution.R Thu Jun 08 12:55:49 2017 -0400 +++ b/ks_distribution.R Wed Jun 28 11:20:17 2017 -0400 |
[ |
b'@@ -5,67 +5,86 @@\n option_list <- list(\n make_option(c("-c", "--components_input"), action="store", dest="components_input", help="Ks significant components input dataset"),\n make_option(c("-k", "--kaks_input"), action="store", dest="kaks_input", help="KaKs analysis input dataset"),\n- make_option(c("-o", "--output"), action="store", dest="output", help="Output dataset")\n+ make_option(c("-n", "--number_comp"), action="store", dest="number_comp", type="integer", help="Number of significant components in the Ks distribution"),\n+ make_option(c("-o", "--output"), action="store", dest="output", help="Output dataset"),\n+ make_option(c("-s", "--specified_colors"), action="store", dest="specified_colors", default=NULL, help="List of component colors")\n )\n \n parser <- OptionParser(usage="%prog [options] file", option_list=option_list)\n args <- parse_args(parser, positional_arguments=TRUE)\n opt <- args$options\n \n-\n-get_num_components = function(components_data)\n-{\n- # Get the max of the number_comp column.\n- number_comp = components_data[, 3]\n- num_components <- max(number_comp, na.rm=TRUE)\n- return(num_components)\n+set_component_colors = function(colors, number_comp) {\n+ # Handle colors for components.\n+ if (is.null(colors)) {\n+ # Randomly specify colors for components.\n+ component_colors <- c("red", "yellow", "green", "black", "blue", "darkorange")\n+ } else {\n+ # Handle selected colors for components.\n+ component_colors <- c()\n+ colors <- as.character(colors) \n+ items <- strsplit(colors, ",") \n+ for (item in items) { \n+ component_colors <- c(component_colors, item)\n+ }\n+ num_colors_specified <- length(component_colors)\n+ if (num_colors_specified < number_comp) {\n+ # The number of selected colors is less than the number of\n+ # components, so we\'ll add random colors that were not\n+ # selected to the set of component colors until we have a\n+ # color for each component.\n+ loop_count <- number_comp - num_colors_specified\n+ for (i in 1:loop_count) {\n+ if (!(is.element("red", component_colors))) {\n+ component_colors <- c(component_colors, "red")\n+ } else if (!(is.element("yellow", component_colors))) {\n+ component_colors <- c(component_colors, "yellow")\n+ } else if (!(is.element("green", component_colors))) {\n+ component_colors <- c(component_colors, "green")\n+ } else if (!(is.element("black", component_colors))) {\n+ component_colors <- c(component_colors, "black")\n+ } else if (!(is.element("blue", component_colors))) {\n+ component_colors <- c(component_colors, "blue")\n+ } else if (!(is.element("darkorange", component_colors))) {\n+ component_colors <- c(component_colors, "darkorange")\n+ }\n+ }\n+ }\n+ }\n+ return(component_colors)\n }\n \n-get_pi_mu_var = function(components_data, num_components)\n-{\n- # FixMe: enhance this to generically handle any integer value for num_components.\n- if (num_components == 1)\n- {\n+get_pi_mu_var = function(components_data, number_comp) {\n+ if (number_comp == 1) {\n pi <- c(components_data[1, 9])\n mu <- c(components_data[1, 7])\n var <- c(components_data[1, 8])\n- }\n- else if (num_components == 2)\n- {\n+ } else if (number_comp == 2) {\n pi <- c(components_data[2, 9], components_data[3, 9])\n mu <- c(components_data[2, 7], components_data[3, 7])\n var <- c(components_data[2, 8], components_data[3, 8])\n- }\n- else if (num_components == 3)\n- {\n+ } else if (number_comp == 3) {\n pi <- c(components_data[4, 9], components_data[5, 9], components_data[6, 9])\n mu <- c(components_data[4, 7], components_data[5, 7], compo'..b'ents_data[15, 8])\n- }\n- else if (num_components == 6)\n- {\n+ } else if (number_comp == 6) {\n pi <- c(components_data[16, 9], components_data[17, 9], components_data[18, 9], components_data[19, 9], components_data[20, 9], components_data[21, 9])\n mu <- c(components_data[16, 7], components_data[17, 7], components_data[18, 7], components_data[19, 7], components_data[20, 7], components_data[21, 7])\n var <- c(components_data[16, 8], components_data[17, 8], components_data[18, 8], components_data[19, 8], components_data[20, 8], components_data[21, 8])\n }\n- results = c(pi, mu, var)\n+ results <- c(pi, mu, var)\n return(results)\n }\n \n-plot_ks<-function(kaks_input, output, pi, mu, var)\n-{\n+plot_ks<-function(kaks_input, component_colors, output, pi, mu, var) {\n # Start PDF device driver to save charts to output.\n pdf(file=output, bg="white")\n kaks <- read.table(file=kaks_input, header=T)\n@@ -89,27 +108,24 @@\n barplot(nc, space=0.25, offset=0, width=0.04, xlim=c(0, max_ks), ylim=c(0, ymax), col="lightpink1", border="lightpink3")\n # Add x-axis.\n axis(1)\n- color <- c(\'red\', \'yellow\',\'green\',\'black\',\'blue\', \'darkorange\' )\n- for (i in 1:length(mu))\n- {\n- lines(vx, g[,i] * h, lwd=2, col=color[i])\n+ for (i in 1:length(mu)) {\n+ lines(vx, g[,i] * h, lwd=2, col=component_colors[i])\n }\n }\n \n-calculate_fitted_density <- function(pi, mu, var, max_ks)\n-{\n+calculate_fitted_density <- function(pi, mu, var, max_ks) {\n comp <- length(pi)\n var <- var/mu^2\n mu <- log(mu)\n # Calculate lognormal density.\n vx <- seq(1, 100) * (max_ks / 100)\n fx <- matrix(0, 100, comp)\n- for (i in 1:100)\n- {\n- for (j in 1:comp)\n- {\n- fx[i, j] <- pi[j] * dlnorm(vx[i], meanlog=mu[j], sdlog=(sqrt(var[j])))\n- if (is.nan(fx[i,j])) fx[i,j]<-0\n+ for (i in 1:100) {\n+ for (j in 1:comp) {\n+ fx[i, j] <- pi[j] * dlnorm(vx[i], meanlog=mu[j], sdlog=(sqrt(var[j])))\n+ if (is.nan(fx[i,j])) {\n+ fx[i,j]<-0\n+ }\n }\n }\n return(fx)\n@@ -117,47 +133,42 @@\n \n # Read in the components data.\n components_data <- read.delim(opt$components_input, header=TRUE)\n-# Get the number of components.\n-num_components <- get_num_components(components_data)\n+number_comp <- as.integer(opt$number_comp)\n+if (number_comp == 0) {\n+ # Default to 1 component to allow functional testing.\n+ number_comp <- 1\n+}\n+\n+# Set component colors.\n+component_colors <- set_component_colors(opt$specified_colors, number_comp)\n \n # Set pi, mu, var.\n-items <- get_pi_mu_var(components_data, num_components)\n-if (num_components == 1)\n-{\n-\tpi <- items[1]\n-\tmu <- items[2]\n-\tvar <- items[3]\n-}\n-if (num_components == 2)\n-{\n-\tpi <- items[1:2]\n-\tmu <- items[3:4]\n-\tvar <- items[5:6]\n-}\n-if (num_components == 3)\n-{\n-\tpi <- items[1:3]\n-\tmu <- items[4:6]\n-\tvar <- items[7:9]\n-}\n-if (num_components == 4)\n-{\n-\tpi <- items[1:4]\n-\tmu <- items[5:8]\n-\tvar <- items[9:12]\n-}\n-if (num_components == 5)\n-{\n-\tpi <- items[1:5]\n-\tmu <- items[6:10]\n-\tvar <- items[11:15]\n-}\n-if (num_components == 6)\n-{\n-\tpi <- items[1:6]\n-\tmu <- items[7:12]\n-\tvar <- items[13:18]\n+items <- get_pi_mu_var(components_data, number_comp)\n+if (number_comp == 1) {\n+ pi <- items[1]\n+ mu <- items[2]\n+ var <- items[3]\n+} else if (number_comp == 2) {\n+ pi <- items[1:2]\n+ mu <- items[3:4]\n+ var <- items[5:6]\n+} else if (number_comp == 3) {\n+ pi <- items[1:3]\n+ mu <- items[4:6]\n+ var <- items[7:9]\n+} else if (number_comp == 4) {\n+ pi <- items[1:4]\n+ mu <- items[5:8]\n+ var <- items[9:12]\n+} else if (number_comp == 5) {\n+ pi <- items[1:5]\n+ mu <- items[6:10]\n+ var <- items[11:15]\n+} else if (number_comp == 6) {\n+ pi <- items[1:6]\n+ mu <- items[7:12]\n+ var <- items[13:18]\n }\n \n # Plot the output.\n-plot_ks(opt$kaks_input, opt$output, pi, mu, var)\n+plot_ks(opt$kaks_input, component_colors, opt$output, pi, mu, var)\n' |
b |
diff -r c5846258c458 -r 56f42cc1dd58 ks_distribution.xml --- a/ks_distribution.xml Thu Jun 08 12:55:49 2017 -0400 +++ b/ks_distribution.xml Wed Jun 28 11:20:17 2017 -0400 |
b |
@@ -1,4 +1,4 @@ -<tool id="ks_distribution" name="KsDistribution" version="1.0.0"> +<tool id="ks_distribution" name="KsDistribution" version="1.0.1"> <description>plots the distribution of synonymous substitution (Ks) rates and fits significant component(s)</description> <macros> <import>macros.xml</import> @@ -8,11 +8,39 @@ Rscript $__tool_directory__/ks_distribution.R -k '$input' -c '$components' +-n $components.metadata.number_comp -o '$output' +#if str($choose_colors_cond.choose_colors) == 'yes': + #set specified_colors = list() + #for $selection in $choose_colors_cond.colors: + $specified_colors.append(str($selection.color)) + #end for + #set specified_colors = ",".join($specified_colors) + -s '$specified_colors' +#end if ]]></command> <inputs> <param name="input" format="tabular" type="data" label="KaKsAnalysis tabular file" /> - <param name="components" format="tabular" type="data" label="Significant components" /> + <param name="components" format="ptkscmp" type="data" label="Significant components" /> + <conditional name="choose_colors_cond"> + <param name="choose_colors" type="select" label="Choose colors for significant components"> + <option value="no" selected="true">No</option> + <option value="yes">Yes</option> + </param> + <when value="no" /> + <when value="yes"> + <repeat name="colors" title="Component colors" min="1"> + <param name="color" type="select" label="Color"> + <option value="red" selected="True">red</option> + <option value="green">green</option> + <option value="blue">blue</option> + <option value="yellow">yellow</option> + <option value="darkorange">dark orange</option> + <option value="black">black</option> + </param> + </repeat> + </when> + </conditional> </inputs> <outputs> <data name="output" format="pdf"/> @@ -20,7 +48,7 @@ <tests> <test> <param name="input" value="kaks_input1.tabular" ftype="tabular" /> - <param name="components" value="components.tabular" ftype="tabular" /> + <param name="components" value="components.ptkscmp" ftype="ptkscmp" /> <output name="output" file="output.pdf" ftype="pdf" compare="contains" /> </test> </tests> @@ -37,6 +65,9 @@ * **Synonymous substitution rates** - estimated synonymous substitution (Ks) rates output file produced by the KaKsAnalysis tool selected from your history. * **Synonymous components** - estimated significant component(s) output file produced by the KaKsAnalysis tool selected from your history. + * **Choose colors for significant components** - select 'Yes' to specify component colors or 'No' for colors chosen randlomly. + + * **Component colors** - select a color from the palette for each component (colors will be chosen randomly for unspecified components). </help> <citations> <expand macro="citation1" /> |
b |
diff -r c5846258c458 -r 56f42cc1dd58 macros.xml --- a/macros.xml Thu Jun 08 12:55:49 2017 -0400 +++ b/macros.xml Wed Jun 28 11:20:17 2017 -0400 |
b |
@@ -3,7 +3,7 @@ <token name="@WRAPPER_VERSION@">1.0</token> <xml name="requirements_assembly_post_processor"> <requirements> - <requirement type="package" version="1.0.0">plant_tribes_assembly_post_processor</requirement> + <requirement type="package" version="1.0.1">plant_tribes_assembly_post_processor</requirement> </requirements> </xml> <xml name="requirements_gene_family_aligner"> |
b |
diff -r c5846258c458 -r 56f42cc1dd58 output.pdf --- a/output.pdf Thu Jun 08 12:55:49 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
[ |
@@ -1,52 +0,0 @@ -1 0 obj -<< -/Title (R Graphics Output) -/Creator (R) ->> -endobj -2 0 obj -<< /Type /Catalog /Pages 3 0 R >> -endobj -7 0 obj -<< /Type /Page /Parent 3 0 R /Contents 8 0 R /Resources 4 0 R >> -endobj -8 0 obj -<< ->> -stream -endobj -3 0 obj -<< /Type /Pages /Kids [ 7 0 R ] /Count 1 /MediaBox [0 0 504 504] >> -endobj -4 0 obj -<< -/ProcSet [/PDF /Text] -/Font <</F2 10 0 R >> -/ExtGState << >> -/ColorSpace << /sRGB 5 0 R >> ->> -endobj -5 0 obj -[/ICCBased 6 0 R] -endobj -6 0 obj -<< /Alternate /DeviceRGB /N 3 /Length 2596 /Filter /FlateDecode >> -stream -9 0 obj -<< -/Type /Encoding /BaseEncoding /WinAnsiEncoding -/Differences [ 45/minus 96/quoteleft -144/dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent -/dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron /space] ->> -endobj -10 0 obj -<< /Type /Font /Subtype /Type1 /Name /F2 /BaseFont /Helvetica -/Encoding 9 0 R >> -endobj -xref -0 11 -trailer -<< /Size 11 /Info 1 0 R /Root 2 0 R >> -startxref -%%EOF |
b |
diff -r c5846258c458 -r 56f42cc1dd58 test-data/components.ptkscmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/components.ptkscmp Wed Jun 28 11:20:17 2017 -0400 |
b |
@@ -0,0 +1,2 @@ +species n number_comp lnL AIC BIC mean variance porportion +species1 3 1 -3.4750 6.95 6.95 3.1183 5.7732 1.00 |
b |
diff -r c5846258c458 -r 56f42cc1dd58 test-data/kaks_input1.tabular --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/kaks_input1.tabular Wed Jun 28 11:20:17 2017 -0400 |
b |
@@ -0,0 +1,4 @@ +SEQ1 SEQ2 Ka Ks Ka\Ks +contig_241; contig_241 1.5312 7.1619 0.2138 +contig_300 contig_300; 0.8653 3.7872 0.2285 +contig_586 contig_586; 1.7791 1.1181 1.5912 |
b |
diff -r c5846258c458 -r 56f42cc1dd58 test-data/output.pdf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/output.pdf Wed Jun 28 11:20:17 2017 -0400 |
[ |
@@ -0,0 +1,52 @@ +1 0 obj +<< +/Title (R Graphics Output) +/Creator (R) +>> +endobj +2 0 obj +<< /Type /Catalog /Pages 3 0 R >> +endobj +7 0 obj +<< /Type /Page /Parent 3 0 R /Contents 8 0 R /Resources 4 0 R >> +endobj +8 0 obj +<< +>> +stream +endobj +3 0 obj +<< /Type /Pages /Kids [ 7 0 R ] /Count 1 /MediaBox [0 0 504 504] >> +endobj +4 0 obj +<< +/ProcSet [/PDF /Text] +/Font <</F2 10 0 R >> +/ExtGState << >> +/ColorSpace << /sRGB 5 0 R >> +>> +endobj +5 0 obj +[/ICCBased 6 0 R] +endobj +6 0 obj +<< /Alternate /DeviceRGB /N 3 /Length 2596 /Filter /FlateDecode >> +stream +9 0 obj +<< +/Type /Encoding /BaseEncoding /WinAnsiEncoding +/Differences [ 45/minus 96/quoteleft +144/dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent +/dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron /space] +>> +endobj +10 0 obj +<< /Type /Font /Subtype /Type1 /Name /F2 /BaseFont /Helvetica +/Encoding 9 0 R >> +endobj +xref +0 11 +trailer +<< /Size 11 /Info 1 0 R /Root 2 0 R >> +startxref +%%EOF |