Commit 39af88c5afa802b437df13de8a2b280baab041f2
1 parent
8bfefd7afe
Exists in
master
fixed issue with spaces and choosing the second name (UNTESTED)
Showing
1 changed file
with
9 additions
and
27 deletions
Show diff stats
RClean4.R
... | ... | @@ -97,36 +97,18 @@ NAFIXING <- function(GIDNAM){ |
97 | 97 | GIDNAM |
98 | 98 | } |
99 | 99 | |
100 | -##4#Function for changing the gene ID to gene name | |
101 | -##cgeneID <- function(GeneName,DATA){ | |
102 | -## colGene <- dim(GeneName)[2] | |
103 | -## j <- 1 | |
104 | -## for(j in 1:colGene){ | |
105 | -## chngsreq <- grep(GeneName[1,j],DATA[1,]) | |
106 | -## if(sum(chngsreq) > 0){ | |
107 | -## #DATA[1,chngsreq] <- gsub(GeneName[1,j],GeneName[2,j],DATA[1,chngsreq]) | |
108 | -## DATA[1,chngsreq] <- gsub(paste0("^",GeneName[1,j]),GeneName[2,j],DATA[1,chngsreq]) | |
109 | -## } | |
110 | -## j = j+1 | |
111 | -## } | |
112 | -## DATA | |
113 | -##} | |
114 | 100 | #4#Function for changing the gene ID to gene name |
115 | 101 | cgeneID <- function(GeneName,DATA){ |
116 | 102 | colGene <- dim(GeneName)[2] |
117 | 103 | j <- 1 |
118 | 104 | for(j in 1:colGene){ |
119 | - chngsreq <- grep(paste0("^",GeneName[1,j],"$"),DATA[1,]) | |
120 | - if(is.na(sum(chngsreq))==FALSE){ | |
121 | - if(sum(chngsreq) > 0){ | |
122 | - DATA[1,chngsreq] <- gsub(paste0("^",GeneName[1,j]),GeneName[2,j],DATA[1,chngsreq]) | |
123 | - } | |
124 | - } | |
125 | - #if(sum(chngsreq) > 0){ | |
126 | - ##DATA[1,chngsreq] <- gsub(GeneName[1,j],GeneName[2,j],DATA[1,chngsreq]) | |
127 | - #DATA[1,chngsreq] <- gsub(paste0("^",GeneName[1,j]),GeneName[2,j],DATA[1,chngsreq]) | |
128 | - #} | |
129 | - j = j+1 | |
105 | + chngsreq <- grep(paste0("^",GeneName[1,j],"$"),DATA[1,]) | |
106 | + if(is.na(sum(chngsreq))==FALSE){ | |
107 | + if(sum(chngsreq) > 0){ | |
108 | + DATA[1,chngsreq] <- gsub(paste0("^",GeneName[1,j]),GeneName[2,j],DATA[1,chngsreq]) | |
109 | + } | |
110 | + } | |
111 | + j = j+1 | |
130 | 112 | } |
131 | 113 | DATA |
132 | 114 | } |
... | ... | @@ -138,9 +120,9 @@ gcnames <- function(DiData,usecol=1){ |
138 | 120 | nwnam <- rep("0",length.out=nuruns) |
139 | 121 | for(i in 1:nuruns){ |
140 | 122 | if(length(strsplit(colnames(DiData)[i],"///")[[1]]) >= usecol){ |
141 | - nwnam[i]=strsplit(colnames(DiData)[i],"///")[[1]][usecol] | |
123 | + nwnam[i]=str_trim(strsplit(colnames(DiData)[i],"///")[[1]][usecol]) | |
142 | 124 | } else{ |
143 | - nwnam[i]=strsplit(colnames(DiData)[i],"///")[[1]][1] | |
125 | + nwnam[i]=str_trim(strsplit(colnames(DiData)[i],"///")[[1]][1]) | |
144 | 126 | } |
145 | 127 | |
146 | 128 | } |