pub struct VolcanoPlot {Show 13 fields
pub points: Vec<VolcanoPoint>,
pub fc_cutoff: f64,
pub p_cutoff: f64,
pub color_up: String,
pub color_down: String,
pub color_ns: String,
pub point_size: f64,
pub label_top: usize,
pub label_style: LabelStyle,
pub pvalue_floor: Option<f64>,
pub legend_label: Option<String>,
pub show_tooltips: bool,
pub tooltip_labels: Option<Vec<String>>,
}Expand description
Builder for a volcano plot.
A volcano plot visualises differential expression results by plotting log₂ fold change (x-axis) against −log₁₀(p-value) (y-axis). Points that pass both the fold-change cutoff and p-value threshold are colored as up-regulated (right) or down-regulated (left); all others are shown as not-significant (gray).
Dashed threshold lines are drawn automatically at ±fc_cutoff and at
the y position corresponding to p_cutoff.
§Gene labels
Call with_label_top(n) to label the n most
significant points. Three placement styles are available via
with_label_style: LabelStyle::Nudge
(default), LabelStyle::Exact, and LabelStyle::Arrow.
§Zero p-values
p-values of exactly 0.0 cannot be log-transformed. They are
automatically capped at the smallest non-zero p-value in the data.
Set an explicit cap with with_pvalue_floor
to control the y-axis ceiling across multiple plots.
§Example
use kuva::plot::VolcanoPlot;
use kuva::backend::svg::SvgBackend;
use kuva::render::render::render_multiple;
use kuva::render::layout::Layout;
use kuva::render::plots::Plot;
let vp = VolcanoPlot::new()
.with_points(vec![
("EGFR", 3.2_f64, 1e-4_f64),
("AKT1", 3.5, 5e-5 ),
("VHL", -3.0, 5e-4 ),
("GAPDH", 0.3, 0.5 ),
])
.with_label_top(3)
.with_legend("DEG status");
let plots = vec![Plot::Volcano(vp)];
let layout = Layout::auto_from_plots(&plots)
.with_title("Tumour vs. Normal")
.with_x_label("log₂ fold change")
.with_y_label("−log₁₀(p-value)");
let svg = SvgBackend.render_scene(&render_multiple(plots, layout));
std::fs::write("volcano.svg", svg).unwrap();Fields§
§points: Vec<VolcanoPoint>All data points.
fc_cutoff: f64|log₂FC| threshold for up/down classification (default 1.0).
Dashed vertical lines are drawn at ±fc_cutoff.
p_cutoff: f64p-value threshold for significance (default 0.05).
A dashed horizontal line is drawn at −log10(p_cutoff).
color_up: StringColor for up-regulated points: |log2FC| ≥ fc_cutoff and p ≤ p_cutoff
(default "firebrick").
color_down: StringColor for down-regulated points: log2FC ≤ −fc_cutoff and p ≤ p_cutoff
(default "steelblue").
color_ns: StringColor for not-significant points (default "#aaaaaa").
point_size: f64Circle radius in pixels (default 3.0).
label_top: usizeNumber of most-significant points to label (default 0 — no labels).
label_style: LabelStyleLabel placement style (default LabelStyle::Nudge).
pvalue_floor: Option<f64>Explicit p-value floor for the −log10 transform. When None, the
minimum non-zero p-value in the data is used automatically.
legend_label: Option<String>When Some, a legend box shows Up / Down / NS entries.
show_tooltips: bool§tooltip_labels: Option<Vec<String>>Implementations§
Source§impl VolcanoPlot
impl VolcanoPlot
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a volcano plot with default settings.
Defaults: fc_cutoff 1.0, p_cutoff 0.05, firebrick/steelblue/gray
colors, point size 3.0, no labels, no legend.
Sourcepub fn floor(&self) -> f64
pub fn floor(&self) -> f64
Compute the p-value floor used for -log10 transformation. Uses explicit floor if set, otherwise finds minimum non-zero p-value.
Sourcepub fn with_point<S, F, G>(self, name: S, log2fc: F, pvalue: G) -> Self
pub fn with_point<S, F, G>(self, name: S, log2fc: F, pvalue: G) -> Self
Add a single point by name, log₂FC, and raw p-value.
Useful when building a plot incrementally. For bulk input prefer
with_points.
let vp = VolcanoPlot::new()
.with_point("EGFR", 3.2_f64, 1e-4_f64)
.with_point("GAPDH", 0.3, 0.5);Sourcepub fn with_points<I, S, F, G>(self, iter: I) -> Self
pub fn with_points<I, S, F, G>(self, iter: I) -> Self
Add multiple points from an iterator of (name, log2fc, pvalue) tuples.
This is the primary input method. Accepts any types that implement
Into<String> / Into<f64>. Slices, Vec, or any other iterable
of tuples all work.
let results = vec![
("EGFR", 3.2_f64, 1e-4_f64),
("AKT1", 3.5, 5e-5 ),
("VHL", -3.0, 5e-4 ),
("GAPDH", 0.3, 0.5 ),
];
let vp = VolcanoPlot::new().with_points(results);Sourcepub fn with_fc_cutoff(self, cutoff: f64) -> Self
pub fn with_fc_cutoff(self, cutoff: f64) -> Self
Set the absolute log₂FC threshold for up/down classification
(default 1.0 — corresponding to a 2× fold change).
Dashed vertical lines are drawn at ±fc_cutoff. Points with
|log2FC| < fc_cutoff are always shown as not-significant regardless
of their p-value.
Sourcepub fn with_p_cutoff(self, cutoff: f64) -> Self
pub fn with_p_cutoff(self, cutoff: f64) -> Self
Set the p-value significance threshold (default 0.05).
A dashed horizontal line is drawn at −log10(p_cutoff). Points with
pvalue > p_cutoff are shown as not-significant regardless of their
fold change.
Sourcepub fn with_color_up<S: Into<String>>(self, color: S) -> Self
pub fn with_color_up<S: Into<String>>(self, color: S) -> Self
Set the color for up-regulated points (default "firebrick").
A point is up-regulated when log2fc ≥ fc_cutoff and
pvalue ≤ p_cutoff. Accepts any CSS color string.
Sourcepub fn with_color_down<S: Into<String>>(self, color: S) -> Self
pub fn with_color_down<S: Into<String>>(self, color: S) -> Self
Set the color for down-regulated points (default "steelblue").
A point is down-regulated when log2fc ≤ −fc_cutoff and
pvalue ≤ p_cutoff. Accepts any CSS color string.
Sourcepub fn with_color_ns<S: Into<String>>(self, color: S) -> Self
pub fn with_color_ns<S: Into<String>>(self, color: S) -> Self
Set the color for not-significant points (default "#aaaaaa").
All points that do not meet both the fold-change and p-value thresholds are drawn in this color. Accepts any CSS color string.
Sourcepub fn with_point_size(self, size: f64) -> Self
pub fn with_point_size(self, size: f64) -> Self
Set the circle radius in pixels (default 3.0).
Sourcepub fn with_label_top(self, n: usize) -> Self
pub fn with_label_top(self, n: usize) -> Self
Label the n most significant points (lowest p-values) with their names.
When n = 0 (default) no labels are drawn. Use
with_label_style to control placement.
let vp = VolcanoPlot::new()
.with_points(vec![("EGFR", 3.2_f64, 1e-4_f64)])
.with_label_top(10); // label the 10 most significant genesSourcepub fn with_label_style(self, style: LabelStyle) -> Self
pub fn with_label_style(self, style: LabelStyle) -> Self
Set the label placement style (default LabelStyle::Nudge).
LabelStyle::Nudge— labels are sorted by x and nudged vertically to reduce overlap. Best default for most datasets.LabelStyle::Exact— labels are placed at the exact point position with no adjustment. May overlap on dense plots.LabelStyle::Arrow— labels are offset by(offset_x, offset_y)px with a gray leader line back to the point.
use kuva::plot::{VolcanoPlot, LabelStyle};
let vp = VolcanoPlot::new()
.with_points(vec![("EGFR", 3.2_f64, 1e-4_f64)])
.with_label_top(10)
.with_label_style(LabelStyle::Arrow { offset_x: 14.0, offset_y: 16.0 });Sourcepub fn with_pvalue_floor(self, floor: f64) -> Self
pub fn with_pvalue_floor(self, floor: f64) -> Self
Set an explicit p-value floor for the −log10 transform.
Points with pvalue == 0.0 are clamped to this value before
transformation, preventing infinite y positions. Also sets the
y-axis ceiling to −log10(floor).
When not set, the floor is inferred as the minimum non-zero p-value in the data. Set it explicitly when comparing multiple plots that should share the same y-axis scale.
let vp = VolcanoPlot::new()
.with_points(vec![("EGFR", 3.2_f64, 0.0_f64)]) // p = 0 is valid input
.with_pvalue_floor(1e-10); // y-axis ceiling = 10Sourcepub fn with_legend<S: Into<String>>(self, label: S) -> Self
pub fn with_legend<S: Into<String>>(self, label: S) -> Self
Enable a legend showing Up, Down, and NS entries.
The legend uses the active up/down/NS colors. The string argument is not currently used as a title but must be set to enable the legend.
let vp = VolcanoPlot::new()
.with_points(vec![("EGFR", 3.2_f64, 1e-4_f64)])
.with_legend("DEG status");pub fn with_tooltips(self) -> Self
pub fn with_tooltip_labels( self, labels: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Trait Implementations§
Source§impl Default for VolcanoPlot
impl Default for VolcanoPlot
Source§impl From<VolcanoPlot> for Plot
impl From<VolcanoPlot> for Plot
Source§fn from(p: VolcanoPlot) -> Self
fn from(p: VolcanoPlot) -> Self
Auto Trait Implementations§
impl Freeze for VolcanoPlot
impl RefUnwindSafe for VolcanoPlot
impl Send for VolcanoPlot
impl Sync for VolcanoPlot
impl Unpin for VolcanoPlot
impl UnsafeUnpin for VolcanoPlot
impl UnwindSafe for VolcanoPlot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.