pub struct ColorDomain { /* private fields */ }Expand description
Finite exact color limits, including a constant domain.
Implementations§
Source§impl ColorDomain
impl ColorDomain
Sourcepub fn exact(minimum: f64, maximum: f64) -> Result<ColorDomain, Error>
pub fn exact(minimum: f64, maximum: f64) -> Result<ColorDomain, Error>
Construct finite minimum/maximum with maximum at least minimum; normalize zero.
Examples found in repository?
examples/strided_heatmap.rs (line 67)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let mut arguments = std::env::args_os().skip(1);
10 let directory = match arguments.next() {
11 Some(path) if !path.is_empty() => std::path::PathBuf::from(path),
12 Some(_) => return Err("output directory must not be empty".into()),
13 None => std::env::current_dir()?,
14 };
15 if arguments.next().is_some() {
16 return Err("usage: strided_heatmap [output-directory]".into());
17 }
18 std::fs::create_dir_all(&directory)?;
19 // ANCHOR: strided-values
20 // Interleaved quality-control columns are deliberately excluded by the view.
21 let measurements = array![
22 [0.2, 99.0, 0.8, 99.0, 1.4, 99.0, 1.7, 99.0],
23 [0.1, 99.0, 0.6, 99.0, 1.1, 99.0, 1.3, 99.0],
24 [-0.1, 99.0, -0.5, 99.0, -0.9, 99.0, -1.4, 99.0],
25 [0.0, 99.0, 0.3, 99.0, 0.9, 99.0, 1.2, 99.0],
26 ];
27 let times = ["0 h", "2 h", "6 h", "12 h"];
28 let programs = [
29 "Inflammation",
30 "Stress response",
31 "Cell cycle",
32 "DNA repair",
33 ];
34 let present = array![
35 [true, true, true, true],
36 [true, true, true, true],
37 [true, false, true, true],
38 [true, true, true, true],
39 ];
40 let highlights = array![
41 [false, false, false, true],
42 [false, false, false, false],
43 [false, false, false, true],
44 [false, false, false, false],
45 ];
46 let cell_ids = array![
47 [101u64, 102, 103, 104],
48 [105, 106, 107, 108],
49 [109, 110, 111, 112],
50 [113, 114, 115, 116]
51 ];
52 let heatmap = nd::Heatmap::new((measurements.slice(s![.., ..;2]), present.view()))?
53 .heatmap_highlight(highlights.view())?
54 .source_rows(cell_ids.view())?;
55 // ANCHOR_END: strided-values
56 // ANCHOR: strided-plot
57 heatmap
58 .labels(Labels::raw())
59 .x_labels(times)?
60 .y_labels(programs)?
61 .x_label("Time after stimulus")
62 .y_label("Response program")
63 .color_label("Response (log2 fold change)")
64 .continuous_color_scale(ContinuousColorScale::diverging(
65 0.0,
66 None,
67 Some(ColorDomain::exact(-2.0, 2.0)?),
68 )?)
69 .size(780, 480)
70 .title("Response programs from a strided assay matrix")
71 .caption("Synthetic illustration · alternate source columns · one missing cell · no inferred clustering")
72 .svg(directory.join("strided_heatmap.svg"))?
73 .svg_preserve_text(directory.join("strided_heatmap_text.svg"))?;
74 // ANCHOR_END: strided-plot
75 Ok(())
76}Trait Implementations§
Source§impl Clone for ColorDomain
impl Clone for ColorDomain
Source§fn clone(&self) -> ColorDomain
fn clone(&self) -> ColorDomain
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ColorDomain
impl Debug for ColorDomain
impl Eq for ColorDomain
Source§impl PartialEq for ColorDomain
impl PartialEq for ColorDomain
impl StructuralPartialEq for ColorDomain
Auto Trait Implementations§
impl Forget for ColorDomain
impl Freeze for ColorDomain
impl Move for ColorDomain
impl RefUnwindSafe for ColorDomain
impl Send for ColorDomain
impl Sync for ColorDomain
impl Unpin for ColorDomain
impl UnsafeUnpin for ColorDomain
impl UnwindSafe for ColorDomain
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.