diff --git a/RAutoClDs.R b/RAutoClDs.R index ac5e077..2e23841 100644 --- a/RAutoClDs.R +++ b/RAutoClDs.R @@ -104,20 +104,38 @@ NAFIXING <- function(GIDNAM){ } #4#Function for changing the gene ID to gene name -cgeneID <- function(GeneName,DATA){ - colGene <- dim(GeneName)[2] - j <- 1 - for(j in 1:colGene){ - chngsreq <- grep(paste0("^",GeneName[1,j],"$"),DATA[1,]) - if(is.na(sum(chngsreq))==FALSE){ - if(sum(chngsreq) > 0){ - DATA[1,chngsreq] <- gsub(paste0("^",GeneName[1,j]),GeneName[2,j],DATA[1,chngsreq]) +cgeneID2 <- function(GeneName,DATA){ + nj <- t(GeneName) + nq <- t(DATA) + colGene <- dim(nj)[2] + colDATA <- dim(nq)[2] + j <- 1 + for(j in 1:colDATA){ + #where is that gene id located within the GPL file + chngreq <- grep(paste0("^",nq[1,j],"$"),nj[1,]) + if(is.na(sum(chngreq))==FALSE){ + if(sum(chngreq) > 0){ + nq[1,j] <- gsub(paste0("^",nq[1,j],"$"),nj[2,chngreq],nq[1,j]) + } } + j <- j + 1 } - j = j+1 - } - DATA + nq } +#cgeneID <- function(GeneName,DATA){ +# colGene <- dim(GeneName)[2] +# j <- 1 +# for(j in 1:colGene){ +# chngsreq <- grep(paste0("^",GeneName[1,j],"$"),DATA[1,]) +# if(is.na(sum(chngsreq))==FALSE){ +# if(sum(chngsreq) > 0){ +# DATA[1,chngsreq] <- gsub(paste0("^",GeneName[1,j]),GeneName[2,j],DATA[1,chngsreq]) +# } +# } +# j = j+1 +# } +# DATA +#} #5#Function for adjusting the gene names gcnames <- function(DiData,usecol=1){