10
$\begingroup$

I’m trying to find common names from a list of scientific names (not all will have them though).

I was attempting to use taxize in R but it aborts if it doesn’t find an entry in EOL and I don’t know a way around this other than manually editing the list - in which case I might as well check all this way.

Does anyone have a better way of doing this?

$\endgroup$
  • 2
    $\begingroup$ The answer to your question might be taxon-specific. For instance, if you deal with fish, the fishbase database has quite important common-name information. Are you dealing with a particular kind of organism? $\endgroup$ – bli Jun 8 '17 at 10:45
  • $\begingroup$ Commons names in any language? Or specifically in English? Or another specific language? $\endgroup$ – Nicolas Raoul Jun 9 '17 at 3:03
  • $\begingroup$ to answer the above two, it's a mix of all types of prokaryotes. The returns would need to be in English, it seems EOL gives other languages as well (but returns nested lists of diff lengths- i gave up trying to use those). $\endgroup$ – Daniel Mead Jun 12 '17 at 15:15
14
$\begingroup$

As Pierre mentioned, NCBI is a good resource for this kind of transformation.

You can still use taxize to perform the conversion:

library("taxize")

species <- c('Helianthus annuus', 'Mycobacterium bovis', 'Rattus rattus', 'XX', 'Mus musculus')

uids <- get_uid(species)

# keep only uids which you have in the database
uids.found <- as.uid(uids[!is.na(uids)])
# keep only species names  corresponding to your ids
species.found <- species[!is.na(uids)]

common.names <- sci2comm(uids.found, db = 'ncbi')
names(common.names) <- species.found

common.names

## output:
## $`Helianthus annuus`
## [1] "common sunflower"
## 
## $`Mycobacterium bovis`
## character(0)
## 
## $`Rattus rattus`
## [1] "black rat"
## 
## $`Mus musculus`
## [1] "house mouse"

This works correctly if no common name is available, or if there is no species in the database. You can also try a different database, e.g. db='itis'.

The advantage of this approach is that you do not have to parse a file yourself. The downside is that it can be slow for large list, since for every species a database request is performed.

$\endgroup$
  • $\begingroup$ great stuff, thanks folks- this works perfectly for the ncbi data. one small addition is that due to the complexities of the eol database being searchable in a different way you can't use that option without some other wizzy functions (i have a chap working on this but no joy so far) $\endgroup$ – Daniel Mead Jun 9 '17 at 13:48
13
$\begingroup$

use the NCBI taxon dump under ftp://ftp.ncbi.nih.gov/pub/taxonomy

in taxdmp.zip you'll find all the names for a given NCBI taxon

$ grep -w ^9606 names.dmp 
9606    |   Homo sapiens    |       |   scientific name |
9606    |   Homo sapiens Linnaeus, 1758 |       |   authority   |
9606    |   human   |       |   genbank common name |
9606    |   man |       |   common name |
$\endgroup$
4
$\begingroup$

Getting back to the original question about using taxize to search specifically in EOL, it looks like the most recent version of the package does not produce this error.

The current version of R I'm using (3.4.2) produces the following output:

sci2comm( c("Cancer", "Lophopanopeus"), db="eol" )

$Cancer [1] "En art taskekrabbe" "Felsenkrabbe" "Atlantic rock crab"
[4] "Jaiba de roca amarilla" "Tourteau poïnclos" "Granciporro atlantico giallo"
[7] "Atlantische rotskrab" "Sapateira de rocha do Atlântico" "Bogenkrabbe"
[10] "red rock crab" "Pacific rock crab" "Jaiba del Pacífico"
[13] "Tourteau du Pacifique" "Granciporro del Pacifico" "Pacifische rotskrab"
[16] "Sapateira de rocha do Pacífico" "Jonahkrabbe" "Jonah crab"
[19] "Jaiba de roca Jonás" "Tourteau jona" "Grancipporo atlantico rosso"
[22] "Jonakrab" "Sapateira boreal" "Bou"
[25] "Almindelig taskekrabbe" "Taskekrabbe" "Taschenkrebs"
[28] "Edible crab" "rock crab" "Buey"
[31] "Buey de mar" "Jaiba de roca masera" "Masera"
[34] "Paguro" "Pato" "Sabago"
[37] "Isotaskurapu" "Crabe dormeur" "Dormeur"
[40] "Tourteau" "crabe-dormeur" "Granchio di mare"
[43] "Granciporro" "Noordzeekrab" "grote krab"
[46] "grote noordzeekrab" "hoofdkrab" "slagkrab"
[49] "steenkrab" "toogkrab" "zeekrab"
[52] "Sapateira"

$Lophopanopeus [1] "blackclaw crestleg crab" "knobkneed crestleg crab" "knobknee crestleg crab" "molarless crestleg crab"

$'Pugettia foliata' character(0)

A slightly older version of R (3.3.2) produces an error when one of the taxa was not found:

sci2comm( c("Cancer", "Lophopanopeus", "Pugettia foliata"), db="eol" )

Error in eol_pages(taxonconceptID = x, common_names = TRUE, ...) : Not Found (HTTP 404).

I am very thankful for the package updates!

$\endgroup$
1
$\begingroup$

As Pierre suggested, you can get a dump of such names from NCBI. Then, to query it for the common name for a species using its Latin name, you can do:

$ awk -F'\t' -vname="Mus musculus" '($7=="scientific name" && $3==name){
                                      a[$1]=$3
                                    } 
                                    ($1 in a && /genbank common name/){  
                                      print $3
                                    }' names.dmp
house mouse
$\endgroup$
  • $\begingroup$ please note : the tabulation is not the delimiter, it's a mix of spaces and pipes $\endgroup$ – Pierre Jun 8 '17 at 11:00
  • $\begingroup$ @Pierre is it? I admit I've never worked with this file before but I downloaded it and saw that it is tab-separated. The | are their own fields and are actually \t|\t in the file, so using tab as the separator seems the best approach. Am I wrong? $\endgroup$ – terdon Jun 8 '17 at 11:02
  • $\begingroup$ By the way, @Pierre, this is only making your answer a bit more specific. It might be better to just add it into your answer instead of cluttering up the page with multiple answers. I would have done so but I don't have enough rep to do so directly yet. So feel free to just copy this (or your improved version of it) into your answer. If you do, let me know and I'll delete this one. $\endgroup$ – terdon Jun 8 '17 at 11:03
  • $\begingroup$ ah yes, with your awk indexes, it should be ok. And no, leave your answer here please. $\endgroup$ – Pierre Jun 8 '17 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.