mantispy.tl.project_cell_cycle#
- mantispy.tl.project_cell_cycle(adata, model='cell_cycle', by=('Metadata_Plate', 'Metadata_Well'), checks=('irregular', 'small', 'dim'), key_added='cell_cycle', copy=False)[source]#
Place every cell on the cycle of a model from
fit_cell_cycle(), with its uncertainty.Each cell gets a posterior over its position: the age distribution of the reference as the prior, times how well the cell’s DNA content fits each position. From it come the probability of each phase, and of sitting below 2N or above 4N, off the cycle, and quantiles of the position. An S cell is placed tightly. A G1 or G2M cell spreads over its whole plateau, since DNA content does not order cells within it, so there its position is the prior. Perturbed cells are placed on the reference’s cycle, so an arrest shows up as cells piling up at one position.
Each
bygroup, normally a well, is also checked against the reference. When its 2N and 4N peaks both sit off the reference’s by more than the 2N peak width, the well reads its DNA stain differently, every position in it is biased by that shift, and a warning names it. The positions are not corrected, since a well with only one of the two peaks, such as an arrested one, cannot tell a shifted stain from a shifted population. Groups that cannot be checked are named in a warning with the reason.- Parameters:
- adata
AnnData Object-resolution object carrying the DNA content column the model was fitted on.
- model
str|Mapping(default:'cell_cycle') Key of the model in
uns["mantispy"], or the model itself, such as one fitted on another object.- by
Sequence[str] |str|None(default:('Metadata_Plate', 'Metadata_Well')) The
obscolumns of a well, to check each well’s peaks against the reference;Noneskips the check. The default uses whichever ofMetadata_PlateandMetadata_Wellthe object has.- checks
Sequence[str] (default:('irregular', 'small', 'dim')) The shape checks to flag, out of
"irregular","small"and"dim", when the model holdsqc_features. Rounded mitotic cells can fail the solidity check as merged nuclei do, so whether to use"irregular"depends on the cell line and the question.- key_added
str(default:'cell_cycle') Prefix of the outputs written.
- copy
bool(default:False) Return a modified copy instead of mutating in place.
- adata
- Return type:
- Returns:
None, or the modified copy. Writesobsm[key_added + "_probabilities"], a frame with the probability of each ofCYCLE_PHASESper cell;obs[key_added + "_phase"], the most probable of them, for convenience;obs[key_added + "_position"], the posterior median in [0, 1), 0 being the start of G1;obsm[key_added + "_quantiles"], a frame with the 5%, 25%, 50%, 75% and 95% posterior quantiles;obs[key_added + "_qc"], when the model holdsqc_features, the first ofchecksa nucleus fails:"irregular"for a solidity below the reference’s, as merged nuclei and mitotic figures have,"small"for an area below it, as fragments and debris have,"dim"for too little DNA per area, and"ok"otherwise;uns["mantispy"][key_added], the model used, so plots read its phase edges from there; anduns["mantispy"][key_added + "_wells"], one row perbygroup with itsn_cellsand theshiftits 2N and 4N peaks share against the reference, in doublings,NaNwhen it could not be checked. A cell without a DNA content getsNaNpositions and phases, as does every cell when the model failed its check. A cell off the cycle getsNaNpositions. Columns of an earlier projection underkey_addedthat this model does not write, and the orders ofphase_order(), are removed.- Raises:
KeyError –
uns["mantispy"]has no entrymodel, orobslacks the DNA content column it was fitted on or abycolumn, or the object lacks a feature of the model’sqc_features.ValueError – A
bycolumn holds missing values, orchecksnames an unknown check.
See also
Where cells sit in the cycle for a worked example, and How the cell-cycle model works for how the model works, step by step.