funki.plots

funki.plots.plot_counts_vs_n_genes(data, ax=None)

Generates a scatter plot displaying the number of genes by counts versus total gene counts.

Parameters:
  • data (funki.input.DataSet) – The data set from which to generate the figure

  • ax (matplotlib.axes.Axes) – Matplotlib Axes instance where to draw the plot. Defaults to None, meaning a new figure and axes will be generated.

Returns:

The figure contataining the resulting scatter plot. If an axes is passed, nothing is returned.

Return type:

matplotlib.figure.Figure | None

funki.plots.plot_counts_vs_pct_mito(data, ax=None)

Generates a scatter plot displaying the percentage of mitochondrial genes versus total gene counts.

Parameters:
  • data (funki.input.DataSet) – The data set from which to generate the figure

  • ax (matplotlib.axes.Axes) – Matplotlib Axes instance where to draw the plot. Defaults to None, meaning a new figure and axes will be generated.

Returns:

The figure contataining the resulting scatter plot. If an axes is passed, nothing is returned.

Return type:

matplotlib.figure.Figure | None

funki.plots.plot_dex(data, contrast=None, logfc_thr=1.0, fdr_thr=0.05, top=15, ax=None)

Plots the results of the differential expression analisis as a volcano plot.

Parameters:
  • data (funki.input.DataSet) – The data set from which to generate the figure

  • contrast (str) – Which result of the differential expression to use for the enrichment. Must be present in data.varm_keys named with the format '{contrast_var}_vs_{ref_var}'. Defaults to None.

  • logfc_thr (float, optional) – Threshold for signifacnce based on the log2(FC) value, defaults to 1.0

  • fdr_thr (float, optional) – Threshold for signifacnce based on the FDR value, defaults to 0.05

  • top (int, optional) – Number of top genes for which to display their gene name, defaults to 15.

  • ax (matplotlib.axes.Axes) – Matplotlib Axes instance where to draw the plot. Defaults to None, meaning a new figure and axes will be generated.

Returns:

The figure contataining the resulting scatter plot. If an axes is passed, nothing is returned.

Return type:

matplotlib.figure.Figure | None

funki.plots.plot_enrich(data, top=10, method=None, ax=None)

Generates a dotplot displaying the top results of an enrichment analysis based on the provided methods.

Parameters:
  • data (funki.input.DataSet) – The data set from which to generate the figure (it is assumed that funki.analysis.enrich() as been performed beforehand).

  • top (int, optional) – Number of top enriched gene sets to display based on their score, defaults to 10.

  • method (NoneType | str) – Which statistical method to use in order to compute the enrichment, defaults to None. If none is provided, uses 'ulm'. To see all the available methods, you can run decoupler.mt.show() function.

  • ax (matplotlib.axes.Axes) – Matplotlib Axes instance where to draw the plot. Defaults to None, meaning a new figure and axes will be generated.

Returns:

The figure contataining the resulting bar plot

Return type:

matplotlib.figure.Figure

funki.plots.plot_highest_expr(data, top=10, ax=None)

Generates a box plot of the top expressed genes (based on mean expression).

Parameters:
  • data (funki.input.DataSet) – The data set from which to generate the figure

  • top (int, optional) – Number of top genes to represent, defaults to 10

  • ax (matplotlib.axes.Axes) – Matplotlib Axes instance where to draw the plot. Defaults to None, meaning a new figure and axes will be generated.

Returns:

The figure contataining the resulting box plot. If an axes is passed, nothing is returned.

Return type:

matplotlib.figure.Figure | None

funki.plots.plot_n_genes(data, ax=None)

Generates a violin plot displaying the number of genes by counts. This is, number of genes per cell that have non-zero counts.

Parameters:
  • data (funki.input.DataSet) – The data set from which to generate the figure

  • ax (matplotlib.axes.Axes) – Matplotlib Axes instance where to draw the plot. Defaults to None, meaning a new figure and axes will be generated.

Returns:

The figure contataining the resulting violin plot. If an axes is passed, nothing is returned.

Return type:

matplotlib.figure.Figure | None

funki.plots.plot_obs(data, obs_var, ax=None)

Generates a plot to visualize the metadata.

Parameters:
  • data (funki.input.DataSet) – The data set from which to generate the figure (it is assumed that funki.analysis.enrich() as been performed beforehand).

  • obs_var (str) – The variable (column name) of the observations matrix to plot.

  • ax (matplotlib.axes.Axes) – Matplotlib Axes instance where to draw the plot. Defaults to None, meaning a new figure and axes will be generated.

Returns:

The figure contataining the resulting plot. If an axes is passed, nothing is returned.

Return type:

matplotlib.figure.Figure | None

funki.plots.plot_pca(data, color=None, use_highly_variable=True, recalculate=False, ax=None, **kwargs)

Plots the dimensionality reduction PCA results of a data set.

Parameters:
  • data (funki.input.DataSet) – The data set from which to compute the PCA

  • color (str, optional) – Variable to color from, defaults to None

  • use_highly_variable (bool, optional) – Whether to use highly variable genes only or all genes available, defaults to True

  • recalculate (bool, optional) – Whether to recalculate the dimensionality reduction, defaults to False

  • ax (matplotlib.axes.Axes) – Matplotlib Axes instance where to draw the plot. Defaults to None, meaning a new figure and axes will be generated.

  • **kwargs (optional) – Other keyword arguments that can be passed to scanpy.pp.pca()

Returns:

The figure contataining the scatter plot showing the PCA embedding

Return type:

matplotlib.figure.Figure

funki.plots.plot_pct_counts_mito(data, ax=None)

Generates a violin plot displaying the percentage of mitochondrial genes.

Parameters:
  • data (funki.input.DataSet) – The data set from which to generate the figure

  • ax (matplotlib.axes.Axes) – Matplotlib Axes instance where to draw the plot. Defaults to None, meaning a new figure and axes will be generated.

Returns:

The figure contataining the resulting violin plot. If an axes is passed, nothing is returned.

Return type:

matplotlib.figure.Figure | None

funki.plots.plot_total_counts(data, ax=None)

Generates a violin plot displaying the total counts per gene.

Parameters:
  • data (funki.input.DataSet) – The data set from which to generate the figure

  • ax (matplotlib.axes.Axes) – Matplotlib Axes instance where to draw the plot. Defaults to None, meaning a new figure and axes will be generated.

Returns:

The figure contataining the resulting violin plot. If an axes is passed, nothing is returned.

Return type:

matplotlib.figure.Figure | None

funki.plots.plot_tsne(data, color=None, perplexity=30, recalculate=False, ax=None)

Plots the dimensionality reduction t-SNE results of a data set.

Parameters:
  • data (funki.input.DataSet) – The data set from which to compute the t-SNE

  • color (str, optional) – Variable to color from, defaults to None

  • perplexity (int, optional) – Perplexity hyperparmaeter for the t-SNE representation. Relates to the number of nearest neighbours, defaults to 30

  • recalculate (bool, optional) – Whether to recalculate the dimensionality reduction, defaults to False

  • ax (matplotlib.axes.Axes) – Matplotlib Axes instance where to draw the plot. Defaults to None, meaning a new figure and axes will be generated.

Returns:

The figure contataining the scatter plot showing the tSNE embedding

Return type:

matplotlib.figure.Figure

funki.plots.plot_umap(data, color=None, min_dist=0.5, spread=1.0, alpha=1.0, gamma=1.0, recalculate=False, ax=None, **kwargs)

Plots the dimensionality reduction UMAP results of a data set.

Parameters:
  • data (funki.input.DataSet) – The data set from which to compute the UMAP

  • color (str, optional) – Variable to color from, defaults to None

  • min_dist (float, optional) – Effective minimum distance between the embedded points

  • spread (float, optional) – Effective scale of embedded points

  • alpha (float, optional) – Initial learning rate for the optimization

  • gamma (float, optional) – Weighting applied to negative samples for the optimization

  • recalculate (bool, optional) – Whether to recalculate the dimensionality reduction, defaults to False

  • ax (matplotlib.axes.Axes) – Matplotlib Axes instance where to draw the plot. Defaults to None, meaning a new figure and axes will be generated.

  • **kwargs (optional) – Other keyword arguments that can be passed to scanpy.tl.umap()

Returns:

The figure contataining the scatter plot showing the UMAP embedding

Return type:

matplotlib.figure.Figure