gugl58
10/23/2017 - 9:53 AM

ID to symbol

Get the gene symbols to the related gene IDs (Microarray) (Median Polish)


#' Title
#' Function from Michael Altenbuchinger
#' @param data 
#' @param chip 
#'
#' @return
#' @export
#'
#' @examples

FK_getSYMBOL <- function(data,chip)
{
	require(package=paste(chip,".db",sep=""), character.only=TRUE)
	cat(date(),">> symbols universe \n")

	symbols.universe <- unlist(mget(rownames(data), envir=eval(as.symbol(paste(chip,"SYMBOL",sep="")))))# hgu133plus2: n=54675
	symbols.unique <- unique(symbols.universe)# hgu133plus2: n=20185
	symbols.list <- sapply(symbols.unique, function(x) which(symbols.universe==x)) # for each symbol, get all its probeIDs
	tmp <- which(is.na(names(symbols.list))) # n = 1 at index

	if (length(tmp)>0){
		symbols.list <- symbols.list[-tmp]
	}
	data.ent <- matrix(nrow=length(symbols.list), ncol=ncol(data))
	dimnames(data.ent) <- list(names(symbols.list),colnames(data))
	cat(date(),">> symbols list \n")
	for (i in 1:length(symbols.list)) {
		if (length(symbols.list[[i]])>1) {
			tmp1 <- medpolish(data[symbols.list[[i]],], trace.iter=FALSE)
			data.ent[i,] <- c( tmp1$col+tmp1$over)
		}
		if (length(symbols.list[[i]])<2) {
			data.ent[i,] <- unlist( data[symbols.list[[i]],])
		}
		if (i%%100==0)
			cat(".")
	}
	return(data.ent)
}