comparison kegg_maps_visualization.R @ 2:8a6863adcd09 draft

planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
author proteore
date Tue, 18 Dec 2018 09:23:35 -0500
parents 789acaab8255
children 4cc2265d1294
comparison
equal deleted inserted replaced
1:48f302ae5545 2:8a6863adcd09
165 res = unlist(sapply(tab[,1],function(x) strsplit(x,";")),use.names = F) 165 res = unlist(sapply(tab[,1],function(x) strsplit(x,";")),use.names = F)
166 res = data.frame(res[which(!is.na(res[res!=""]))],stringsAsFactors = F) 166 res = data.frame(res[which(!is.na(res[res!=""]))],stringsAsFactors = F)
167 colnames(res)=colnames(tab) 167 colnames(res)=colnames(tab)
168 } 168 }
169 return(res) 169 return(res)
170 }
171
172 get_limit <- function(mat) {
173 min = min(apply(mat,2,min))
174 max = max(apply(mat,2,max))
175 return(c(min,max))
170 } 176 }
171 177
172 get_args <- function(){ 178 get_args <- function(){
173 179
174 ## Collect arguments 180 ## Collect arguments
289 mat = tab[geneID_indices,c(ncol,fold_change)] 295 mat = tab[geneID_indices,c(ncol,fold_change)]
290 mat = mat[(!duplicated(mat$geneID)),] 296 mat = mat[(!duplicated(mat$geneID)),]
291 geneID=mat$geneID 297 geneID=mat$geneID
292 mat = as.data.frame(mat[,-1]) 298 mat = as.data.frame(mat[,-1])
293 row.names(mat)=geneID 299 row.names(mat)=geneID
300 limit = get_limit(mat)
294 } else { 301 } else {
295 mat = unique(as.character(tab$geneID[!is.na(tab$geneID[tab$geneID!=""])])) 302 mat = unique(as.character(tab$geneID[!is.na(tab$geneID[tab$geneID!=""])]))
296 geneID=mat 303 geneID=mat
304 limit=1
297 } 305 }
298 306
299 #####mapping geneID (with or without expression values) on KEGG pathway 307 #####mapping geneID (with or without expression values) on KEGG pathway
300 plot.col.key= TRUE 308 plot.col.key= TRUE
301 low_color = "green" 309 low_color = "green"
302 mid_color = "#F3F781" #yellow 310 mid_color = "#F3F781" #yellow
303 high_color = "red" 311 high_color = "red"
304 if (!fold_change_data) { 312 if (!fold_change_data) {
305 plot.col.key= FALSE #if there's no exrepession data, we don't show the color key 313 plot.col.key= FALSE #if there's no exrepession data, we don't show the color key
306 high_color = "#81BEF7" #blue 314 high_color = "#81BEF7" #blue
307 } 315 }
308 316
309 #create graph(s) and text output 317 #create graph(s) and text output
310 for (id in ids) { 318 for (id in ids) {
311 suffix= get_suffix(pathways_list,species,id) 319 suffix= get_suffix(pathways_list,species,id)
312 pv.out <- suppressMessages(pathview(gene.data = mat, 320 pv.out <- suppressMessages(pathview(gene.data = mat,
320 mid = list(gene = mid_color, cpd = "transparent"), 328 mid = list(gene = mid_color, cpd = "transparent"),
321 high = list(gene = high_color, cpd = "yellow"), 329 high = list(gene = high_color, cpd = "yellow"),
322 na.col="#D8D8D8", #gray 330 na.col="#D8D8D8", #gray
323 cpd.data=NULL, 331 cpd.data=NULL,
324 plot.col.key = plot.col.key, 332 plot.col.key = plot.col.key,
325 pdf.size=c(9,9))) 333 pdf.size=c(9,9),
334 limit=list(gene=limit, cpd=limit)))
326 335
327 if (is.list(pv.out)){ 336 if (is.list(pv.out)){
328 337
329 #creating text file 338 #creating text file
330 if (!exists("DF")) { 339 if (!exists("DF")) {