ropensci / taxize

A taxonomic toolbelt for R
https://docs.ropensci.org/taxize
Other
264 stars 58 forks source link

Is there a function in taxize for getting all genera in a family? #918

Closed monis4567 closed 4 months ago

monis4567 commented 9 months ago

With the code below I can get the family back, I would like to get all genera in the family. Is this possible to do with a function in taxize? I apologize if I have overlooked something. I can see here https://en.wikipedia.org/wiki/True_toad

That there a couple of different genera. Thanks in advance for any help

Session Info ```r library(taxize) taxize::tax_name(sci = "Bufonidae", get = c("genus","family","order"), db = "ncbi") ```

devtools::session_info() ─ Session info ───────────────────────────────────────────────────────────────────── setting value version R version 4.3.1 (2023-06-16) os Ubuntu 22.04.3 LTS system x86_64, linux-gnu ui RStudio language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz Europe/Rome date 2023-09-25 rstudio 2023.06.2+561 Mountain Hydrangea (desktop) pandoc NA

─ Packages ───────────────────────────────────────────────────────────────────────── ! package version date (UTC) lib source ade4 1.7-22 2023-02-06 [1] CRAN (R 4.3.0) ape 5.7-1 2023-03-13 [1] CRAN (R 4.3.0) Biobase 2.60.0 2023-04-25 [1] Bioconductor BiocGenerics 0.46.0 2023-04-25 [1] Bioconductor BiocManager 1.30.22 2023-08-08 [1] CRAN (R 4.3.1) biomformat 1.28.0 2023-04-25 [2] Bioconductor Biostrings 2.68.1 2023-05-16 [1] Bioconductor bitops 1.0-7 2021-04-24 [1] CRAN (R 4.3.0) bold 1.3.0 2023-05-02 [1] CRAN (R 4.3.1) cachem 1.0.8 2023-05-01 [1] CRAN (R 4.3.0) callr 3.7.3 2022-11-02 [1] CRAN (R 4.3.0) cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.3.0) cli 3.6.1 2023-03-23 [1] CRAN (R 4.3.0) cluster 2.1.4 2022-08-22 [1] CRAN (R 4.3.0) codetools 0.2-19 2023-02-01 [1] CRAN (R 4.3.0) colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.3.0) conditionz 0.1.0 2019-04-24 [1] CRAN (R 4.3.1) crayon 1.5.2 2022-09-29 [1] CRAN (R 4.3.0) crul 1.4.0 2023-05-17 [1] CRAN (R 4.3.0) curl 5.0.2 2023-08-14 [1] CRAN (R 4.3.1) data.table 1.14.8 2023-02-17 [1] CRAN (R 4.3.0) devtools 2.4.5 2022-10-11 [1] CRAN (R 4.3.0) digest 0.6.33 2023-07-07 [1] CRAN (R 4.3.1) dismo 1.3-14 2023-05-21 [1] CRAN (R 4.3.0) dplyr 1.1.2 2023-04-20 [1] CRAN (R 4.3.0) ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.3.0) factoextra 1.0.7 2020-04-01 [1] CRAN (R 4.3.1) fansi 1.0.4 2023-01-22 [1] CRAN (R 4.3.0) fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0) foreach 1.5.2 2022-02-02 [1] CRAN (R 4.3.0) fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.1) generics 0.1.3 2022-07-05 [1] CRAN (R 4.3.0) GenomeInfoDb 1.36.1 2023-06-21 [1] Bioconductor GenomeInfoDbData 1.2.10 2023-04-28 [1] Bioconductor ggplot2 3.4.3 2023-08-14 [1] CRAN (R 4.3.1) ggrepel 0.9.3 2023-02-03 [1] CRAN (R 4.3.0) glue 1.6.2 2022-02-24 [1] CRAN (R 4.3.0) gtable 0.3.3 2023-03-21 [1] CRAN (R 4.3.0) htmltools 0.5.6 2023-08-10 [1] CRAN (R 4.3.1) htmlwidgets 1.6.2 2023-03-17 [1] CRAN (R 4.3.0) httpcode 0.3.0 2020-04-10 [1] CRAN (R 4.3.0) httpuv 1.6.11 2023-05-11 [1] CRAN (R 4.3.0) httr 1.4.7 2023-08-15 [1] CRAN (R 4.3.1) igraph 1.5.1 2023-08-10 [1] CRAN (R 4.3.1) IRanges 2.34.1 2023-06-22 [1] Bioconductor iterators 1.0.14 2022-02-05 [1] CRAN (R 4.3.0) jsonlite 1.8.7 2023-06-29 [1] CRAN (R 4.3.1) later 1.3.1 2023-05-02 [1] CRAN (R 4.3.0) lattice 0.21-8 2023-04-05 [1] CRAN (R 4.3.0) lazyeval 0.2.2 2019-03-15 [1] CRAN (R 4.3.0) lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.3.0) magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0) MASS 7.3-60 2023-05-04 [1] CRAN (R 4.3.0) Matrix 1.6-1 2023-08-14 [1] CRAN (R 4.3.1) memoise 2.0.1 2021-11-26 [1] CRAN (R 4.3.0) mgcv 1.9-0 2023-07-11 [1] CRAN (R 4.3.1) mime 0.12 2021-09-28 [1] CRAN (R 4.3.0) miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.3.0) mirlyn 1.4.0 2023-07-16 [1] Github (escamero/mirlyn@8cbdd3d) multtest 2.56.0 2023-04-25 [1] Bioconductor munsell 0.5.0 2018-06-12 [1] CRAN (R 4.3.0) R nlme 3.1-162 [4] oai 0.4.0 2022-11-10 [1] CRAN (R 4.3.0) permute 0.9-7 2022-01-27 [1] CRAN (R 4.3.0) phyloseq 1.44.0 2023-04-25 [2] Bioconductor pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.0) pkgbuild 1.4.2 2023-06-26 [1] CRAN (R 4.3.1) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.0) pkgload 1.3.2.1 2023-07-08 [1] CRAN (R 4.3.1) plyr 1.8.8 2022-11-11 [1] CRAN (R 4.3.1) prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.3.0) processx 3.8.2 2023-06-30 [1] CRAN (R 4.3.1) profvis 0.3.8 2023-05-02 [1] CRAN (R 4.3.0) promises 1.2.1 2023-08-10 [1] CRAN (R 4.3.1) ps 1.7.5 2023-04-18 [1] CRAN (R 4.3.0) purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.1) R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0) raster 3.6-23 2023-07-04 [1] CRAN (R 4.3.1) Rcpp 1.0.11 2023-07-06 [1] CRAN (R 4.3.1) RCurl 1.98-1.12 2023-03-27 [1] CRAN (R 4.3.0) readxl 1.4.3 2023-07-06 [1] CRAN (R 4.3.1) remotes 2.4.2.1 2023-07-18 [1] CRAN (R 4.3.1) reshape2 1.4.4 2020-04-09 [1] CRAN (R 4.3.0) rgbif 3.7.7 2023-04-03 [1] CRAN (R 4.3.0) rhdf5 2.44.0 2023-04-25 [2] Bioconductor rhdf5filters 1.12.0 2023-04-25 [2] Bioconductor Rhdf5lib 1.22.0 2023-04-25 [1] Bioconductor rlang 1.1.1 2023-04-28 [1] CRAN (R 4.3.0) rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.3.1) R S4Vectors 0.38.0 [2] scales 1.2.1 2022-08-20 [1] CRAN (R 4.3.0) sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0) shiny 1.7.5 2023-08-12 [1] CRAN (R 4.3.1) sp 2.0-0 2023-06-22 [1] CRAN (R 4.3.1) stringi 1.7.12 2023-01-11 [1] CRAN (R 4.3.0) stringr 1.5.0 2022-12-02 [1] CRAN (R 4.3.0) survival 3.5-7 2023-08-14 [1] CRAN (R 4.3.1) taxize 0.9.100 2022-04-22 [1] CRAN (R 4.3.1) terra 1.7-39 2023-06-23 [1] CRAN (R 4.3.1) tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.0) tidyr 1.3.0 2023-01-24 [1] CRAN (R 4.3.0) tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.3.0) triebeard 0.4.1 2023-03-04 [1] CRAN (R 4.3.0) urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.3.0) urltools 1.7.3 2019-04-14 [1] CRAN (R 4.3.0) usethis 2.2.2 2023-07-06 [1] CRAN (R 4.3.1) utf8 1.2.3 2023-01-31 [1] CRAN (R 4.3.0) uuid 1.1-1 2023-08-17 [1] CRAN (R 4.3.1) vctrs 0.6.3 2023-06-14 [1] CRAN (R 4.3.0) vegan 2.6-4 2022-10-11 [1] CRAN (R 4.3.0) whisker 0.4.1 2022-12-05 [1] CRAN (R 4.3.0) xml2 1.3.5 2023-07-06 [1] CRAN (R 4.3.1) xtable 1.8-4 2019-04-21 [1] CRAN (R 4.3.0) XVector 0.40.0 2023-04-25 [1] Bioconductor zlibbioc 1.46.0 2023-04-25 [1] Bioconductor zoo 1.8-12 2023-04-13 [1] CRAN (R 4.3.0)

[1] /home/hal9000/R/x86_64-pc-linux-gnu-library/4.3 [2] /usr/local/lib/R/site-library [3] /usr/lib/R/site-library [4] /usr/lib/R/library

R ── Package was removed from disk.

────────────────────────────────────────────────────────────────────────────────────

sessionInfo() R version 4.3.1 (2023-06-16) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 22.04.3 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

time zone: Europe/Rome tzcode source: system (glibc)

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] taxize_0.9.100

loaded via a namespace (and not attached): [1] bitops_1.0-7 remotes_2.4.2.1 permute_0.9-7
[4] readxl_1.4.3 rlang_1.1.1 magrittr_2.0.3
[7] ade4_1.7-22 compiler_4.3.1 mgcv_1.9-0
[10] callr_3.7.3 vctrs_0.6.3 reshape2_1.4.4
[13] profvis_0.3.8 stringr_1.5.0 rgbif_3.7.7
[16] httpcode_0.3.0 pkgconfig_2.0.3 crayon_1.5.2
[19] fastmap_1.1.1 XVector_0.40.0 ellipsis_0.3.2
[22] utf8_1.2.3 promises_1.2.1 sessioninfo_1.2.2
[25] ps_1.7.5 purrr_1.0.2 zlibbioc_1.46.0
[28] cachem_1.0.8 GenomeInfoDb_1.36.1 jsonlite_1.8.7
[31] biomformat_1.28.0 later_1.3.1 rhdf5filters_1.12.0
[34] uuid_1.1-1 Rhdf5lib_1.22.0 terra_1.7-39
[37] prettyunits_1.1.1 parallel_4.3.1 cluster_2.1.4
[40] R6_2.5.1 stringi_1.7.12 pkgload_1.3.2.1
[43] cellranger_1.1.0 Rcpp_1.0.11 iterators_1.0.14
[46] usethis_2.2.2 zoo_1.8-12 triebeard_0.4.1
[49] IRanges_2.34.1 httpuv_1.6.11 Matrix_1.6-1
[52] splines_4.3.1 igraph_1.5.1 tidyselect_1.2.0
[55] rstudioapi_0.15.0 vegan_2.6-4 codetools_0.2-19
[58] miniUI_0.1.1.1 processx_3.8.2 curl_5.0.2
[61] pkgbuild_1.4.2 lattice_0.21-8 tibble_3.2.1
[64] plyr_1.8.8 Biobase_2.60.0 shiny_1.7.5
[67] mirlyn_1.4.0 survival_3.5-7 urlchecker_1.0.1
[70] xml2_1.3.5 Biostrings_2.68.1 pillar_1.9.0
[73] BiocManager_1.30.22 phyloseq_1.44.0 whisker_0.4.1
[76] foreach_1.5.2 stats4_4.3.1 generics_0.1.3
[79] sp_2.0-0 RCurl_1.98-1.12 S4Vectors_0.38.0
[82] ggplot2_3.4.3 munsell_0.5.0 scales_1.2.1
[85] xtable_1.8-4 glue_1.6.2 lazyeval_0.2.2
[88] tools_4.3.1 data.table_1.14.8 fs_1.6.3
[91] rhdf5_2.44.0 grid_4.3.1 bold_1.3.0
[94] tidyr_1.3.0 ape_5.7-1 urltools_1.7.3
[97] devtools_2.4.5 colorspace_2.1-0 nlme_3.1-162
[100] GenomeInfoDbData_1.2.10 raster_3.6-23 conditionz_0.1.0
[103] cli_3.6.1 fansi_1.0.4 dplyr_1.1.2
[106] gtable_0.3.3 oai_0.4.0 digest_0.6.33
[109] BiocGenerics_0.46.0 ggrepel_0.9.3 crul_1.4.0
[112] htmlwidgets_1.6.2 memoise_2.0.1 htmltools_0.5.6
[115] multtest_2.56.0 factoextra_1.0.7 lifecycle_1.0.3
[118] dismo_1.3-14 httr_1.4.7 mime_0.12
[121] MASS_7.3-60

joshpersi commented 5 months ago

Would downstream() work?

As an example, the code downstream("Bufonidae", db = "gbif", downto = "genus") returns the following results:

✔  Found:  Bufonidae
══  Results  ═════════════════

• Total: 1 
• Found: 1 
• Not Found: 0
$Bufonidae
                name  rank      key     name_type
1           Adenomus genus  2423083 canonicalname
2     Altiphrynoides genus  2423166 canonicalname
3     Amazophrynella genus  8452850 canonicalname
4           Anaxyrus genus  2422857 canonicalname
5            Ansonia genus  2422593 canonicalname
6           Atelopus genus  2422265 canonicalname
7      Barbarophryne genus  9637998 canonicalname
8       Blythophryne genus  8905080 canonicalname
9               Bufo genus  7580221 canonicalname
10              Bufo genus  7435367 canonicalname
11          Bufoides genus  2422523 canonicalname
12           Bufotes genus  4817029 canonicalname
13       Capensibufo genus  2422520 canonicalname
14         Churamiti genus  2422504 canonicalname
15  Dendrophryniscus genus  2422255 canonicalname
16       Didynamipus genus  2422251 canonicalname
17      Duttaphrynus genus  2422528 canonicalname
18          Epidalea genus  2422506 canonicalname
19          Frostius genus  2422959 canonicalname
20       Ghatophryne genus  5785371 canonicalname
21        Hylaplesia genus  4817034 canonicalname
22        Hysaplesia genus  4817038 canonicalname
23          Incilius genus  2422364 canonicalname
24     Ingerophrynus genus  2422165 canonicalname
25    Laurentophryne genus  2423171 canonicalname
26       Leptophryne genus  2422135 canonicalname
27  Melanophryniscus genus  2422139 canonicalname
28    Mertensophryne genus  2423054 canonicalname
29    Metaphryniscus genus  2423135 canonicalname
30       Nannophryne genus  2422945 canonicalname
31       Nectophryne genus  2422854 canonicalname
32   Nectophrynoides genus  2422543 canonicalname
33   Nimbaphrynoides genus  2422130 canonicalname
34     Oreophrynella genus  2422509 canonicalname
35      Osornophryne genus  2422190 canonicalname
36    Parapelophryne genus  2423139 canonicalname
37        Pedostibes genus  2422953 canonicalname
38        Pelophryne genus  2422563 canonicalname
39       Peltophryne genus  2422477 canonicalname
40        Phrynoidis genus  2422557 canonicalname
41   Poyntonophrynus genus  2422450 canonicalname
42        Pseudobufo genus  2422199 canonicalname
43          Rentapia genus  8742471 canonicalname
44            Rhaebo genus  2423143 canonicalname
45          Rhinella genus  2422625 canonicalname
46      Sabahphrynus genus  2422963 canonicalname
47      Schismaderma genus  2422518 canonicalname
48       Sclerophrys genus  9436441 canonicalname
49 Sigalegalephrnnus genus 12224088 canonicalname
50 Sigalegalephrynus genus 10876496 canonicalname
51       Strauchbufo genus 10809427 canonicalname
52         Truebella genus  2422474 canonicalname
53   Vandijkophrynus genus  2422234 canonicalname
54          Werneria genus  2422576 canonicalname
55   Wolterstorffina genus  2422247 canonicalname
56      Xanthophryne genus  5785345 canonicalname
monis4567 commented 4 months ago

Yes. This worked. Thanks . In the meantime I solved the problem using the package 'rgbif', using the code below. But thanks for following up on this

if(!require(rgbif)){
  install.packages("rgbif")
}
library(rgbif)
# define family to look for
s.fam <- "Bufonidae"
# then use the family name to get the GBIF info
nMlk1 <- rgbif::name_lookup(s.fam,rank="family",status = "accepted")
# make sure it matches the family name, and not a synonym
# and use this to get the tax GBIF ID number inside the info 
fam.key <- nMlk1$data$key[nMlk1$data$scientificName==s.fam]
# then get the info for this tax GBIF ID number
nMlk2 <- rgbif::name_lookup(higherTaxonKey = fam.key,rank="genus")
# then from this tax GBIF ID number get the scientific genus names
genNms <- nMlk2$data$scientificName
# then get all the unique names
genNms <- unique(genNms)