Contents Menu Expand Light mode Dark mode Auto light/dark mode
CellRank 1.5.1 documentation
Logo

General

  • Installation
  • API
    • Kernels
      • cellrank.kernels.VelocityKernel
      • cellrank.kernels.ConnectivityKernel
      • cellrank.kernels.PseudotimeKernel
      • cellrank.kernels.CytoTRACEKernel
      • cellrank.kernels.PrecomputedKernel
      • cellrank.external.kernels.StationaryOTKernel
      • cellrank.external.kernels.WOTKernel
    • Estimators
      • cellrank.estimators.GPCCA
      • cellrank.estimators.CFLARE
    • Models
      • cellrank.models.GAM
      • cellrank.models.GAMR
      • cellrank.models.SKLearnModel
    • Plotting
      • cellrank.pl.circular_projection
      • cellrank.pl.gene_trends
      • cellrank.pl.log_odds
      • cellrank.pl.heatmap
      • cellrank.pl.cluster_trends
      • cellrank.pl.aggregate_absorption_probabilities
    • Datasets
      • cellrank.datasets.pancreas
      • cellrank.datasets.lung
      • cellrank.datasets.reprogramming_morris
      • cellrank.datasets.reprogramming_schiebinger
      • cellrank.datasets.zebrafish
      • cellrank.datasets.pancreas_preprocessed
      • cellrank.datasets.bone_marrow
    • Developer API
  • Release Notes
    • CellRank dev (2023-03-26)
    • CellRank 1.5.1 (2022-01-13)
    • CellRank 1.5.0 (2021-09-13)
    • CellRank 1.4.0 (2021-06-30)
    • CellRank 1.3.1 (2021-04-09)
    • CellRank 1.3.0 (2021-03-29)
    • CellRank 1.2.0 (2021-02-02)
    • CellRank 1.1.0 (2020-11-17)
    • CellRank 1.0.0 (2020-10-17)
  • Contributing guide
  • References

Gallery

  • Tutorials
    • CellRank basics
    • CellRank meets pseudotime
    • CellRank meets CytoTRACE
    • Creating a new kernel
  • Examples

About

  • About CellRank
  • How to cite us
  • Team
  • GitHub
  • Discourse
  v: latest
Versions
latest
stable
Downloads
html
On Read the Docs
Project Home
Builds
Back to top
Edit this page

cellrank.pl.gene_trends#

cellrank.pl.gene_trends(adata, model, genes, lineages=None, backward=False, data_key='X', time_key='latent_time', time_range=None, transpose=False, 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=None, 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', obs_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, return_figure=False, plot_kwargs=mappingproxy({}), **kwargs)[source]#

Plot gene expression trends along lineages.

Each lineage is defined via it’s lineage weights. This function accepts any model based off cellrank.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.models.BaseModel to fit.

    If a dict, gene and lineage specific models can be specified. Use '*' to indicate all genes or lineages, for example {'gene_1': {'*': ...}, 'gene_2': {'lineage_1': ..., '*': ...}}.

  • genes (Union[str, Sequence[str]]) – Genes in anndata.AnnData.var_names or in anndata.AnnData.raw.var_names, if use_raw = True.

  • lineages (Union[str, Sequence[str], None]) – Names of the lineages to plot. If None, plot all lineages.

  • backward (bool) – Direction of the process.

  • data_key (str) – Key in anndata.AnnData.layers or ‘X’ for anndata.AnnData.X where the data is stored.

  • time_key (str) – Key in anndata.AnnData.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:

    • If a tuple, it specifies the minimum and maximum pseudotime. Both values can be None, in which case the minimum is the earliest pseudotime and the maximum is automatically determined.

    • If a float, it specifies the maximum pseudotime.

    This can also be specified on per-lineage basis.

  • gene_symbols – Key in anndata.AnnData.var to use instead of anndata.AnnData.var_names.

  • transpose (bool) – If same_plot = True, group the trends by lineages instead of genes. This forces hide_cells = True. If same_plot = False, show lineages in rows and genes in columns.

  • callback (Union[Callable, Mapping[str, Mapping[str, Callable]], None]) – Function which takes a cellrank.models.BaseModel and some keyword arguments for cellrank.models.BaseModel.prepare() and returns the prepared model. Can be specified in gene- and lineage-specific manner, similarly to model.

  • conf_int (Union[bool, float]) – Whether to compute and show confidence interval. If the model is cellrank.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.

  • hide_cells (bool) – If True, hide all cells.

  • 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 and same_plot, use the corresponding colors in anndata.AnnData.uns, otherwise use ‘black’.

  • abs_prob_cmap (ListedColormap) – Continuous colormap to use when visualizing the absorption probabilities for each lineage. Only used when same_plot = False.

  • cell_color (Optional[str]) – Key in anndata.AnnData.obs or anndata.AnnData.var_names used for coloring the cells.

  • cell_alpha (float) – Alpha channel for cells.

  • lineage_alpha (float) – Alpha channel for lineage confidence intervals.

  • size (float) – Size of the points.

  • lw (float) – Line width of the smoothed values.

  • cbar (bool) – Whether to show colorbar. Always shown when percentiles for lineages differ. Only used when same_plot = False.

  • margins (float) – Margins around the plot.

  • 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.

  • obs_legend_loc (Optional[str]) – Location of the legend when cell_color corresponds to a categorical variable.

  • ncols (int) – Number of columns of the plot when plotting multiple genes. Only used when same_plot = True.

  • suptitle (Optional[str]) – Suptitle of the figure.

  • return_figure (bool) – Whether to return the figure object.

  • return_models (bool) – If True, return the fitted models for each gene in genes and lineage in lineages.

  • 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 (Literal['loky', 'multiprocessing', 'threading']) – Which backend to use for parallelization. See joblib.Parallel for valid options.

  • figsize (Optional[Tuple[float, float]]) – Size of the figure.

  • dpi (Optional[int]) – Dots per inch.

  • save (Union[str, Path, None]) – Filename where to save the plot.

  • plot_kwargs (Mapping[str, Any]) – Keyword arguments for cellrank.models.BaseModel.plot().

  • kwargs (Any) – Keyword arguments for cellrank.models.BaseModel.prepare().

Return type:

Optional[Mapping[str, Mapping[str, BaseModel]]]

Returns:

: None

If return_models = False, just plots the figure and optionally saves it based on save.

Dict[str, Dict[str, cellrank.models.BaseModel]]

Otherwise returns the fitted models as {'gene_1': {'lineage_1': <model_11>, ...}, ...}. Models which have failed will be instances of cellrank.models.FailedModel.

Next
cellrank.pl.log_odds
Previous
cellrank.pl.circular_projection
Copyright © 2023, Marius Lange, Michal Klein, Philipp Weiler
Made with Furo
On this page
  • cellrank.pl.gene_trends
    • gene_trends()