cellrank.pl.gene_trends¶
-
cellrank.pl.
gene_trends
(adata, model, genes, lineages=None, backward=False, data_key='X', time_key='latent_time', transpose=False, time_range=None, callback=None, conf_int=True, same_plot=False, hide_cells=False, perc=None, lineage_cmap=None, abs_prob_cmap=<matplotlib.colors.ListedColormap object>, cell_color='black', cell_alpha=0.6, lineage_alpha=0.2, size=15, lw=2, cbar=True, margins=0.015, sharex=None, sharey=None, gene_as_title=None, legend_loc='best', ncols=2, suptitle=None, return_models=False, n_jobs=1, backend='loky', show_progress_bar=True, figsize=None, dpi=None, save=None, plot_kwargs=mappingproxy({}), **kwargs)[source]¶ Plot gene expression trends along lineages.
Each lineage is defined via it’s lineage weights which we compute using
cellrank.tl.lineages()
. This function accepts any model based offcellrank.ul.models.BaseModel
to fit gene expression, where we take the lineage weights into account in the loss function.- Parameters
adata¶ (
anndata.AnnData
) – Annotated data object.model¶ (
Union
[BaseModel
,Mapping
[str
,Mapping
[str
,BaseModel
]]]) –Model based on
cellrank.ul.models.BaseModel
to fit.If a
dict
, gene and lineage specific models can be specified. Use'*'
to indicate all genes or lineages, for example{'Map2': {'*': ...}, 'Dcx': {'Alpha': ..., '*': ...}}
.genes¶ (
Union
[str
,Sequence
[str
]]) – Genes inadata.var_names
or inadata.raw.var_names
, ifuse_raw=True
.lineages¶ (
Union
[str
,Sequence
[str
],None
]) – Names of the lineages to plot. If None, plot all lineages.data_key¶ (
str
) – Key inadata.layers
or ‘X’ foradata.X
where the data is stored.time_key¶ (
str
) – Key inadata.obs
where the pseudotime is stored.time_range¶ (
Union
[float
,Tuple
[Optional
[float
],Optional
[float
]],None
,List
[Union
[float
,Tuple
[Optional
[float
],Optional
[float
]],None
]]]) –Specify start and end times:
This can also be specified on per-lineage basis.
transpose¶ (
bool
) – Ifsame_plot=True
, group the trends bylineages
instead ofgenes
. This enforceshide_cells=True
. Ifsame_plot=False
, showlineages
in rows andgenes
in columns.callback¶ (
Union
[Callable
,Mapping
[str
,Mapping
[str
,Callable
]],None
]) – Function which takes acellrank.ul.models.BaseModel
and some keyword arguments forcellrank.ul.models.BaseModel.prepare()
and returns the prepared model. Can be specified in gene- and lineage-specific manner, similarly tomodel
.conf_int¶ (
Union
[bool
,float
]) – Whether to compute and show confidence interval. If themodel
iscellrank.ul.models.GAMR
, it can also specify the confidence level, the default is 0.95.same_plot¶ (
bool
) – Whether to plot all lineages for each gene in the same plot.perc¶ (
Union
[Tuple
[float
,float
],Sequence
[Tuple
[float
,float
]],None
]) – Percentile for colors. Valid values are in interval [0, 100]. This can improve visualization. Can be specified individually for each lineage.lineage_cmap¶ (
Optional
[ListedColormap
]) – Categorical colormap to use when coloring in the lineages. If None andsame_plot
, use the corresponding colors inadata.uns
, otherwise use ‘black’.abs_prob_cmap¶ (
ListedColormap
) – Continuous colormap to use when visualizing the absorption probabilities for each lineage. Only used whensame_plot=False
.cell_color¶ (
str
) – Color of the cells when not visualizing absorption probabilities. Only used whensame_plot=True
.lineage_alpha¶ (
float
) – Alpha channel for lineage confidence intervals.cbar¶ (
bool
) – Whether to show colorbar. Always shown when percentiles for lineages differ. Only used whensame_plot=False
.sharex¶ (
Union
[str
,bool
,None
]) – Whether to share x-axis. Valid options are ‘row’, ‘col’ or ‘none’.sharey¶ (
Union
[str
,bool
,None
]) – Whether to share y-axis. Valid options are ‘row’, ‘col’ or ‘none’.gene_as_title¶ (
Optional
[bool
]) – Whether to show gene names as titles instead on y-axis.legend_loc¶ (
Optional
[str
]) – Location of the legend displaying lineages. Only used when same_plot=True.ncols¶ (
int
) – Number of columns of the plot when plotting multiple genes. Only used whensame_plot=True
.return_models¶ (
bool
) – If True, return the fitted models for each gene ingenes
and lineage inlineages
.show_progress_bar¶ (
bool
) – Whether to show a progress bar. Disabling it may slightly improve performance.n_jobs¶ (
Optional
[int
]) – Number of parallel jobs. If -1, use all available cores. If None or 1, the execution is sequential.backend¶ (
str
) – Which backend to use for parallelization. Seejoblib.Parallel
for valid options.figsize¶ (
Optional
[Tuple
[float
,float
]]) – Size of the figure.save¶ (
Union
[Path
,str
,None
]) – Filename where to save the plot.plot_kwargs¶ (
Mapping
) – Keyword arguments forcellrank.ul.models.BaseModel.plot()
.**kwargs¶ – Keyword arguments for
cellrank.ul.models.BaseModel.prepare()
.
- Return type
- Returns
None – If
return_models=False
, just plots the figure and optionally saves it based onsave
.Dict[str, Dict[str,
cellrank.ul.models.BaseModel
]] – Otherwise returns the fitted models as{'gene_1': {'lineage_1': <model_11>, ...}, ...}
. Models which have failed will be instances ofcellrank.ul.models.FailedModel
.