Visualizing YAML well metadata

Many of the features of rushd load metadata using YAML files. However, writing these files can be error-prone, especially with complicated experimental setups.

rushd also includes plotting functions that can generate well maps automatically for you! Enter plot_well_metadata, which has the following interface:

rushd.plot.plot_well_metadata(filename, *, output_dir=None, plate_size=None, columns=None, style=None)[source]

Plot the specified metadata columns listed in a YAML file.

Parameters:
  • filename (str or pathlib.Path) – The path to the YAML file containing the mapping

  • output_dir (optional pathlib.Path) – If given, outputs plate maps as PNGs, PDFs, and SVGs into this folder. If not given, plots are plt.show’d interactively.

  • plate_size (optional Tuple[int,int]) – The width and height of the plate, in number of wells. Defaults to a 96- or 384-well plate.

  • columns (optional List[str]) – The list of columns to plot. If not specified, all metadata columns are plotted.

Automatic plotting of well metadata

Consider the following YAML metadata file:

metadata:
    inducible_fluorophore:
        - TagBFP: A1-H9
        - EGFP: A10-H12
    orientation:
        - tandem: A1-H3, A10-H12
        - convergent: A4-H6
        - divergent: A7-H9
    inducible_spacerlength:
        - 0: A1-H9
        - 2: A10-H12
    dox:
        - 0: A1-A12
        - 0.0000820: B1-B12
        - 0.0003248: C1-C12
        - 0.0012864: D1-D12
        - 0.0050940: E1-E12
        - 0.0201723: F1-F12
        - 0.0798822: G1-G12
        - 0.3163330: H1-H12

By default, plot_well_metadata will use a default color scheme for every column listed in the metadata file. For numerical columns, it will auto-detect if a linear or log plot is better, and use a Viridis color scheme (with the yellow part of viridis removed).

For the above YAML file, we can get the following plots:

import rushd as rd
../_images/inducible_fluorophore.svg
../_images/orientation.svg
../_images/inducible_spacerlength.svg
../_images/dox.svg

Here, you can see the automatic color assignment for both categorical variables, linear numerical variables, and log-distributed variables.

Note

The automatic detection of log-distributed data examines the median of the values. If all values are non-negative and the median is outside of the percentile range [0.15, 0.85], the data is detected as log-distributed.

You can override this as discussed below.

Modifying output color mapping

You can override the default color set in multiple ways. First, you can specify the style of a column to be 'category', 'linear', or 'log' to override autodetection:


../_images/dox1.svg

Importantly, you don’t have to specify a style for each column plotted; it will default to style autodetection.

You can also specify an explicit colormap that specifies a color for each entry:

rd.plot.plot_well_metadata("example_plot_metadata.yaml", columns=["dox"], style={"dox": "linear"})
rd.plot.plot_well_metadata(
    "example_plot_metadata.yaml",
    columns=["orientation"],
    style={"orientation": {"tandem": "#19D2BF", "convergent": "#FFB133", "divergent": "#FE484E"}},
../_images/orientation1.svg

Plotting non-96 wells

By using the plate_size parameter, you can plot smaller plates, like a 6 well plate:

metadata:
  virus:
    - N: A1
    - I: A2
    - L: A3
    - B: B1
    - A: B2
    - M: B3
)
../_images/virus.svg