Try using ifnotfound
argument for mget
function.
Following example code I used:
See if this works:
1) I saved the entrez id list above, as a text file "test"
entrezgene
1 138241
2 283349
3 101930100
4 3841
5 92703
6 653659
2) Loaded the file in R
test=read.delim2("test", header = T, stringsAsFactors = F, sep = "")
3) loaded the library
library("targetscan.Hs.eg.db")
4) executed following code without errors:
mget(as.character(test[,1]), targetscan.Hs.egTARGETS, ifnotfound = as.list(NA))
output is huge and didn't want to paste here.
5) executed following code to reproduce error:
mget(as.character(test[,1]), targetscan.Hs.egTARGETS)
Error produced:
Error in .checkKeys(value, Lkeys(x), x@ifnotfound) :value for "138241" not found
session info:
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu Wily Werewolf (development branch)
locale:
[1] LC_CTYPE=en_IN.UTF-8 LC_NUMERIC=C LC_TIME=en_IN.UTF-8
[4] LC_COLLATE=en_IN.UTF-8 LC_MONETARY=en_IN.UTF-8 LC_MESSAGES=en_IN.UTF-8
[7] LC_PAPER=en_IN.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_IN.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets methods
[9] base
other attached packages:
[1] targetscan.Hs.eg.db_0.6.1 RSQLite_1.0.0 DBI_0.3.1
[4] AnnotationDbi_1.30.1 GenomeInfoDb_1.4.3 IRanges_2.2.9
[7] S4Vectors_0.6.6 Biobase_2.28.0 BiocGenerics_0.14.0
loaded via a namespace (and not attached):
[1] tools_3.2.2
Please post example data and session info.
Thank you for your reply
... continues