Question: Iterate through sever annotation database packages
0
gravatar for Morgan Howard
6 months ago by
IUPUI
Morgan Howard0 wrote:

Hello,

I am looking for a method in R to check a list of accession numbers against annotation databases for 19 species. In theory the code below should extract the ENTREZID, SYMBOL, GENENAME and match the mapped results with the results file via the ACCNUM

mapped <- foreach(i = dbMap$dbName) %do% select(i, as.character(ResultsFile$ACCNUM), c("ENTREZID","SYMBOL","GENENAME"), "ACCNUM")

However select is throwing the error:

Error in select(i, as.character(ResultsFile$ACCNUM), c("ENTREZID", "SYMBOL",  : 
  task 1 failed - "unable to find an inherited method for function ‘select’ for signature ‘"factor"’

This is because i is a factor with 19 levels (one for each database). How could I coerce this to work and produce the desired results?

Thanks for your time and help,

Morgan

Image showing the layout of the dbMap dataframe

annotation R • 143 views
ADD COMMENTlink modified 6 months ago by James W. MacDonald50k • written 6 months ago by Morgan Howard0
Answer: Iterate through sever annotation database packages
2
gravatar for James W. MacDonald
6 months ago by
United States
James W. MacDonald50k wrote:

Ideally you wouldn't start with a factor, so when you create your data.frame (however you are doing that), you would want to use stringsAsFactors = FALSE. Also note that select expects you to pass an OrgDb, not a character value that has the same name as an OrgDb, so you need to get the OrgDb. Something like this

mapped <- foreach(i = get(dbMap$dbName)) %do% select(i, as.character(ResultsFile$ACCNUM), c("ENTREZID","SYMBOL","GENENAME"), "ACCNUM")

And having ResultsFile$ACCNUM already being a character is one less coercion you need to worry about.

ADD COMMENTlink written 6 months ago by James W. MacDonald50k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 281 users visited in the last hour