A wrapper of [gbif.range::get_gbif()] function to plot the range of taxa using ggplot2. The function can take either a phyloseq object or a vector of taxonomic names. If a phyloseq object is provided, the taxonomic names are extracted from the specified taxonomic rank. The occurrences are plotted either as points or using hexagonal binning. The function can also filter the occurrences by country.
Usage
plot_tax_gbif_pq(
physeq = NULL,
taxnames = NULL,
taxonomic_rank = "currentCanonicalSimple",
interactive_plot = FALSE,
zcol = c("year", "taxonomicStatus"),
hexagons = FALSE,
bins = 100,
verbose = TRUE,
countries = NULL,
info_names = c("country", "country code", "acceptedScientificName", "ScientificName"),
discard_genus_alone = taxonomic_rank == "currentCanonicalSimple",
discard_NA = TRUE,
...
)Arguments
- physeq
(optional) A phyloseq object
- taxnames
(optional) A character vector of taxonomic names.
- taxonomic_rank
(Character, default "currentCanonicalSimple") The column(s) present in the @tax_table slot of the phyloseq object. Can be a vector of two columns (e.g. c("Genus", "Species")).
- interactive_plot
(logical, default FALSE) If TRUE, an interactive map is created using the package mapview.
- zcol
(character vector, default c("year", "taxonomicStatus")) Only used if interactive_plot is TRUE. The column(s) of the occurrences to use for coloring the points in the interactive map. See ?mapview::mapview() for more details.
- hexagons
(logical, default FALSE) Only used if interactive_plot is FALSE. If TRUE, use hexagonal binning to plot the occurrences. If FALSE, plot the occurrences as points.
- bins
(Number of bins for hexagonal binning, default 100) Only used if hexagons is TRUE and interactive_plot is FALSE.
- verbose
(logical, default TRUE) If TRUE, prompt some messages.
- countries
A character vector of country names to filter the occurrences. If NULL (default), all countries are used (no filter).
- info_names
(Character vector) The information to retrieve from GBIF for each occurrence. See [gbif.range::get_gbif()] for more details.
- ...
Additional arguments to pass to [gbif.range::get_gbif()].
See also
[gbif.range::get_gbif()], [range_bioreg_pq()], [tax_check_occur_pq()], [tax_check_ecoregion()]
Examples
# \donttest{
data_fungi_mini_cleanNames <- gna_verifier_pq(data_fungi_mini, data_sources = 210)
#> ✔ GNA verification summary:
#> • Total taxa in phyloseq: 45
#> • Taxa submitted for verification: 37
#> • Genus-level only taxa: 2
#> • Total matches found: 25
#> • Synonyms: 4 (including 4 at genus level)
#> • Accepted names: 21 (including 15 at genus level)
p <- plot_tax_gbif_pq(
subset_taxa_pq(
data_fungi_mini_cleanNames,
taxa_sums(data_fungi_mini) > 20000
),
hexagons = TRUE,
verbose = TRUE, bins = 50, occ_samp = 100, grain = 10000
)
#> Cleaning suppress 0 taxa ( ) and 27 sample(s) ( AD26-005-B_S9_MERGED.fastq.gz / AD26-005-H_S10_MERGED.fastq.gz / ADABM30X-M_S16_MERGED.fastq.gz / B18-006-B_S19_MERGED.fastq.gz / BG7-010-H_S31_MERGED.fastq.gz / BQ4-018-M_S51_MERGED.fastq.gz / BV11-002-M_S59_MERGED.fastq.gz / CB8-019-H_S70_MERGED.fastq.gz / DJ2-008-H_S88_MERGED.fastq.gz / DS1-ABM002-B_S91_MERGED.fastq.gz / DY5-004-B_S96_MERGED.fastq.gz / DY5-004-H_S97_MERGED.fastq.gz / F6-ABM-001_S105_MERGED.fastq.gz / F7-015-M_S106_MERGED.fastq.gz / FOMES19-M_S109_MERGED.fastq.gz / J18-004-M_S116_MERGED.fastq.gz / N23-002-B_S130_MERGED.fastq.gz / NVABM-0163-H_S135_MERGED.fastq.gz / NVABM0216_S136_MERGED.fastq.gz / NVABM0244-M_S137_MERGED.fastq.gz / T28-ABM602-B_S162_MERGED.fastq.gz / W26-001-B_S165_MERGED.fastq.gz / W9-025-M_S169_MERGED.fastq.gz / X24-009-B_S170_MERGED.fastq.gz / X29-004-B_S174_MERGED.fastq.gz / Y28-002-B_S178_MERGED.fastq.gz / Z29-001-H_S185_MERGED.fastq.gz ).
#> Number of non-matching ASV 0
#> Number of matching ASV 45
#> Number of filtered-out ASV 38
#> Number of kept ASV 7
#> Number of kept samples 110
#> ℹ Start the computation of Stereum ostrea
#> Error in loadNamespace(x): there is no package called ‘gbif.range’
p <- plot_tax_gbif_pq(taxnames = c("Xylobolus subpileatus", "Stereum subpileatus"))
#> ℹ Start the computation of Xylobolus subpileatus
#> Error in loadNamespace(x): there is no package called ‘gbif.range’
p <- plot_tax_gbif_pq(taxnames = c("Stereum ostrea", "Mycena renati"))
#> ℹ Start the computation of Stereum ostrea
#> Error in loadNamespace(x): there is no package called ‘gbif.range’
requireNamespace("patchwork")
p[[1]] / p[[2]] & no_legend()
#> Error: object 'p' not found
p <- plot_tax_gbif_pq(
taxnames = c("Xylobolus subpileatus", "Stereum subpileatus"),
hexagons = TRUE, verbose = FALSE
)
#> Error in loadNamespace(x): there is no package called ‘gbif.range’
p <- plot_tax_gbif_pq(
taxnames = c("Xylobolus subpileatus", "Stereum subpileatus"),
hexagons = TRUE, verbose = FALSE, countries = c("france", "spain")
)
#> The rnaturalearthhires package needs to be installed.
#> Installing the rnaturalearthhires package.
#> ! Using bundled GitHub PAT. Please add your own PAT using `gitcreds::gitcreds_set()`.
#>
#> → Will install 1 package.
#> → The package (0 B) is cached.
#> + rnaturalearthhires 1.0.0.9000 [bld][cmp] (GitHub: e4736f6)
#> ℹ No downloads are needed, 1 pkg is cached
#> ✔ Got rnaturalearthhires 1.0.0.9000 (source) (21.38 MB)
#> ℹ Packaging rnaturalearthhires 1.0.0.9000
#> ✔ Packaged rnaturalearthhires 1.0.0.9000 (2.3s)
#> ℹ Building rnaturalearthhires 1.0.0.9000
#> ✔ Built rnaturalearthhires 1.0.0.9000 (35.3s)
#> ✔ Installed rnaturalearthhires 1.0.0.9000 (github::ropensci/rnaturalearthhires@e4736f6) (1.1s)
#> ✔ 1 pkg: added 1, dld 1 (NA B) [53.6s]
#> Error: [as,sf] the geometry column is not valid (perhaps first load the sf package)
p[[1]] + coord_fixed(ylim = c(30, 50), xlim = c(-5, 25)) + no_legend()
#> Error: object 'p' not found
p <- plot_tax_gbif_pq(
taxnames = c(
"Ossicaulis lachnopus",
"Antrodiella brasiliensis",
"Stereum ostrea",
"Xylobolus subpileatus"
),
hexagons = TRUE,
verbose = F, bins = 50, occ_samp = 100, grain = 10000
)
#> Error in loadNamespace(x): there is no package called ‘gbif.range’
requireNamespace("patchwork")
(p[[1]] + p[[2]]) /
(p[[3]] + p[[4]]) & no_legend()
#> Error: object 'p' not found
# }