mantispy.pl.cell_cycle_clock#
- mantispy.pl.cell_cycle_clock(adata, key='cell_cycle', color=None, groups=None, radius=None, groupby=None, ncols=None, ax=None, size=None, alpha=None, width=None, palette=None, cmap=None, vmin=None, vmax=None, na_color='lightgray', legend_loc='right margin', legend_fontsize=6, frameon=False, rim=True, seed=0, kind='cells', bandwidth=0.02, reference=None, **kwargs)[source]#
Cells on a ring, placed by angle at a cycle position drawn from their posterior.
The angle is a cycle position drawn from each cell’s posterior from
project_cell_cycle(), seeded for a stable figure, so the ring fills rather than stacking on the medians. Position 0 is at the top and the angle runs clockwise, so G1 starts at twelve o’clock and a cell comes back to the top as it divides. Cells sit in a band around a ring, spread radially at random withinwidth, or, withradius, on an annulus whose radius follows anobscolumn such as the DNA content.DNA content orders cells only through S, since it is flat at 2N through G1 and at 4N through G2M. The S arc therefore places each cell from its own DNA, while in the G1 and G2M arcs the angle follows the reference’s age distribution, where a cell is more likely to sit early. Those two arcs are shaded and labelled as the population prior. When
obs[key + "_" + phase + "_order"]holds an order fromphase_order(), the cells of that phase sit on their arc by that order instead, and the arc is labelled as the experimental order. Read the clock by where a colour concentrates, not as a fine order within a prior arc. Cells off the cycle have no position and are left out.With
kind="rings"the same positions are smoothed into one density per category ofcolor, each on its own ring in the order ofgroups, the first outermost, so where in the cycle the cells of each group concentrate reads from the ring’s height.kind="ridge"draws the same densities as rows over a straight cycle axis, which stays readable for many groups. Densities share one scale within a panel and across panels with the same number of rings or rows, and each density reads against its own dashed line, which marks the height of cells spread evenly over the cycle. A category with too few cells in a panel to give a density gets none there, with a warning. Within a prior arc the shape of a density follows the prior, so compare how much of each group sits in an arc rather than its shape there.The colour and legend parameters follow
scanpy.pl.embedding().- Parameters:
- adata
AnnData Single-cell object
project_cell_cycle()has run on.- key
str(default:'cell_cycle') The
key_addedprefixproject_cell_cycle()wrote.- color
str|None(default:None) What colours the cells:
Nonefor the phase;"position"orkey + "_position"for the cycle position on a cyclic colour map; anotherobscolumn, categorical or numeric; or a feature. Cells with a position but no value are drawn inna_color.- groups
list[str] |str|None(default:None) With a categorical
color, colour only the named categories, each with its own colour and a legend, and draw every other cell inna_colorbehind them.Nonecolours every category.- radius
str|None(default:None) An
obscolumn mapped to the radius, so the ring becomes an annulus, its inner edge the column’s 2nd percentile and its outer edge the 98th.Nonekeeps the ring.- groupby
str|None(default:None) obscolumn whose groups each get their own clock on a shared layout, colour scale and legend, orNonefor one clock.- ncols
int|None(default:None) Clocks per row when
groupbyis given, orNonefor up to five per row.- ax
Axes|None(default:None) Axes to draw a single clock on, or
Nonefor a new figure.- size
float|None(default:None) Marker area;
Nonescales it with the number of cells, as scanpy does.- alpha
float|None(default:None) Marker opacity;
Nonefor a default that depends oncolor.- width
float|None(default:None) Thickness of the band the cells sit in, as a fraction of the ring’s radius. A wider band spreads a crowded arc out.
Nonegives 0.3 for the ring and 0.6 for theradiusannulus.- palette
Mapping[str,Any] |Sequence[Any] |str|None(default:None) Colours for a categorical
color: a mapping from category to colour, a list of colours taken in order, or a colour map name. Categories it leaves out keep the phase colours or a default.- cmap
str|None(default:None) Colour map for a numeric or feature
color; defaults to twilight for the cyclic position and viridis otherwise.- vmin
float|str|None(default:None) Lower end of a numeric colour scale: a number, or
"pN"for the N-th percentile of the drawn values.Nonegives the 2nd percentile.- vmax
float|str|None(default:None) Upper end, read the same way;
Nonegives the 98th percentile.- na_color
Any(default:'lightgray') Colour of cells with a position but no value, and of the cells outside
groups.- legend_loc
str|None(default:'right margin') "right margin"for a legend beside the clock,"on data"to write each category at the angle where its cells concentrate, orNonefor no legend.- legend_fontsize
float(default:6) Font size of the legend or the labels on the clock.
- frameon
bool(default:False) Draw a frame around each clock.
- rim
bool(default:True) Draw the phase arcs outside the ring.
- seed
int(default:0) Seed for the drawn positions, the radial spread and the draw order.
- kind
str(default:'cells') "cells"for one marker per cell,"rings"for one density ring per category ofcolor, or"ridge"for one density row per category. Withcolor=Nonethe densities draw one curve over every cell, filled by phase.radius,size,alpha,width, the colour scale andkwargsapply to"cells"only.- bandwidth
float(default:0.02) Standard deviation of the smoothing kernel of
"rings"and"ridge", as a fraction of the cycle.- reference
str|None(default:None) A category, such as the controls, whose density becomes the dashed line of every ring and row instead of the even spread, so a group’s arrest shows where it rises above the reference. It is a category of
color, drawn first, or ofgroupbywhencolorisNone. A panel with too few reference cells compares to the reference cells of every panel.- kwargs
Any Passed to the scatter, overriding its defaults;
normsets a numeric scale.
- adata
- Return type:
- Returns:
The axes when the caller passed
ax, elseNonebecause the plot then owns the figure it created.- Raises:
KeyError –
obsmhas nokey + "_quantiles", orcolororradiusnames nothing.ValueError –
coloris both anobscolumn and a feature,groupsis given without a categoricalcolor, a name ingroupsis not a category ofcolor,axis given withgroupby,legend_locis not one of its options,vminorvmaxis a string that is not a percentile,kindis not one of its options,kinddraws densities of a numericcolor,bandwidthis not positive, orreferenceis not a category ofcolororgroupby.