Mercurial > repos > proteore > proteore_heatmap_visualization
comparison heatmap_viz.R @ 3:07748b0136bb draft default tip
planemo upload commit fb27a6b5de5cd7b269a41be3c85c593b77aa1b18-dirty
| author | proteore |
|---|---|
| date | Thu, 27 Jun 2019 04:18:07 -0400 |
| parents | 99207b432ebc |
| children |
comparison
equal
deleted
inserted
replaced
| 2:99207b432ebc | 3:07748b0136bb |
|---|---|
| 1 #!/usr/bin/Rscript | 1 #!/usr/bin/Rscript |
| 2 options(warn=-1) #TURN OFF WARNINGS !!!!!! | |
| 2 | 3 |
| 3 suppressMessages(library('plotly',quietly = T)) | 4 suppressMessages(library('plotly',quietly = T)) |
| 4 suppressMessages(library('heatmaply',quietly = T)) | 5 suppressMessages(library('heatmaply',quietly = T)) |
| 5 | 6 |
| 6 #packageVersion('plotly') | 7 #packageVersion('plotly') |
| 78 #} | 79 #} |
| 79 return(uto) | 80 return(uto) |
| 80 } | 81 } |
| 81 | 82 |
| 82 get_cols <-function(input_cols) { | 83 get_cols <-function(input_cols) { |
| 83 input_cols <- gsub("c","",input_cols) | 84 input_cols <- gsub("c","",gsub("C","",gsub(" ","",input_cols))) |
| 84 if (grepl(":",input_cols)) { | 85 if (grepl(":",input_cols)) { |
| 85 first_col=unlist(strsplit(input_cols,":"))[1] | 86 first_col=unlist(strsplit(input_cols,":"))[1] |
| 86 last_col=unlist(strsplit(input_cols,":"))[2] | 87 last_col=unlist(strsplit(input_cols,":"))[2] |
| 87 cols=first_col:last_col | 88 cols=first_col:last_col |
| 88 } else { | 89 } else { |
| 100 header=str2bool(args$header) | 101 header=str2bool(args$header) |
| 101 output <- rapply(strsplit(args$output,"\\."),c) #remove extension | 102 output <- rapply(strsplit(args$output,"\\."),c) #remove extension |
| 102 output <- paste(output[1:length(output)-1],collapse=".") | 103 output <- paste(output[1:length(output)-1],collapse=".") |
| 103 output <- paste(output,args$type,sep=".") | 104 output <- paste(output,args$type,sep=".") |
| 104 cols = get_cols(args$cols) | 105 cols = get_cols(args$cols) |
| 105 rownames_col = as.integer(gsub("c","",args$row_names)) | 106 rownames_col = as.integer(gsub("c","",gsub("C","",gsub(" ","",args$row_names)))) |
| 106 if (length(cols) <=1 ){ | 107 if (length(cols) <=1 ){ |
| 107 stop("You need several colums to build a heatmap") | 108 stop("You need several colums to build a heatmap") |
| 108 } | 109 } |
| 109 dist=args$dist | 110 dist=args$dist |
| 110 clust=args$clust | 111 clust=args$clust |
| 114 uto <- read_file(args$input,header) | 115 uto <- read_file(args$input,header) |
| 115 uto <- clean_df(uto,cols,rownames_col) | 116 uto <- clean_df(uto,cols,rownames_col) |
| 116 uto <- uto[rowSums(is.na(uto)) != ncol(uto), ] #remove emptylines | 117 uto <- uto[rowSums(is.na(uto)) != ncol(uto), ] #remove emptylines |
| 117 | 118 |
| 118 if (header) { | 119 if (header) { |
| 119 col_names = names(data) | 120 col_names = names(uto) |
| 120 } else { | 121 } else { |
| 121 col_names = cols | 122 col_names = cols |
| 122 } | 123 } |
| 123 | 124 |
| 124 #building heatmap | 125 #building heatmap |
