Package 'ggdiceplot'

Title: DicePlot Visualization for 'ggplot2'
Description: Provides 'ggplot2' extensions for creating dice-based visualizations where each dot position represents a specific categorical variable. The package includes 'geom_dice()' for displaying presence/absence of categorical variables using traditional dice patterns. Each dice position (1-6) represents a different category, with dots shown only when that category is present. This allows intuitive visualization of up to 6 categorical variables simultaneously.
Authors: Matthias Flotho [aut, cre] (ORCID: <https://orcid.org/0009-0006-4374-0801>)
Maintainer: Matthias Flotho <[email protected]>
License: MIT + file LICENSE
Version: 1.2.0
Built: 2026-05-31 07:04:15 UTC
Source: https://github.com/maflot/ggdiceplot

Help Index


Calculate Dice Dot Offsets

Description

Computes the (x, y) offset positions for drawing dots on dice faces.

Usage

make_offsets(n, width = 0.5, height = 0.5, pad = 0.1)

Arguments

n

Integer from 1 to 6, indicating the number of dots on the die face.

width

Total width of the die face (default: 0.5).

height

Total height of the die face (default: 0.5).

pad

Padding to apply around the dot grid (default: 0.1).

Value

A data.frame with key, x, and y columns indicating dot positions.


Sample Dice Dataset for Visualization

Description

This toy dataset (sample_dice_data1) is used to demonstrate the geom_dice() function. It simulates log fold-change (LFC) and adjusted p-values (q-values) for a range of oral taxa across disease types and specimen sites.

Usage

data(sample_dice_data1)

Format

A data frame with 160 rows and 5 columns:

taxon

Character. Microbial taxon name (8 taxa).

disease

Character. Disease condition (Caries, Periodontitis, Healthy, Gingivitis).

specimen

Character. Body site specimen (Saliva, Plaque, Tongue, Buccal, Gingival).

lfc

Numeric. Simulated log2 fold change value; may contain NA.

q

Numeric. Simulated adjusted p-value (q-value); may contain NA.

Examples

data(sample_dice_data1)
head(sample_dice_data1)

Sample Dice Dataset 2 for Visualization

Description

sample_dice_data2 is a toy dataset designed to demonstrate geom_dice() with multiple specimen types. It simulates log2 fold-change (LFC) and adjusted p-values (q-values) for oral taxa across disease conditions and specimen sites, with some missing values.

Usage

data(sample_dice_data2)

Format

A data frame with 160 rows and 5 columns:

taxon

Character. Microbial taxon name (8 taxa).

disease

Character. Disease condition (Caries, Periodontitis, Healthy, Gingivitis).

specimen

Character. Body site specimen (Saliva, Plaque, Tongue, Buccal, Gingival).

lfc

Numeric. Simulated log2 fold change; may contain NA.

q

Numeric. Simulated adjusted p-value (q-value); may contain NA.

Examples

data(sample_dice_data2)
head(sample_dice_data2)

Large Sample Dice Dataset

Description

sample_dice_large is a larger toy dataset with 60 taxa, designed to test geom_dice() at higher density. It simulates log2 fold-change and q-values with approximately 50\

Usage

data(sample_dice_large)

Format

A data frame with 480 rows and 6 columns:

taxon

Character. Taxon name (Taxon_1 through Taxon_60).

disease

Character. Disease condition (Caries, Periodontitis, Healthy, Gingivitis).

specimen

Character. Specimen type (Saliva, Plaque).

replicate

Integer. Replicate identifier.

lfc

Numeric. Simulated log2 fold change; may contain NA.

q

Numeric. Simulated adjusted p-value; may contain NA.

Examples

data(sample_dice_large)
head(sample_dice_large)

Sample miRNA Dice Dataset

Description

sample_dice_miRNA is a toy dataset for demonstrating geom_dice() with categorical fill mapping. It simulates miRNA dysregulation across compounds and organs, with direction (Up, Down, Unchanged) as the fill variable.

Usage

data(sample_dice_miRNA)

Format

A data frame with approximately 90 rows and 5 columns:

miRNA

Factor. miRNA identifier (miR-1 through miR-5).

Compound

Factor. Treatment compound (Control, Compound_1 through Compound_4).

Organ

Factor. Target organ (Lung, Liver, Brain, Kidney).

log2FC

Numeric. Simulated log2 fold change.

direction

Factor. Regulation direction (Down, Unchanged, Up).

Examples

data(sample_dice_miRNA)
head(sample_dice_miRNA)

Discrete Scale for Dice Dot Colors

Description

Creates a ggplot2 discrete scale for dice dot aesthetics.

Usage

scale_dots_discrete(..., aesthetics = "dots")

Arguments

...

Passed to ggplot2::discrete_scale()

aesthetics

Character string of the target aesthetic (default: "dots")

Value

A ggplot2 scale


Dice Theme for ggplot2

Description

A minimal ggplot2 theme for dice plots.

Usage

theme_dice(x_length, y_length, ...)

Arguments

x_length

Width of the plotting area (kept for compatibility)

y_length

Height of the plotting area (kept for compatibility)

...

Additional arguments passed to theme_grey()

Value

A ggplot2 theme