mira.time.trace_differentiation#
- mira.time.trace_differentiation(adata, basis='X_umap', pseudotime_key='mira_pseudotime', diffmap_distances_key='X_diffmap_distances', diffmap_coordinates_key='X_diffmap', transport_map_key=None, start_cells=None, start_lineage=None, num_start_cells=50, palette='BuPu', add_outline=True, outline_width=(0, 12), outline_color='lightgrey', size=1, figsize=(10, 7), fps=24, steps_per_frame=1, num_steps=4000, ka=5, vmax_quantile=0.99, direction='forward', num_preview_frames=4, log_prob=False, sqrt_time=False, *, save_name, **plot_args)#
Starting from a group of initial cells, trace the diffusion over time through the markov chain model of differentiation.
In “forward” mode, traces the cells along paths from less to more differentiated states and elucides paths to different terminal states.
In “backward” mode, start from a terminal state and find ancestor populations of cells.
- Parameters
- adataanndata.AnnData
Anndata with pseudotime defined.
- save_namestr
Filepath to write .gif file of trace.
- direction{“forward”,”backward”}, default = “forward”
Which direction to run the diffusion process. Forward simulates the differentiation process and traces descendent cell populations. Backwards finds ancestral cell populations.
- palettestr or None, default = “BuPu”
Palette of plot. Default of None will set palette to the style-specific default.
- fpsint > 0, default = 24
Frames-per-second of movie.
- setps_per_frameint > 0, default = 1
Number of steps to take on the transport map for each frame. Larger values will give a more “jumpy” trace, but will reduce the amount of frames to plot.
- num_stepsint > 0, default = 40000
Number of steps to take through transport map. This must be set high enough to show the desired diffusion process, but may be trimmed to the appropriate length for your data.
- kaint > 0, default = 5
The ka-th neighbor defines the neighborhood size when creating the transport map. A larger neighborhood size creates a transport map that is more tolerant of backwards steps.
- basisstr, default = “X_umap”
- Returns
- None, but saves a gif of the diffusion process to save_name.
- Other Parameters
- figsizetuple(int, int), default = (10,7)
Size of plot
- add_outlinebool, default = True
Add outline around embedding plots of cells. Shows boundaries of cells with low color values more clearly.
- outline_widthtuple(int, int), default = (0,12)
Width of the outline, if add_outline is True. The first value in the tuple is the additional size around the data point of a white outline. The second value is the additional size around the data point of a colored outline.
- outline_colorstr, default = “lightgrey”
Color of the outline, if add_outline is True.
- sizeint, default = 1
Size of datapoints on embedding plot.
- num_preview_framesint > 0, default = 4
Number of frames to preview.
- vmax_quantilefloat > 0, < 1, default = 0.99
At each frame, the color scale is capped at this quantile of probabilities in the data. Adjusting this down will show lower-probability cells in each frame.
- sqrt_timebool, default = False
Take frames at steps linearly increasing in sqrt space. This makes smaller jumps at lower step counts than at higher stepcounts. If your are tracing a process that evolves more quaickly at the onset, set this to True.
- log_probbool, default = False
Plot log-probabilities instead of probabilities. If frames are dominated by high-probability cells, this may reveal other populations.
Examples
>>> mira.time.trace_differentiation(data, start_lineage='IRS', num_steps=1500, ... save_name='data/hf_diff.gif', direction='backward', sqrt_time=True, ... log_prob=True, steps_per_frame=15, figsize=(7,4))
Note
This function is part of the mira.time API and works with several others to help users understand lineage structures and dynamic processes in their data. Please refer to the pseudotime trajectory inference tutorial.