scanpy.pl.scrublet_score_distribution

scanpy.pl.scrublet_score_distribution#

Note

Both backends are accessible as scanpy.pl.scrublet_score_distribution. 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.scrublet_score_distribution(adata)[source]

Plot the doublet score distribution.

Plots the doublet score probability densities for observed transcriptomes and simulated doublets.

Parameters:
adata AnnData

The AnnData object.

Return type:

Layout

Returns:

Layout containing two histograms.

Examples

import scanpy as sc

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

adata = sc.datasets.pbmc68k_reduced()
adata_sim = sc.pp.scrublet_simulate_doublets(adata)
sc.pp.scrublet(adata, adata_sim)
sc.pl.scrublet_score_distribution(adata)
import scanpy as sc

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

adata = sc.datasets.pbmc68k_reduced()
adata_sim = sc.pp.scrublet_simulate_doublets(adata)
sc.pp.scrublet(adata, adata_sim)
sc.pl.scrublet_score_distribution(adata)
WARNING:param.main: Option 'shared_axes' for Histogram type not valid for selected backend ('matplotlib'). Option only applies to following backends: ['bokeh']
import scanpy as sc

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

adata = sc.datasets.pbmc68k_reduced()
adata_sim = sc.pp.scrublet_simulate_doublets(adata)
sc.pp.scrublet(adata, adata_sim)
sc.pl.scrublet_score_distribution(adata)
WARNING:param.main: Option 'shared_axes' for Histogram type not valid for selected backend ('plotly'). Option only applies to following backends: ['bokeh']
/home/docs/.local/share/hatch/env/virtual/scanpy/T0JdXacZ/docs/lib/python3.13/site-packages/holoviews/plotting/plotly/element.py:575: RuntimeWarning: divide by zero encountered in log10
  yaxis["range"] = np.log10(yaxis["range"])
scanpy.pl.scrublet_score_distribution(adata, *, scale_hist_obs='log', scale_hist_sim='linear', figsize=(8, 3), return_fig=False, show=True, save=None)[source]#

Plot histogram of doublet scores for observed transcriptomes and simulated doublets.

The histogram for simulated doublets is useful for determining the correct doublet score threshold.

Scrublet must have been run previously with the input object.

Parameters:
adata AnnData

An AnnData object resulting from scrublet().

scale_hist_obs Literal['linear', 'log', 'symlog', 'logit'] | str (default: 'log')

Set y axis scale transformation in matplotlib for the plot of observed transcriptomes

scale_hist_sim Literal['linear', 'log', 'symlog', 'logit'] | str (default: 'linear')

Set y axis scale transformation in matplotlib for the plot of simulated doublets

figsize tuple[float | int, float | int] (default: (8, 3))

width, height

show bool (default: True)

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'}.

Return type:

Figure | Sequence[tuple[Axes, Axes]] | tuple[Axes, Axes] | None

Returns:

If return_fig is True, a Figure. If show==False a list of Axes.

See also

scrublet()

Main way of running Scrublet, runs preprocessing, doublet simulation and calling.

scrublet_simulate_doublets()

Run Scrublet’s doublet simulation separately for advanced usage.