Giter Club home page Giter Club logo

yatah's Introduction

yatah

packageversion R-CMD-check CRAN_Status_Badge

The goal of yatah is to manage taxonomy when lineages are described with strings and ranks separated with special patterns like |*__ or ;*__.

For instance, the well-known Escherichia coli could be coded as k__Bacteria|p__Proteobacteria|c__Gammaproteobacteria|o__Enterobacteriales|f__Enterobacteriaceae|g__Escherichia|s__Escherichia_coli.

Installation

You can install the released version of yatah from CRAN with:

install.packages("yatah")

And the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("abichat/yatah")

Example

library(yatah)

yatah handles 8 different ranks:

all_ranks
#> [1] "kingdom" "phylum"  "class"   "order"   "family"  "genus"   "species" "strain"

A lineage is composed of a succession of clades separated by special characters indicating the current rank.

lineages <- c(
  "k__Bacteria|p__Actinobacteria|c__Actinobacteria|o__Coriobacteriales",
  "k__Bacteria|p__Bacteroidetes|c__Bacteroidia|o__Bacteroidales",
  "k__Bacteria|p__Bacteroidetes|c__Flavobacteriia|o__Flavobacteriales",
  "k__Bacteria|p__Firmicutes|c__Bacilli|o__Bacillales",
  "k__Bacteria|p__Firmicutes|c__Bacilli|o__Lactobacillales",
  "k__Bacteria|p__Firmicutes|c__Clostridia|o__Clostridiales",
  "k__Bacteria|p__Proteobacteria|c__Epsilonproteobacteria|o__Campylobacterales",
  "k__Bacteria|p__Proteobacteria|c__Gammaproteobacteria|o__Enterobacteriales",
  "k__Bacteria|p__Proteobacteria|c__Gammaproteobacteria|o__Pseudomonadales"
)

yatah offers functions to verify if lineages meet a desired property, to extract information, or to compute summary objects.

  • is_rank() and is_at_least_rank() check if the lineages are of the desired rank.
is_rank(lineages, rank = "order")
#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
is_at_least_rank(lineages, rank = "species")
#> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
  • is_clade() checks if the lineages belong to the desired clade.
is_clade(lineages, clade = "Proteobacteria", rank = "phylum")
#> [1] FALSE FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE
  • get_clade() extracts the clade of the desired rank.
get_clade(lineages, rank = "class")
#> [1] "Actinobacteria"        "Bacteroidia"           "Flavobacteriia"        "Bacilli"              
#> [5] "Bacilli"               "Clostridia"            "Epsilonproteobacteria" "Gammaproteobacteria"  
#> [9] "Gammaproteobacteria"
  • get_last_clade() extracts the last clade of the lineages.
get_last_clade(lineages)
#> [1] "Coriobacteriales"  "Bacteroidales"     "Flavobacteriales"  "Bacillales"        "Lactobacillales"  
#> [6] "Clostridiales"     "Campylobacterales" "Enterobacteriales" "Pseudomonadales"
  • get_all_clades() extracts all clades of the lineages.
get_all_clades(lineages, simplify = TRUE)
#>  [1] "Actinobacteria"        "Bacillales"            "Bacilli"               "Bacteria"             
#>  [5] "Bacteroidales"         "Bacteroidetes"         "Bacteroidia"           "Campylobacterales"    
#>  [9] "Clostridia"            "Clostridiales"         "Coriobacteriales"      "Enterobacteriales"    
#> [13] "Epsilonproteobacteria" "Firmicutes"            "Flavobacteriales"      "Flavobacteriia"       
#> [17] "Gammaproteobacteria"   "Lactobacillales"       "Proteobacteria"        "Pseudomonadales"
  • taxtable() computes the taxonomic table corresponding to the lineages.
table <- taxtable(lineages)
table
#>    kingdom         phylum                 class             order
#> 1 Bacteria Actinobacteria        Actinobacteria  Coriobacteriales
#> 2 Bacteria  Bacteroidetes           Bacteroidia     Bacteroidales
#> 3 Bacteria  Bacteroidetes        Flavobacteriia  Flavobacteriales
#> 4 Bacteria     Firmicutes               Bacilli        Bacillales
#> 5 Bacteria     Firmicutes               Bacilli   Lactobacillales
#> 6 Bacteria     Firmicutes            Clostridia     Clostridiales
#> 7 Bacteria Proteobacteria Epsilonproteobacteria Campylobacterales
#> 8 Bacteria Proteobacteria   Gammaproteobacteria Enterobacteriales
#> 9 Bacteria Proteobacteria   Gammaproteobacteria   Pseudomonadales
  • taxtree() computes the taxonomic tree (format phylo) from a taxonomic table.
tree <- taxtree(table)
tree
#> 
#> Phylogenetic tree with 9 tips and 6 internal nodes.
#> 
#> Tip labels:
#>   Coriobacteriales, Bacteroidales, Flavobacteriales, Bacillales, Lactobacillales, Clostridiales, ...
#> Node labels:
#>   Bacteria, Bacteroidetes, Firmicutes, Bacilli, Proteobacteria, Gammaproteobacteria
#> 
#> Rooted; includes branch lengths.
plot(tree, show.node.label = TRUE)

Separator

If you want to change the default separator from | to, e.g., ;, use options(yatah_sep = ";"). Reset it with options(yatah_sep = "\\|").

yatah's People

Contributors

abichat avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.