changeset 51:1a3973eea61c draft

Uploaded
author greg
date Mon, 26 Jun 2017 14:33:04 -0400
parents 0b3d12ecce28
children 53bc81f3ebad
files ks_distribution.R
diffstat 1 files changed, 20 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/ks_distribution.R	Mon Jun 26 14:28:27 2017 -0400
+++ b/ks_distribution.R	Mon Jun 26 14:33:04 2017 -0400
@@ -19,31 +19,31 @@
     # Handle colors for components.
     if (is.na(colors) == 0) {
         # Randomly specify colors for components.
-        specified_colors <- c('red', 'yellow', 'green', 'black', 'blue', 'darkorange')
+        component_colors <- c('red', 'yellow', 'green', 'black', 'blue', 'darkorange')
     } else {
         # Handle selected colors for components.
         colors <- as.character(colors)
-        specified_colors <- strsplit(colors, ",")
-        num_colors_specified <- length(specified_colors)
+        component_colors <- strsplit(colors, ",")
+        num_colors_specified <- length(component_colors)
         if (num_colors_specified < number_comp) {
             for (i in num_colors_specified:number_comp) {
-                if (!('red' %in% names(specified_colors))) {
-                    specified_colors <- c(specified_colors, 'red')
-                } else if (!('yellow' %in% names(specified_colors))) {
-                    specified_colors <- c(specified_colors, 'yellow')
-                } else if (!('green' %in% names(specified_colors))) {
-                    specified_colors <- c(specified_colors, 'green')
-                } else if (!('black' %in% names(specified_colors))) {
-                    specified_colors <- c(specified_colors, 'black')
-                } else if (!('blue' %in% names(specified_colors))) {
-                    specified_colors <- c(specified_colors, 'blue')
+                if (!('red' %in% names(component_colors))) {
+                    component_colors <- c(component_colors, 'red')
+                } else if (!('yellow' %in% names(component_colors))) {
+                    component_colors <- c(component_colors, 'yellow')
+                } else if (!('green' %in% names(component_colors))) {
+                    component_colors <- c(component_colors, 'green')
+                } else if (!('black' %in% names(component_colors))) {
+                    component_colors <- c(component_colors, 'black')
+                } else if (!('blue' %in% names(component_colors))) {
+                    component_colors <- c(component_colors, 'blue')
                 } else {
-                    specified_colors <- c(specified_colors, 'darkorange')
+                    component_colors <- c(component_colors, 'darkorange')
                 }
             }
         }
     }
-    return(specified_colors)
+    return(component_colors)
 }
 
 get_pi_mu_var = function(components_data, number_comp)
@@ -74,11 +74,11 @@
         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])
         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])
     }
-    results = c(pi, mu, var)
+    results <- c(pi, mu, var)
     return(results)
 }
 
-plot_ks<-function(kaks_input, number_comp, specified_colors, output, pi, mu, var)
+plot_ks<-function(kaks_input, number_comp, component_colors, output, pi, mu, var)
 {
     # Start PDF device driver to save charts to output.
     pdf(file=output, bg="white")
@@ -104,7 +104,7 @@
     # Add x-axis.
     axis(1)
     for (i in 1:length(mu)) {
-       lines(vx, g[,i] * h, lwd=2, col=specified_colors[i])
+       lines(vx, g[,i] * h, lwd=2, col=component_colors[i])
     }
 }
 
@@ -132,7 +132,7 @@
 number_comp <- as.integer(opt$number_comp)
 
 # Set component colors.
-specified_colors <- set_component_colors(opt$colors, number_comp)
+component_colors <- set_component_colors(opt$colors, number_comp)
 
 # Set pi, mu, var.
 items <- get_pi_mu_var(components_data, number_comp)
@@ -163,4 +163,4 @@
 }
 
 # Plot the output.
-plot_ks(opt$kaks_input, number_comp, specified_colors, opt$output, pi, mu, var)
+plot_ks(opt$kaks_input, number_comp, component_colors, opt$output, pi, mu, var)