Learn R Programming

tabula (version 1.5.1)

plot_matrix: Heatmap

Description

Plots a heatmap.

Usage

plot_heatmap(object, ...)

# S4 method for CountMatrix plot_heatmap(object, PVI = FALSE, frequency = TRUE)

# S4 method for AbundanceMatrix plot_heatmap(object)

# S4 method for IncidenceMatrix plot_heatmap(object)

Arguments

object

An object to be plotted.

...

Further arguments to be passed to internal methods.

PVI

A logical scalar: should the PVI be drawn instead of frequencies (see details)?

frequency

A logical scalar: should relative frequencies be drawn? If FALSE, raw data are plotted.

Value

A ggplot object.

Details

If PVI is FALSE, it plots a heatmap of relative abundances (frequency), otherwise percentages of the independence value are drawn (in french, "pourcentages de valeur d'ind<U+00E9>pendance", PVI).

PVI is calculated for each cell as the percentage to the column theoretical independence value: PVI greater than \(1\) represent positive deviations from the independence, whereas PVI smaller than \(1\) represent negative deviations (Desachy 2004).

The PVI matrix allows to explore deviations from independence (an intuitive graphical approach to \(\chi^2\)), in such a way that a high-contrast matrix has quite significant deviations, with a low risk of being due to randomness (Desachy 2004).

References

Desachy, B. (2004). Le s<U+00E9>riographe EPPM: un outil informatis<U+00E9> de s<U+00E9>riation graphique pour tableaux de comptages. Revue arch<U+00E9>ologique de Picardie, 3(1), 39-56. DOI: 10.3406/pica.2004.2396.

See Also

Other plot: plot_bar, plot_date(), plot_diversity(), plot_line, plot_spot()

Examples

Run this code
# NOT RUN {
## Abundance data
## Coerce dataset to a count matrix (data from Desachy 2004)
compiegne_count <- as_count(compiegne)

## Plot matrix diagram...
## ...without threshod (i.e. heatmap)
plot_heatmap(compiegne_count)
## ...with PVI as threshold (i.e. Bruno Desachy's matrigraphe)
plot_heatmap(compiegne_count, PVI = TRUE) +
  ggplot2::scale_fill_gradient2(midpoint = 1)

## Presence/absence data
bin <- IncidenceMatrix(data = sample(0:1, size = 100, replace = TRUE),
                       nrow = 10, ncol = 10)
plot_heatmap(bin) +
  ggplot2::scale_fill_manual(values = c("TRUE" = "black", "FALSE" = "white"))
# }

Run the code above in your browser using DataLab