Commit 69ac507843530d76722471db7ddbf5f213a11aee
1 parent
ae780ea650
Exists in
master
Don't use this code yet
Updated to decrease time of search for cgeneID
Showing
1 changed file
with
29 additions
and
11 deletions
Show diff stats
RAutoClDs.R
| ... | ... | @@ -104,20 +104,38 @@ NAFIXING <- function(GIDNAM){ |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | #4#Function for changing the gene ID to gene name |
| 107 | -cgeneID <- function(GeneName,DATA){ | |
| 108 | - colGene <- dim(GeneName)[2] | |
| 109 | - j <- 1 | |
| 110 | - for(j in 1:colGene){ | |
| 111 | - chngsreq <- grep(paste0("^",GeneName[1,j],"$"),DATA[1,]) | |
| 112 | - if(is.na(sum(chngsreq))==FALSE){ | |
| 113 | - if(sum(chngsreq) > 0){ | |
| 114 | - DATA[1,chngsreq] <- gsub(paste0("^",GeneName[1,j]),GeneName[2,j],DATA[1,chngsreq]) | |
| 107 | +cgeneID2 <- function(GeneName,DATA){ | |
| 108 | + nj <- t(GeneName) | |
| 109 | + nq <- t(DATA) | |
| 110 | + colGene <- dim(nj)[2] | |
| 111 | + colDATA <- dim(nq)[2] | |
| 112 | + j <- 1 | |
| 113 | + for(j in 1:colDATA){ | |
| 114 | + #where is that gene id located within the GPL file | |
| 115 | + chngreq <- grep(paste0("^",nq[1,j],"$"),nj[1,]) | |
| 116 | + if(is.na(sum(chngreq))==FALSE){ | |
| 117 | + if(sum(chngreq) > 0){ | |
| 118 | + nq[1,j] <- gsub(paste0("^",nq[1,j],"$"),nj[2,chngreq],nq[1,j]) | |
| 119 | + } | |
| 115 | 120 | } |
| 121 | + j <- j + 1 | |
| 116 | 122 | } |
| 117 | - j = j+1 | |
| 118 | - } | |
| 119 | - DATA | |
| 123 | + nq | |
| 120 | 124 | } |
| 125 | +#cgeneID <- function(GeneName,DATA){ | |
| 126 | +# colGene <- dim(GeneName)[2] | |
| 127 | +# j <- 1 | |
| 128 | +# for(j in 1:colGene){ | |
| 129 | +# chngsreq <- grep(paste0("^",GeneName[1,j],"$"),DATA[1,]) | |
| 130 | +# if(is.na(sum(chngsreq))==FALSE){ | |
| 131 | +# if(sum(chngsreq) > 0){ | |
| 132 | +# DATA[1,chngsreq] <- gsub(paste0("^",GeneName[1,j]),GeneName[2,j],DATA[1,chngsreq]) | |
| 133 | +# } | |
| 134 | +# } | |
| 135 | +# j = j+1 | |
| 136 | +# } | |
| 137 | +# DATA | |
| 138 | +#} | |
| 121 | 139 | |
| 122 | 140 | #5#Function for adjusting the gene names |
| 123 | 141 | gcnames <- function(DiData,usecol=1){ |