This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Using Taxonomizr to Call Bacterial Taxonomy From CSV File

I am trying to use taxonomizr in R to get taxonomy from a csv file with NCBI accession numbers.

However, using these lines:

bacterial<-read.csv('unique_accession.csv')
taxaId<-accessionToTaxa("bacterial$Accession_Number","accessionTaxa.sql")
getTaxonomy(taxaId,taxaNodes,taxaNames)

I followed taxonomizr vignette in correctly setting it up. I've tested it by giving just accession numbers, and it has been able to give taxonomic classifications.

But when I provide it with my csv file, instead of getting taxonomic classifications for all my accession numbers, I am getting NA in the classification.

I was wondering if anyone else has run into this issue, and how to solve it.

r software error taxonomizr

Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time. Formatting bar

This looks like a problem with how you read the file. Tweak the parser parameters passed to read.csv and ensure the data that was read looks as it should - often times, you will need options such as stringsAsFactors=FALSE, quote=FALSE, comment.char="", etc.

1 answer

Sorry I don't really follow biostars (feel free to leave a GitHub issue if you have any further problems) so this is pretty late but just in case anyone else ends up here, the problem is that you have quotes around "bacterial$Accession_Number". R is interpreting that as a string so it's trying to look up the taxa ID for a taxon called literally "bacterial$Accession_Number" (which obviously doesn't exist and returns NA).

Remove the quotes and you should be on your way.

Thank you for checking out this post on biostars. I'd think that user queries are better off in forums than on GitHub as issues, no? After all, seldom are user queries directly related to genuine software bugs/feature requests. If people could open a question on a scientific forum such as biostars or seqanswers or bioinformatics SE, they can be directed to add a tag, say. taxonomizr, and you can find these tagged posts (or subscribe to a feed that automatically emails you new posts with the tag), and you can access these posts easily using https://biostars.org/t/taxonomizr/. I edited this post and added the tag so it should show up in the search.

What do you think?

Log in to answer this question.