Go Term Import
2
0
Entering edit mode
8.4 years ago
V ▴ 410

Hello Everyone,

Naive question. I have an object "cd" that has ensembl ids as row names. I use the following to construct a dataframe with 2 columns.

go <- getBM(attributes = c("ensembl_gene_id", "go_id"), filters = "ensembl_gene_id", values = rownames(cd), mart = ensembl)

and that works fine, then what I want to do is use the Go.db library to add a column to that object with the Go-term, so I do the following:

go$term <- Term(go$go_id)

This adds the column but all of the values are "NA".

Any clues what I'm doing wrong or if its further upstream? Thanks

GOTerm Ensembl BioMart • 3.0k views
ADD COMMENT
0
Entering edit mode
8.4 years ago
Emily 24k

Why don't you just get the GO term as an attribute in BiomaRt?

go <- getBM(attributes = c("ensembl_gene_id", "go_id", " name_1006"), filters = "ensembl_gene_id", values = rownames(cd), mart = ensembl)
ADD COMMENT
0
Entering edit mode

Worked like a charm! thank you!!

ADD REPLY
0
Entering edit mode

Hi Emily,

I was wondering if you could help me with this, i'm trying to rerun the code you sent me above but this time having a list of official gene names. I've tried altering the "attributes" and "filters" to a number of stuff like "external_gene_name" or "official_gene_symbol" but nothing seems to be working. My rows are named normally such as "Sox2", "Wnt9a" etc. If you could help it would be great.

Thanks

ADD REPLY
0
Entering edit mode

Use listAttributes(ensembl) to see the attribute names and descriptions.

ADD REPLY
0
Entering edit mode

Tried that and "associated_gene_name" comes up but R outputs the same error:

Error in getBM(attributes = c("associated_gene_name", "go_id", "name_1006"),  : 
  Invalid attribute(s): associated_gene_name
Please use the function 'listAttributes' to get valid attribute names
ADD REPLY
0
Entering edit mode

Yes, because associated_gene_name is not an attribute name. You need find the attribute name on the list of attributes.

ADD REPLY
0
Entering edit mode
8.4 years ago
russhh 5.7k

There's nothing wrong with your code as it stands. I used the following example, since you didn't provide an explicit one:

library(biomaRt)
library(GO.db)
ensembl <- useMart('ensembl')
ensembl <- useDataset('hsapiens_gene_ensembl',
                      mart = useMart('ensembl'))
id <- 'ENSG00000134294'
go <- getBM(attributes = c("ensembl_gene_id", "go_id"),
            filters = "ensembl_gene_id",
            values = id,
            mart = ensembl)
head(go)

#  ensembl_gene_id      go_id
#1 ENSG00000134294 GO:0006865
#2 ENSG00000134294 GO:0014047
#3 ENSG00000134294 GO:0015293
#4 ENSG00000134294 GO:0005515
#5 ENSG00000134294 GO:0006811
#6 ENSG00000134294 GO:0006814

go$term <- Term(go$go_id)
head(go)
 #     ensembl_gene_id      go_id                 term
 #   1 ENSG00000134294 GO:0006865 amino acid transport
 #   2 ENSG00000134294 GO:0014047  glutamate secretion
 #   3 ENSG00000134294 GO:0015293   symporter activity
 #   4 ENSG00000134294 GO:0005515      protein binding
 #   5 ENSG00000134294 GO:0006811        ion transport
 #   6 ENSG00000134294 GO:0006814 sodium ion transport

Maybe you should check your row.names

ADD COMMENT
0
Entering edit mode

Dear Russhh,

thanks for this! I keep getting the same error though, I substituted values = id, to values =cd (cd is the name of my table) and also changed the useDataset to ('mmusculus_gene_ensembl') the table generated is completely empty, not even the ensembl Ids show up. I've looked at my row names and they seem pretty normal, not sure if I'm missing something in the identifiers

e.g: ENSMUSG00000102693, ENSMUSG00000064842 etc

ADD REPLY
0
Entering edit mode

Please update your post with an explicit, reproducible, example

ADD REPLY

Login before adding your answer.

Traffic: 2731 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6