I'm having an issue how to convert data. Actually, I have data file which contains tons of gene sets and genes as follows.
GO.1 GO.2 ...
811 811
1520 3638
3685 3685
8943 5719
10197
...
Here, each column (gene set) contains a list of genes which are annotated on corresponding gene set. The number means ENTREZ ID of specific annotated gene. I'm trying to convert ENTREZ ID to Official gene symbol and then make output file from it. What am I supposed to do for it?
I know there are various ways to convert like this.
library(annotate)
library(org.Hs.eg.db)
lookUp('811','org.Hs.eg','SYMBOL')
$`811`
[1] "CALR"
But, I don't have any idea to read text file and convert data and then write it.
2 answers
You could simply use the biomaRt Rpackage. There is a user guide available which details out how to use it. It is pretty easy and more comprehensive when you have to convert one id type to the other. Additionally it always queries the latest version of the BioMart library so it is always up-to-date.
I missed that you know how to translate. You want R IO basics and this is not really the place but:
tab <- read.table("inputfile", sep="\t", as.is=TRUE, header=TRUE, comment="", fill=TRUE)
//hope that its really tab formatted
ids1 <- tab[,1]
ids2 <- tab[,2]
... now the conversion ...
write.table(tab, "outfile", col.names=TRUE, row.names=FALSE, sep="\t", quote=FALSE)
But you should read up on R.
like: https://www.datacamp.com/courses/introduction-to-r
http://tryr.codeschool.com or a nice dead tree
Log in to answer this question.
If reading, converting and writing data is the problem, then you need to learn the basic R skills to do this. Perhaps start with the documentation for R data import/export.