Mercurial > repos > iuc > charts
comparison histogram.r @ 1:344ac3ca7557 draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/charts/ commit 4494db13b69987fbc97d47177d2a5956e46e927b"
| author | iuc |
|---|---|
| date | Wed, 17 Nov 2021 09:06:59 +0000 |
| parents | a87a3773d8ed |
| children |
comparison
equal
deleted
inserted
replaced
| 0:a87a3773d8ed | 1:344ac3ca7557 |
|---|---|
| 8 m <- list() | 8 m <- list() |
| 9 for (key in names(columns)) { | 9 for (key in names(columns)) { |
| 10 # load column data | 10 # load column data |
| 11 column <- as.numeric(columns[key]) | 11 column <- as.numeric(columns[key]) |
| 12 column_data <- suppressWarnings(as.numeric(as.character(table[column][[1]]))) | 12 column_data <- suppressWarnings(as.numeric(as.character(table[column][[1]]))) |
| 13 | 13 |
| 14 # collect vectors in list | 14 # collect vectors in list |
| 15 m <- append(m, list(column_data)) | 15 m <- append(m, list(column_data)) |
| 16 } | 16 } |
| 17 | 17 |
| 18 # identify optimal breaks | 18 # identify optimal breaks |
| 19 hist_data <- hist(unlist(m), plot=FALSE) | 19 hist_data <- hist(unlist(m), plot = FALSE) |
| 20 breaks <- hist_data$breaks; | 20 breaks <- hist_data$breaks; |
| 21 | 21 |
| 22 # add as first column | 22 # add as first column |
| 23 l <- append(l, list(breaks[2: length(breaks)])) | 23 l <- append(l, list(breaks[2: length(breaks)])) |
| 24 | 24 |
| 25 # loop through all columns | 25 # loop through all columns |
| 26 for (key in seq(m)) { | 26 for (key in seq(m)) { |
| 27 # load column data | 27 # load column data |
| 28 column_data <- m[[key]] | 28 column_data <- m[[key]] |
| 29 | 29 |
| 30 # create hist data | 30 # create hist data |
| 31 hist_data <- hist(column_data, breaks=breaks, plot=FALSE) | 31 hist_data <- hist(column_data, breaks = breaks, plot = FALSE) |
| 32 | 32 |
| 33 # normalize densities | 33 # normalize densities |
| 34 count_sum <- sum(hist_data$counts) | 34 count_sum <- sum(hist_data$counts) |
| 35 if (count_sum > 0) { | 35 if (count_sum > 0) { |
| 36 hist_data$counts = hist_data$counts / count_sum | 36 hist_data$counts <- hist_data$counts / count_sum |
| 37 } | 37 } |
| 38 | 38 |
| 39 # collect vectors in list | 39 # collect vectors in list |
| 40 l <- append(l, list(hist_data$counts)) | 40 l <- append(l, list(hist_data$counts)) |
| 41 } | 41 } |
| 42 | 42 |
| 43 # return | 43 # return |
| 44 return (l) | 44 return(l) |
| 45 } | 45 } |
