From 69ac507843530d76722471db7ddbf5f213a11aee Mon Sep 17 00:00:00 2001 From: Efrain Gonzalez Date: Tue, 20 Jun 2017 15:03:46 -0400 Subject: [PATCH] Don't use this code yet Updated to decrease time of search for cgeneID --- RAutoClDs.R | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) 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){ -- 2.29.0