-
Notifications
You must be signed in to change notification settings - Fork 18
/
README.Rmd
156 lines (113 loc) · 5.54 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
---
output: github_document
---
```{r setup, eval=TRUE, echo=FALSE}
library(knitr)
# opts_knit$set(upload.fun = image_uri)
opts_knit$set(upload.fun = imgur_upload)
```
<!-- badges: start -->
[![R-CMD-check](https://github.com/ropensci/rotl/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ropensci/rotl/actions/workflows/R-CMD-check.yaml)
[![codecov.io](https://app.codecov.io/github/ropensci/rotl?branch=master)](https://app.codecov.io/github/ropensci/rotl?branch=master)
[![](https://www.r-pkg.org/badges/version/rotl)](https://www.r-pkg.org/pkg/rotl)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/rotl)](https://www.r-pkg.org/pkg/rotl)
[![](https://badges.ropensci.org/17_status.svg)](https://github.com/ropensci/software-review/issues/17)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
<!-- badges: end -->
# rotl: An R interface to Open Tree API <img src="man/figures/logo.svg" align="right" />
`rotl` is an R package to interact with the Open Tree of Life data APIs. It was
initially developed as part of the
NESCENT/OpenTree/Arbor hackathon.
Client libraries to interact with the Open Tree of Life API also exists for
[Python](https://github.com/OpenTreeOfLife/pyopentree)
and [Ruby](https://github.com/SpeciesFileGroup/bark).
## Installation
The current stable version is available from CRAN, and can be installed by
typing the following at the prompt in R:
```{r, eval=FALSE}
install.packages("rotl")
```
If you want to test the development version, you first need to install
the `remotes` package.
```{r, eval=FALSE}
install.packages("remotes")
```
Then you can install `rotl` using:
```{r, eval=FALSE}
remotes::install_github("ropensci/rotl")
```
## Vignettes
There are three vignettes:
- Start by checking out the "How to use `rotl`?" by typing:
`vignette("rotl", package="rotl")` after installing the
package.
- Then explore how you can use `rotl` with other packages to combine your data
with trees from the Open Tree of Life project by typing:
`vignette("data_mashups", package="rotl")`.
- The vignette "Using the Open Tree Synthesis in a comparative analysis"
demonstrates how you can reproduce an analysis of a published paper by
downloading the tree they used, and data from the supplementary material:
`vignette("meta-analysis", package="rotl")`.
The vignettes are also available from CRAN:
[How to use `rotl`?](https://cran.r-project.org/package=rotl/vignettes/rotl.html),
[Data mashups](https://cran.r-project.org/package=rotl/vignettes/data_mashups.html),
and
[Using the Open Tree synthesis in a comparative analysis](https://cran.r-project.org/package=rotl/vignettes/meta-analysis.html).
## Quick start
### Get a little bit of the big Open Tree tree
Taxonomic names are represented in the Open Tree by numeric identifiers, the
`ott_ids` (Open Tree Taxonomy identifiers). To extract a portion of a tree from
the Open Tree, you first need to find `ott_ids` for a set of names using the
`tnrs_match_names` function:
```{r resolve}
library(rotl)
apes <- c("Pongo", "Pan", "Gorilla", "Hoolock", "Homo")
(resolved_names <- tnrs_match_names(apes))
```
Now we can get the tree with just those tips:
```{r get_tr}
tr <- tol_induced_subtree(ott_ids = ott_id(resolved_names))
plot(tr)
```
The code above can be summarized in a single pipe:
```{r pipe, plot=FALSE}
library(magrittr)
## or expressed as a pipe:
c("Pongo", "Pan", "Gorilla", "Hoolock", "Homo") %>%
tnrs_match_names() %>%
ott_id() %>%
tol_induced_subtree() %>%
plot()
```
## Citation and Manuscript
To cite `rotl` in publications pleases use:
> Michonneau, F., Brown, J. W. and Winter, D. J. (2016), rotl: an R package to
> interact with the Open Tree of Life data. Methods in Ecology and
> Evolution. 7(12):1476-1481. doi:
> [10.1111/2041-210X.12593](https://doi.org/10.1111/2041-210X.12593)
You may also want to cite the paper for the Open Tree of Life
> Hinchliff, C. E., et al. (2015). Synthesis of phylogeny and taxonomy into a
> comprehensive tree of life. Proceedings of the National Academy of Sciences
> 112.41 (2015): 12764-12769
> doi: [10.1073/pnas.1423041112](https://doi.org/10.1073/pnas.1423041112)
The manuscript in *Methods in Ecology and Evolution* includes additional
examples on how to use the package. The manuscript and the code it contains are
also hosted on GitHub at: https://github.com/fmichonneau/rotl-ms
## Versioning
Starting with v3.0.0 of the package, the major and minor version numbers (the
first 2 digits of the version number) will be matched to those of the API. The
patch number (the 3rd digit of the version number) will be used to reflect
bug fixes and other changes that are independent from changes to the API.
`rotl` can be used to access other versions of the API (if they are available)
but most likely the high level functions will not work. Instead, you will need
to parse the output yourself using the "raw" returns from the unexported
low-level functions (all prefixed with a `.`). For instance to use the
`tnrs/match_names` endpoint for `v2` of the API:
```{r versioning, eval=FALSE}
rotl:::.tnrs_match_names(c("pan", "pango", "gorilla", "hoolock", "homo"), otl_v = "v2")
```
### Code of Conduct
Please note that this project is released with a
[Contributor Code of Conduct](https://github.com/ropensci/rotl/blob/master/CONDUCT.md). By participating in this project you
agree to abide by its terms.
[![](https://ropensci.org/public_images/github_footer.png)](https://ropensci.org/)