Mercurial > repos > proteore > proteore_maps_visualization
annotate kegg_maps_visualization.R @ 6:eb140217a9f1 draft default tip
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
author | proteore |
---|---|
date | Thu, 05 Mar 2020 10:10:20 -0500 |
parents | 8e611bdc96ec |
children |
rev | line source |
---|---|
0
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
1 #!/usr/bin/Rscript |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
2 #Rscript made for mapping genesID on KEGG pathway with Pathview package |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
3 #input : csv file containing ids (uniprot or geneID) to map, plus parameters |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
4 #output : KEGG pathway : jpeg or pdf file. |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
5 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
6 options(warn=-1) #TURN OFF WARNINGS !!!!!! |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
7 suppressMessages(library("pathview")) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
8 suppressMessages(library(KEGGREST)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
9 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
10 read_file <- function(path,header){ |
1
6f389729a30b
planemo upload commit 93c44875036dbc9b3b9c1416566cf91004b97429-dirty
proteore
parents:
0
diff
changeset
|
11 file <- try(read.csv(path,header=header, sep="\t",stringsAsFactors = FALSE, quote="\"", check.names = F, comment.char = ""),silent=TRUE) |
0
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
12 if (inherits(file,"try-error")){ |
1
6f389729a30b
planemo upload commit 93c44875036dbc9b3b9c1416566cf91004b97429-dirty
proteore
parents:
0
diff
changeset
|
13 stop("Read file error ! Please check your file (header, # character, etc) ") |
0
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
14 }else{ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
15 return(file) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
16 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
17 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
18 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
19 ##### fuction to clean and concatenate pathway name (allow more flexibility for user input) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
20 concat_string <- function(x){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
21 x <- gsub(" - .*","",x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
22 x <- gsub(" ","",x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
23 x <- gsub("-","",x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
24 x <- gsub("_","",x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
25 x <- gsub(",","",x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
26 x <- gsub("\\'","",x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
27 x <- gsub("\\(.*)","",x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
28 x <- gsub("\\/","",x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
29 x <- tolower(x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
30 return(x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
31 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
32 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
33 #return output suffix (pathway name) from id kegg (ex : hsa:00010) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
34 get_suffix <- function(pathways_list,species,id){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
35 suffix = gsub("/","or",pathways_list[pathways_list[,1]==paste(species,id,sep=""),2]) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
36 suffix = gsub(" ","_",suffix) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
37 if (nchar(suffix) > 50){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
38 suffix = substr(suffix,1,50) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
39 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
40 return(suffix) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
41 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
42 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
43 str2bool <- function(x){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
44 if (any(is.element(c("t","true"),tolower(x)))){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
45 return (TRUE) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
46 }else if (any(is.element(c("f","false"),tolower(x)))){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
47 return (FALSE) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
48 }else{ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
49 return(NULL) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
50 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
51 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
52 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
53 is.letter <- function(x) grepl("[[:alpha:]]", x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
54 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
55 #### hsa00010 -> 00010 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
56 remove_kegg_prefix <- function(x){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
57 x = gsub(":","",x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
58 if (substr(x,1,4) == 'path'){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
59 x=substr(x,5,nchar(x)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
60 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
61 if (is.letter(substr(x,1,3))){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
62 x <- substr(x,4,nchar(x)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
63 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
64 return(x) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
65 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
66 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
67 kegg_to_geneID <- function(vector){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
68 vector <- sapply(vector, function(x) unlist(strsplit(x,":"))[2],USE.NAMES = F) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
69 return (vector) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
70 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
71 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
72 clean_bad_character <- function(string) { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
73 string <- gsub("X","",string) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
74 return(string) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
75 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
76 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
77 get_list_from_cp <-function(list){ |
3
dfceadc0b703
planemo upload commit 4ba1ebe7b3f5e3fabf78b5fed7ed0b92e2cbf9e5-dirty
proteore
parents:
1
diff
changeset
|
78 list = gsub(";","\t",list) |
1
6f389729a30b
planemo upload commit 93c44875036dbc9b3b9c1416566cf91004b97429-dirty
proteore
parents:
0
diff
changeset
|
79 list = gsub(",","\t",list) |
0
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
80 list = strsplit(list, "[ \t\n]+")[[1]] |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
81 list = list[list != ""] #remove empty entry |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
82 list = gsub("-.+", "", list) #Remove isoform accession number (e.g. "-2") |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
83 return(list) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
84 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
85 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
86 get_ref_pathways <- function(species){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
87 ##all available pathways for the species |
4
8e611bdc96ec
"planemo upload commit 6bef056b0e52bfa39dbe8591bfe67f8c95bf3ba2-dirty"
proteore
parents:
3
diff
changeset
|
88 pathways <- keggLink("pathway", species) |
8e611bdc96ec
"planemo upload commit 6bef056b0e52bfa39dbe8591bfe67f8c95bf3ba2-dirty"
proteore
parents:
3
diff
changeset
|
89 tot_path <- unique(pathways) |
0
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
90 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
91 ##formating the dat into a list object |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
92 ##key= pathway ID, value = genes of the pathway in the kegg format |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
93 pathways_list <- sapply(tot_path, function(pathway) names(which(pathways==pathway))) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
94 return (pathways_list) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
95 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
96 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
97 mapping_summary <- function(pv.out,species,id,id_type,pathways_list,geneID,uniprotID,mapped2geneID){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
98 ref_pathways = get_ref_pathways(species) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
99 names(ref_pathways) <- sapply(names(ref_pathways), function(x) gsub("path:[a-z]{3}","",x),USE.NAMES = F) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
100 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
101 #genes present in pathway |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
102 genes = ref_pathways[id][[1]] |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
103 nb_genes = length(genes) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
104 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
105 #genes mapped on pathway genes |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
106 mapped <- unlist(sapply(pv.out$plot.data.gene$all.mapped, function(x) strsplit(x,",")),use.names = F) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
107 mapped = unique(mapped[mapped!=""]) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
108 nb_mapped <- length(mapped) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
109 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
110 #compue ratio of mapping |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
111 ratio = round((nb_mapped/nb_genes)*100, 2) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
112 if (is.nan(ratio)) { ratio = ""} |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
113 pathway_id = paste(species,id,sep="") |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
114 pathway_name = as.character(pathways_list[pathways_list[,1]==pathway_id,][2]) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
115 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
116 if (id_type=="geneid" || id_type=="keggid") { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
117 row <- c(pathway_id,pathway_name,length(unique(geneID)),nb_mapped,nb_genes,ratio,paste(mapped,collapse=";")) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
118 names(row) <- c("KEGG pathway ID","pathway name","nb of Entrez gene ID used","nb of Entrez gene ID mapped", |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
119 "nb of Entrez gene ID in the pathway", "ratio of Entrez gene ID mapped (%)","Entrez gene ID mapped") |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
120 } else if (id_type=="uniprotid") { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
121 row <- c(pathway_id,pathway_name,length(unique(uniprotID)),length(unique(geneID)),nb_mapped,nb_genes,ratio,paste(mapped,collapse=";"),paste(mapped2geneID[which(mapped2geneID[,2] %in% mapped)],collapse=";")) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
122 names(row) <- c("KEGG pathway ID","pathway name","nb of Uniprot_AC used","nb of Entrez gene ID used","nb of Entrez gene ID mapped", |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
123 "nb of Entrez gene ID in the pathway", "ratio of Entrez gene ID mapped (%)","Entrez gene ID mapped","uniprot_AC mapped") |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
124 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
125 return(row) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
126 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
127 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
128 #take data frame, return data frame |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
129 split_ids_per_line <- function(line,ncol){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
130 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
131 #print (line) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
132 header = colnames(line) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
133 line[ncol] = gsub("[[:blank:]]|\u00A0","",line[ncol]) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
134 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
135 if (length(unlist(strsplit(as.character(line[ncol]),";")))>1) { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
136 if (length(line)==1 ) { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
137 lines = as.data.frame(unlist(strsplit(as.character(line[ncol]),";")),stringsAsFactors = F) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
138 } else { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
139 if (ncol==1) { #first column |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
140 lines = suppressWarnings(cbind(unlist(strsplit(as.character(line[ncol]),";")), line[2:length(line)])) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
141 } else if (ncol==length(line)) { #last column |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
142 lines = suppressWarnings(cbind(line[1:ncol-1],unlist(strsplit(as.character(line[ncol]),";")))) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
143 } else { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
144 lines = suppressWarnings(cbind(line[1:ncol-1], unlist(strsplit(as.character(line[ncol]),";"),use.names = F), line[(ncol+1):length(line)])) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
145 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
146 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
147 colnames(lines)=header |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
148 return(lines) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
149 } else { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
150 return(line) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
151 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
152 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
153 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
154 #create new lines if there's more than one id per cell in the columns in order to have only one id per line |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
155 one_id_one_line <-function(tab,ncol){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
156 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
157 if (ncol(tab)>1){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
158 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
159 tab[,ncol] = sapply(tab[,ncol],function(x) gsub("[[:blank:]]","",x)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
160 header=colnames(tab) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
161 res=as.data.frame(matrix(ncol=ncol(tab),nrow=0)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
162 for (i in 1:nrow(tab) ) { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
163 lines = split_ids_per_line(tab[i,],ncol) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
164 res = rbind(res,lines) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
165 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
166 }else { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
167 res = unlist(sapply(tab[,1],function(x) strsplit(x,";")),use.names = F) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
168 res = data.frame(res[which(!is.na(res[res!=""]))],stringsAsFactors = F) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
169 colnames(res)=colnames(tab) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
170 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
171 return(res) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
172 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
173 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
174 get_limit <- function(mat) { |
6
eb140217a9f1
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
proteore
parents:
4
diff
changeset
|
175 min = min(apply(mat,2,min,na.rm=TRUE)) |
eb140217a9f1
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
proteore
parents:
4
diff
changeset
|
176 max = max(apply(mat,2,max,na.rm=TRUE)) |
0
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
177 return(c(min,max)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
178 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
179 |
6
eb140217a9f1
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
proteore
parents:
4
diff
changeset
|
180 check_pathway_ids<- function(pathways_ids) { |
eb140217a9f1
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
proteore
parents:
4
diff
changeset
|
181 problematic_pathways <- c("04215","04723") |
eb140217a9f1
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
proteore
parents:
4
diff
changeset
|
182 to_remove <- intersect(pathways_ids,problematic_pathways) |
eb140217a9f1
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
proteore
parents:
4
diff
changeset
|
183 if (length(to_remove) > 0){ print(paste("Pathway(s)",to_remove,"have been remove from input")) } |
eb140217a9f1
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
proteore
parents:
4
diff
changeset
|
184 pathways_ids <- pathways_ids[which(!pathways_ids %in% problematic_pathways)] |
eb140217a9f1
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
proteore
parents:
4
diff
changeset
|
185 if (length(pathways_ids) == 0){stop("No pathways ids to process")} |
eb140217a9f1
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
proteore
parents:
4
diff
changeset
|
186 return (pathways_ids) |
eb140217a9f1
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
proteore
parents:
4
diff
changeset
|
187 } |
eb140217a9f1
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
proteore
parents:
4
diff
changeset
|
188 |
0
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
189 get_args <- function(){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
190 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
191 ## Collect arguments |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
192 args <- commandArgs(TRUE) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
193 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
194 ## Default setting when no arguments passed |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
195 if(length(args) < 1) { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
196 args <- c("--help") |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
197 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
198 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
199 ## Help section |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
200 if("--help" %in% args) { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
201 cat("Pathview R script |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
202 Arguments: |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
203 --help Print this test |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
204 --input path of the input file (must contains a colum of uniprot and/or geneID accession number) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
205 --id_list list of ids to use, ',' separated |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
206 --pathways_id Id(s) of pathway(s) to use, if several, semicolon separated list : hsa00010;hsa05412 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
207 --id_type Type of accession number ('uniprotID' or 'geneID') |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
208 --id_column Column containing accesion number of interest (ex : 'c1') |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
209 --header Boolean, TRUE if header FALSE if not |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
210 --output Output filename |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
211 --fold_change_col Column(s) containing fold change values (comma separated) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
212 --native_kegg TRUE : native KEGG graph, FALSE : Graphviz graph |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
213 --species KEGG species (hsa, mmu, ...) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
214 --pathways_input Tab with pathways in a column, output format of find_pathways |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
215 --pathway_col Column of pathways to use |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
216 --header2 Boolean, TRUE if header FALSE if not |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
217 --pathways_list path of file containg the species pathways list (hsa_pathways.loc, mmu_pathways.loc, ...) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
218 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
219 Example: |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
220 ./PathView.R --input 'input.csv' --pathway_id '05412' --id_type 'uniprotID' --id_column 'c1' --header TRUE \n\n") |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
221 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
222 q(save="no") |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
223 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
224 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
225 parseArgs <- function(x) strsplit(sub("^--", "", x), "=") |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
226 argsDF <- as.data.frame(do.call("rbind", parseArgs(args))) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
227 args <- as.list(as.character(argsDF$V2)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
228 names(args) <- argsDF$V1 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
229 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
230 return(args) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
231 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
232 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
233 main <- function(){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
234 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
235 args <- get_args() |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
236 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
237 #save(args,file="/home/dchristiany/proteore_project/ProteoRE/tools/kegg_maps_visualization/args.Rda") |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
238 #load("/home/dchristiany/proteore_project/ProteoRE/tools/kegg_maps_visualization/args.Rda") |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
239 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
240 ###setting variables |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
241 if (!is.null(args$pathways_id)) { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
242 ids <- get_list_from_cp(clean_bad_character(args$pathways_id)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
243 ids <- sapply(ids, function(x) remove_kegg_prefix(x),USE.NAMES = FALSE) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
244 }else if (!is.null(args$pathways_input)){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
245 header2 <- str2bool(args$header2) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
246 pathway_col <- as.numeric(gsub("c", "" ,args$pathway_col)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
247 pathways_file = read_file(args$pathways_input,header2) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
248 ids <- sapply(rapply(strsplit(clean_bad_character(pathways_file[,pathway_col]),","),c), function(x) remove_kegg_prefix(x),USE.NAMES = FALSE) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
249 } |
6
eb140217a9f1
"planemo upload commit 1f9a98db2496834cc38a281cbe3d4b11de2bc3d2-dirty"
proteore
parents:
4
diff
changeset
|
250 if (args$native_kegg) {ids = check_pathway_ids(ids)} #remove problematic pathways |
0
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
251 pathways_list <- read_file(args$pathways_list,F) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
252 if (!is.null(args$id_list)) { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
253 id_list <- get_list_from_cp(args$id_list) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
254 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
255 id_type <- tolower(args$id_type) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
256 ncol <- as.numeric(gsub("c", "" ,args$id_column)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
257 header <- str2bool(args$header) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
258 native_kegg <- str2bool(args$native_kegg) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
259 species=args$species |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
260 fold_change_data = str2bool(args$fold_change_data) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
261 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
262 #org list used in mapped2geneID |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
263 org <- c('Hs','Mm','Rn') |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
264 names(org) <- c('hsa','mmu','rno') |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
265 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
266 #read input file or list |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
267 if (!is.null(args$input)){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
268 tab <- read_file(args$input,header) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
269 tab <- data.frame(tab[which(tab[ncol]!=""),],stringsAsFactors = F) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
270 tab = one_id_one_line(tab,ncol) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
271 } else { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
272 id_list = gsub("[[:blank:]]|\u00A0|NA","",id_list) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
273 id_list = unique(id_list[id_list!=""]) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
274 tab <- data.frame(id_list,stringsAsFactors = F) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
275 ncol=1 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
276 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
277 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
278 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
279 ##### map uniprotID to entrez geneID and kegg to geneID |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
280 uniprotID="" |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
281 mapped2geneID="" |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
282 if (id_type == "uniprotid") { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
283 uniprotID=tab[,ncol] |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
284 mapped2geneID = id2eg(ids = uniprotID, category = "uniprot", org = org[[species]], pkg.name = NULL) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
285 geneID = mapped2geneID[,2] |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
286 tab = cbind(tab,geneID) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
287 ncol=ncol(tab) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
288 }else if (id_type == "keggid"){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
289 keggID = tab[,ncol] |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
290 geneID = kegg_to_geneID(keggID) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
291 tab = cbind(tab,geneID) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
292 ncol=ncol(tab) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
293 }else if (id_type == "geneid"){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
294 colnames(tab)[ncol] <- "geneID" |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
295 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
296 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
297 ##### build matrix to map on KEGG pathway (kgml : KEGG xml) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
298 geneID_indices = which(!is.na(tab$geneID)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
299 if (fold_change_data) { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
300 fold_change <- as.integer(unlist(strsplit(gsub("c","",args$fold_change_col),","))) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
301 if (length(fold_change) > 3) { fold_change= fold_change[1:3] } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
302 if (length(fold_change)==1){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
303 tab[,fold_change] <- as.double(gsub(",",".",as.character(tab[,fold_change]) )) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
304 } else { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
305 tab[,fold_change] <- apply(tab[,fold_change],2,function(x) as.double(gsub(",",".",as.character(x)))) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
306 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
307 mat = tab[geneID_indices,c(ncol,fold_change)] |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
308 mat = mat[(!duplicated(mat$geneID)),] |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
309 geneID=mat$geneID |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
310 mat = as.data.frame(mat[,-1]) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
311 row.names(mat)=geneID |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
312 limit = get_limit(mat) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
313 } else { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
314 mat = unique(as.character(tab$geneID[!is.na(tab$geneID[tab$geneID!=""])])) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
315 geneID=mat |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
316 limit=1 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
317 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
318 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
319 #####mapping geneID (with or without expression values) on KEGG pathway |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
320 plot.col.key= TRUE |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
321 low_color = "green" |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
322 mid_color = "#F3F781" #yellow |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
323 high_color = "red" |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
324 if (!fold_change_data) { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
325 plot.col.key= FALSE #if there's no exrepession data, we don't show the color key |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
326 high_color = "#81BEF7" #blue |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
327 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
328 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
329 #create graph(s) and text output |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
330 for (id in ids) { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
331 suffix= get_suffix(pathways_list,species,id) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
332 pv.out <- suppressMessages(pathview(gene.data = mat, |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
333 gene.idtype = "entrez", |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
334 pathway.id = id, |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
335 species = species, |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
336 kegg.dir = ".", |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
337 out.suffix=suffix, |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
338 kegg.native = native_kegg, |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
339 low = list(gene = low_color, cpd = "blue"), |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
340 mid = list(gene = mid_color, cpd = "transparent"), |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
341 high = list(gene = high_color, cpd = "yellow"), |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
342 na.col="#D8D8D8", #gray |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
343 cpd.data=NULL, |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
344 plot.col.key = plot.col.key, |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
345 pdf.size=c(9,9), |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
346 limit=list(gene=limit, cpd=limit))) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
347 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
348 if (is.list(pv.out)){ |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
349 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
350 #creating text file |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
351 if (!exists("DF")) { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
352 DF <- data.frame(t(mapping_summary(pv.out,species,id,id_type,pathways_list,geneID,uniprotID,mapped2geneID)),stringsAsFactors = F,check.names = F) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
353 } else { |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
354 #print (mapping_summary(pv.out,species,id)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
355 DF <- rbind(DF,data.frame(t(mapping_summary(pv.out,species,id,id_type,pathways_list,geneID,uniprotID,mapped2geneID)),stringsAsFactors = F,check.names = F)) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
356 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
357 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
358 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
359 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
360 DF <- as.data.frame(apply(DF, c(1,2), function(x) gsub("^$|^ $", NA, x))) #convert "" et " " to NA |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
361 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
362 #text file output |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
363 write.table(DF,file=args$output,quote=FALSE, sep='\t',row.names = FALSE, col.names = TRUE) |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
364 } |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
365 |
9845dc9c7323
planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
proteore
parents:
diff
changeset
|
366 main() |