How to get dot values from ``?

I’m using the function to draw dotplots, and I’m interested to get the fraction of cells and mean expression values for each dot.
If I assign the function call output to a variable dp, I can see some values related the axes, but is there a wat to get the values the dots?

I’m using this:

import scanpy as sc
adata = sc.datasets.pbmc68k_reduced()
markers = ['C1QA', 'PSAP', 'CD79A', 'CD79B', 'CST3', 'LYZ'], markers, groupby="bulk_labels", return_fig=True)
# <scanpy.plotting._dotplot.DotPlot at 0x7fd840a03df0>

# {'mainplot_ax': <Axes: >,
# 'size_legend_ax': <Axes: title={'center': 'Fraction of cells\nin group (%)'}>,
# 'color_legend_ax': <Axes: title={'center': 'Mean expression\nin group'}>}

There isn’t a direct way, but using the recent release candidate for scanpy you could use the new function sc.get.aggregate to accomplish this:

Something like:

aggregated = sc.get.aggregate(
    adata[:, markers],
    func=["sum", "count_nonzero"],
mean_in_expressed = aggregated.to_df(layer="sum") / aggregated.to_df(layer="count_nonzero")
1 Like