# HG changeset patch # User proteore # Date 1542038065 18000 # Node ID da82872f5c80adb17f3998031a5127ed248ffc3e # Parent be8115c73b0d65782399777624e97808e27507b4 planemo upload commit 63302cb49d4f0f4dbc9ae141d20704822588f54e-dirty diff -r be8115c73b0d -r da82872f5c80 kegg_pathways_visualization.R --- a/kegg_pathways_visualization.R Fri Nov 09 05:22:50 2018 -0500 +++ b/kegg_pathways_visualization.R Mon Nov 12 10:54:25 2018 -0500 @@ -64,6 +64,11 @@ return(x) } +kegg_to_geneID <- function(vector){ + vector <- sapply(vector, function(x) unlist(strsplit(x,":"))[2],USE.NAMES = F) + return (vector) +} + clean_bad_character <- function(string) { string <- gsub("X","",string) return(string) @@ -79,7 +84,7 @@ #return a summary from the mapping with pathview in a vector mapping_summary <- function(pv.out,species,id,id_type){ - mapped <- pv.out$plot.data.gene$kegg.names[which(pv.out$plot.data.gene$all.mapped!='')] + mapped <- unique(pv.out$plot.data.gene$kegg.names[which(pv.out$plot.data.gene$all.mapped!='')]) nb_mapped <- length(mapped) nb_kegg_id <- length(unique(pv.out$plot.data.gene$kegg.names)) ratio = round((nb_mapped/nb_kegg_id)*100, 2) @@ -87,11 +92,11 @@ pathway_id = paste(species,id,sep="") pathway_name = as.character(pathways_list[pathways_list[,1]==pathway_id,][2]) - if (id_type=="geneid"){ + if (id_type=="geneid" || id_type=="keggid") { row <- c(pathway_id,pathway_name,length(unique(geneID)),nb_kegg_id,nb_mapped,ratio,paste(mapped,collapse=";")) names(row) <- c("KEGG pathway ID","pathway name","nb of Entrez gene ID used","nb of Entrez gene ID mapped", "nb of Entrez gene ID in the pathway", "ratio of Entrez gene ID mapped (%)","Entrez gene ID mapped") - }else if (id_type=="uniprotid"){ + } else if (id_type=="uniprotid") { row <- c(pathway_id,pathway_name,length(unique(uniprotID)),length(unique(geneID)),nb_mapped,nb_kegg_id,ratio,paste(mapped,collapse=";"),paste(mapped2geneID[which(mapped2geneID[,2] %in% mapped)],collapse=";")) 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", "nb of Entrez gene ID in the pathway", "ratio of Entrez gene ID mapped (%)","Entrez gene ID mapped","uniprot_AC mapped") @@ -194,12 +199,16 @@ } } -##### map uniprotID to entrez geneID +##### map uniprotID to entrez geneID and kegg to geneID if (id_type == "uniprotid") { uniprotID = tab[,ncol] mapped2geneID = id2eg(ids = uniprotID, category = "uniprot", org = org[[species]], pkg.name = NULL) geneID = mapped2geneID[,2] tab = cbind(tab,geneID) +}else if (id_type == "keggid"){ + keggID = tab[,ncol] + geneID = kegg_to_geneID(keggID) + tab = cbind(tab,geneID) }else if (id_type == "geneid"){ colnames(tab)[ncol] <- "geneID" } diff -r be8115c73b0d -r da82872f5c80 kegg_pathways_visualization.xml --- a/kegg_pathways_visualization.xml Fri Nov 09 05:22:50 2018 -0500 +++ b/kegg_pathways_visualization.xml Mon Nov 12 10:54:25 2018 -0500 @@ -1,4 +1,4 @@ - + map visualisation (PathView) bioconductor-pathview @@ -148,7 +148,7 @@ - +