# HG changeset patch # User proteore # Date 1544091980 18000 # Node ID d7d2a451205975c3b42457cceebfc081e5c68733 # Parent 70e3b70ded2247cfafe33db8ecd88511d4a17a90 planemo upload commit 78ad61e52c2bf8c5ffada89a8eed429a332eb40b-dirty diff -r 70e3b70ded22 -r d7d2a4512059 add_expression_HPA.R --- a/add_expression_HPA.R Tue Dec 04 05:47:23 2018 -0500 +++ b/add_expression_HPA.R Thu Dec 06 05:26:20 2018 -0500 @@ -21,7 +21,7 @@ add_expression = function(input, atlas, options) { input <- unique(input[!is.na(input)]) - input <- gsub("[[:blank:]]","",input) + input <- gsub("[[:blank:]]|\u00A0","",input) if (all(!input %in% atlas$Ensembl)) { return(NULL) } else { @@ -72,12 +72,19 @@ #create new lines if there's more than one id per cell in the columns in order to have only one id per line one_id_one_line <-function(tab,ncol){ - tab[,ncol] = sapply(tab[,ncol],function(x) gsub("[[:blank:]]","",x)) - header=colnames(tab) - res=as.data.frame(matrix(ncol=ncol(tab),nrow=0)) - for (i in 1:nrow(tab) ) { - lines = split_ids_per_line(tab[i,],ncol) - res = rbind(res,lines) + if (ncol(tab)>1){ + + tab[,ncol] = sapply(tab[,ncol],function(x) gsub("[[:blank:]]","",x)) + header=colnames(tab) + res=as.data.frame(matrix(ncol=ncol(tab),nrow=0)) + for (i in 1:nrow(tab) ) { + lines = split_ids_per_line(tab[i,],ncol) + res = rbind(res,lines) + } + }else { + res = unlist(sapply(tab[,1],function(x) strsplit(x,";")),use.names = F) + res = data.frame(res[which(!is.na(res[res!=""]))],stringsAsFactors = F) + colnames(res)=colnames(tab) } return(res) }