changeset 3:d7d2a4512059 draft

planemo upload commit 78ad61e52c2bf8c5ffada89a8eed429a332eb40b-dirty
author proteore
date Thu, 06 Dec 2018 05:26:20 -0500
parents 70e3b70ded22
children 3f9057cdfdde
files add_expression_HPA.R
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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)
 }