Mercurial > repos > greg > ideas_genome_tracks
comparison create_heatmap.R @ 81:dcd4be407063 draft
Uploaded
| author | greg |
|---|---|
| date | Thu, 04 Jan 2018 12:31:46 -0500 |
| parents | efbc9e58c4eb |
| children | cf0a62d084dc |
comparison
equal
deleted
inserted
replaced
| 80:6d97ef6bf7b7 | 81:dcd4be407063 |
|---|---|
| 5 # based on the received data_frame which was created | 5 # based on the received data_frame which was created |
| 6 # by reading the .para file. | 6 # by reading the .para file. |
| 7 num_columns = dim(data_frame)[2]; | 7 num_columns = dim(data_frame)[2]; |
| 8 num_rows = dim(data_frame)[1]; | 8 num_rows = dim(data_frame)[1]; |
| 9 p = (sqrt(9 + 8 * (num_columns-1)) - 3) / 2; | 9 p = (sqrt(9 + 8 * (num_columns-1)) - 3) / 2; |
| 10 data_matrix = as.matrix(data_frame[,1+1:p] / data_frame[,1]); | 10 data_matrix = as.matrix(data_frame[,1+1:p]/data_frame[,1]); |
| 11 colnames(data_matrix) = colnames(data_frame)[1+1:p]; | 11 colnames(data_matrix) = colnames(data_frame)[1+1:p]; |
| 12 histone_marks = colnames(data_matrix); | 12 histone_marks = colnames(data_matrix); |
| 13 rownames(data_matrix) = paste(1:num_rows-1, " (", round(data_frame[,1]/sum(data_frame[,1])*10000)/100, "%)", sep=""); | 13 rownames(data_matrix) = paste(1:num_rows-1, " (", round(data_frame[,1]/sum(data_frame[,1])*10000)/100, "%)", sep=""); |
| 14 if (!is.null(output_file_name)) { | 14 if (!is.null(output_file_name)) { |
| 15 # Open the output PDF file. | 15 # Open the output PDF file. |
| 24 defpalette = palette(my_palette); | 24 defpalette = palette(my_palette); |
| 25 # Plot the heatmap for the current .para / .state combination. | 25 # Plot the heatmap for the current .para / .state combination. |
| 26 plot(NA, NA, xlim=c(0, p+0.7), ylim=c(0, num_rows), xaxt="n", yaxt="n", xlab=NA, ylab=NA, frame.plot=F); | 26 plot(NA, NA, xlim=c(0, p+0.7), ylim=c(0, num_rows), xaxt="n", yaxt="n", xlab=NA, ylab=NA, frame.plot=F); |
| 27 axis(1, at=1:p-0.5, labels=colnames(data_matrix), las=2); | 27 axis(1, at=1:p-0.5, labels=colnames(data_matrix), las=2); |
| 28 axis(4, at=1:num_rows-0.5, labels=rownames(data_matrix), las=2); | 28 axis(4, at=1:num_rows-0.5, labels=rownames(data_matrix), las=2); |
| 29 color = round((t(data_matrix) - min_max_vector[1]) / (min_max_vector[2] - min_max_vector[1]) * 100); | 29 col = round((t(data_matrix) - min_max_vector[1]) / (min_max_vector[2] - min_max_vector[1]) * 100); |
| 30 rect(rep(1:p-1, num_rows), rep(1:num_rows-1, each=p), rep(1:p, num_rows), rep(1:num_rows, each=p), col=color); | 30 rect(rep(1:p-1, num_rows), rep(1:num_rows-1, each=p), rep(1:p, num_rows), rep(1:num_rows, each=p), col=col); |
| 31 histone_mark_color = t(col2rgb(terrain.colors(ceiling(p))[1:p])); | 31 histone_mark_color = t(col2rgb(terrain.colors(ceiling(p))[1:p])); |
| 32 | 32 |
| 33 # Specify a color for common feature names like "h3k4me3". | 33 # Specify a color for common feature names like "h3k4me3". |
| 34 # These are histone marks frequently used to identify | 34 # These are histone marks frequently used to identify |
| 35 # promoter activities in a cell, and are often displayed | 35 # promoter activities in a cell, and are often displayed |
