R语言【taxa】——classification():储存分类树的分类信息

Package taxa version 0.4.2


Usage

classification(x = NULL, taxonomy = NULL, .names = NULL)

Arguments

参数【x】:以下之一:

  •         一个列表,每个元素表示一组嵌套的类群。列表内容允许是任何能够转换为taxon的格式。
  • 一个 taxonomy 对象中 单个 taxon 对象的索引或名称,taxonomy 对象由参数【taxonomy】指定。长度不限,但必须是 taxonomy 对象中有效的索引。

参数【taxonomy】:一个 taxonomy 对象。只有当第一个参数提供的是类群的索引时才需要此参数。

参数【.names】:向量的名称。


Value

一个 taxa_classification 类的 S3 对象。


Examples

通过 列表 创建 classification 向量:

x <- classification(list(
  c('Carnivora', 'Felidae', 'Panthera', 'Panthera leo'),
  c('Carnivora', 'Felidae', 'Panthera', 'Panthera tigris'),
  c('Carnivora', 'Ursidae', 'Ursus', 'Ursus arctos'),
  c('Carnivora', 'Ursidae', 'Ursus', 'Ursus arctos'),
  c('Carnivora', 'Felidae', 'Panthera', 'Panthera tigris')
))

[1] Carnivora|Felidae|Panthera|Panthera leo   
[2] Carnivora|Felidae|Panthera|Panthera tigris
[3] Carnivora|Ursidae|Ursus|Ursus arctos      
[4] Carnivora|Ursidae|Ursus|Ursus arctos      
[5] Carnivora|Felidae|Panthera|Panthera tigris

通过 taxonomy 对象 及其 索引 创建 classification:

x <- classification(c(3, 4, 4, 5, 5, 6, 8, 8, 2, 5, 6, 2),
                    taxonomy(c('Carnivora', 'Felidae', 'Panthera', 'Panthera leo',
                               'Panthera tigris', 'Ursidae', 'Ursus', 'Ursus arctos'),
                             supertaxa = c(NA, 1, 2, 3, 3, 1, 6, 7)))

 [1] Carnivora|Felidae|Panthera                
 [2] Carnivora|Felidae|Panthera|Panthera leo   
 [3] Carnivora|Felidae|Panthera|Panthera leo   
 [4] Carnivora|Felidae|Panthera|Panthera tigris
 [5] Carnivora|Felidae|Panthera|Panthera tigris
 [6] Carnivora|Ursidae                         
 [7] Carnivora|Ursidae|Ursus|Ursus arctos      
 [8] Carnivora|Ursidae|Ursus|Ursus arctos      
 [9] Carnivora|Felidae                         
[10] Carnivora|Felidae|Panthera|Panthera tigris
[11] Carnivora|Ursidae                         
[12] Carnivora|Felidae 
x <- classification(c(3, 4, 4, 5, 5, 6, 8, 8, 2, 5, 6, 2),
                    taxonomy(taxon(name = c('Carnivora', 'Felidae', 'Panthera', 'Panthera leo',
                                            'Panthera tigris', 'Ursidae', 'Ursus', 'Ursus arctos'),
                                   rank = c('order', 'family', 'genus', 'species',
                                            'species', 'family', 'genus', 'species'),
                                   id = taxon_id(c('33554', '9681', '9688', '9689',
                                                   '9694', '9632', '9639', '9644'),
                                                 db = 'ncbi'),
                                   auth = c('Bowdich, 1821', 'Fischer, 1817',
                                            'Oken, 1816', 'L., 1758',
                                            'L., 1758', 'Fischer, 1817',
                                            'L., 1758', 'L., 1758')),
                             supertaxa = c(NA, 1, 2, 3, 3, 1, 6, 7)))
names(x) <- letters[1:12]

                                         a 
                Carnivora|Felidae|Panthera 
                                         b 
   Carnivora|Felidae|Panthera|Panthera leo 
                                         c 
   Carnivora|Felidae|Panthera|Panthera leo 
                                         d 
Carnivora|Felidae|Panthera|Panthera tigris 
                                         e 
Carnivora|Felidae|Panthera|Panthera tigris 
                                         f 
                         Carnivora|Ursidae 
                                         g 
      Carnivora|Ursidae|Ursus|Ursus arctos 
                                         h 
      Carnivora|Ursidae|Ursus|Ursus arctos 
                                         i 
                         Carnivora|Felidae 
                                         j 
Carnivora|Felidae|Panthera|Panthera tigris 
                                         k 
                         Carnivora|Ursidae 
                                         l 
                         Carnivora|Felidae 
Rank levels: order < family < genus < species

查看 classification 对象的各个组分:

> tax_name(x)
                a                 b                 c                 d                 e                 f                 g 
       "Panthera"    "Panthera leo"    "Panthera leo" "Panthera tigris" "Panthera tigris"         "Ursidae"    "Ursus arctos" 
                h                 i                 j                 k                 l 
   "Ursus arctos"         "Felidae" "Panthera tigris"         "Ursidae"         "Felidae" 
> tax_rank(x)

      a       b       c       d       e       f       g       h       i       j       k       l 
  genus species species species species  family species species  family species  family  family 
Rank levels: order < family < genus < species
> tax_id(x)

          a           b           c           d           e           f           g           h           i           j           k 
9688 (ncbi) 9689 (ncbi) 9689 (ncbi) 9694 (ncbi) 9694 (ncbi) 9632 (ncbi) 9644 (ncbi) 9644 (ncbi) 9681 (ncbi) 9694 (ncbi) 9632 (ncbi) 
          l 
9681 (ncbi) 
> tax_db(x)

   a    b    c    d    e    f    g    h    i    j    k    l 
ncbi ncbi ncbi ncbi ncbi ncbi ncbi ncbi ncbi ncbi ncbi ncbi 
> tax_auth(x)

           a            b            c            d            e            f            g            h            i            j 
   Oken 1816      L. 1758      L. 1758      L. 1758      L. 1758 Fischer 1817      L. 1758      L. 1758 Fischer 1817      L. 1758 
           k            l 
Fischer 1817 Fischer 1817 
> tax_author(x)
        a         b         c         d         e         f         g         h         i         j         k         l 
   "Oken"      "L."      "L."      "L."      "L." "Fischer"      "L."      "L." "Fischer"      "L." "Fischer" "Fischer" 
> tax_date(x)
     a      b      c      d      e      f      g      h      i      j      k      l 
"1816" "1758" "1758" "1758" "1758" "1817" "1758" "1758" "1817" "1758" "1817" "1817" 
> tax_cite(x)
 a  b  c  d  e  f  g  h  i  j  k  l 

操作 classification 向量:

> x[1:3]

                                      a                                       b 
             Carnivora|Felidae|Panthera Carnivora|Felidae|Panthera|Panthera leo 
                                      c 
Carnivora|Felidae|Panthera|Panthera leo 
Rank levels: order < family < genus < species


> x[tax_rank(x) > 'family']

                                         a                                          b 
                Carnivora|Felidae|Panthera    Carnivora|Felidae|Panthera|Panthera leo 
                                         c                                          d 
   Carnivora|Felidae|Panthera|Panthera leo Carnivora|Felidae|Panthera|Panthera tigris 
                                         e                                          g 
Carnivora|Felidae|Panthera|Panthera tigris       Carnivora|Ursidae|Ursus|Ursus arctos 
                                         h                                          j 
      Carnivora|Ursidae|Ursus|Ursus arctos Carnivora|Felidae|Panthera|Panthera tigris 
Rank levels: order < family < genus < species


> is.na(x)
 [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

你可能感兴趣的:(taxa,r语言,分类,开发语言)