crested.pl.qc.sort_and_filter_cutoff#
- crested.pl.qc.sort_and_filter_cutoff(adata, cutoffs=None, method='proportion', min_scores=None, model_name=None, max_k=2000, cmap='tab20', legend=True, class_labels=True, ax=None, plot_kws=None, cutoff_line_kws=None, score_line_kws=None, **kwargs)#
Plot the effect of different
top_kcutoffs insort_and_filter_regions_on_specificity(), which takes the top k regions per class.This function plots the gini scores for those regions per class, indicating the specificity. If the specificity is too low for the lower-ranked genes, decrease
top_k.- Parameters:
adata (AnnData) – AnnData object with region data. This should not be filtered yet!
cutoffs (int | list[int] | None (default:
None)) – (List of) considered top # of regions to plot an illustrative line at, as insort_and_filter_regions_on_specificity()’stop_k.model_name (str | None (default:
None)) – The name of the model to calculate scores from. If None or ‘truth’/’groundtruth’/’X’ (default), will use the values in adata.X.method (Literal[‘gini’, ‘proportion’] (default:
'proportion')) – The method to use for calculating scores, either ‘gini’ or ‘proportion’. Default is ‘proportion’.min_scores (float | None (default:
None)) – Minimum score(s) required to plot an illustrative line at, as insort_and_filter_regions_on_specificity()’smin_score.max_k (int (default:
2000)) – The maximum number of top regions per cell type to plot. Should be higher than the cutoffs you’re considering.cmap (str | Sequence (default:
'tab20')) – Colors or colormap to draw colors for the different cell types from. Any valid input tocolor_palette()works. Examples are a matplotlib or seaborn colormap name or a list of colors.legend (bool (default:
True)) – Whether to add a cell type legend.class_labels (bool (default:
True)) – Whether to add labels on the per-class lines to the right edge of the plot.ax (plt.Axes | None (default:
None)) – Axis to plot values on. If not supplied, creates a figure from scratch.plot_kws (dict | None (default:
None)) – Extra keyword arguments passed toscatter(). Defaults:'s': 4.cutoff_line_kws (dict | None (default:
None)) – Extra keyword arguments passed toaxvline()to showcutoffs. Defaults:'color': 'black','linestyle': '--'.score_line_kws (dict | None (default:
None)) – Extra keyword arguments passed toaxhline()to showmin_score. Defaults:'color': 'darkgray',linestyle: '-.'.width – Width of the newly created figure if
ax=None. Default is 8.height – Height of the newly created figure if
ax=None. Default is 5.kwargs – Additional arguments passed to
render_plot()to control the final plot output. Please seerender_plot()for details. Custom defaults for?:xlabel='Rank',ylabel='Gini score',grid='x'.
- Return type:
(plt.Figure, plt.Axes) | None
Example
>>> crested.pl.qc.sort_and_filter_cutoff( ... adata, ... cutoffs=[2000, 3000, 4000], ... min_scores=[0.2, 0.3], ... max_k=5000 ... )