### # To calculate maximum values from biochemical / genetic data ### sep='@@@' biochem <- read.csv('score_biochem.csv', header=F) biochem$grouping <- as.factor(paste(biochem[,1], biochem[,2], sep=sep)) maxp <- tapply(biochem[,3], biochem$grouping, max) ids <- matrix(unlist(strsplit(rownames(maxp), sep)), ncol=2, byrow=T) max_biochem <- cbind(ids, maxp) colnames(max_biochem) <- c('up_id', 'go_term', 'score') genetic <- read.csv('score_genetic.csv', header=F) genetic$grouping <- as.factor(paste(genetic[,1], genetic[,2], sep=sep)) maxp <- tapply(genetic[,3], genetic$grouping, max) ids <- matrix(unlist(strsplit(rownames(maxp), sep)), ncol=2, byrow=T) max_genetic <- cbind(ids, maxp) colnames(max_genetic) <- c('up_id', 'go_term', 'score') data_out <- merge(max_biochem, max_genetic, by=c('up_id', 'go_term'), all=T) write.csv(data_out, 'score_biochem_genetic.csv')