scanpy.pl.highest_expr_genes

scanpy.pl.highest_expr_genes#

Note

Both backends are accessible as scanpy.pl.highest_expr_genes. The active backend is chosen by scanpy.settings.preset: the default is the legacy matplotlib backend; set it to scanpy.Preset.ScanpyV2Preview to use the HoloViews backend.

scanpy.plotting._v2.highest_expr_genes(adata, n_top=20, *, layer=None, gene_symbols=None)[source]

Get n_top genes by mean expression.

Parameters:
adata AnnData

The AnnData object.

n_top int (default: 20)

The number of top genes to plot.

layer str | None (default: None)

The layer to use.

gene_symbols str | None (default: None)

The column name containing gene symbols.

Return type:

BoxWhisker

Returns:

A box-and-whisker plot.

Examples

import scanpy as sc

sc.settings.preset = sc.Preset.ScanpyV2Preview
A = sc.pl.hv_init('bokeh')

adata = sc.datasets.pbmc68k_reduced()
sc.pl.highest_expr_genes(adata, layer="counts")
import scanpy as sc

sc.settings.preset = sc.Preset.ScanpyV2Preview
A = sc.pl.hv_init('matplotlib')

adata = sc.datasets.pbmc68k_reduced()
sc.pl.highest_expr_genes(adata, layer="counts")
import scanpy as sc

sc.settings.preset = sc.Preset.ScanpyV2Preview
A = sc.pl.hv_init('plotly')

adata = sc.datasets.pbmc68k_reduced()
sc.pl.highest_expr_genes(adata, layer="counts")
scanpy.pl.highest_expr_genes(adata, n_top=30, *, layer=None, gene_symbols=None, log=False, show=None, save=None, ax=None, **kwds)[source]#

Fraction of counts assigned to each gene over all cells.

Computes, for each gene, the fraction of counts assigned to that gene within a cell. The n_top genes with the highest mean fraction over all cells are plotted as boxplots.

This plot is similar to the scater package function plotHighestExprs(type = "highest-expression"), see here. Quoting from there:

We expect to see the “usual suspects”, i.e., mitochondrial genes, actin, ribosomal protein, MALAT1. A few spike-in transcripts may also be present here, though if all of the spike-ins are in the top 50, it suggests that too much spike-in RNA was added. A large number of pseudo-genes or predicted genes may indicate problems with alignment. – Davis McCarthy and Aaron Lun

Parameters:
adata AnnData

Annotated data matrix.

n_top int (default: 30)

Number of top

layer str | None (default: None)

Layer from which to pull data.

gene_symbols str | None (default: None)

Key for field in .var that stores gene symbols if you do not want to use .var_names.

log bool (default: False)

Plot x-axis in log scale

show bool | None (default: None)

Show the plot, do not return axis.

save str | bool | None (default: None)

If True or a str, save the figure. A string is appended to the default filename. Infer the filetype if ending on {'.pdf', '.png', '.svg'}. (deprecated in favour of sc.pl.plot(show=False).figure.savefig()).

ax Axes | None (default: None)

A matplotlib axes object. Only works if plotting a single component.

**kwds

Are passed to boxplot().

Returns:

If show==False a Axes.

Examples

import scanpy as sc
sc.settings.preset = sc.Preset.ScanpyV1
adata = sc.datasets.pbmc3k()
sc.pl.highest_expr_genes(adata)
  0%|          | 0.00/5.58M [00:00<?, ?B/s]
 84%|████████▎ | 4.67M/5.58M [00:00<00:00, 48.7MB/s]
100%|██████████| 5.58M/5.58M [00:00<00:00, 49.5MB/s]
../../_images/4b0516f0ffc772d9fe5db0ebf07de0a38ebad165dd3e99f85c1056984d8f069f.png

Show only the top 10 genes

sc.pl.highest_expr_genes(adata, n_top=10)