[med-svn] [r-cran-rotl] 10/12: New upstream version 3.0.3

Andreas Tille tille at debian.org
Sat Sep 23 06:49:55 UTC 2017


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository r-cran-rotl.

commit 35211084c22ff96dc3478e7b06cacc13e36c2045
Author: Andreas Tille <tille at debian.org>
Date:   Sat Sep 23 08:17:29 2017 +0200

    New upstream version 3.0.3
---
 DESCRIPTION                             |   8 +-
 LICENSE                                 |   2 +-
 MD5                                     | 106 ++++++++++++------------
 NAMESPACE                               |   3 +
 NEWS.md                                 |  23 ++++++
 R/api-studies.R                         |   9 +-
 R/deduplicate_labels.R                  |   3 +-
 R/is_in_tree.R                          |  50 ++++++++++++
 R/studies.R                             |  56 ++++++++-----
 R/tax_utils.R                           |   7 ++
 README.md                               | 140 ++++++++++++--------------------
 build/vignette.rds                      | Bin 316 -> 315 bytes
 inst/CITATION                           |  75 ++++++++++++-----
 inst/doc/data_mashups.html              |  22 ++---
 inst/doc/how-to-use-rotl.R              |  15 ++--
 inst/doc/how-to-use-rotl.Rmd            |  46 +++++++----
 inst/doc/how-to-use-rotl.html           |  92 +++++++++++++--------
 inst/doc/meta-analysis.R                |   3 +-
 inst/doc/meta-analysis.Rmd              |   5 +-
 inst/doc/meta-analysis.html             |  20 ++---
 inst/extdata/protist_mutation_rates.csv |   0
 man/get_study.Rd                        |   1 -
 man/get_study_meta.Rd                   |  13 ++-
 man/get_study_subtree.Rd                |  29 +++++--
 man/get_study_tree.Rd                   |   9 +-
 man/is_in_tree.Rd                       |  40 +++++++++
 man/list_trees.Rd                       |   1 -
 man/match_names-methods.Rd              |   5 +-
 man/match_names.Rd                      |   3 +-
 man/source_list.Rd                      |   1 -
 man/strip_ott_ids.Rd                    |   1 -
 man/studies_find_studies.Rd             |   1 -
 man/studies_find_trees.Rd               |   1 -
 man/studies_properties.Rd               |   1 -
 man/study_external_IDs.Rd               |   1 -
 man/synonyms.match_names.Rd             |   1 -
 man/tax_lineage.Rd                      |   1 -
 man/taxon_external_IDs.Rd               |   1 -
 man/taxonomy-methods.Rd                 |   7 +-
 man/taxonomy_about.Rd                   |   1 -
 man/taxonomy_mrca.Rd                    |  13 ++-
 man/taxonomy_subtree.Rd                 |   1 -
 man/taxonomy_taxon_info.Rd              |  15 ++--
 man/tnrs_contexts.Rd                    |   1 -
 man/tnrs_infer_context.Rd               |   1 -
 man/tnrs_match_names.Rd                 |   1 -
 man/tol_about.Rd                        |   7 +-
 man/tol_induced_subtree.Rd              |   1 -
 man/tol_mrca.Rd                         |  11 ++-
 man/tol_node_info.Rd                    |  13 ++-
 man/tol_subtree.Rd                      |   1 -
 tests/testthat/test-match_names.R       |  14 ++--
 tests/testthat/test-studies.R           |  57 ++++++++-----
 tests/testthat/test-taxonomy.R          |  38 ++++++++-
 vignettes/how-to-use-rotl.Rmd           |  46 +++++++----
 vignettes/meta-analysis.Rmd             |   5 +-
 56 files changed, 632 insertions(+), 396 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 460558c..fb309a4 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
 Package: rotl
 Title: Interface to the 'Open Tree of Life' API
-Version: 3.0.1
+Version: 3.0.3
 Authors at R: c(
   person("Francois", "Michonneau", role=c("aut", "cre"),
          email="francois.michonneau at gmail.com"),
@@ -21,12 +21,12 @@ Suggests: knitr (>= 1.12), rmarkdown (>= 0.7), testthat, RNeXML,
         phylobase, MCMCglmm, fulltext (>= 0.1.6), readxl
 VignetteBuilder: knitr
 LazyData: true
-RoxygenNote: 5.0.1.9000
+RoxygenNote: 6.0.1
 NeedsCompilation: no
-Packaged: 2016-09-19 20:21:54 UTC; francois
+Packaged: 2017-03-04 00:50:11 UTC; francois
 Author: Francois Michonneau [aut, cre],
   Joseph Brown [aut],
   David Winter [aut]
 Maintainer: Francois Michonneau <francois.michonneau at gmail.com>
 Repository: CRAN
-Date/Publication: 2016-09-20 00:45:03
+Date/Publication: 2017-03-04 07:27:19
diff --git a/LICENSE b/LICENSE
index 68de442..d1a7a70 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,2 +1,2 @@
-YEAR: 2016
+YEAR: 2017
 COPYRIGHT HOLDER: Francois Michonneau, Joseph W. Brown, David Winter
\ No newline at end of file
diff --git a/MD5 b/MD5
index 9a1c324..5a33829 100644
--- a/MD5
+++ b/MD5
@@ -1,70 +1,72 @@
-7652ea6d7ffe68af7d47e583c3447a6f *DESCRIPTION
-c0db011c3d740ac7b1bfd97861660487 *LICENSE
-52103d2d4b2a149f145c18da06b216f1 *NAMESPACE
-a79be268498bada7555d5f77b08eb33c *NEWS.md
+bef13507a27f905c474b5ac48e21dc51 *DESCRIPTION
+41ba68f62ff5f58f05f96a0dbd08b282 *LICENSE
+1b572ebec7a85682af97cf46a8954c85 *NAMESPACE
+f3ff4e9fdc6e6eaf6b8b101d5f9dec82 *NEWS.md
 9a7c4a54d4f95926b66ed6e06476df86 *R/api-collections.R
-de19c1b60f39999478066198ec586cd3 *R/api-studies.R
+9bd92e4fd5729c1c914772ea6051c0d5 *R/api-studies.R
 cf7e3dc77115551f7a666294970d090c *R/api-taxonomy.R
 08064573a536c31daf9a479eec383e25 *R/api-tnrs.R
 9049ace110a1de5d23d81cc09e1022b5 *R/api-tol.R
 f1d6f185eb969bcb30e8fa01828389b9 *R/base.R
-0b7d73e3fc74165f4a88ae6a6d3c08f8 *R/deduplicate_labels.R
+6286c2d7b82011d166cf7e0b68391d82 *R/deduplicate_labels.R
 71769e61f96290be93a642ed5e7e1bf1 *R/external_data.R
+67afa5276ae39353db1be4c9748202e4 *R/is_in_tree.R
 8f6a526c44396e5afe7a980ea0116d39 *R/match_names.R
 dc83309cfcec969f308dc5ef128b24c8 *R/methods.R
 885012a0fef7e432f1e3ab49ac05a621 *R/rotl-package.R
 ecec63dfc2513887fcc35f62ad8bbf10 *R/studies-methods.R
 e3689dd313ea6b632450c24f11ec56e8 *R/studies-utils.R
-bca9348daa609e2f03f5107bc678124d *R/studies.R
-6b70557ad769ce15aa747941be85903d *R/tax_utils.R
+c2833f9705fb7e369e1678a37d87250b *R/studies.R
+f1f397f5739142664c28e4068893be34 *R/tax_utils.R
 3c36224fa41a50053831efb15ff2675c *R/taxonomy.R
 2b2d1c28d1e4b229a59780ba94059a47 *R/tnrs.R
 a884ca1e7339f1d913dc058a4d4a3653 *R/tol.R
 cadefaffbca9725850fbc2218753179a *R/tree_to_labels.R
-4cc01a99eb408fd699476cd28a8f76a0 *README.md
-5b69e412b9eb01d1c67779f8b9064e0f *build/vignette.rds
-8fea5362ecb8e33f8a73c289da7ff801 *inst/CITATION
+41bc3a21bc29333d534950c8e8ac0084 *README.md
+f9b8ccf74106a49197ffc1dbc4e04e75 *build/vignette.rds
+f0fd4ea89eb96fe8746602e268fbf502 *inst/CITATION
 319582efa0a202fed973883555cf0e51 *inst/doc/data_mashups.R
 64c62d69bc9cec722c7f26e6d025ef35 *inst/doc/data_mashups.Rmd
-b7999410f9f487044fd1ec75cfdf7972 *inst/doc/data_mashups.html
-1ac42821867e8a575732c0cc48ae1104 *inst/doc/how-to-use-rotl.R
-7667f4f210b3fc36aa564a8c1ab4bcd5 *inst/doc/how-to-use-rotl.Rmd
-3ac44cb716cefb574425c56d1369d7bc *inst/doc/how-to-use-rotl.html
-eeaeb60fea9421f2f37f3b05d79034fb *inst/doc/meta-analysis.R
-0c9eebd21ffe483249d1b1c769e44d52 *inst/doc/meta-analysis.Rmd
-50f657b46970a015dd8ebd996c23a4ed *inst/doc/meta-analysis.html
+11af7fe6047e439efb39b4eaace09c9b *inst/doc/data_mashups.html
+4f8c602b56730ad3c3a97caaf33d4719 *inst/doc/how-to-use-rotl.R
+8001eb5bddaaf93285424d383c3195f3 *inst/doc/how-to-use-rotl.Rmd
+1b8e7ff8dc6a4dd14cab710f443bc71d *inst/doc/how-to-use-rotl.html
+b5e8ba63b31d0baf609e763d168b8b14 *inst/doc/meta-analysis.R
+ef518f65da0362f9bf5b5fefa5329cd0 *inst/doc/meta-analysis.Rmd
+171d4496da0b82d1f9dbf22220fd2d91 *inst/doc/meta-analysis.html
 09d93b49b2b38f2495761ea86e134006 *inst/extdata/egg.csv
 5e5eb20ee387ba7192c62e629a3383f2 *inst/extdata/protist_mutation_rates.csv
-ea6a8fb50d20fd58b3072a9d7fbd0f01 *man/get_study.Rd
-7926e12f926142deb0ad4837110becdf *man/get_study_meta.Rd
-af93584e72106c40ef5f607259d9f616 *man/get_study_subtree.Rd
-4539fa72f42b2225f1860d52d3717a7e *man/get_study_tree.Rd
-20d9c6022758c5e82152bcc9fccc55dc *man/list_trees.Rd
-7e09ca72cc00b2319838296535c57b2d *man/match_names-methods.Rd
-1f9bc0f18b389ade4cf46d1c94888138 *man/match_names.Rd
+f30954a01d7420beb303c1916ea08971 *man/get_study.Rd
+d261a5dcd926401050929be39c1ed44d *man/get_study_meta.Rd
+9297cffa642515239d15c2efebdce3a2 *man/get_study_subtree.Rd
+f60b580ce8808e50d0479e4d22c6779d *man/get_study_tree.Rd
+7376b3c8fbc5c5d83c06e9c2756fbb35 *man/is_in_tree.Rd
+8572338a55159b4b45eea44191cbc82f *man/list_trees.Rd
+e0386442684f2019f009dbd9dc75b9b3 *man/match_names-methods.Rd
+ce1a6b4c35d7ca5209b664938b081d7b *man/match_names.Rd
 9f9c58fcedf44fecf5cfc9741ef54a3d *man/rotl.Rd
-e634c8c1f147fa2f39452f5b04db5dd8 *man/source_list.Rd
-e55bfa18aa6569359dc345326d24d05f *man/strip_ott_ids.Rd
-f1bf287630f8175d7358b522d5ad20bb *man/studies_find_studies.Rd
-7234766a4098b978eb9bcc21e41455b9 *man/studies_find_trees.Rd
-dad09a2555cc16f7a56b0200d8bc5f15 *man/studies_properties.Rd
-d306ed46f0e31121bf222bfe5e2df59c *man/study_external_IDs.Rd
-23b68f20f00f123a291f68a92844be96 *man/synonyms.match_names.Rd
-405f784cbcad294e767615d515389498 *man/tax_lineage.Rd
-2fe60e574b50374f14391b26bf0a903a *man/taxon_external_IDs.Rd
-f4fbe9e06a5c3542c59bdedaf53b9526 *man/taxonomy-methods.Rd
-2b4d81f1844a3561d12d1ccd680caaf0 *man/taxonomy_about.Rd
-5b0e808095fef1a19ece9cc8fa4a0f3f *man/taxonomy_mrca.Rd
-a8fb26f5f4fd69197416a6a4bbf3c470 *man/taxonomy_subtree.Rd
-95300f9b71cc6b82d4ad9eb990de4af9 *man/taxonomy_taxon_info.Rd
-99109d680828b91907f0db01094b9674 *man/tnrs_contexts.Rd
-8dcab348f50f8373446ffc1d3b2bad08 *man/tnrs_infer_context.Rd
-a8f2f0bea95cb247f8288e9758815225 *man/tnrs_match_names.Rd
-49026107b0a09e12070a80499021b377 *man/tol_about.Rd
-bec1c576d209985c3d66b7ee4a8db22f *man/tol_induced_subtree.Rd
-e572dd198f4bf21642ca0236482ecaa5 *man/tol_mrca.Rd
-8f8de8edd36bd21d9193b68dc935c973 *man/tol_node_info.Rd
-c6cef93ea9dbdabf4648a5cc6f4d32f7 *man/tol_subtree.Rd
+ea8938c2220f0b358930fbaa9b9af738 *man/source_list.Rd
+6310137f447dbe11a8bda6f2a1c1ed40 *man/strip_ott_ids.Rd
+5b3f7b8629b906dc79ac5d1de9e11255 *man/studies_find_studies.Rd
+ddf9261b772dbcf6846955b1d34b1683 *man/studies_find_trees.Rd
+b52b8d1f1701bf1d7d1b4549d56ccc90 *man/studies_properties.Rd
+76ee971ef937ff9fe23ceca701b35ce6 *man/study_external_IDs.Rd
+39e2c7bacba5befea2f3d8bc6be223a9 *man/synonyms.match_names.Rd
+ccb54bd7485bddbe4ee59b4e117a0b21 *man/tax_lineage.Rd
+0c0a51d7f1b9365e27f9c84b8095a0da *man/taxon_external_IDs.Rd
+5f58b0e589b08000432acb5656fc2be2 *man/taxonomy-methods.Rd
+f72255eacbb9eadb1fa2eb513557afaa *man/taxonomy_about.Rd
+5fa0e3a349e2d596e24ce621c567497b *man/taxonomy_mrca.Rd
+5b43cd3d8577fc8f9df28a7f1276972c *man/taxonomy_subtree.Rd
+40ef74245553816685e5c7b07096ec8b *man/taxonomy_taxon_info.Rd
+c01395cc8ca421b4e607c110fd714a53 *man/tnrs_contexts.Rd
+a16c0de937a7de364fbff3a7e1581c44 *man/tnrs_infer_context.Rd
+a3e1aa967d58fadf26e62d458ed075e5 *man/tnrs_match_names.Rd
+0399a2876a415a962c1c35f52ad418b6 *man/tol_about.Rd
+34b418796c5f85fbfecbe1b663e86197 *man/tol_induced_subtree.Rd
+69cc652562e542dc2572068edbe28d6c *man/tol_mrca.Rd
+16bd284ab4cf10574bcd7700d074266d *man/tol_node_info.Rd
+a520ea68a2b1b4943a0941832761beae *man/tol_subtree.Rd
 43c8ae96b072c5ffa02ee1476ab517af *tests/test-all.R
 8aa44593dfd95bba9fc05fe726562a4f *tests/testthat/test-API.R
 0978d0c6f16459de48230f0ca7242888 *tests/testthat/test-api-studies.R
@@ -74,14 +76,14 @@ eec189b1b610d1fab12164c96ba55ff5 *tests/testthat/test-api-tol.R
 9a25dd598f4420dc68f2280ce323c367 *tests/testthat/test-base.R
 91e80d240d100527a3496b9c2040c771 *tests/testthat/test-deduplicate_labels.R
 51c9a683157c0ca97ca7fa7656dbf4a2 *tests/testthat/test-external.R
-4ead099ce223e9037f477fd200035935 *tests/testthat/test-match_names.R
-4aeb495b775e003fa9f273039a75cd19 *tests/testthat/test-studies.R
-c266628e0538911559aeb0cad7f9980d *tests/testthat/test-taxonomy.R
+47dd8941c039e76be1a91266434680b4 *tests/testthat/test-match_names.R
+4ca3762a30b73adc31d149a81e15c3a4 *tests/testthat/test-studies.R
+d4eb07768af70ce855fbad1323a0994e *tests/testthat/test-taxonomy.R
 57bcbfabee0c58d895dce12a81166027 *tests/testthat/test-tnrs.R
 da7d30c00521dcf6ebaa16a1ddd5dc50 *tests/testthat/test-tol.R
 85a49232f1097e80d7f059bea79d885d *tests/testthat/test-tree_to_labels.R
 fb4b19651907e0fdb26e6f4c0581af83 *tests/tree_of_life.json
 64c62d69bc9cec722c7f26e6d025ef35 *vignettes/data_mashups.Rmd
-7667f4f210b3fc36aa564a8c1ab4bcd5 *vignettes/how-to-use-rotl.Rmd
-0c9eebd21ffe483249d1b1c769e44d52 *vignettes/meta-analysis.Rmd
+8001eb5bddaaf93285424d383c3195f3 *vignettes/how-to-use-rotl.Rmd
+ef518f65da0362f9bf5b5fefa5329cd0 *vignettes/meta-analysis.Rmd
 da8cb33974fa673158fea8ccf2d8bbac *vignettes/vignette.css
diff --git a/NAMESPACE b/NAMESPACE
index 3d26d50..3ec0299 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,5 +1,6 @@
 # Generated by roxygen2: do not edit by hand
 
+S3method("[",otl_ott_id)
 S3method(candidate_for_synth,study_meta)
 S3method(flags,match_names)
 S3method(flags,taxon_info)
@@ -8,6 +9,7 @@ S3method(get_publication,study_meta)
 S3method(get_study_year,study_meta)
 S3method(get_tree_ids,study_meta)
 S3method(inspect,match_names)
+S3method(is_in_tree,otl_ott_id)
 S3method(is_suppressed,match_names)
 S3method(is_suppressed,taxon_info)
 S3method(is_suppressed,taxon_mrca)
@@ -68,6 +70,7 @@ export(get_study_tree)
 export(get_study_year)
 export(get_tree_ids)
 export(inspect)
+export(is_in_tree)
 export(is_suppressed)
 export(list_trees)
 export(ott_id)
diff --git a/NEWS.md b/NEWS.md
index f7e3705..1d59f37 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,26 @@
+## rotl 3.0.2
+
+### New features
+
+* The function `get_study_subtree` gains the argument `tip_label` to control the
+  formatting of the tip labels, #90, reported by @bomeara
+* The new function `is_in_tree` takes a list of OTT ids (i.e., the output of
+  `ott_id()`), and returns a vector of logical indiicating whether they are
+  included in the synthetic tree (workaround #31).
+
+### Bug fixes
+
+* The function `get_study_subtree` ignored the argument `subtree_id`, #89
+  reported by @bomeara
+
+### Other chaanges
+
+* `citation("rotl")` now includes the reference to the Open Tree of Life
+  publication.
+* The "How to use rotl?" vignette was updated to document the behavior of v3 of
+  the OTL API which returns an HTTP error code 400 when the request for induced
+  subtree includes taxa that are not in the synthetic tree (fix #84)
+
 ## rotl 3.0.1
 
 * Fix tests and vignette to reflect changes accompanying release 6.1 of the
diff --git a/R/api-studies.R b/R/api-studies.R
index 420b3a4..dbf02f1 100644
--- a/R/api-studies.R
+++ b/R/api-studies.R
@@ -124,7 +124,9 @@
 
 ##' @importFrom httr content
 .get_study_subtree <- function(study_id, tree_id, subtree_id,
-                               format=c("newick", "nexus", "nexml", "json"), ...) {
+                               format=c("newick", "nexus", "nexml"),
+                               tip_label = c("ot:originallabel", "ot:ottid", "ot:otttaxonname"),
+                               ...) {
     if (is.null(study_id)) {
         stop("Must supply a \'study_id\' argument")
     } else if (!is.character(study_id)) {
@@ -142,8 +144,9 @@
     }
     format <- match.arg(format)
     format <- otl_formats(format)
-    url_stem <- paste("study", study_id, "tree", paste0(tree_id, format), sep="/")
-    res <- otl_GET(path=paste(url_stem, "?subtree_id=", subtree_id, sep=""), ...)
+    tip_label <- match.arg(tip_label)
+    url_stem <- paste("study", study_id, "subtree", paste0(tree_id, format), sep="/")
+    res <- otl_GET(path=paste0(url_stem, "?subtree_id=", subtree_id, "&tip_label=", tip_label), ...)
     res
 }
 
diff --git a/R/deduplicate_labels.R b/R/deduplicate_labels.R
index 8ba3c01..5b77305 100644
--- a/R/deduplicate_labels.R
+++ b/R/deduplicate_labels.R
@@ -23,7 +23,8 @@ dedup_lbl <- function(tr_str) {
                           paste0("\\1", tr_lbl_unq[i], "\\2"),  tr_str)
         }
         warning("Some tip labels were duplicated and have been modified: ",
-                paste(tr_lbl[duplicated(tr_lbl)], collapse = ", "))
+                paste(tr_lbl[duplicated(tr_lbl)], collapse = ", "),
+                call. = FALSE)
     }
     paste0(tr_str, ";")
 }
diff --git a/R/is_in_tree.R b/R/is_in_tree.R
new file mode 100644
index 0000000..c69d26c
--- /dev/null
+++ b/R/is_in_tree.R
@@ -0,0 +1,50 @@
+##' Some valid taxonomic names do not occur in the Synthetic
+##' Tree. This convenience function allows you to check whether a
+##' given Open Tree Taxonomy identifier (OTT id) is in the tree. A taxonomic
+##' name may not occur in the synthetic tree because (1) it is an
+##' extinct or invalid taxon, or (2) it is part of a group that is not
+##' monophyletic in the tree.
+##'
+##' @title Check that OTT ids occur in the Synthetic Tree
+##' @param ott_ids a vector of Open Tree Taxonomy identifiers
+##' @param ...  additional arguments to customize the API request (see
+##'     \code{\link{rotl}} package documentation).
+##' @return A named logical vector. \code{TRUE} indicates that the OTT
+##'     id is in the synthetic tree, and \code{FALSE} that it is not.
+##' @examples
+##' \dontrun{
+##'   plant_families <- c("Asteraceae", "Solanaceae", "Poaceae", "Amaranthaceae",
+##'                       "Zamiaceae", "Araceae", "Juncaceae")
+##'   matched_names <- tnrs_match_names(plant_families)
+##'   ## This fails because some ott ids are not in the tree
+##'   ## plant_tree <- tol_induced_subtree(ott_id(matched_names))
+##'   ## So let's check which ones are actually in the tree first:
+##'   in_tree <- is_in_tree(ott_id(matched_names))
+##'   ## This now works:
+##'   plant_tree <- tol_induced_subtree(ott_id(matched_names)[in_tree])
+##' }
+##'
+##' @export
+is_in_tree <- function(ott_ids, ...) UseMethod("is_in_tree")
+
+
+##' @export
+is_in_tree.otl_ott_id <- function(ott_ids, ...) {
+
+    in_tree <- vapply(ott_ids, function(ottid) {
+        test <- try(tol_node_info(ottid, ...), silent = TRUE)
+        if (inherits(test, "try-error")) {
+            if (grepl("not find any synthetic tree nodes corresponding to the OTT id provided", test) &&
+                grepl(paste0("(", ottid, ")"), test)) {
+            } else {
+                warning("something seems off, check your internet connection?")
+            }
+            return(FALSE)
+        } else {
+            ott_id(test)[[1]] == ottid
+        }
+
+    }, logical(1), USE.NAMES = TRUE)
+
+    in_tree
+}
diff --git a/R/studies.R b/R/studies.R
index 56c2f71..04fa7a6 100644
--- a/R/studies.R
+++ b/R/studies.R
@@ -303,12 +303,12 @@ get_study <- function(study_id = NULL, object_format = c("phylo", "nexml"),
 ##' @importFrom jsonlite toJSON
 ##' @examples
 ##' \dontrun{
-##'  tree <- get_study_tree(study_id="pg_1144", tree="tree2324")
+##'  tree <- get_study_tree(study_id="pg_1144", tree_id="tree2324")
 ##'
 ##'  ## comparison of the first few tip labels depending on the options used
-##'  head(get_study_tree(study_id="pg_1144", tree="tree2324", tip_label="original_label")$tip.label)
-##'  head(get_study_tree(study_id="pg_1144", tree="tree2324", tip_label="ott_id")$tip.label)
-##'  head(get_study_tree(study_id="pg_1144", tree="tree2324", tip_label="ott_taxon_name")$tip.label)
+##'  head(get_study_tree(study_id="pg_1144", tree_id="tree2324", tip_label="original_label")$tip.label)
+##'  head(get_study_tree(study_id="pg_1144", tree_id="tree2324", tip_label="ott_id")$tip.label)
+##'  head(get_study_tree(study_id="pg_1144", tree_id="tree2324", tip_label="ott_taxon_name")$tip.label)
 ##' }
 
 get_study_tree <- function(study_id = NULL, tree_id = NULL, object_format = c("phylo"),
@@ -407,40 +407,55 @@ print.study_meta <- function(x, ...) {
 ##' @param object_format the class of the object returned by the
 ##'     function (default, and currently only possibility \code{phylo}
 ##'     from the \code{\link[ape]{ape}} package)
+##' @param tip_label the format of the tip
+##'     labels. \dQuote{\code{original_label}} (default) returns the
+##'     original labels as provided in the study,
+##'     \dQuote{\code{ott_id}} labels are replaced by their ott IDs,
+##'     \dQuote{\code{ott_taxon_name}} labels are replaced by their
+##'     Open Tree Taxonomy taxon name.
 ##' @param file_format character, the file format to use to save the
-##'     results of the query (possible values, \sQuote{newick},
-##'     \sQuote{nexus}, \sQuote{json}).
+##'     results of the query (possible values, \sQuote{newick} or
+##'     \sQuote{nexus}).
 ##' @param file character, the path and file name where the output
 ##'     should be written.
+##' @param deduplicate logical (default \code{TRUE}). If the tree
+##'     returned by the study contains duplicated taxon names, should
+##'     they be made unique? It is normally illegal for NEXUS/Newick
+##'     tree strings to contain duplicated tip names. This is a
+##'     workaround to circumvent this requirement. If \code{TRUE},
+##'     duplicated tip labels will be appended \code{_1}, \code{_2},
+##'     etc.
 ##' @param subtree_id, either a node id that specifies a subtree or
 ##'     \dQuote{ingroup} which returns the ingroup for this subtree.
 ##' @param ...  additional arguments to customize the API request (see
 ##'     \code{\link{rotl}} package documentation).
 ##' @export
-##' @importFrom jsonlite toJSON
 ##' @examples
 ##' \dontrun{
-##' small_tr <- get_study_subtree(study_id="pg_1144", tree="tree2324", subtree_id="node552052")
-##' ingroup  <- get_study_subtree(study_id="pg_1144", tree="tree2324", subtree_id="ingroup")
+##' small_tr <- get_study_subtree(study_id="pg_1144", tree_id="tree5800", subtree_id="node991044")
+##' ingroup  <- get_study_subtree(study_id="pg_1144", tree_id="tree5800", subtree_id="ingroup")
 ##' nexus_file <- tempfile(fileext=".nex")
-##' get_study_subtree(study_id="pg_1144", tree="tree2324", subtree_id="ingroup", file=nexus_file,
+##' get_study_subtree(study_id="pg_1144", tree_id="tree5800", subtree_id="ingroup", file=nexus_file,
 ##'                   file_format="nexus")
 ##' }
 get_study_subtree <- function(study_id, tree_id, subtree_id, object_format=c("phylo"),
-                              file_format, file, ...) {
+                              tip_label = c("original_label", "ott_id", "ott_taxon_name"),
+                              file_format, file, deduplicate = TRUE, ...) {
     object_format <- match.arg(object_format)
+    tip_label <- match.arg(tip_label)
+    tip_label <- switch(tip_label,
+                        original_labels = "ot:originallabel",
+                        ott_id =  "ot:ottid",
+                        ott_taxon_name = "ot:otttaxonname")
     if (!missing(file)) {
         if (!missing(file_format)) {
             if (missing(file)) stop("You must specify a file to write your output")
-            file_format <- match.arg(file_format, c("newick", "nexus", "json"))
+            file_format <- match.arg(file_format, c("newick", "nexus"))
             res <- .get_study_subtree(study_id = study_id, tree_id = tree_id,
-                                      subtree_id = subtree_id, format=file_format, ...)
+                                      subtree_id = subtree_id, format=file_format,
+                                      tip_label = tip_label,  ...)
             unlink(file)
-            if (identical(file_format, "json")) {
-                cat(jsonlite::toJSON(res), file=file)
-            } else {
-                cat(res, file=file)
-            }
+            cat(res, file=file)
             return(invisible(file.exists(file)))
         } else {
             stop(sQuote("file_format"), " must be specified.")
@@ -448,8 +463,9 @@ get_study_subtree <- function(study_id, tree_id, subtree_id, object_format=c("ph
     } else if (identical(object_format, "phylo")) {
         file_format <- "newick"
         res <-  .get_study_subtree(study_id = study_id, tree_id = tree_id,
-                                   subtree_id = subtree_id, format=file_format, ...)
-        res <- phylo_from_otl(res)
+                                   subtree_id = subtree_id, format=file_format,
+                                   tip_label = tip_label, ...)
+        res <- phylo_from_otl(res, dedup = deduplicate)
         ## NeXML should be possible for both object_format and file_format but it seems there
         ## is something wrong with the server at this time (FM - 2015-06-07)
         ## } else if (identical(object_format, "nexml")) {
diff --git a/R/tax_utils.R b/R/tax_utils.R
index 4bdeff9..8da2007 100644
--- a/R/tax_utils.R
+++ b/R/tax_utils.R
@@ -71,3 +71,10 @@ add_otl_class <- function(res, .f) {
                     class(res))
     res
 }
+
+##' @export
+`[.otl_ott_id` <- function(x, i, ...) {
+    r <- NextMethod()
+    class(r) <- class(x)
+    r
+}
diff --git a/README.md b/README.md
index 6391802..1b150b3 100644
--- a/README.md
+++ b/README.md
@@ -1,121 +1,93 @@
 
+[![Build Status](https://travis-ci.org/ropensci/rotl.svg?branch=master)](https://travis-ci.org/ropensci/rotl) [![Build status](https://ci.appveyor.com/api/projects/status/jwvl84e6m36bqwga?svg=true)](https://ci.appveyor.com/project/fmichonneau/rotl) [![codecov.io](https://codecov.io/github/ropensci/rotl/coverage.svg?branch=master)](https://codecov.io/github/ropensci/rotl?branch=master) [![](http://www.r-pkg.org/badges/version/rotl)](http://www.r-pkg.org/pkg/rotl) [![CRAN RStudio mirror do [...]
 
-[![Build Status](https://travis-ci.org/ropensci/rotl.svg?branch=master)](https://travis-ci.org/ropensci/rotl)
-[![Build status](https://ci.appveyor.com/api/projects/status/jwvl84e6m36bqwga?svg=true)](https://ci.appveyor.com/project/fmichonneau/rotl)
-[![codecov.io](https://codecov.io/github/ropensci/rotl/coverage.svg?branch=master)](https://codecov.io/github/ropensci/rotl?branch=master)
-[![](http://www.r-pkg.org/badges/version/rotl)](http://www.r-pkg.org/pkg/rotl)
-[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/rotl)](http://www.r-pkg.org/pkg/rotl)
-[![Research software impact](http://depsy.org/api/package/cran/rotl/badge.svg)](http://depsy.org/package/r/rotl)
+An R interface to Open Tree API
+===============================
 
-# An R interface to Open Tree API
+`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](http://blog.opentreeoflife.org/2014/06/11/apply-for-tree-for-all-a-hackathon-to-access-opentree-resources/).
 
-`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](http://blog.opentreeoflife.org/2014/06/11/apply-for-tree-for-all-a-hackathon-to-access-opentree-resources/).
+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).
 
-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:
 
-## Installation
-
-The current stable version is available from CRAN, and can be installed by
-typing the following at the prompt in R:
-
-
-```r
+``` r
 install.packages("rotl")
 ```
 
-If you want to test the development version, you first need to install
-[ghit](https://github.com/cloudyr/ghit) (`ghit` is a more lightweight version of
-[devtools](https://github.com/hadley/devtools) if your sole purpose is to
-install packages that are hosted on GitHub).
-
+If you want to test the development version, you first need to install [ghit](https://github.com/cloudyr/ghit) (`ghit` is a more lightweight version of [devtools](https://github.com/hadley/devtools) if your sole purpose is to install packages that are hosted on GitHub).
 
-```r
+``` r
 install.packages("ghit")
 ```
 
 Then you can install `rotl` using:
 
-
-```r
+``` r
 library(ghit) # or library(devtools)
 install_github("ropensci/rotl")
 ```
 
-## Vignettes
+Vignettes
+---------
 
 There are three vignettes:
 
-- Start by checking out the "How to use `rotl`?" by typing:
-  `vignette("how-to-use-rotl", package="rotl")` after installing the
-  package.
+-   Start by checking out the "How to use `rotl`?" by typing: `vignette("how-to-use-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")`.
+-   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 analsysis"
-  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 vignette "Using the Open Tree Synthesis in a comparative analsysis" 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/web/packages/rotl/vignettes/how-to-use-rotl.html),
-[Data mashups](https://cran.r-project.org/web/packages/rotl/vignettes/data_mashups.html),
-and
-[Using the Open Tree synthesis in a comparative analysis](https://cran.r-project.org/web/packages/rotl/vignettes/meta-analysis.html).
+The vignettes are also available from CRAN: [How to use `rotl`?](https://cran.r-project.org/package=rotl/vignettes/how-to-use-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
+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:
-
+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
+``` r
 library(rotl)
+```
+
+    ## Warning: package 'rotl' was built under R version 3.4.0
+
+``` r
 apes <- c("Pan", "Pongo", "Pan", "Gorilla", "Hoolock", "Homo")
 (resolved_names <- tnrs_match_names(apes))
 ```
 
-```
-##   search_string unique_name approximate_match ott_id is_synonym flags
-## 1           pan         Pan             FALSE 417957      FALSE      
-## 2         pongo       Pongo             FALSE 417949      FALSE      
-## 3           pan         Pan             FALSE 417957      FALSE      
-## 4       gorilla     Gorilla             FALSE 417969      FALSE      
-## 5       hoolock     Hoolock             FALSE 712902      FALSE      
-## 6          homo        Homo             FALSE 770309      FALSE      
-##   number_matches
-## 1              1
-## 2              1
-## 3              1
-## 4              1
-## 5              1
-## 6              1
-```
+    ##   search_string unique_name approximate_match ott_id is_synonym flags
+    ## 1           pan         Pan             FALSE 417957      FALSE      
+    ## 2         pongo       Pongo             FALSE 417949      FALSE      
+    ## 3           pan         Pan             FALSE 417957      FALSE      
+    ## 4       gorilla     Gorilla             FALSE 417969      FALSE      
+    ## 5       hoolock     Hoolock             FALSE 712902      FALSE      
+    ## 6          homo        Homo             FALSE 770309      FALSE      
+    ##   number_matches
+    ## 1              2
+    ## 2              2
+    ## 3              2
+    ## 4              1
+    ## 5              1
+    ## 6              1
 
 Now we can get the tree with just those tips:
 
-
-```r
+``` r
 tr <- tol_induced_subtree(ott_ids=ott_id(resolved_names))
 plot(tr)
 ```
 
-![plot of chunk get_tr](http://i.imgur.com/t9GhUs5.png)
+![](http://i.imgur.com/u0JYjjN.png)
 
 The code above can be summarized in a single pipe:
 
-
-```r
+``` r
 library(magrittr)
 ## or expressed as a pipe:
 c("Pan", "Pongo", "Pan", "Gorilla", "Hoolock", "Homo") %>%
@@ -125,31 +97,21 @@ c("Pan", "Pongo", "Pan", "Gorilla", "Hoolock", "Homo") %>%
     plot
 ```
 
-![plot of chunk pipe](http://i.imgur.com/wDgMNtP.png)
-
-## Versioning
+![](http://i.imgur.com/1wjfPsN.png)
 
-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.
+Versioning
+----------
 
-`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:
+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
+``` r
 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](CONDUCT.md). By participating in this project you
-agree to abide by its terms.
+Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.
 
 [![](http://ropensci.org/public_images/github_footer.png)](http://ropensci.org)
diff --git a/build/vignette.rds b/build/vignette.rds
index 42e1a0f..108770e 100644
Binary files a/build/vignette.rds and b/build/vignette.rds differ
diff --git a/inst/CITATION b/inst/CITATION
index f904c0b..ebb58c3 100644
--- a/inst/CITATION
+++ b/inst/CITATION
@@ -1,20 +1,57 @@
-citHeader("To cite rotl in publications use:")
-
-citEntry(entry = "Article",
-  title        = "{rotl}: an R package to interact with the Open Tree of Life data",
-  author       = personList(as.person("Francois Michonneau"),
-                            as.person("Joseph W. Brown"),
-                            as.person("David J. Winter")),
-  journal      = "Methods in Ecology and Evolution",
-  year         = "2016",
-  volume       = "",
-  number       = "",
-  pages        = "",
-  url          = "https://doi.org/10.1111/2041-210X.12593",
-  doi          =  "10.1111/2041-210X.12593",
-
-  textVersion  =
-      paste("Michonneau, F., Brown, J. W. and Winter, D. J. (2016),
+c(
+    bibentry(
+        header = "To cite rotl in publications use:",
+        bibtype = "Article",
+        title        = "{rotl}: an R package to interact with the Open Tree of Life data",
+        author       = personList(as.person("Francois Michonneau"),
+                                  as.person("Joseph W. Brown"),
+                                  as.person("David J. Winter")),
+        journal      = "Methods in Ecology and Evolution",
+        year         = "2016",
+        volume       = "7",
+        number       = "12",
+        pages        = "1476-1481",
+        doi          =  "10.1111/2041-210X.12593",
+        textVersion  =
+            paste("Michonneau, F., Brown, J. W. and Winter, D. J. (2016),
              rotl: an R package to interact with the Open Tree of Life data.
-             Methods Ecol Evol. doi:10.1111/2041-210X.12593")
-  )
+             Methods Ecol Evol. 7(12):1476-1481. doi:10.1111/2041-210X.12593")
+    ),
+    bibentry(
+        header = "You may also want to cite the paper for the Open Tree of Life",
+        bibtype = "Article",
+        title = "Synthesis of phylogeny and taxonomy into a comprehensive tree of life", ,
+        author = personList(
+            as.person("Cody E. Hinchliff"),
+            as.person("Stephen A. Smith"),
+            as.person("James F. Allman"),
+            as.person("J. Gordon Burleigh"),
+            as.person("Ruchi Chaudhary"),
+            as.person("Lyndon M. Coghill"),
+            as.person("Keith A. Crandall"),
+            as.person("Jiabin Deng"),
+            as.person("Bryan T. Drew"),
+            as.person("Romina Gazis"),
+            as.person("Karl Gude"),
+            as.person("David S. Hibbett"),
+            as.person("Laura A. Katz"),
+            as.person("H. Dail Laughinghouse IV"),
+            as.person("Emily Jane McTavish"),
+            as.person("Peter E. Midford"),
+            as.person("Christopher L. Owen"),
+            as.person("Richard H. Ree"),
+            as.person("Jonathan A. Rees"),
+            as.person("Douglas E. Soltis"),
+            as.person("Tiffani Williams"),
+            as.person("Karen A. Cranston")),
+        journal = "Proceedings of the National Academy of Sciences",
+        year = "2015",
+        volume = "112",
+        number = "41",
+        pages = "12764-12769",
+        doi =  "10.1073/pnas.1423041112",
+        textVersion = c("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")
+    )
+)
diff --git a/inst/doc/data_mashups.html b/inst/doc/data_mashups.html
index 23fc9f4..68dc791 100644
--- a/inst/doc/data_mashups.html
+++ b/inst/doc/data_mashups.html
@@ -12,7 +12,7 @@
 
 <meta name="author" content="David Winter" />
 
-<meta name="date" content="2016-09-19" />
+<meta name="date" content="2017-03-03" />
 
 <title>Connecting data to Open Tree trees</title>
 
@@ -70,7 +70,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
 
 <h1 class="title toc-ignore">Connecting data to Open Tree trees</h1>
 <h4 class="author"><em>David Winter</em></h4>
-<h4 class="date"><em>2016-09-19</em></h4>
+<h4 class="date"><em>2017-03-03</em></h4>
 
 
 
@@ -209,11 +209,11 @@ mu$ott_id <-<span class="st"> </span>taxon_search$ott_id</code></pre></div>
 ##  [1] "ot:studyModified"             "ot:focalClade"               
 ##  [3] "ot:focalCladeOTTTaxonName"    "ot:focalCladeOTTId"          
 ##  [5] "ot:studyPublication"          "ot:studyLastEditor"          
-##  [7] "ot:tag"                       "ot:focalCladeTaxonName"      
-##  [9] "ot:studyLabel"                "ot:comment"                  
+##  [7] "ot:focalCladeTaxonName"       "ot:tag"                      
+##  [9] "ot:comment"                   "ot:studyLabel"               
 ## [11] "ot:authorContributed"         "ot:studyPublicationReference"
-## [13] "ot:studyId"                   "ot:curatorName"              
-## [15] "ot:studyUploaded"             "ot:studyYear"                
+## [13] "ot:curatorName"               "ot:studyId"                  
+## [15] "ot:studyYear"                 "ot:studyUploaded"            
 ## [17] "is_deprecated"                "ot:dataDeposit"              
 ## [19] "ot:candidateTreeForSynthesis"</code></pre>
 <p>We have <code>ottIds</code> for our taxa, so let’s use those IDs to search for trees that contain them. Starting with our first species <em>Tetrahymena thermophila</em> we can use <code>studies_find_trees</code> to do this search.</p>
@@ -232,7 +232,7 @@ mu$ott_id <-<span class="st"> </span>taxon_search$ott_id</code></pre></div>
 <p>Using the default arguments you can get a tree object into your R session:</p>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tr <-<span class="st"> </span><span class="kw">tol_induced_subtree</span>(<span class="dt">ott_ids=</span>mu$ott_id)
 <span class="kw">plot</span>(tr)</code></pre></div>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGACAMAAABFpiBcAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGACAMAAABFpiBcAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
 </div>
 <div id="connect-your-data-to-the-tips-of-your-tree" class="section level3">
 <h3>Connect your data to the tips of your tree</h3>
@@ -241,7 +241,7 @@ mu$ott_id <-<span class="st"> </span>taxon_search$ott_id</code></pre></div>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">mu$ott_name[<span class="dv">1</span>]</code></pre></div>
 <pre><code>## [1] "Tetrahymena thermophila"</code></pre>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tr$tip.label[<span class="dv">4</span>]</code></pre></div>
-<pre><code>## [1] "Chlamydomonas_reinhardtii_ott33153"</code></pre>
+<pre><code>## [1] "Dictyostelium_discoideum_ott160850"</code></pre>
 <p><code>rotl</code> provides a convienence function <code>strip_ott_ids</code> to deal with these.</p>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tr$tip.label <-<span class="st"> </span><span class="kw">strip_ott_ids</span>(tr$tip.label, <span class="dt">remove_underscores=</span><span class="ot">TRUE</span>)
 tr$tip.label %in%<span class="st"> </span>mu$ott_name</code></pre></div>
@@ -253,7 +253,7 @@ mu_numeric <-<span class="st"> </span>mu[,<span class="kw">c</span>(<span cla
 tree_data <-<span class="st"> </span><span class="kw">phylo4d</span>(tr, mu_numeric)</code></pre></div>
 <p>And now we can plot the data and the tree together</p>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">plot</span>(tree_data)</code></pre></div>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAHgCAMAAABNUi8GAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAHgCAMAAABNUi8GAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
 </div>
 </div>
 <div id="find-external-data-associated-with-studies-trees-and-taxa-from-open-tree" class="section level2">
@@ -274,7 +274,7 @@ extra_data</code></pre></div>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(rentrez)
 seqs <-<span class="st"> </span><span class="kw">entrez_fetch</span>(<span class="dt">db=</span><span class="st">"nucleotide"</span>, <span class="dt">id=</span>extra_data$nucleotide_ids[<span class="dv">1</span>:<span class="dv">2</span>], <span class="dt">rettype=</span><span class="st">"fasta"</span>)
 <span class="kw">cat</span>(seqs)</code></pre></div>
-<pre><code>## >gi|111606994|emb|AM181011.1| Plectroninia neocaledoniense partial 28S rRNA gene, specimen voucher G316300 (Queensland Museum)
+<pre><code>## >AM181011.1 Plectroninia neocaledoniense partial 28S rRNA gene, specimen voucher G316300 (Queensland Museum)
 ## GCTAGCAAGCGCGTCGGTGGTTCAGCCGGCTGGTCTCGTCGAGTTGTCGGTGTGCGGATCCGAACGGACC
 ## GCGGCCGATGGCGTCGGCGGGCAAGCTGTGGTGCACTCTGTCGGCGTGCGCGTCAGCGTCGGTTTCGGCC
 ## GGACGACGAGGCGCTCGGGGAAGGTAGCTGGACCGGTCTTCGGTGCAGTGTTATAGCCCTGGGCCGCTGG
@@ -301,7 +301,7 @@ seqs <-<span class="st"> </span><span class="kw">entrez_fetch</span>(<span cl
 ## TGTCCGGTGCGCTCTCGACGGCCCTTGAAAATCGCAGGTGTGCATCGATTCTCGCATCCGGTCGTACTCA
 ## TAACCGCATCAGGTCTCCAAGGT
 ## 
-## >gi|111606993|emb|AM181010.1| Eilhardia schulzei partial 28S rRNA gene, specimen voucher G316071 (Queensland Museum)
+## >AM181010.1 Eilhardia schulzei partial 28S rRNA gene, specimen voucher G316071 (Queensland Museum)
 ## GCTAGTAATGTACGTTGGTGGTTCAGCCGGCTAGTCTTGTCGAGTCGTCGTGTGGTGGATCCGACTGGAC
 ## CGTCCGCGGTGGTGTCGGCGGGCGAGCTGTGGTGCACTCTACGGACGTGCGCGTCAGCGTCGGTTCTCGA
 ## TGGGCGATAAGGTGCGTGGGGGAAGGTGGCTCGGTCCTTGGGAACTGAGTGTTACAGACCCTGGTGCTGG
diff --git a/inst/doc/how-to-use-rotl.R b/inst/doc/how-to-use-rotl.R
index 176e721..6c41a26 100644
--- a/inst/doc/how-to-use-rotl.R
+++ b/inst/doc/how-to-use-rotl.R
@@ -60,16 +60,21 @@ giant_squid <- tnrs_match_names("Architeuthis")
 tax_lineage(taxonomy_taxon_info(ott_id(giant_squid), include_lineage = TRUE))
 
 ## ------------------------------------------------------------------------
-turducken <- c("Meleagris", "Anas", "Gallus")
+turducken <- c("Meleagris", "Anas", "Gallus", "Sus")
 taxa <- tnrs_match_names(turducken, context="Animals")
 taxa
 
-## ---- eval=FALSE---------------------------------------------------------
-#  tr <- tol_induced_subtree(taxa$ott_id)
+## ---- error=TRUE---------------------------------------------------------
+tr <- tol_induced_subtree(ott_id(taxa))
+
+## ------------------------------------------------------------------------
+in_tree <- is_in_tree(ott_id(taxa))
+in_tree
+tr <- tol_induced_subtree(ott_id(taxa)[in_tree])
 
 ## ---- fig.width=7, fig.height=4------------------------------------------
-turducken_spp <- c("Meleagris gallopavo", "Anas platyrhynchos", "Gallus gallus")
+turducken_spp <- c("Meleagris gallopavo", "Anas platyrhynchos", "Gallus gallus", "Sus scrofa")
 taxa <- tnrs_match_names(turducken_spp, context="Animals")
-tr <- tol_induced_subtree(taxa$ott_id)
+tr <- tol_induced_subtree(ott_id(taxa))
 plot(tr)
 
diff --git a/inst/doc/how-to-use-rotl.Rmd b/inst/doc/how-to-use-rotl.Rmd
index 77c9d88..8755acc 100644
--- a/inst/doc/how-to-use-rotl.Rmd
+++ b/inst/doc/how-to-use-rotl.Rmd
@@ -249,35 +249,51 @@ resolution service are not part of the Open Tree's synthesis tree. These are
 usually traditional higher-level taxa that have been found to be paraphyletic.
 
 For instance, if you wanted to fetch a tree relating the three birds that go
-into a [Turkducken](https://en.wikipedia.org/wiki/Turducken) you might search
-for the turkey, duck, and chicken genera:
+into a [Turkducken](https://en.wikipedia.org/wiki/Turducken) as well as the pork
+used for stuffing, you might search for the turkey, duck, chicken, and pork
+genera:
 
 ```{r}
-turducken <- c("Meleagris", "Anas", "Gallus")
+turducken <- c("Meleagris", "Anas", "Gallus", "Sus")
 taxa <- tnrs_match_names(turducken, context="Animals")
 taxa
 ```
-So, we have IDs for each genus but those messages in the `flag` column look
-concerning. `BARREN` means these taxa have no descendants and
-`MAJOR_RANK_CONFLICT` refers to inconsitancies between the rank of these taxa
-and some of their relatives. For thtese reasons, _Meleagris_ and _Anas_ are not
-included in the synthetic tree.
 
-If we tried to press on ahead with the IDs that we have, we'd get an
-error (because there are too few good IDs) or a tree with fewer tips that we had
-anticipated.
+We have the OTT ids for each genus, however, if we tried to get the induced
+subtree from these results, we would get an error:
 
-```{r, eval=FALSE}
-tr <- tol_induced_subtree(taxa$ott_id)
+```{r, error=TRUE}
+tr <- tol_induced_subtree(ott_id(taxa))
+```
+
+As the error message suggests, some of the taxa are not found in the synthetic
+tree. This occurs for 2 main reasons: either the taxa is invalid, or it is part
+of a group that is not monophyletic in the synthetic tree. There are two ways to
+get around this issue: (1) removing the taxa that are not part of the Open Tree;
+(2) using the complete species name.
+
+#### Removing the taxa missing from the synthetic tree
+
+To help with this situation, `rotl` provides a way to identify the OTT ids that
+are not part of the synthetic tree. The function `is_in_tree()` takes the output
+of the `ott_id()` function and returns a vector of logical indicating whether
+the taxa are part of the synthetic tree. We can then use to only keep the taxa that appear in the synthetic tree:
+
+```{r}
+in_tree <- is_in_tree(ott_id(taxa))
+in_tree
+tr <- tol_induced_subtree(ott_id(taxa)[in_tree])
 ```
 
+#### Using the full taxonomic names
+
 The best way to avoid these problems is to specify complete species names
 (species being the lowest level of classification in the Open Tree taxonomy they
 are guaranteed to be monophyletic):
 
 ```{r, fig.width=7, fig.height=4}
-turducken_spp <- c("Meleagris gallopavo", "Anas platyrhynchos", "Gallus gallus")
+turducken_spp <- c("Meleagris gallopavo", "Anas platyrhynchos", "Gallus gallus", "Sus scrofa")
 taxa <- tnrs_match_names(turducken_spp, context="Animals")
-tr <- tol_induced_subtree(taxa$ott_id)
+tr <- tol_induced_subtree(ott_id(taxa))
 plot(tr)
 ```
diff --git a/inst/doc/how-to-use-rotl.html b/inst/doc/how-to-use-rotl.html
index e5dce8d..5dee09b 100644
--- a/inst/doc/how-to-use-rotl.html
+++ b/inst/doc/how-to-use-rotl.html
@@ -12,7 +12,7 @@
 
 <meta name="author" content="François Michonneau" />
 
-<meta name="date" content="2016-09-19" />
+<meta name="date" content="2017-03-03" />
 
 <title>How to use rotl?</title>
 
@@ -70,7 +70,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
 
 <h1 class="title toc-ignore">How to use rotl?</h1>
 <h4 class="author"><em>François Michonneau</em></h4>
-<h4 class="date"><em>2016-09-19</em></h4>
+<h4 class="date"><em>2017-03-03</em></h4>
 
 
 
@@ -86,26 +86,26 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
 <table>
 <thead>
 <tr class="header">
-<th align="left">Service</th>
-<th align="left"><code>rotl</code> prefix</th>
+<th>Service</th>
+<th><code>rotl</code> prefix</th>
 </tr>
 </thead>
 <tbody>
 <tr class="odd">
-<td align="left">Tree of Life</td>
-<td align="left"><code>tol_</code></td>
+<td>Tree of Life</td>
+<td><code>tol_</code></td>
 </tr>
 <tr class="even">
-<td align="left">TNRS</td>
-<td align="left"><code>tnrs_</code></td>
+<td>TNRS</td>
+<td><code>tnrs_</code></td>
 </tr>
 <tr class="odd">
-<td align="left">Taxonomy</td>
-<td align="left"><code>taxonomy_</code></td>
+<td>Taxonomy</td>
+<td><code>taxonomy_</code></td>
 </tr>
 <tr class="even">
-<td align="left">Studies</td>
-<td align="left"><code>studies_</code></td>
+<td>Studies</td>
+<td><code>studies_</code></td>
 </tr>
 </tbody>
 </table>
@@ -157,9 +157,9 @@ resolved_names <-<span class="st"> </span><span class="kw">tnrs_match_names</
 </tr>
 <tr class="odd">
 <td align="left">diadema</td>
-<td align="left">Diadema (genus in Holozoa)</td>
+<td align="left">Diadema (genus in Nucletmycea)</td>
 <td align="left">FALSE</td>
-<td align="left">631176</td>
+<td align="left">4930522</td>
 <td align="left">FALSE</td>
 <td align="left"></td>
 <td align="left">3</td>
@@ -184,7 +184,7 @@ resolved_names <-<span class="st"> </span><span class="kw">tnrs_match_names</
 <p>Now that we have the correct <code>ott_id</code> for our taxa, we can ask for the tree using the <code>tol_induced_subtree()</code> function. By default, the object returned by <code>tol_induced_subtree</code> is a phylo object (from the <a href="https://cran.r-project.org/package=ape">ape</a> package), so we can plot it directly.</p>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">my_tree <-<span class="st"> </span><span class="kw">tol_induced_subtree</span>(<span class="dt">ott_ids =</span> resolved_names$ott_id)
 <span class="kw">plot</span>(my_tree, <span class="dt">no.margin=</span><span class="ot">TRUE</span>)</code></pre></div>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGACAMAAABFpiBcAAAC/VBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGACAMAAABFpiBcAAAC91BMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
 </div>
 </div>
 <div id="faq" class="section level2">
@@ -196,11 +196,11 @@ resolved_names <-<span class="st"> </span><span class="kw">tnrs_match_names</
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">taxa <-<span class="st"> </span><span class="kw">c</span>(<span class="st">"Hyla"</span>, <span class="st">"Salmo"</span>, <span class="st">"Diadema"</span>, <span class="st">"Nautilus"</span>)
 resolved_names <-<span class="st"> </span><span class="kw">tnrs_match_names</span>(taxa)
 resolved_names</code></pre></div>
-<pre><code>##   search_string                unique_name approximate_match  ott_id
-## 1          hyla                       Hyla             FALSE 1062216
-## 2         salmo                      Salmo             FALSE  982359
-## 3       diadema Diadema (genus in Holozoa)             FALSE  631176
-## 4      nautilus                   Nautilus             FALSE  616358
+<pre><code>##   search_string                    unique_name approximate_match  ott_id
+## 1          hyla                           Hyla             FALSE 1062216
+## 2         salmo                          Salmo             FALSE  982359
+## 3       diadema Diadema (genus in Nucletmycea)             FALSE 4930522
+## 4      nautilus                       Nautilus             FALSE  616358
 ##   is_synonym flags number_matches
 ## 1      FALSE                    1
 ## 2      FALSE                    1
@@ -208,8 +208,8 @@ resolved_names</code></pre></div>
 ## 4      FALSE                    1</code></pre>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">inspect</span>(resolved_names, <span class="dt">taxon_name =</span> <span class="st">"diadema"</span>)</code></pre></div>
 <pre><code>##   search_string                    unique_name approximate_match  ott_id
-## 1       diadema     Diadema (genus in Holozoa)             FALSE  631176
-## 2       diadema Diadema (genus in Nucletmycea)             FALSE 4930522
+## 1       diadema Diadema (genus in Nucletmycea)             FALSE 4930522
+## 2       diadema     Diadema (genus in Holozoa)             FALSE  631176
 ## 3       diadema                     Hypolimnas             FALSE  643831
 ##   is_synonym flags number_matches
 ## 1      FALSE                    3
@@ -256,9 +256,9 @@ resolved_names</code></pre></div>
 </tr>
 <tr class="odd">
 <td align="left">diadema</td>
-<td align="left">Diadema (genus in Nucletmycea)</td>
+<td align="left">Diadema (genus in Holozoa)</td>
 <td align="left">FALSE</td>
-<td align="left">4930522</td>
+<td align="left">631176</td>
 <td align="left">FALSE</td>
 <td align="left"></td>
 <td align="left">3</td>
@@ -341,9 +341,12 @@ diadema_tax_tree</code></pre></div>
 <h3>How do I get the tree for a particular taxonomic group?</h3>
 <p>If you are looking to get the tree for a particular taxonomic group, you need to first identify it by its node id or ott id, and then use the <code>tol_subtree()</code> function:</p>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">mono_id <-<span class="st"> </span><span class="kw">tnrs_match_names</span>(<span class="st">"Monotremata"</span>)
-mono_tree <-<span class="st"> </span><span class="kw">tol_subtree</span>(<span class="dt">ott_id =</span> <span class="kw">ott_id</span>(mono_id))
-<span class="kw">plot</span>(mono_tree)</code></pre></div>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGACAMAAABFpiBcAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+mono_tree <-<span class="st"> </span><span class="kw">tol_subtree</span>(<span class="dt">ott_id =</span> <span class="kw">ott_id</span>(mono_id))</code></pre></div>
+<pre><code>## Warning in collapse_singles(tr): Dropping singleton nodes with labels:
+## Ornithorhynchidae ott344066, Ornithorhynchus ott962391, Tachyglossus
+## ott16047, Tachyglossus aculeatus ott16038</code></pre>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">plot</span>(mono_tree)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGACAMAAABFpiBcAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
 </div>
 <div id="how-do-i-find-trees-from-studies-focused-on-my-favourite-taxa" class="section level3">
 <h3>How do I find trees from studies focused on my favourite taxa?</h3>
@@ -406,27 +409,44 @@ tr <-<span class="st"> </span>ape::<span class="kw">read.tree</span>(<span cl
 <div id="why-are-ott-ids-discovered-with-rotl-missing-from-an-induced-subtree" class="section level3">
 <h3>Why are OTT IDs discovered with <code>rotl</code> missing from an induced subtree?</h3>
 <p>Some taxonomic names that can be retrieved through the taxonomic name resolution service are not part of the Open Tree’s synthesis tree. These are usually traditional higher-level taxa that have been found to be paraphyletic.</p>
-<p>For instance, if you wanted to fetch a tree relating the three birds that go into a <a href="https://en.wikipedia.org/wiki/Turducken">Turkducken</a> you might search for the turkey, duck, and chicken genera:</p>
-<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">turducken <-<span class="st"> </span><span class="kw">c</span>(<span class="st">"Meleagris"</span>, <span class="st">"Anas"</span>, <span class="st">"Gallus"</span>)
+<p>For instance, if you wanted to fetch a tree relating the three birds that go into a <a href="https://en.wikipedia.org/wiki/Turducken">Turkducken</a> as well as the pork used for stuffing, you might search for the turkey, duck, chicken, and pork genera:</p>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">turducken <-<span class="st"> </span><span class="kw">c</span>(<span class="st">"Meleagris"</span>, <span class="st">"Anas"</span>, <span class="st">"Gallus"</span>, <span class="st">"Sus"</span>)
 taxa <-<span class="st"> </span><span class="kw">tnrs_match_names</span>(turducken, <span class="dt">context=</span><span class="st">"Animals"</span>)
 taxa</code></pre></div>
 <pre><code>##   search_string unique_name approximate_match ott_id is_synonym flags
 ## 1     meleagris   Meleagris             FALSE 446481      FALSE      
 ## 2          anas        Anas             FALSE 765185      FALSE      
 ## 3        gallus      Gallus             FALSE 153562      FALSE      
+## 4           sus         Sus             FALSE 730021      FALSE      
 ##   number_matches
 ## 1              2
 ## 2              1
-## 3              4</code></pre>
-<p>So, we have IDs for each genus but those messages in the <code>flag</code> column look concerning. <code>BARREN</code> means these taxa have no descendants and <code>MAJOR_RANK_CONFLICT</code> refers to inconsitancies between the rank of these taxa and some of their relatives. For thtese reasons, <em>Meleagris</em> and <em>Anas</em> are not included in the synthetic tree.</p>
-<p>If we tried to press on ahead with the IDs that we have, we’d get an error (because there are too few good IDs) or a tree with fewer tips that we had anticipated.</p>
-<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tr <-<span class="st"> </span><span class="kw">tol_induced_subtree</span>(taxa$ott_id)</code></pre></div>
+## 3              3
+## 4              1</code></pre>
+<p>We have the OTT ids for each genus, however, if we tried to get the induced subtree from these results, we would get an error:</p>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tr <-<span class="st"> </span><span class="kw">tol_induced_subtree</span>(<span class="kw">ott_id</span>(taxa))</code></pre></div>
+<pre><code>## Error: HTTP failure: 400
+## The following OTT ids were not found: [765185]. BadIdsExceptionopentree.plugins.BadIdsExceptionlist("opentree.plugins.tree_of_life_v3.doInducedSubtree(tree_of_life_v3.java:516)", "opentree.plugins.tree_of_life_v3.induced_subtree(tree_of_life_v3.java:400)", "java.lang.reflect.Method.invoke(Method.java:498)", "org.neo4j.server.plugins.PluginMethod.invoke(PluginMethod.java:57)", "org.neo4j.server.plugins.PluginManager.invoke(PluginManager.java [...]
+##     "java.lang.reflect.Method.invoke(Method.java:498)", "org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)")</code></pre>
+<p>As the error message suggests, some of the taxa are not found in the synthetic tree. This occurs for 2 main reasons: either the taxa is invalid, or it is part of a group that is not monophyletic in the synthetic tree. There are two ways to get around this issue: (1) removing the taxa that are not part of the Open Tree; (2) using the complete species name.</p>
+<div id="removing-the-taxa-missing-from-the-synthetic-tree" class="section level4">
+<h4>Removing the taxa missing from the synthetic tree</h4>
+<p>To help with this situation, <code>rotl</code> provides a way to identify the OTT ids that are not part of the synthetic tree. The function <code>is_in_tree()</code> takes the output of the <code>ott_id()</code> function and returns a vector of logical indicating whether the taxa are part of the synthetic tree. We can then use to only keep the taxa that appear in the synthetic tree:</p>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">in_tree <-<span class="st"> </span><span class="kw">is_in_tree</span>(<span class="kw">ott_id</span>(taxa))
+in_tree</code></pre></div>
+<pre><code>## Meleagris      Anas    Gallus       Sus 
+##      TRUE     FALSE      TRUE      TRUE</code></pre>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tr <-<span class="st"> </span><span class="kw">tol_induced_subtree</span>(<span class="kw">ott_id</span>(taxa)[in_tree])</code></pre></div>
+</div>
+<div id="using-the-full-taxonomic-names" class="section level4">
+<h4>Using the full taxonomic names</h4>
 <p>The best way to avoid these problems is to specify complete species names (species being the lowest level of classification in the Open Tree taxonomy they are guaranteed to be monophyletic):</p>
-<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">turducken_spp <-<span class="st"> </span><span class="kw">c</span>(<span class="st">"Meleagris gallopavo"</span>, <span class="st">"Anas platyrhynchos"</span>, <span class="st">"Gallus gallus"</span>)
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">turducken_spp <-<span class="st"> </span><span class="kw">c</span>(<span class="st">"Meleagris gallopavo"</span>, <span class="st">"Anas platyrhynchos"</span>, <span class="st">"Gallus gallus"</span>, <span class="st">"Sus scrofa"</span>)
 taxa <-<span class="st"> </span><span class="kw">tnrs_match_names</span>(turducken_spp, <span class="dt">context=</span><span class="st">"Animals"</span>)
-tr <-<span class="st"> </span><span class="kw">tol_induced_subtree</span>(taxa$ott_id)
+tr <-<span class="st"> </span><span class="kw">tol_induced_subtree</span>(<span class="kw">ott_id</span>(taxa))
 <span class="kw">plot</span>(tr)</code></pre></div>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGACAMAAABFpiBcAAAC/VBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAGACAMAAABFpiBcAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+</div>
 </div>
 </div>
 
diff --git a/inst/doc/meta-analysis.R b/inst/doc/meta-analysis.R
index 9433e7a..da43ecd 100644
--- a/inst/doc/meta-analysis.R
+++ b/inst/doc/meta-analysis.R
@@ -1,8 +1,7 @@
 ## ----egg_data, cache=TRUE------------------------------------------------
 library(rotl)
-library(fulltext)
 
-if (require(readxl)) {
+if (require(readxl) && require(fulltext)) {
     doi <- "10.1111/jeb.12282"
     xl_file <- ft_get_si(doi, 1, save.name="egg.xls")
     egg_data <- read_excel(xl_file)
diff --git a/inst/doc/meta-analysis.Rmd b/inst/doc/meta-analysis.Rmd
index 0ff201a..b7bacf4 100644
--- a/inst/doc/meta-analysis.Rmd
+++ b/inst/doc/meta-analysis.Rmd
@@ -45,9 +45,8 @@ papers DOI as input) and read it into memory with `gdata`:
 
 ```{r egg_data, cache=TRUE}
 library(rotl)
-library(fulltext)
 
-if (require(readxl)) {
+if (require(readxl) && require(fulltext)) {
     doi <- "10.1111/jeb.12282"
     xl_file <- ft_get_si(doi, 1, save.name="egg.xls")
     egg_data <- read_excel(xl_file)
@@ -226,6 +225,6 @@ There are an ever-growing number of packages that allow an ever-growing number
 of analysis to performed in R. Some "classics" like ancestral state
 reconstruction,  phylogenetic independent contrasts and lineage through time plots
 are implemented in `ape`. Packages like `phytools`, `caper` and `diversitree`
-provide extensions to these methods.  The [CRAN Phylogenetics Taskview](https://cran.r-project.org/web/views/Phylogenetics.html)
+provide extensions to these methods.  The [CRAN Phylogenetics Taskview](https://CRAN.R-project.org/view=Phylogenetics)
 gives a good idea of the diversity of packages and analyses that can be
 completed in R.
diff --git a/inst/doc/meta-analysis.html b/inst/doc/meta-analysis.html
index e2c1bf1..157318d 100644
--- a/inst/doc/meta-analysis.html
+++ b/inst/doc/meta-analysis.html
@@ -12,7 +12,7 @@
 
 <meta name="author" content="David Winter" />
 
-<meta name="date" content="2016-09-19" />
+<meta name="date" content="2017-03-03" />
 
 <title>Using the Open Tree synthesis in a comparative analysis</title>
 
@@ -70,7 +70,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
 
 <h1 class="title toc-ignore">Using the Open Tree synthesis in a comparative analysis</h1>
 <h4 class="author"><em>David Winter</em></h4>
-<h4 class="date"><em>2016-09-19</em></h4>
+<h4 class="date"><em>2017-03-03</em></h4>
 
 
 
@@ -87,9 +87,8 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
 <h3>Gather the data</h3>
 <p>If we are going to reproduce this analysis, we will first need to gather the data. Thankfully, the data is available as supplementary material from the publisher’s website. We can collect the data from using <code>fulltext</code> (with the papers DOI as input) and read it into memory with <code>gdata</code>:</p>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(rotl)
-<span class="kw">library</span>(fulltext)
 
-if (<span class="kw">require</span>(readxl)) {
+if (<span class="kw">require</span>(readxl) &&<span class="st"> </span><span class="kw">require</span>(fulltext)) {
     doi <-<span class="st"> "10.1111/jeb.12282"</span>
     xl_file <-<span class="st"> </span><span class="kw">ft_get_si</span>(doi, <span class="dv">1</span>, <span class="dt">save.name=</span><span class="st">"egg.xls"</span>)
     egg_data <-<span class="st"> </span><span class="kw">read_excel</span>(xl_file)
@@ -97,6 +96,7 @@ if (<span class="kw">require</span>(readxl)) {
     egg_data <-<span class="st"> </span><span class="kw">read.csv</span>(<span class="kw">system.file</span>(<span class="st">"extdata"</span>, <span class="st">"egg.csv"</span>, <span class="dt">package =</span> <span class="st">"rotl"</span>))
 }</code></pre></div>
 <pre><code>## Loading required package: readxl</code></pre>
+<pre><code>## Loading required package: fulltext</code></pre>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">head</span>(egg_data)</code></pre></div>
 <pre><code>## # A tibble: 6 × 14
 ##                   animal                   Spp       Lndim Measure Neggs
@@ -114,7 +114,7 @@ if (<span class="kw">require</span>(readxl)) {
      <span class="dt">ylab=</span><span class="st">"Effect size (Zr)"</span>,
      <span class="dt">xlab=</span><span class="st">"Precision (1/SE)"</span>,
      <span class="dt">main=</span><span class="st">"Effect sizes for sex bias in egg size among 51 brid species"</span> )</code></pre></div>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkAAAAEgCAMAAABrWDzDAAAC/VBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkAAAAEgCAMAAABrWDzDAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
 <p>In order to use this data later on we need to first convert it to a standard <code>data.frame</code>. We can also convert the <code>animal</code> column (the species names) to lower case which will make it easier to match names later on:</p>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">egg_data <-<span class="st"> </span><span class="kw">as.data.frame</span>(egg_data)
 egg_data$animal <-<span class="st"> </span><span class="kw">tolower</span>(egg_data$animal)</code></pre></div>
@@ -150,12 +150,12 @@ egg_data$animal <-<span class="st"> </span><span class="kw">tolower</span>(eg
 <p>Now we can get the tree. There are really too many tips here to show nicely, so we will leave them out of this plot</p>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tr <-<span class="st"> </span><span class="kw">tol_induced_subtree</span>(taxa$ott_id)
 <span class="kw">plot</span>(tr, <span class="dt">show.tip.label=</span><span class="ot">FALSE</span>)</code></pre></div>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAHgCAMAAABKCk6nAAACoFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM1NTU2NjY3Nzc4ODg7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NVVVVWVlZXV1dZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZGRlZWVmZmZnZ2doaGhpaWlqa [...]
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAHgCAMAAABKCk6nAAACo1BMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiosLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1fX19gYGBhYWFiYmJjY2NkZGRlZWVmZmZnZ2doa [...]
 <p>There are a few things to note here. First, the tree has not branch lengths. At present this is true for the whole of the Open Tree synthetic tree. Some comparative methods require either branch lengths or an ultrametric tree. Before you can use one of those methods you will need to get a tree with branch lengths. You could try looking for published trees made available by the Open Tree with <code>studies_find_trees</code>. Alternatively, you could estimate branch lengths from the top [...]
 <p>Second, the tip labels contain OTT IDs, which means they will not perfectly match the species names in our dataset or the taxon map that we created earlier:</p>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tr$tip.label[<span class="dv">1</span>:<span class="dv">4</span>]</code></pre></div>
-<pre><code>## [1] "Sturnus_vulgaris_ott565813"    "Sturnus_unicolor_ott366470"   
-## [3] "Luscinia_svecica_ott274225"    "Ficedula_albicollis_ott107840"</code></pre>
+<pre><code>## [1] "Erythrura_gouldiae_ott465909"    "Taeniopygia_guttata_ott708327"  
+## [3] "Lonchura_striata_ott306760"      "Molothrus_bonariensis_ott213451"</code></pre>
 <p>Finally, the tree contains node labels for those nodes that match a higher taxonomic group, and empty character vectors (<code>""</code>) for all other nodes. Some comparative methods either do no expect node labels at all, or require all labeled nodes to have a unique name (meaning multiple “empty” labels will cause and error).</p>
 <p>We can deal with all these details easily. <code>rotl</code> provides the convenience function <code>strip_ott_ids</code> to remove the extra information from the tip labels. With the IDs removed, we can use our taxon map to replace the tip labels in the tree with the species names from dataset.</p>
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">otl_tips <-<span class="st"> </span><span class="kw">strip_ott_ids</span>(tr$tip.label, <span class="dt">remove_underscores=</span><span class="ot">TRUE</span>)
@@ -191,13 +191,13 @@ model <-<span class="st"> </span><span class="kw">MCMCglmm</span>(Zr~<span cl
 <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">var_comps <-<span class="st"> </span><span class="kw">colMeans</span>(model$VCV )
 var_comps[<span class="st">"animal"</span>] /<span class="st"> </span><span class="kw">sum</span>(var_comps)</code></pre></div>
 <pre><code>##      animal 
-## 0.002809591</code></pre>
+## 0.003066892</code></pre>
 <p>It appears there is almost no phylogenetic signal to the data. The relationships among species explain much less that one percent of the total variance in the data. If you were wondering, Rutkowska <em>et al</em>. report a similar result, even after adding more predictors to their model most of the variance in <code>Zr</code> was left unexplained.</p>
 </div>
 </div>
 <div id="what-other-comparative-methods-can-i-use-in-r" class="section level2">
 <h2>What other comparative methods can I use in R?</h2>
-<p>Here we have demonstrated just one comparative analysis that you might do in R. There are an ever-growing number of packages that allow an ever-growing number of analysis to performed in R. Some “classics” like ancestral state reconstruction, phylogenetic independent contrasts and lineage through time plots are implemented in <code>ape</code>. Packages like <code>phytools</code>, <code>caper</code> and <code>diversitree</code> provide extensions to these methods. The <a href="https:// [...]
+<p>Here we have demonstrated just one comparative analysis that you might do in R. There are an ever-growing number of packages that allow an ever-growing number of analysis to performed in R. Some “classics” like ancestral state reconstruction, phylogenetic independent contrasts and lineage through time plots are implemented in <code>ape</code>. Packages like <code>phytools</code>, <code>caper</code> and <code>diversitree</code> provide extensions to these methods. The <a href="https:// [...]
 </div>
 
 
diff --git a/inst/extdata/protist_mutation_rates.csv b/inst/extdata/protist_mutation_rates.csv
old mode 100755
new mode 100644
diff --git a/man/get_study.Rd b/man/get_study.Rd
index 8d625a2..ed61618 100644
--- a/man/get_study.Rd
+++ b/man/get_study.Rd
@@ -57,4 +57,3 @@ if (require(RNeXML)) { ## if RNeXML is installed get the object directly
 \seealso{
 \code{\link{get_study_meta}}
 }
-
diff --git a/man/get_study_meta.Rd b/man/get_study_meta.Rd
index debb7c6..0c4b14f 100644
--- a/man/get_study_meta.Rd
+++ b/man/get_study_meta.Rd
@@ -1,15 +1,15 @@
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/studies-methods.R, R/studies.R
 \name{get_tree_ids}
-\alias{candidate_for_synth}
-\alias{candidate_for_synth.study_meta}
+\alias{get_tree_ids}
 \alias{get_publication}
-\alias{get_publication.study_meta}
-\alias{get_study_meta}
+\alias{candidate_for_synth}
 \alias{get_study_year}
-\alias{get_study_year.study_meta}
-\alias{get_tree_ids}
 \alias{get_tree_ids.study_meta}
+\alias{get_publication.study_meta}
+\alias{candidate_for_synth.study_meta}
+\alias{get_study_year.study_meta}
+\alias{get_study_meta}
 \title{Study Metadata}
 \usage{
 get_tree_ids(sm)
@@ -77,4 +77,3 @@ get_publication(req)
 get_study_year(req)
 }
 }
-
diff --git a/man/get_study_subtree.Rd b/man/get_study_subtree.Rd
index 45573d7..417b28e 100644
--- a/man/get_study_subtree.Rd
+++ b/man/get_study_subtree.Rd
@@ -5,7 +5,8 @@
 \title{Study Subtree}
 \usage{
 get_study_subtree(study_id, tree_id, subtree_id, object_format = c("phylo"),
-  file_format, file, ...)
+  tip_label = c("original_label", "ott_id", "ott_taxon_name"), file_format,
+  file, deduplicate = TRUE, ...)
 }
 \arguments{
 \item{study_id}{the study identifier (character)}
@@ -19,13 +20,28 @@ get_study_subtree(study_id, tree_id, subtree_id, object_format = c("phylo"),
 function (default, and currently only possibility \code{phylo}
 from the \code{\link[ape]{ape}} package)}
 
+\item{tip_label}{the format of the tip
+labels. \dQuote{\code{original_label}} (default) returns the
+original labels as provided in the study,
+\dQuote{\code{ott_id}} labels are replaced by their ott IDs,
+\dQuote{\code{ott_taxon_name}} labels are replaced by their
+Open Tree Taxonomy taxon name.}
+
 \item{file_format}{character, the file format to use to save the
-results of the query (possible values, \sQuote{newick},
-\sQuote{nexus}, \sQuote{json}).}
+results of the query (possible values, \sQuote{newick} or
+\sQuote{nexus}).}
 
 \item{file}{character, the path and file name where the output
 should be written.}
 
+\item{deduplicate}{logical (default \code{TRUE}). If the tree
+returned by the study contains duplicated taxon names, should
+they be made unique? It is normally illegal for NEXUS/Newick
+tree strings to contain duplicated tip names. This is a
+workaround to circumvent this requirement. If \code{TRUE},
+duplicated tip labels will be appended \code{_1}, \code{_2},
+etc.}
+
 \item{...}{additional arguments to customize the API request (see
 \code{\link{rotl}} package documentation).}
 }
@@ -34,11 +50,10 @@ Retrieve subtree from a specific tree in the Open Tree of Life data store
 }
 \examples{
 \dontrun{
-small_tr <- get_study_subtree(study_id="pg_1144", tree="tree2324", subtree_id="node552052")
-ingroup  <- get_study_subtree(study_id="pg_1144", tree="tree2324", subtree_id="ingroup")
+small_tr <- get_study_subtree(study_id="pg_1144", tree_id="tree5800", subtree_id="node991044")
+ingroup  <- get_study_subtree(study_id="pg_1144", tree_id="tree5800", subtree_id="ingroup")
 nexus_file <- tempfile(fileext=".nex")
-get_study_subtree(study_id="pg_1144", tree="tree2324", subtree_id="ingroup", file=nexus_file,
+get_study_subtree(study_id="pg_1144", tree_id="tree5800", subtree_id="ingroup", file=nexus_file,
                   file_format="nexus")
 }
 }
-
diff --git a/man/get_study_tree.Rd b/man/get_study_tree.Rd
index 8c3dcd5..ea852e1 100644
--- a/man/get_study_tree.Rd
+++ b/man/get_study_tree.Rd
@@ -50,12 +50,11 @@ Returns a specific tree from within a study
 }
 \examples{
 \dontrun{
- tree <- get_study_tree(study_id="pg_1144", tree="tree2324")
+ tree <- get_study_tree(study_id="pg_1144", tree_id="tree2324")
 
  ## comparison of the first few tip labels depending on the options used
- head(get_study_tree(study_id="pg_1144", tree="tree2324", tip_label="original_label")$tip.label)
- head(get_study_tree(study_id="pg_1144", tree="tree2324", tip_label="ott_id")$tip.label)
- head(get_study_tree(study_id="pg_1144", tree="tree2324", tip_label="ott_taxon_name")$tip.label)
+ head(get_study_tree(study_id="pg_1144", tree_id="tree2324", tip_label="original_label")$tip.label)
+ head(get_study_tree(study_id="pg_1144", tree_id="tree2324", tip_label="ott_id")$tip.label)
+ head(get_study_tree(study_id="pg_1144", tree_id="tree2324", tip_label="ott_taxon_name")$tip.label)
 }
 }
-
diff --git a/man/is_in_tree.Rd b/man/is_in_tree.Rd
new file mode 100644
index 0000000..e1aa9f1
--- /dev/null
+++ b/man/is_in_tree.Rd
@@ -0,0 +1,40 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/is_in_tree.R
+\name{is_in_tree}
+\alias{is_in_tree}
+\title{Check that OTT ids occur in the Synthetic Tree}
+\usage{
+is_in_tree(ott_ids, ...)
+}
+\arguments{
+\item{ott_ids}{a vector of Open Tree Taxonomy identifiers}
+
+\item{...}{additional arguments to customize the API request (see
+\code{\link{rotl}} package documentation).}
+}
+\value{
+A named logical vector. \code{TRUE} indicates that the OTT
+    id is in the synthetic tree, and \code{FALSE} that it is not.
+}
+\description{
+Some valid taxonomic names do not occur in the Synthetic
+Tree. This convenience function allows you to check whether a
+given Open Tree Taxonomy identifier (OTT id) is in the tree. A taxonomic
+name may not occur in the synthetic tree because (1) it is an
+extinct or invalid taxon, or (2) it is part of a group that is not
+monophyletic in the tree.
+}
+\examples{
+\dontrun{
+  plant_families <- c("Asteraceae", "Solanaceae", "Poaceae", "Amaranthaceae",
+                      "Zamiaceae", "Araceae", "Juncaceae")
+  matched_names <- tnrs_match_names(plant_families)
+  ## This fails because some ott ids are not in the tree
+  ## plant_tree <- tol_induced_subtree(ott_id(matched_names))
+  ## So let's check which ones are actually in the tree first:
+  in_tree <- is_in_tree(ott_id(matched_names))
+  ## This now works:
+  plant_tree <- tol_induced_subtree(ott_id(matched_names)[in_tree])
+}
+
+}
diff --git a/man/list_trees.Rd b/man/list_trees.Rd
index 822264e..d7ffa93 100644
--- a/man/list_trees.Rd
+++ b/man/list_trees.Rd
@@ -38,4 +38,3 @@ the search criteria when used on objects returned by
     \code{\link{studies_find_trees}}. The help for these functions
     have examples demonstrating the use of \code{list_trees}.
 }
-
diff --git a/man/match_names-methods.Rd b/man/match_names-methods.Rd
index 576e1f9..0894865 100644
--- a/man/match_names-methods.Rd
+++ b/man/match_names-methods.Rd
@@ -1,9 +1,9 @@
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/match_names.R, R/methods.R
 \name{ott_id.match_names}
-\alias{flags}
-\alias{flags.match_names}
 \alias{ott_id.match_names}
+\alias{flags.match_names}
+\alias{flags}
 \title{\code{ott_id} and \code{flags} for taxonomic names matched
     by \code{tnrs_match_names}}
 \usage{
@@ -57,4 +57,3 @@ returned by \code{\link{tnrs_match_names}}.
   flags(rsp, taxon_name="Tyrannosaurus")
 }
 }
-
diff --git a/man/match_names.Rd b/man/match_names.Rd
index 500fdb0..e64b530 100644
--- a/man/match_names.Rd
+++ b/man/match_names.Rd
@@ -1,8 +1,8 @@
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/match_names.R
 \name{inspect.match_names}
-\alias{inspect}
 \alias{inspect.match_names}
+\alias{inspect}
 \alias{update.match_names}
 \title{Inspect and Update alternative matches for a name returned
     by tnrs_match_names}
@@ -74,4 +74,3 @@ in which the name to be replaced appear or its ott id.
 \seealso{
 \code{\link{tnrs_match_names}}
 }
-
diff --git a/man/source_list.Rd b/man/source_list.Rd
index 5a6f5c1..a9009e3 100644
--- a/man/source_list.Rd
+++ b/man/source_list.Rd
@@ -28,4 +28,3 @@ This function takes the object resulting from
     \code{tree_id}, \code{study_id} and \code{git_sha} for the
     studies currently included in the Tree of Life.
 }
-
diff --git a/man/strip_ott_ids.Rd b/man/strip_ott_ids.Rd
index b140af6..e8a1ae3 100644
--- a/man/strip_ott_ids.Rd
+++ b/man/strip_ott_ids.Rd
@@ -29,4 +29,3 @@ tr$tip.label \%in\% genera
 tr$tip.label <- strip_ott_ids(tr$tip.label)
 tr$tip.label \%in\% genera}
 }
-
diff --git a/man/studies_find_studies.Rd b/man/studies_find_studies.Rd
index e6e8be9..bd37447 100644
--- a/man/studies_find_studies.Rd
+++ b/man/studies_find_studies.Rd
@@ -68,4 +68,3 @@ mammals <- studies_find_studies(property="ot:focalCladeOTTTaxonName",
     searched. \code{\link{list_trees}} that returns a list for all
     tree ids associated with a study.
 }
-
diff --git a/man/studies_find_trees.Rd b/man/studies_find_trees.Rd
index 8de6e59..75068a6 100644
--- a/man/studies_find_trees.Rd
+++ b/man/studies_find_trees.Rd
@@ -77,4 +77,3 @@ list_trees(res, study_id = "pg_2769")
   the studies can be searched on. \code{\link{list_trees}} for
   listing the trees that match the query.
 }
-
diff --git a/man/studies_properties.Rd b/man/studies_properties.Rd
index 837ead4..2b786d0 100644
--- a/man/studies_properties.Rd
+++ b/man/studies_properties.Rd
@@ -36,4 +36,3 @@ from
 \seealso{
 \code{\link{studies_find_trees}}
 }
-
diff --git a/man/study_external_IDs.Rd b/man/study_external_IDs.Rd
index 93933ec..6e6fdd7 100644
--- a/man/study_external_IDs.Rd
+++ b/man/study_external_IDs.Rd
@@ -40,4 +40,3 @@ study_external_IDs(flies[2,]$study_ids)
 \seealso{
 studies_find_studies (used to discover study IDs)
 }
-
diff --git a/man/synonyms.match_names.Rd b/man/synonyms.match_names.Rd
index 5f90b3a..da8566d 100644
--- a/man/synonyms.match_names.Rd
+++ b/man/synonyms.match_names.Rd
@@ -52,4 +52,3 @@ names are returned.
    synonyms(echino, ott_id=337928)
 }
 }
-
diff --git a/man/tax_lineage.Rd b/man/tax_lineage.Rd
index b6b255c..c5b1fbb 100644
--- a/man/tax_lineage.Rd
+++ b/man/tax_lineage.Rd
@@ -29,4 +29,3 @@ returned by \code{\link{taxonomy_taxon_info}}.
 The object passed to this function must have been created using
 the argument \code{include_lineage=TRUE}.
 }
-
diff --git a/man/taxon_external_IDs.Rd b/man/taxon_external_IDs.Rd
index 0ec2e8b..b232fc1 100644
--- a/man/taxon_external_IDs.Rd
+++ b/man/taxon_external_IDs.Rd
@@ -29,4 +29,3 @@ tnrs_matchnames, which can be used to search for taxa by name.
 
 taxonomy_taxon, for more information about a given taxon.
 }
-
diff --git a/man/taxonomy-methods.Rd b/man/taxonomy-methods.Rd
index f05da36..ffa5987 100644
--- a/man/taxonomy-methods.Rd
+++ b/man/taxonomy-methods.Rd
@@ -1,13 +1,13 @@
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/methods.R
 \name{tax_rank}
-\alias{is_suppressed}
+\alias{tax_rank}
 \alias{ott_id}
 \alias{synonyms}
-\alias{tax_name}
-\alias{tax_rank}
 \alias{tax_sources}
+\alias{is_suppressed}
 \alias{unique_name}
+\alias{tax_name}
 \title{Methods for Taxonomy}
 \usage{
 tax_rank(tax, ...)
@@ -40,4 +40,3 @@ This is the page for the generic methods. See the help pages for
 \code{\link{taxonomy_taxon_info}}, \code{\link{taxonomy_mrca}}, and
 \code{\link{tnrs_match_names}} for more information.
 }
-
diff --git a/man/taxonomy_about.Rd b/man/taxonomy_about.Rd
index 88f0a82..9756f42 100644
--- a/man/taxonomy_about.Rd
+++ b/man/taxonomy_about.Rd
@@ -41,4 +41,3 @@ complete taxonomy source files can be downloaded.
 taxonomy_about()
 }
 }
-
diff --git a/man/taxonomy_mrca.Rd b/man/taxonomy_mrca.Rd
index ca2bcfd..07e54bc 100644
--- a/man/taxonomy_mrca.Rd
+++ b/man/taxonomy_mrca.Rd
@@ -1,14 +1,14 @@
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/taxonomy.R
 \name{taxonomy_mrca}
-\alias{flags.taxon_mrca}
-\alias{is_suppressed.taxon_mrca}
-\alias{ott_id.taxon_mrca}
-\alias{tax_name.taxon_mrca}
-\alias{tax_rank.taxon_mrca}
-\alias{tax_sources.taxon_mrca}
 \alias{taxonomy_mrca}
+\alias{tax_rank.taxon_mrca}
+\alias{tax_name.taxon_mrca}
+\alias{ott_id.taxon_mrca}
 \alias{unique_name.taxon_mrca}
+\alias{tax_sources.taxon_mrca}
+\alias{flags.taxon_mrca}
+\alias{is_suppressed.taxon_mrca}
 \title{Taxonomic MRCA}
 \usage{
 taxonomy_mrca(ott_ids = NULL, ...)
@@ -70,4 +70,3 @@ tax_name(req)
 ott_id(req)
 }
 }
-
diff --git a/man/taxonomy_subtree.Rd b/man/taxonomy_subtree.Rd
index 1be019a..7db9a31 100644
--- a/man/taxonomy_subtree.Rd
+++ b/man/taxonomy_subtree.Rd
@@ -65,4 +65,3 @@ req <- taxonomy_subtree(ott_id=515698)
 plot(taxonomy_subtree(ott_id=515698, output_format="phylo"))
 }
 }
-
diff --git a/man/taxonomy_taxon_info.Rd b/man/taxonomy_taxon_info.Rd
index 7eeff4a..d0ac42f 100644
--- a/man/taxonomy_taxon_info.Rd
+++ b/man/taxonomy_taxon_info.Rd
@@ -1,15 +1,15 @@
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/taxonomy.R
 \name{taxonomy_taxon_info}
-\alias{flags.taxon_info}
-\alias{is_suppressed.taxon_info}
-\alias{ott_id.taxon_info}
-\alias{synonyms.taxon_info}
-\alias{tax_name.taxon_info}
-\alias{tax_rank.taxon_info}
-\alias{tax_sources.taxon_info}
 \alias{taxonomy_taxon_info}
+\alias{tax_rank.taxon_info}
+\alias{tax_name.taxon_info}
 \alias{unique_name.taxon_info}
+\alias{synonyms.taxon_info}
+\alias{ott_id.taxon_info}
+\alias{tax_sources.taxon_info}
+\alias{is_suppressed.taxon_info}
+\alias{flags.taxon_info}
 \title{Taxon information}
 \usage{
 taxonomy_taxon_info(ott_ids, include_children = FALSE,
@@ -82,4 +82,3 @@ synonyms(req)
 \code{\link{tnrs_match_names}} to obtain \code{ott_id}
     from a taxonomic name.
 }
-
diff --git a/man/tnrs_contexts.Rd b/man/tnrs_contexts.Rd
index 5fa0eef..96bec6d 100644
--- a/man/tnrs_contexts.Rd
+++ b/man/tnrs_contexts.Rd
@@ -29,4 +29,3 @@ used as input (via the \code{context_name} argument in other
 functions) to limit the search scope of other services including
 \code{\link{tnrs_match_names}}.
 }
-
diff --git a/man/tnrs_infer_context.Rd b/man/tnrs_infer_context.Rd
index 43d7964..a03e8e1 100644
--- a/man/tnrs_infer_context.Rd
+++ b/man/tnrs_infer_context.Rd
@@ -32,4 +32,3 @@ results.
 res <- tnrs_infer_context(names=c("Stellula calliope", "Struthio camelus"))
 }
 }
-
diff --git a/man/tnrs_match_names.Rd b/man/tnrs_match_names.Rd
index e7fd658..e835d7a 100644
--- a/man/tnrs_match_names.Rd
+++ b/man/tnrs_match_names.Rd
@@ -79,4 +79,3 @@ function.
     \code{\link{update.match_names}},
     \code{\link{synonyms.match_names}}.
 }
-
diff --git a/man/tol_about.Rd b/man/tol_about.Rd
index e27b95f..9830d8e 100644
--- a/man/tol_about.Rd
+++ b/man/tol_about.Rd
@@ -1,12 +1,12 @@
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/tol.R
 \name{tol_about}
-\alias{ott_id.tol_summary}
-\alias{tax_name.tol_summary}
+\alias{tol_about}
 \alias{tax_rank.tol_summary}
 \alias{tax_sources.tol_summary}
-\alias{tol_about}
 \alias{unique_name.tol_summary}
+\alias{tax_name.tol_summary}
+\alias{ott_id.tol_summary}
 \title{Information about the Tree of Life}
 \usage{
 tol_about(include_source_list = FALSE, ...)
@@ -120,4 +120,3 @@ studies <- source_list(tol_about(include_source_list=TRUE))}
 \code{\link{source_list}} to explore the list of studies
     used in the synthetic tree (see example).
 }
-
diff --git a/man/tol_induced_subtree.Rd b/man/tol_induced_subtree.Rd
index 6818bc5..7f2a875 100644
--- a/man/tol_induced_subtree.Rd
+++ b/man/tol_induced_subtree.Rd
@@ -47,4 +47,3 @@ tree_file <- tempfile(fileext=".tre")
 tol_induced_subtree(ott_ids=c(292466, 267845, 666104, 316878, 102710),
                     file=tree_file)}
 }
-
diff --git a/man/tol_mrca.Rd b/man/tol_mrca.Rd
index 7a09e15..c8832c2 100644
--- a/man/tol_mrca.Rd
+++ b/man/tol_mrca.Rd
@@ -1,13 +1,13 @@
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/tol.R
 \name{tol_mrca}
-\alias{ott_id.tol_mrca}
-\alias{source_list.tol_mrca}
-\alias{tax_name.tol_mrca}
-\alias{tax_rank.tol_mrca}
-\alias{tax_sources.tol_mrca}
 \alias{tol_mrca}
+\alias{tax_sources.tol_mrca}
 \alias{unique_name.tol_mrca}
+\alias{tax_name.tol_mrca}
+\alias{tax_rank.tol_mrca}
+\alias{ott_id.tol_mrca}
+\alias{source_list.tol_mrca}
 \title{MRCA of taxa from the synthetic tree}
 \usage{
 tol_mrca(ott_ids = NULL, node_ids = NULL, ...)
@@ -154,4 +154,3 @@ birds_mrca <- tol_mrca(ott_ids=c(412129, 536234))
 ott_id(birds_mrca)
 tax_sources(birds_mrca)}
 }
-
diff --git a/man/tol_node_info.Rd b/man/tol_node_info.Rd
index 83efc83..c1308d6 100644
--- a/man/tol_node_info.Rd
+++ b/man/tol_node_info.Rd
@@ -1,16 +1,16 @@
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/methods.R, R/tol.R
 \name{tol_lineage}
+\alias{tol_lineage}
+\alias{tol_node_info}
+\alias{tax_rank.tol_node}
+\alias{tax_sources.tol_node}
+\alias{unique_name.tol_node}
+\alias{tax_name.tol_node}
 \alias{ott_id.tol_node}
 \alias{source_list.tol_node}
 \alias{tax_lineage.tol_node}
-\alias{tax_name.tol_node}
-\alias{tax_rank.tol_node}
-\alias{tax_sources.tol_node}
-\alias{tol_lineage}
 \alias{tol_lineage.tol_node}
-\alias{tol_node_info}
-\alias{unique_name.tol_node}
 \title{Node info}
 \usage{
 tol_lineage(tax, ...)
@@ -143,4 +143,3 @@ ott_id(birds)
 tax_lineage(birds)
 tol_lineage(birds)}
 }
-
diff --git a/man/tol_subtree.Rd b/man/tol_subtree.Rd
index 569713a..192b87f 100644
--- a/man/tol_subtree.Rd
+++ b/man/tol_subtree.Rd
@@ -43,4 +43,3 @@ Given a node, return the subtree of the synthetic tree descended
 \dontrun{
 res <- tol_subtree(ott_id=241841)}
 }
-
diff --git a/tests/testthat/test-match_names.R b/tests/testthat/test-match_names.R
index 4d6f838..813c9e0 100644
--- a/tests/testthat/test-match_names.R
+++ b/tests/testthat/test-match_names.R
@@ -125,7 +125,7 @@ test_that("correct data is being returned when asked to lookup by taxon name", {
 
 test_that("correct data is being returned when asked to lookup by ott_id", {
     skip_on_cran()
-    tt <- inspect(rsp, ott_id = 631176)[["ott_id"]]
+    tt <- inspect(rsp, ott_id = ott_id(rsp)[2])[["ott_id"]]
     expect_true(all(tt %in% diadema_ids))
 })
 
@@ -146,7 +146,7 @@ test_that("correct data is being returned when asked to lookup by taxon name (wi
 
 test_that("correct data is being returned when asked to lookup by ott_id (with missing data)", {
     skip_on_cran()
-    tt <- inspect(rsp_na, ott_id = 631176)[["ott_id"]]
+    tt <- inspect(rsp_na, ott_id = ott_id(rsp)[2])[["ott_id"]]
     expect_true(all(tt %in% diadema_ids))
 })
 
@@ -179,7 +179,7 @@ test_that("synonyms", {
     tt <- synonyms(rsp)
     expect_true(inherits(tt, "list"))
     expect_equal(names(tt),
-                 c("Holothuria", "Diadema (genus in Holozoa)", "Fromia"))
+                 c("Holothuria", "Diadema (genus in Nucletmycea)", "Fromia"))
 })
 
 
@@ -219,7 +219,7 @@ test_that("synonyms", {
     tt <- synonyms(rsp_na)
     expect_true(inherits(tt, "list"))
     expect_equal(names(tt),
-                 c("Holothuria", "Diadema (genus in Holozoa)", "Fromia"))
+                 c("Holothuria", "Diadema (genus in Nucletmycea)", "Fromia"))
 })
 
 
@@ -294,16 +294,16 @@ test_that("it works correctly when providing a new row number", {
     new_rsp <- update(rsp, row_number = 2,
                       new_row_number = 2)
     expect_equal(new_rsp[new_rsp$search_string == "diadema", "ott_id"],
-                 "4930522")
+                 "631176")
 })
 
 
 test_that("it works correctly when providing a new ott id", {
     skip_on_cran()
     new_rsp <- update(rsp, row_number = 2,
-                      new_ott_id = 4930522)
+                      new_ott_id = 631176)
     expect_equal(new_rsp[new_rsp$search_string == "diadema", "ott_id"],
-                 "4930522")
+                 "631176")
 })
 
 test_that("it produces warning when trying to update with unmatched name", {
diff --git a/tests/testthat/test-studies.R b/tests/testthat/test-studies.R
index 1b7039f..16840bd 100644
--- a/tests/testthat/test-studies.R
+++ b/tests/testthat/test-studies.R
@@ -155,7 +155,7 @@ test_that("get_study_tree returns a phylo object and original labels for tip lab
 
 test_that("get_study_tree returns an error if file is given but file format is not", {
     skip_on_cran()
-    expect_error(get_study_tree(study_id="pg_1144", tree="tree2324", file = "test"),
+    expect_error(get_study_tree(study_id="pg_1144", tree_id="tree2324", file = "test"),
                  "must be specified")
 })
 
@@ -197,28 +197,34 @@ test_that("get_study_subtree returns an error when tree_id doesn't exist", {
     expect_error(get_study_subtree("pg_1144", "tree55555", subtree_id = "node555555"))
 })
 
-## API still returns object
-## test_that("get_study_subtree returns an error when the subtree_id is invalid",
-##           expect_error(get_study_subtree("pg_1144", "tree2324", "foobar")))
+test_that("get_study_subtree returns an error when the subtree_id is invalid", {
+    skip_on_cran()
+    expect_error(get_study_subtree("pg_1144", "tree2324", "foobar"))
+})
 
 test_that("get_study_subtree returns a phylo object", {
     skip_on_cran()
-    tt <- get_study_subtree("pg_1144", "tree2324", subtree_id = "ingroup",
+    tt <- get_study_subtree("pg_420", "tree522", subtree_id = "ingroup",
                             object_format = "phylo")
+    sub_tt <- get_study_subtree("pg_420", "tree522", subtree_id = "node208580",
+                                object_format = "phylo")
     expect_true(inherits(tt, "phylo"))
     expect_true(length(tt$tip.label) > 1)
+    expect_true(inherits(sub_tt, "phylo"))
+    expect_true(length(sub_tt$tip.label) > 1)
+    expect_true(length(tt$tip.label) > length(sub_tt$tip.label))
 })
 
 test_that("get_study_subtree fails if file name is given but no file format", {
     skip_on_cran()
-    expect_error(get_study_subtree("pg_1144", "tree2324", subtree_id = "ingroup",
+    expect_error(get_study_subtree("pg_420", "tree522", subtree_id = "ingroup",
                                    file = "test"), "must be specified")
 })
 
 test_that("get_study_subtree returns a nexus file", {
     skip_on_cran()
     ff <- tempfile(fileext = ".nex")
-    tt <- get_study_subtree("pg_1144", "tree2324", subtree_id = "ingroup",
+    tt <- get_study_subtree("pg_420", "tree522", subtree_id = "ingroup",
                             file_format = "nexus", file = ff)
     expect_true(tt)
     expect_true(grepl("^#NEXUS", readLines(ff, n = 1, warn = FALSE)))
@@ -227,21 +233,30 @@ test_that("get_study_subtree returns a nexus file", {
 test_that("get_study_subtree returns a newick file", {
     skip_on_cran()
     ff <- tempfile(fileext = ".tre")
-    tt <- get_study_subtree("pg_1144", "tree2324", subtree_id = "ingroup",
+    tt <- get_study_subtree("pg_420", "tree522", subtree_id = "ingroup",
                             file_format = "newick", file = ff)
     expect_true(tt)
     expect_true(grepl("^\\(", readLines(ff, n = 1, warn = FALSE)))
 })
 
-test_that("get_study_subtree returns a json file", {
+test_that("get_study_subtree can deduplicate labels", {
     skip_on_cran()
-    ff <- tempfile(fileext = ".json")
-    tt <- get_study_subtree("pg_1144", "tree2324", subtree_id = "ingroup",
-                            file_format = "json", file = ff)
-    expect_true(tt)
-    expect_true(grepl("^\\{", readLines(ff, n = 1, warn = FALSE)))
+    expect_warning(get_study_subtree(study_id="pg_710", tree_id="tree1277",
+                                     tip_label='ott_taxon_name',
+                                     subtree_id = "ingroup", deduplicate = TRUE),
+                   "and have been modified")
 })
 
+test_that("get_study_subtree fails with duplicate labels", {
+    skip_on_cran()
+    expect_error(get_study_subtree(study_id="pg_710", tree_id="tree1277",
+                                     tip_label='ott_taxon_name',
+                                   subtree_id = "ingroup", deduplicate = FALSE),
+                 "has already been encountered")
+})
+
+
+
 
 ############################################################################
 ## get_study_meta                                                         ##
@@ -336,7 +351,7 @@ test_that("single study detailed=FALSE", {
 test_that("multiple studies detailed=TRUE", {
               skip_on_cran()
               res <- studies_find_studies(property = "ot:focalCladeOTTTaxonName",
-                                          value = "Aves", detailed = TRUE)
+                                          value = "mammalia", detailed = TRUE)
               expect_true(inherits(res, "data.frame"))
               expect_true(inherits(res, "matched_studies"))
               expect_true(all(names(res) %in% c("study_ids", "n_trees", "tree_ids",
@@ -350,7 +365,7 @@ test_that("multiple studies detailed=TRUE", {
 test_that("multiple studies detailed=FALSE", {
               skip_on_cran()
               res <- studies_find_studies(property = "ot:focalCladeOTTTaxonName",
-                                          value = "Aves", detailed = FALSE)
+                                          value = "mammalia", detailed = FALSE)
               expect_true(inherits(res, "study_ids"))
               expect_true(inherits(res, "matched_studies"))
               expect_true(inherits(res, "data.frame"))
@@ -454,13 +469,13 @@ test_that("list_trees with studies_find_studies and detailed = FALSE", {
 test_that("list_trees with studies_find_studies and detailed = TRUE",  {
               skip_on_cran()
               res <- studies_find_studies(property = "ot:focalCladeOTTTaxonName",
-                                          value = "Aves", detailed = TRUE)
+                                          value = "mammalia", detailed = TRUE)
               expect_true(inherits(list_trees(res), "list"))
               expect_true(length(list_trees(res)) >= 8)
-              expect_true(sum(names(list_trees(res)) %in% c("pg_435", "ot_428",
-                                                            "pg_420", "ot_429",
-                                                            "ot_214", "ot_117",
-                                                            "ot_116", "pg_2799")) >= 8)
+              expect_true(sum(names(list_trees(res)) %in% c("pg_2647", "ot_308",
+                                                            "pg_2812", "ot_109",
+                                                            "pg_2582", "pg_1428",
+                                                            "ot_755", "pg_2550")) >= 8)
           })
 
 test_that("list_trees with studies_find_trees and detailed=FALSE", {
diff --git a/tests/testthat/test-taxonomy.R b/tests/testthat/test-taxonomy.R
index 1916acb..5980692 100644
--- a/tests/testthat/test-taxonomy.R
+++ b/tests/testthat/test-taxonomy.R
@@ -171,6 +171,16 @@ test_that("taxonomy_mrca with ott_id for tax_info", {
 })
 
 
+test_that("ott_id subset works", {
+    skip_on_cran()
+    expect_true(inherits(ott_id(tax_info), "otl_ott_id"))
+    expect_true(inherits(ott_id(tax_info)[1], "otl_ott_id"))
+    expect_true(!is.null(names(ott_id(tax_info))))
+})
+
+
+
+
 ############################################################################
 ## taxon subtree                                                          ##
 ############################################################################
@@ -225,6 +235,8 @@ test_that("taxonomy subtree works if taxa has only 1 descendant", {
     expect_true(inherits(tt$tip_label, "character"))
 })
 
+
+
 ############################################################################
 ## taxonomic MRCA                                                         ##
 ############################################################################
@@ -254,7 +266,7 @@ test_that("mrca tax_name method", {
 
 test_that("mrca ott_id method", {
     skip_on_cran()
-    expect_equal(ott_id(tax_mrca)[1],
+    expect_equivalent(ott_id(tax_mrca)[1],
                  list("Asterales" = 1042120))
     expect_true(inherits(ott_id(tax_mrca), "otl_ott_id"))
 })
@@ -339,3 +351,27 @@ test_that("taxonomy_mrca with ott_id for tax_mrca", {
     expect_equivalent(ott_id(tax_mrca_mono),
                       ott_id(taxonomy_mrca(ott_id(tax_mrca_mono))))
 })
+
+test_that("ott_id subset works", {
+    skip_on_cran()
+    expect_true(inherits(ott_id(tax_mrca_mono), "otl_ott_id"))
+    expect_true(inherits(ott_id(tax_mrca_mono)[1], "otl_ott_id"))
+    expect_true(!is.null(names(ott_id(tax_mrca_mono))))
+})
+
+
+
+### is_in_tree() ---------------------------------------------------------------
+
+if (identical(Sys.getenv("NOT_CRAN"), "true"))  {
+    spp <- c("Tyrannosaurus rex", "Velociraptor", "Fabaceae", "Solanaceae")
+    ot_names <- tnrs_match_names(spp)
+    ot_ids <- ott_id(ot_names)
+}
+
+test_that("test is_in_tree", {
+    skip_on_cran()
+    in_tree <- is_in_tree(ot_ids)
+    expect_equal(sum(in_tree), 1)
+    expect_true(all(names(in_tree) %in% spp))
+})
diff --git a/vignettes/how-to-use-rotl.Rmd b/vignettes/how-to-use-rotl.Rmd
index 77c9d88..8755acc 100644
--- a/vignettes/how-to-use-rotl.Rmd
+++ b/vignettes/how-to-use-rotl.Rmd
@@ -249,35 +249,51 @@ resolution service are not part of the Open Tree's synthesis tree. These are
 usually traditional higher-level taxa that have been found to be paraphyletic.
 
 For instance, if you wanted to fetch a tree relating the three birds that go
-into a [Turkducken](https://en.wikipedia.org/wiki/Turducken) you might search
-for the turkey, duck, and chicken genera:
+into a [Turkducken](https://en.wikipedia.org/wiki/Turducken) as well as the pork
+used for stuffing, you might search for the turkey, duck, chicken, and pork
+genera:
 
 ```{r}
-turducken <- c("Meleagris", "Anas", "Gallus")
+turducken <- c("Meleagris", "Anas", "Gallus", "Sus")
 taxa <- tnrs_match_names(turducken, context="Animals")
 taxa
 ```
-So, we have IDs for each genus but those messages in the `flag` column look
-concerning. `BARREN` means these taxa have no descendants and
-`MAJOR_RANK_CONFLICT` refers to inconsitancies between the rank of these taxa
-and some of their relatives. For thtese reasons, _Meleagris_ and _Anas_ are not
-included in the synthetic tree.
 
-If we tried to press on ahead with the IDs that we have, we'd get an
-error (because there are too few good IDs) or a tree with fewer tips that we had
-anticipated.
+We have the OTT ids for each genus, however, if we tried to get the induced
+subtree from these results, we would get an error:
 
-```{r, eval=FALSE}
-tr <- tol_induced_subtree(taxa$ott_id)
+```{r, error=TRUE}
+tr <- tol_induced_subtree(ott_id(taxa))
+```
+
+As the error message suggests, some of the taxa are not found in the synthetic
+tree. This occurs for 2 main reasons: either the taxa is invalid, or it is part
+of a group that is not monophyletic in the synthetic tree. There are two ways to
+get around this issue: (1) removing the taxa that are not part of the Open Tree;
+(2) using the complete species name.
+
+#### Removing the taxa missing from the synthetic tree
+
+To help with this situation, `rotl` provides a way to identify the OTT ids that
+are not part of the synthetic tree. The function `is_in_tree()` takes the output
+of the `ott_id()` function and returns a vector of logical indicating whether
+the taxa are part of the synthetic tree. We can then use to only keep the taxa that appear in the synthetic tree:
+
+```{r}
+in_tree <- is_in_tree(ott_id(taxa))
+in_tree
+tr <- tol_induced_subtree(ott_id(taxa)[in_tree])
 ```
 
+#### Using the full taxonomic names
+
 The best way to avoid these problems is to specify complete species names
 (species being the lowest level of classification in the Open Tree taxonomy they
 are guaranteed to be monophyletic):
 
 ```{r, fig.width=7, fig.height=4}
-turducken_spp <- c("Meleagris gallopavo", "Anas platyrhynchos", "Gallus gallus")
+turducken_spp <- c("Meleagris gallopavo", "Anas platyrhynchos", "Gallus gallus", "Sus scrofa")
 taxa <- tnrs_match_names(turducken_spp, context="Animals")
-tr <- tol_induced_subtree(taxa$ott_id)
+tr <- tol_induced_subtree(ott_id(taxa))
 plot(tr)
 ```
diff --git a/vignettes/meta-analysis.Rmd b/vignettes/meta-analysis.Rmd
index 0ff201a..b7bacf4 100644
--- a/vignettes/meta-analysis.Rmd
+++ b/vignettes/meta-analysis.Rmd
@@ -45,9 +45,8 @@ papers DOI as input) and read it into memory with `gdata`:
 
 ```{r egg_data, cache=TRUE}
 library(rotl)
-library(fulltext)
 
-if (require(readxl)) {
+if (require(readxl) && require(fulltext)) {
     doi <- "10.1111/jeb.12282"
     xl_file <- ft_get_si(doi, 1, save.name="egg.xls")
     egg_data <- read_excel(xl_file)
@@ -226,6 +225,6 @@ There are an ever-growing number of packages that allow an ever-growing number
 of analysis to performed in R. Some "classics" like ancestral state
 reconstruction,  phylogenetic independent contrasts and lineage through time plots
 are implemented in `ape`. Packages like `phytools`, `caper` and `diversitree`
-provide extensions to these methods.  The [CRAN Phylogenetics Taskview](https://cran.r-project.org/web/views/Phylogenetics.html)
+provide extensions to these methods.  The [CRAN Phylogenetics Taskview](https://CRAN.R-project.org/view=Phylogenetics)
 gives a good idea of the diversity of packages and analyses that can be
 completed in R.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-rotl.git



More information about the debian-med-commit mailing list