Mercurial > repos > greg > ideas_genome_tracks
changeset 80:6d97ef6bf7b7 draft
Uploaded
author | greg |
---|---|
date | Thu, 04 Jan 2018 12:31:30 -0500 |
parents | efbc9e58c4eb |
children | dcd4be407063 |
files | ideas_genome_tracks.R |
diffstat | 1 files changed, 27 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/ideas_genome_tracks.R Wed Jan 03 14:36:01 2018 -0500 +++ b/ideas_genome_tracks.R Thu Jan 04 12:31:30 2018 -0500 @@ -103,41 +103,44 @@ create_track_db = function(galaxy_url, encoded_dataset_id, input_dir_para, input_dir_state, build, chrom_len_file, tracks_dir, hub_name, hub_short_label, hub_long_label, state_indexes, state_names, state_colors) { # Create a trackDb.txt file that includes each state. - para_files <- list.files(path=input_dir_para, full.names=TRUE); - ###### - # The following is temporary and will be eliminated when there - # are multiple .para files. See the comments in the for loop - # below. - data_frame <- read.table(para_files[1], comment="!", header=T); - color_hex_code <- create_heatmap(data_frame); - ###### - if (!is.null(state_indexes)) { + s_indexes = c(); + s_names = c(); + s_colors = c(); + if (is.null(state_indexes)) { + # Generate state colors automatically. + index = 0; + para_files = list.files(path=input_dir_para, full.names=TRUE); + for (para_file in para_files) { + data_frame = read.table(para_file, comment="!", header=T); + color_hex_code = create_heatmap(data_frame); + s_indexes = c(s_indexes, index); + s_names = c(s_names, toString(index)); + s_colors = c(s_colors, color_hex_code); + } + } else { # Split state_indexes into a list of integers. - s_indexes <- c(); - index_str <- as.character(state_indexes); - items <- strsplit(index_str, ",") + index_str = as.character(state_indexes); + items = strsplit(index_str, ",") for (item in items) { - s_indexes <- c(s_indexes, as.integer(item)); + s_indexes = c(s_indexes, as.integer(item)); } # Split state_names into a list of strings. - s_names <- c(); - name_str <- as.character(state_colors); - items <- strsplit(name_str, ","); - item_index <- 0; + name_str = as.character(state_colors); + items = strsplit(name_str, ","); + item_index = 0; for (item in items) { item_index = item_index + 1; # Handle the special string "use state index". if (identical(item, "use state index")) { - item <- s_indexes[item_index]; + item = s_indexes[item_index]; } - s_names <- c(s_names, item); + s_names = c(s_names, item); } # Split state_colors into a list of strings. - s_colors <- c(); - color_str <- as.character(state_colors); - items <- strsplit(color_str, ","); + color_str = as.character(state_colors); + items = strsplit(color_str, ","); for (item in items) { - s_colors <- c(s_colors, item); + s_colors = c(s_colors, item); } } base_track_file_name <- paste(tracks_dir, hub_name, sep=""); @@ -145,16 +148,7 @@ track_db = NULL; for (i in 1:length(cells)) { # Get the color for the current state. - if (is.null(state_indexes) || !is.element(i, s_indexes)) { - ###### - # This is for future use since there is currently only a single .para file. - # data_frame <- read.table(para_files[i], comment="!", header=T); - # color_hex_code <- create_heatmap(data_frame); - } else { - # Use the selected color for the current state. - color_hex_code <- s_colors[i]; - } - color <- paste(c(col2rgb(color_hex_code)), collapse=","); + color <- paste(c(col2rgb(s_colors[i])), collapse=","); # Get the bigDataUrl. big_data_url <- get_big_data_url(galaxy_url, encoded_dataset_id, tracks_dir, i, build); # trackDb.txt track hub entry.