harpy.qc.metrics_histogram#
- harpy.qc.metrics_histogram(sdata, table_name, labels_name=None, metrics=(('obs', 'total_counts'), ('obs', 'n_genes_by_counts'), ('var', 'total_counts'), ('var', 'log1p_total_counts'), ('var', 'n_cells_by_counts'), ('var', 'mean_counts')), ax=None, bins='auto', range=None, quantile_range=None, histplot_kwargs=mappingproxy({}), median_line_kwargs=mappingproxy({}), median_text_kwargs=mappingproxy({}), figsize=None, ncols=3, subplot_width=5.5, subplot_height=4.5, sharex=False, sharey=False, title=None, display_column=None, color=None, show_median=True, show_std=True)#
Plot a standard panel of QC metric histograms for an
AnnDatatable.This function is read-only and expects QC metrics to already be present on the selected table, typically after running
scanpy.pp.calculate_qc_metrics()during preprocessing.- Parameters:
sdata (
SpatialData) –SpatialDataobject containing the table.table_name (
str) – Table element insdata.tables.labels_name (
str|Iterable[str] |None(default:None)) – Labels element or elements used to subset the selected table viaProcessTable.metrics (
Sequence[tuple[Literal['obs','var'],str]] (default:(('obs', 'total_counts'), ('obs', 'n_genes_by_counts'), ('var', 'total_counts'), ('var', 'log1p_total_counts'), ('var', 'n_cells_by_counts'), ('var', 'mean_counts')))) – Sequence of(dataframe, column)tuples to plot. Defaults to a standard transcript QC panel obtained throughscanpy.pp.calculate_qc_metrics().ax (
ndarray|Sequence[Axes] |None(default:None)) – Array-like collection of axes to draw on. IfNone, subplot axes are created.bins (
int|str|Sequence[int|str] (default:'auto')) – Histogram bin specification passed toseaborn.histplot(). If a sequence is provided, it must match the length ofmetricsand each value is applied to the corresponding panel.range (
tuple[float,float] |None(default:None)) – Lower and upper bounds of the histogram x-axis applied to all panels.quantile_range (
tuple[float,float] |None(default:None)) – Quantile interval used to derive the histogram x-axis automatically whenrangeisNone.histplot_kwargs (
Mapping[str,Any] (default:mappingproxy({}))) – Keyword arguments passed toseaborn.histplot().median_line_kwargs (
Mapping[str,Any] (default:mappingproxy({}))) – Keyword arguments passed tomatplotlib.axes.Axes.axvline().median_text_kwargs (
Mapping[str,Any] (default:mappingproxy({}))) – Keyword arguments passed tomatplotlib.axes.Axes.text().figsize (
tuple[float,float] |None(default:None)) – Figure size used whenaxisNone. IfNone, a size is inferred fromncolsand the number of metrics.ncols (
int(default:3)) – Number of subplot columns whenaxisNone.subplot_width (
float(default:5.5)) – Width of each subplot whenfigsizeis not provided.subplot_height (
float(default:4.5)) – Height of each subplot whenfigsizeis not provided.sharex (
bool(default:False)) – Whether to share x-axes across subplots whenaxisNone.sharey (
bool(default:False)) – Whether to share y-axes across subplots whenaxisNone.title (
str|None(default:None)) – Figure title applied whenaxisNone.display_column (
str|Sequence[str|None] |None(default:None)) – Display name override for the plotted metrics. If a single string is provided, it is applied to all panels. If a sequence is provided, it must match the length ofmetricsand each value is applied to the corresponding panel. Entries set toNonefall back to a readable label derived from the metric name.color (
str|Sequence[str] |None(default:None)) – Histogram color override. If a single string is provided, it is applied to all panels. If a sequence is provided, it must match the length ofmetricsand each value is applied to the corresponding panel.show_median (
bool(default:True)) – IfTrue, add a dashed median line and annotate the median.show_std (
bool(default:True)) – IfTrue, include the standard deviation in the annotation box.
- Return type:
- Returns:
:
numpy.ndarraycontaining the histogram axes.
Examples
import harpy as hp sdata = hp.datasets.xenium_human_ovarian_cancer( subset=True, processed=True, ) hp.qc.metrics_histogram( sdata, table_name="table_transcriptomics_preprocessed", labels_name="nucleus_segmentation_mask", quantile_range=(0.1, 0.99), )