plot.early_lucid: Visualize an early-integration LUCID model through a Sankey...

View source: R/plot_lucid.R

plot.early_lucidR Documentation

Visualize an early-integration LUCID model through a Sankey diagram

Description

Draws the fitted model as a Sankey diagram: exposures flow into the latent clusters, and the clusters flow on into the omics features and the outcome. Each node is either a variable (exposure, omics or outcome) or a latent cluster, and its colour indicates which. Each link is an estimated association: its width is the magnitude of the effect and its colour the sign, so the diagram shows at a glance which exposures drive which cluster and how that cluster differs in the omics layer.

Only exposures and omics features retained by the model are drawn, so a penalized fit yields a correspondingly sparser diagram.

Usage

## S3 method for class 'early_lucid'
plot(x, ...)

Arguments

x

A LUCID model fitted by estimate_lucid or lucid, of class early_lucid.

...

Appearance options, all optional:

G_color

Colour of the exposure nodes (default "dimgray").

X_color

Colour of the latent-cluster nodes (default "#eb8c30").

Z_color

Colour of the omics nodes (default "#2fa4da").

Y_color

Colour of the outcome node (default "#afa58e").

pos_link_color

Colour of links with a positive effect (default "#67928b").

neg_link_color

Colour of links with a negative effect (default "#d1e5eb").

fontsize

Node label size in points (default 7).

Value

An HTML widget created by sankeyNetwork. It renders when printed, in the RStudio viewer or a browser, and can be written to a standalone file with htmlwidgets::saveWidget.

Model types

Implemented for early integration only. A lucid_parallel or lucid_serial fit has a registered method (plot.lucid_parallel/plot.lucid_serial), but it raises an error: the parallel and serial diagrams are still under development.

Examples

# prepare data (a small subset keeps the example quick)
G <- sim_data$G[1:150, ]
Z <- sim_data$Z[1:150, ]
Y_normal <- sim_data$Y_normal[1:150, , drop = FALSE]

# plot lucid model
fit1 <- estimate_lucid(G = G, Z = Z, Y = Y_normal, lucid_model = "early",
CoY = NULL, family = "normal", K = 2, seed = 1008,
max_itr = 20, max_tot.itr = 50)
plot(fit1)

# change node color
plot(fit1, G_color = "yellow")
plot(fit1, Z_color = "red")

# change link color
plot(fit1, pos_link_color = "red", neg_link_color = "green")

LUCIDus documentation built on Sept. 3, 2026, 1:06 a.m.