Sc.external.pp.scrublet vs

Hi everyone,

Dose anyone know how can I make a plot like (link below) through scanpy or scrublet?

Screen Shot 2022-10-25 at 10.12.52 am

Here is a small example (you can always add more colors if you want):

import scanpy as sc
import scanpy.external as sce
import matplotlib.pyplot as plt

# Load data
adata = sc.datasets.pbmc3k()

# Compute scrublet scores
sce.pp.scrublet(adata, verbose=False)

# Define plotting function
def plot_scrublet_scores(adata, ax):
    thr =  adata.uns['scrublet']['threshold']
    # Plot histogram
    ax.hist(adata.obs['doublet_score'], bins=100, color='gray')
    ax.axvline(x=thr, linestyle='--', color="black")
    ax.set_xlabel('Scrublet score distribution')

# Plot
fig, ax = plt.subplots(1, 1)
plot_scrublet_scores(adata, ax)

The result looks like this:

1 Like

Thanks for reply, I knew about this plot, but I did not know that I can add colours and thresholds!

Thanks :slight_smile:

1 Like