Mercurial > repos > greg > create_genome_tracks
comparison create_genome_tracks.R @ 4:47f6ba0fc3f4 draft
Uploaded
author | greg |
---|---|
date | Fri, 10 Nov 2017 13:55:04 -0500 |
parents | 3bc9d3e88e7b |
children | d46bbaa386de |
comparison
equal
deleted
inserted
replaced
3:3bc9d3e88e7b | 4:47f6ba0fc3f4 |
---|---|
116 if(length(opt$hub_name) == 0) { | 116 if(length(opt$hub_name) == 0) { |
117 hub_name = opt$hub_id; | 117 hub_name = opt$hub_id; |
118 } | 118 } |
119 | 119 |
120 # Create the tracks output directory. | 120 # Create the tracks output directory. |
121 tracks_output_dir = paste("tracks_", hub_id, "/", sep=""); | 121 tracks_output_dir = paste("tracks_", opt$hub_id, "/", sep=""); |
122 dir.create(tracks_output_dir, showWarnings=FALSE); | 122 dir.create(tracks_output_dir, showWarnings=FALSE); |
123 | 123 |
124 # Create the color scheme. | 124 # Create the color scheme. |
125 mc = NULL; | 125 mc = NULL; |
126 x = read.table(opt$parameter_files, comment="!", nrows=1); | 126 x = read.table(opt$parameter_files, comment="!", nrows=1); |
135 p = x[,1] / sum(x[,1]); | 135 p = x[,1] / sum(x[,1]); |
136 m = array(as.matrix(x[,1:l+1] / x[,1]), dim=c(dim(x)[1], l)); | 136 m = array(as.matrix(x[,1:l+1] / x[,1]), dim=c(dim(x)[1], l)); |
137 state_color = get_state_color(m, mc); | 137 state_color = get_state_color(m, mc); |
138 | 138 |
139 # Create the tracks. | 139 # Create the tracks. |
140 cells = create_track(opt$state_files, opt$chrom_len_file, paste(tracks_output_dir, hub_id, sep=""), state_color, header=opt$header, state_name=opt$state_name); | 140 cells = create_track(opt$state_files, opt$chrom_len_file, paste(tracks_output_dir, opt$hub_id, sep=""), state_color, header=opt$header, state_name=opt$state_name); |
141 cell_info = opt$cell_info | 141 cell_info = opt$cell_info |
142 if(length(cell_info) == 0) { | 142 if(length(cell_info) == 0) { |
143 cell_info = cbind(cells, cells, cells, "#000000"); | 143 cell_info = cbind(cells, cells, cells, "#000000"); |
144 cell_info = array(cell_info, dim=c(length(cells), 4)); | 144 cell_info = array(cell_info, dim=c(length(cells), 4)); |
145 } | 145 } |
155 track_db = c(track_db, paste("track bigBed", i, sep="")); | 155 track_db = c(track_db, paste("track bigBed", i, sep="")); |
156 track_db = c(track_db, paste("priority", ii)); | 156 track_db = c(track_db, paste("priority", ii)); |
157 track_db = c(track_db, "type bigBed 9 ."); | 157 track_db = c(track_db, "type bigBed 9 ."); |
158 track_db = c(track_db, "itemRgb on"); | 158 track_db = c(track_db, "itemRgb on"); |
159 track_db = c(track_db, "maxItems 100000"); | 159 track_db = c(track_db, "maxItems 100000"); |
160 track_db = c(track_db, paste("bigDataUrl ", opt$target_url, hub_id, ".", i, ".bb", sep="")); | 160 track_db = c(track_db, paste("bigDataUrl ", opt$target_url, opt$hub_id, ".", i, ".bb", sep="")); |
161 track_db = c(track_db, paste("shortLabel", cell_info[ii, 2])); | 161 track_db = c(track_db, paste("shortLabel", cell_info[ii, 2])); |
162 track_db = c(track_db, paste("longLabel", paste(opt$hub_name, cell_info[ii, 3]))); | 162 track_db = c(track_db, paste("longLabel", paste(opt$hub_name, cell_info[ii, 3]))); |
163 track_db = c(track_db, paste("color", paste(c(col2rgb(cell_info[ii, 4])), collapse=","))); | 163 track_db = c(track_db, paste("color", paste(c(col2rgb(cell_info[ii, 4])), collapse=","))); |
164 track_db = c(track_db, "visibility dense"); | 164 track_db = c(track_db, "visibility dense"); |
165 track_db = c(track_db, ""); | 165 track_db = c(track_db, ""); |
166 } | 166 } |
167 | 167 |
168 # Write the outputs. | 168 # Write the outputs. |
169 write.table(track_db, opt$output_track_db, quote=F, row.names=F, col.names=F); | 169 write.table(track_db, opt$output_track_db, quote=F, row.names=F, col.names=F); |
170 write.table(c(paste("genome", opt$build), opt$output_build, paste(tracks_output_dir, "genomes_", hub_id, ".txt", sep=""), quote=F,row.names=F,col.names=F); | 170 write.table(c(paste("genome", opt$build), opt$output_build, paste(tracks_output_dir, "genomes_", opt$hub_id, ".txt", sep=""), quote=F,row.names=F,col.names=F); |
171 write.table(c(paste("hub", hub_id), paste("shortLabel", hub_id), paste("longLabel", opt$hub_name), paste("genomesFile genomes_", hub_id, ".txt", sep=""), "email yzz2 at psu.edu"), opt$output_hub, quote=F, row.names=F, col.names=F); | 171 write.table(c(paste("hub", opt$hub_id), paste("shortLabel", opt$hub_id), paste("longLabel", opt$hub_name), paste("genomesFile genomes_", opt$hub_id, ".txt", sep=""), "email yzz2 at psu.edu"), opt$output_hub, quote=F, row.names=F, col.names=F); |