View source: R/para_explo_abund.R
| para_explo_abund | R Documentation |
Generates exploratory visualizations of parasite abundance distributions across taxa and optional grouping variables. The function produces histograms combined with kernel density curves to facilitate the assessment of distributional patterns, including skewness, dispersion and zero inflation.
para_explo_abund(dataset, sp_cols, group_vars = NULL,
bins = 30, n_col = NULL, verbose = FALSE)
dataset |
Data frame containing parasite data. |
sp_cols |
Vector with the names of the columns containing parasite abundance (taxa) to be plotted. |
group_vars |
Vector with the names of categorical variables used to define groups (e.g., "Sex", "Site"). Default = |
bins |
Integer specifying the number of bins used in the histogram. Higher values provide finer resolution but may introduce noise, while lower values produce smoother but less detailed distributions. Default = |
n_col |
Integer specifying the number of columns in the faceted plot layout. If |
verbose |
A logical value indicating if progress messages should be given. Default = |
The function reshapes the input dataset into a long format, where parasite taxa are treated as a single variable and their abundances as observations. For each parasite taxon and combination of grouping variables (if provided), the function generates:
A histogram representing the distribution of parasite abundance values
A kernel density curve (when sufficient data are available), providing a smoothed approximation of the underlying distribution.
Both elements are scaled to represent density, allowing direct comparison between distributions. These plots are intended for exploratory purposes and should not be used as formal inference tools. Faceting is applied to display each taxon and grouping combination in separate panels. Special cases are handled as follows:
When all abundance values for a given combination are zero, no histogram or density curve is drawn and a message is displayed indicating that the parasite was not recorded for that combination.
When the number of observations is insufficient (less than 2), a message is displayed indicating that there is not enough data to compute a meaningful distribution.
Density curves are only computed when there are more than two observations and non-zero variation.
All plots use independent scales (free scales) to better represent the variability within each facet.
A ggplot2 object containing the generated faceted plots. This object can be further customized using standard ggplot2 functions.
Juan Manuel Cabrera, Exequiel Furlan and Elisa Helman
#Species 1 and 2
para_explo_abund (para_data$dataset,
sp_cols = c("Sp1", "Sp2"),
group_vars = c("Site", "Sp_host"),
bins = 30,
n_col = 4,
verbose = TRUE)
#Species 3 and 4
para_explo_abund (para_data$dataset,
sp_cols = c("Sp3", "Sp4"),
group_vars = c("Site", "Sp_host"),
bins = 30,
n_col = 4,
verbose = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.