Mercurial > repos > greg > ks_distribution
comparison ks_distribution.R @ 21:e6bbc7426cd1 draft
Uploaded
author | greg |
---|---|
date | Mon, 26 Jun 2017 07:51:11 -0400 |
parents | 79e00e063a40 |
children | 492ef68d73f7 |
comparison
equal
deleted
inserted
replaced
20:79e00e063a40 | 21:e6bbc7426cd1 |
---|---|
5 option_list <- list( | 5 option_list <- list( |
6 make_option(c("-c", "--components_input"), action="store", dest="components_input", help="Ks significant components input dataset"), | 6 make_option(c("-c", "--components_input"), action="store", dest="components_input", help="Ks significant components input dataset"), |
7 make_option(c("-k", "--kaks_input"), action="store", dest="kaks_input", help="KaKs analysis input dataset"), | 7 make_option(c("-k", "--kaks_input"), action="store", dest="kaks_input", help="KaKs analysis input dataset"), |
8 make_option(c("-n", "--num_comp"), action="store", dest="num_comp", type="integer", help="Number of significant components in the Ks distribution"), | 8 make_option(c("-n", "--num_comp"), action="store", dest="num_comp", type="integer", help="Number of significant components in the Ks distribution"), |
9 make_option(c("-o", "--output"), action="store", dest="output", help="Output dataset"), | 9 make_option(c("-o", "--output"), action="store", dest="output", help="Output dataset"), |
10 make_option(c("-r", "--colors"), action="store", default=NA, help="List of component colors") | 10 make_option(c("-r", "--colors"), action="store", default=[], help="List of component colors") |
11 ) | 11 ) |
12 | 12 |
13 parser <- OptionParser(usage="%prog [options] file", option_list=option_list) | 13 parser <- OptionParser(usage="%prog [options] file", option_list=option_list) |
14 args <- parse_args(parser, positional_arguments=TRUE) | 14 args <- parse_args(parser, positional_arguments=TRUE) |
15 opt <- args$options | 15 opt <- args$options |
80 vx <- seq(1, 100) * (max_ks / 100) | 80 vx <- seq(1, 100) * (max_ks / 100) |
81 ymax <- max(nc) | 81 ymax <- max(nc) |
82 barplot(nc, space=0.25, offset=0, width=0.04, xlim=c(0, max_ks), ylim=c(0, ymax), col="lightpink1", border="lightpink3") | 82 barplot(nc, space=0.25, offset=0, width=0.04, xlim=c(0, max_ks), ylim=c(0, ymax), col="lightpink1", border="lightpink3") |
83 # Add x-axis. | 83 # Add x-axis. |
84 axis(1) | 84 axis(1) |
85 if is.na(colors) | 85 if (length(colors) == 0) |
86 { | 86 { |
87 color <- c('red', 'yellow', 'green', 'black', 'blue', 'darkorange') | 87 color <- c('red', 'yellow', 'green', 'black', 'blue', 'darkorange') |
88 } | 88 } |
89 else | 89 else |
90 { | 90 { |
94 items <- strsplit(cStr, ",") | 94 items <- strsplit(cStr, ",") |
95 for (item in items) { | 95 for (item in items) { |
96 color <- c(color, item) | 96 color <- c(color, item) |
97 } | 97 } |
98 num_colors_specified = length(color) | 98 num_colors_specified = length(color) |
99 if num_colors_specified < num_components: | 99 if (num_colors_specified < num_components): |
100 { | 100 { |
101 for (i in num_colors_specified:num_components) | 101 for (i in num_colors_specified:num_components) |
102 { | 102 { |
103 if !(any(color=='red') | 103 if !(any(color=='red')) |
104 { | 104 { |
105 color <- c(color, 'red') | 105 color <- c(color, 'red') |
106 } | 106 } |
107 else if !(any(color=='yellow') | 107 else if !(any(color=='yellow')) |
108 { | 108 { |
109 color <- c(color, 'yellow') | 109 color <- c(color, 'yellow') |
110 } | 110 } |
111 else if !(any(color=='green') | 111 else if !(any(color=='green')) |
112 { | 112 { |
113 color <- c(color, 'green') | 113 color <- c(color, 'green') |
114 } | 114 } |
115 else if !(any(color=='black') | 115 else if !(any(color=='black')) |
116 { | 116 { |
117 color <- c(color, 'black') | 117 color <- c(color, 'black') |
118 } | 118 } |
119 else if !(any(color=='blue') | 119 else if !(any(color=='blue')) |
120 { | 120 { |
121 color <- c(color, 'blue') | 121 color <- c(color, 'blue') |
122 } | 122 } |
123 else | 123 else |
124 { | 124 { |