Skip to content

Instantly share code, notes, and snippets.

@jwaageSnippets
Created December 17, 2012 12:33
Show Gist options
  • Save jwaageSnippets/4317970 to your computer and use it in GitHub Desktop.
Save jwaageSnippets/4317970 to your computer and use it in GitHub Desktop.
Convert between human and mouse gene IDs
read.delim("/Volumes/BP_NextGen/jwg/Projects/Porse/TET1/homologene.data", stringsAsFactors=F) -> homologene
split(homologene, f=homologene[,1]) -> hSplit
#Tax ID: Homo 9606
#Mus: 10090
getHumanAndMouseHomologues <- function(x)
{
if (c(9606)%in%x[,2]&&c(10090)%in%x[,2])
{
x[x[,2]==9606 | x[,2]==10090,4] -> result
result
}
}
lapply(hSplit, FUN=getHumanAndMouseHomologues) -> results
results[lapply(results, FUN=length)==2] -> results
do.call("rbind", results) -> results
results -> mouseHuman
colnames(mouseHuman) <- c("homoID", "musID")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment