This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Problem with extracting information from txdb object!

Hi,

I am trying to extract GENEID and corresponding CDSSTART from a txdb object using select function but it doesn't work. Could someone give a little help if you see where I am doing wrong? Here is the last few codes that lead to error. I appreciate your help in advance.

> keytypes(txdb)
[1] "GENEID"   "TXID"     "TXNAME"   "EXONID"   "EXONNAME" "CDSID"    "CDSNAME" 
> columns(txdb)
 [1] "CDSID"      "CDSNAME"    "CDSCHROM"   "CDSSTRAND"  "CDSSTART"   "CDSEND"     "EXONID"    
 [8] "EXONNAME"   "EXONCHROM"  "EXONSTRAND" "EXONSTART"  "EXONEND"    "GENEID"     "TXID"      
[15] "EXONRANK"   "TXNAME"     "TXCHROM"    "TXSTRAND"   "TXSTART"    "TXEND"     
> head(select(txdb, keys="GENEID", columns = "CDSSTART", keytype = "GENEID"))
Error in head(select(txdb, keys = "GENEID", columns = "CDSSTART", keytype = "GENEID")) : 
  error in evaluating the argument 'x' in selecting a method for function 'head': Error in .testForValidKeys(x, keys, keytype) : 
  None of the keys entered are valid keys for 'GENEID'. Please use the keys method to see a listing of valid arguments.
keytypes txdb

1 answer

As error message says None of the keys entered are valid keys

# Available keys
keys(txdb)

[1] "ENSG00000011198" "ENSG00000067646" "ENSG00000103343" "ENSG00000111837"
[5] "ENSG00000207157" "ENSG00000231116"

# Extract wanted keys
select(txdb, keys="ENSG00000011198", columns = "CDSSTART", keytype = "GENEID")

           GENEID CDSSTART
1 ENSG00000011198 43690993
2 ENSG00000011198 43699276
3 ENSG00000011198 43699502

Nice thanks. I did:

keys <- keys(txdb)
select(txdb, keys=keys, columns = "CDSSTART", keytype = "GENEID")

and it works now. However I don't understand what are keys and what are keytypes. A little explanation on that is very appreciated.

Happy it helped. All I can do is to copy/paste info from ?biomaRt::keys

keys: the keys to select records for from the database. Keys for some keytypes can be extracted by using the 'keys' method.

keytype: the keytype that matches the keys used. For the 'select' methods, this is used to indicate the kind of ID being used with the keys argument. For the 'keys' method this is used to indicate which kind of keys are desired from 'keys'

Log in to answer this question.