Mercurial > repos > greg > ks_distribution
comparison ks_distribution.R @ 64:b7468c75c4a5 draft
Uploaded
| author | greg |
|---|---|
| date | Tue, 27 Jun 2017 11:00:36 -0400 |
| parents | a9c1203d5eb6 |
| children | ad406d4702b2 |
comparison
equal
deleted
inserted
replaced
| 63:99ba4a5320e0 | 64:b7468c75c4a5 |
|---|---|
| 15 opt <- args$options | 15 opt <- args$options |
| 16 | 16 |
| 17 set_component_colors = function(colors, number_comp) | 17 set_component_colors = function(colors, number_comp) |
| 18 { | 18 { |
| 19 # Handle colors for components. | 19 # Handle colors for components. |
| 20 if (is.na(colors)) { | 20 if (is.null(colors)) { |
| 21 # Randomly specify colors for components. | 21 # Randomly specify colors for components. |
| 22 component_colors <- c("red", "yellow", "green", "black", "blue", "darkorange") | 22 component_colors <- c("red", "yellow", "green", "black", "blue", "darkorange") |
| 23 } else { | 23 } else { |
| 24 # Handle selected colors for components. | 24 # Handle selected colors for components. |
| 25 component_colors <- c() | 25 component_colors <- c() |
| 84 } | 84 } |
| 85 results <- c(pi, mu, var) | 85 results <- c(pi, mu, var) |
| 86 return(results) | 86 return(results) |
| 87 } | 87 } |
| 88 | 88 |
| 89 plot_ks<-function(kaks_input, number_comp, component_colors, output, pi, mu, var) | 89 plot_ks<-function(kaks_input, component_colors, output, pi, mu, var) |
| 90 { | 90 { |
| 91 # Start PDF device driver to save charts to output. | 91 # Start PDF device driver to save charts to output. |
| 92 pdf(file=output, bg="white") | 92 pdf(file=output, bg="white") |
| 93 kaks <- read.table(file=kaks_input, header=T) | 93 kaks <- read.table(file=kaks_input, header=T) |
| 94 max_ks <- max(kaks$Ks, na.rm=TRUE) | 94 max_ks <- max(kaks$Ks, na.rm=TRUE) |
| 136 } | 136 } |
| 137 | 137 |
| 138 # Read in the components data. | 138 # Read in the components data. |
| 139 components_data <- read.delim(opt$components_input, header=TRUE) | 139 components_data <- read.delim(opt$components_input, header=TRUE) |
| 140 number_comp <- as.integer(opt$number_comp) | 140 number_comp <- as.integer(opt$number_comp) |
| 141 if (number_comp == 0) { | |
| 142 # Default to 1 component to allow functional testing. | |
| 143 number_comp <- 1 | |
| 144 } | |
| 141 | 145 |
| 142 # Set component colors. | 146 # Set component colors. |
| 143 component_colors <- set_component_colors(opt$specified_colors, number_comp) | 147 component_colors <- set_component_colors(opt$specified_colors, number_comp) |
| 144 | 148 |
| 145 # Set pi, mu, var. | 149 # Set pi, mu, var. |
| 166 var <- items[11:15] | 170 var <- items[11:15] |
| 167 } else if (number_comp == 6) { | 171 } else if (number_comp == 6) { |
| 168 pi <- items[1:6] | 172 pi <- items[1:6] |
| 169 mu <- items[7:12] | 173 mu <- items[7:12] |
| 170 var <- items[13:18] | 174 var <- items[13:18] |
| 171 } | |
| 172 | 175 |
| 173 # Plot the output. | 176 # Plot the output. |
| 174 plot_ks(opt$kaks_input, number_comp, component_colors, opt$output, pi, mu, var) | 177 plot_ks(opt$kaks_input, component_colors, opt$output, pi, mu, var) |
