next up previous
Next: info Up: CHNOSZ examples Previous: util.units

taxonomy

## get information about Homo sapiens from the ## packaged taxonomy files taxdir <- system.file("extdata/taxonomy",package="CHNOSZ") # H. sapiens' taxonomic id id1 <- 9606 # that is a species getrank(id1,taxdir)
Read 63 records [1] "species"
# the next step up the taxonomy id2 <- parent(id1,taxdir)
Read 63 records
print(id2)
[1] 9605
# that is a genus getrank(id2,taxdir)
Read 63 records [1] "genus"
# that genus is "Homo" sciname(id2,taxdir)
Read 215 records [1] "Homo"
# we can ask what phylum is it part of? id3 <- parent(id1,taxdir,"phylum")
Read 63 records
# answer: "Chordata" sciname(id3,taxdir)
Read 215 records [1] "Chordata"
# H. sapiens' complete taxonomy id4 <- allparents(id1,taxdir)
Read 63 records
sciname(id4,taxdir)
Read 215 records [1] "Homo sapiens" "Homo" "Homininae" "Hominidae" [5] "Hominoidea" "Catarrhini" "Simiiformes" "Haplorrhini" [9] "Primates" "Euarchontoglires" "Eutheria" "Theria" [13] "Mammalia" "Amniota" "Tetrapoda" "Sarcopterygii" [17] "Euteleostomi" "Teleostomi" "Gnathostomata" "Vertebrata" [21] "Craniata" "Chordata" "Deuterostomia" "Coelomata" [25] "Bilateria" "Eumetazoa" "Metazoa" "Fungi/Metazoa group" [29] "Eukaryota" "cellular organisms" "root"
## the names of the organisms in the supplied taxonomy files taxdir <- system.file("extdata/taxonomy",package="CHNOSZ") id5 <- c(83333,4932,9606,186497,243232) sciname(id5,taxdir)
Read 215 records [1] "Escherichia coli K-12" "Saccharomyces cerevisiae" [3] "Homo sapiens" "Pyrococcus furiosus DSM 3638" [5] "Methanocaldococcus jannaschii DSM 2661"
# these are not all species, though # (those with "no rank" are something like strains, # e.g. Escherichia coli K-12) getrank(id5,taxdir)
Read 63 records [1] "no rank" "species" "species" "no rank" "no rank"
# find the species for each of these id6 <- sapply(id5,function(x) parent(x,taxdir=taxdir,rank="species"))
Read 63 records Read 63 records Read 63 records Read 63 records Read 63 records
stopifnot(unique(getrank(id6,taxdir))=="species")
Read 63 records
# note that the K-12 is dropped sciname(id6,taxdir)
Read 215 records [1] "Escherichia coli" "Saccharomyces cerevisiae" "Homo sapiens" [4] "Pyrococcus furiosus" "Methanocaldococcus jannaschii"
## the complete nodes.dmp and names.dmp files are quite large, ## so it helps to store them in memory when performing multiple queries ## (this doesn't have a noticeable speed-up for the small files ## we use in this example) taxdir <- system.file("extdata/taxonomy",package="CHNOSZ") nodes <- getnodes(taxdir=taxdir)
Read 63 records
# all of the node ids in this file id7 <- nodes$id # all of the non-leaf nodes id8 <- unique(parent(id7,nodes=nodes)) names <- getnames(taxdir=taxdir)
Read 215 records
sciname(id8,names=names)
[1] "root" "cellular organisms" "Enterobacteriales" [4] "Enterobacteriaceae" "Escherichia" "Bacteria" [7] "Proteobacteria" "Methanococci" "Methanocaldococcus" [10] "Thermococci" "Thermococcales" "Thermococcaceae" [13] "Pyrococcus" "Fungi/Metazoa group" "Dikarya" [16] "Saccharomycotina" "Saccharomycetes" "Saccharomycetales" [19] "Saccharomycetaceae" "Saccharomyces" "Metazoa" [22] "Deuterostomia" "Craniata" "Vertebrata" [25] "Euteleostomi" "Theria" "Euarchontoglires" [28] "Simiiformes" "Hominoidea" "Homininae" [31] "Homo" "Archaea" "Sarcopterygii" [34] "Tetrapoda" "Mammalia" "Eukaryota" [37] "Eumetazoa" "Bilateria" "Coelomata" [40] "Amniota" "Escherichia coli" "Chordata" [43] "Gammaproteobacteria" "Gnathostomata" "Teleostomi" [46] "Saccharomyceta" "Euryarchaeota" "Pyrococcus furiosus" [49] "Methanococcales" "Methanocaldococcaceae" "Hominidae" [52] "Methanocaldococcus jannaschii" "Eutheria" "Haplorrhini" [55] "Catarrhini" "Primates" "Fungi" [58] "Ascomycota"


next up previous
Next: info Up: CHNOSZ examples Previous: util.units