Scatterplot with marginal distributions and statistical results against Hill diversity of phyloseq object
Source:R/plot_functions.R
ggscatt_pq.Rd
Basically a wrapper of function ggstatsplot::ggscatterstats()
for
object of class phyloseq and Hill number.
Usage
ggscatt_pq(
physeq,
num_modality,
hill_scales = c(0, 1, 2),
rarefy_by_sample = FALSE,
one_plot = TRUE,
...
)
Arguments
- physeq
(required): a
phyloseq-class
object obtained using thephyloseq
package.- num_modality
(required) Name of the numeric column in
physeq@sam_data
to plot and test against hill numberk- hill_scales
(a vector of integer) The list of q values to compute the hill number H^q. If Null, no hill number are computed. Default value compute the Hill number 0 (Species richness), the Hill number 1 (exponential of Shannon Index) and the Hill number 2 (inverse of Simpson Index).
- rarefy_by_sample
(logical, default FALSE) If TRUE, rarefy samples using
phyloseq::rarefy_even_depth()
function.- one_plot
(logical, default FALSE) If TRUE, return a unique plot with the three plot inside using the patchwork package.
- ...
Other arguments passed on to
ggstatsplot::ggscatterstats()
function.
Value
Either an unique ggplot2 object (if one_plot is TRUE) or a list of ggplot2 plot for each hill_scales.
Details
This function is mainly a wrapper of the work of others.
Please make a reference to ggstatsplot::ggscatterstats()
if you
use this function.
Examples
if (requireNamespace("ggstatsplot")) {
ggscatt_pq(data_fungi_mini, "Time", type = "non-parametric")
ggscatt_pq(data_fungi_mini, "Time", hill_scales = 1:4, type = "parametric")
ggscatt_pq(data_fungi_mini, "Sample_id",
hill_scales = c(0, 0.5),
one_plot = FALSE
)
}
#> Taxa are now in columns.
#> Cleaning suppress 0 taxa and 0 samples.
#> Taxa are now in rows.
#> Joining with `by = join_by(Sample)`
#> Registered S3 method overwritten by 'ggside':
#> method from
#> +.gg ggplot2
#> Taxa are now in columns.
#> Cleaning suppress 0 taxa and 0 samples.
#> Taxa are now in rows.
#> Joining with `by = join_by(Sample)`
#> Taxa are now in columns.
#> Cleaning suppress 0 taxa and 0 samples.
#> Taxa are now in rows.
#> Joining with `by = join_by(Sample)`
#> [[1]]
#> `stat_xsidebin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_ysidebin()` using `bins = 30`. Pick better value with `binwidth`.
#>
#> [[2]]
#> `stat_xsidebin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_ysidebin()` using `bins = 30`. Pick better value with `binwidth`.
#>