manhattan

manhattan(
    points
    *
    significance
    significance_direction='above'
    labels=None
    groups=None
)

Declare a scatter a Manhattan plot. Experimental.

A Manhattan plot puts genomic position (x) against significance (y, usually -log10 p). Declared one, the chart opens with how many points clear the threshold, which they are and which chromosomes they fall on, offers a rotor over just those points, and announces each point’s name and chromosome.

There is no effect cutoff: x is a position on the genome, not a size. Nothing in the drawing says where the threshold is, so it is never guessed: significance is required.

Parameters

Name Type Description Default
points Axes, PathCollection or sequence of PathCollection What ax.scatter returned – often one call per chromosome – or the axes they are drawn on, for every scatter on it. They become one layer, in the order given, or the order they were drawn for an Axes. Given some scatters of several on an axes, only those are converted; the others stay plain scatter layers. Declaring points again replaces the layer an earlier call made of them. required
significance float The cutoff on the y axis: 7.3 for genome-wide significance (p < 5e-8) on a -log10(p) axis. required
significance_direction ('above', 'below') Which side of significance the significant points are on. "below" is for a raw p-value axis. "above"
labels sequence or None A name per point, in the order the points were given to the scatter calls – the SNP ids. None
groups sequence or None A chromosome per point, in the same order. None

Returns

Name Type Description
Maidr The figure’s Maidr, now holding the Manhattan layer in place of the scatter layers of those points.

Raises

Name Type Description
TypeError If points is not a scatter or axes, or the cutoff is not a number.
ValueError If there is no scatter to declare, the cutoff is invalid, or labels or groups does not hold one entry per point.

Examples

>>> import matplotlib.pyplot as plt
>>> import maidr
>>> fig, ax = plt.subplots()
>>> points = ax.scatter([10, 120, 260], [2.1, 8.4, 1.0])
>>> _ = maidr.manhattan(
...     points,
...     significance=7.3,
...     labels=["rs1", "rs2", "rs3"],
...     groups=["chr1", "chr1", "chr2"],
... )