harpy.qc.metric_histogram#
- harpy.qc.metric_histogram(sdata, table_name, labels_name=None, column='total_counts', display_column=None, dataframe='auto', ax=None, bins='auto', range=None, quantile_range=None, histplot_kwargs=mappingproxy({}), median_line_kwargs=mappingproxy({}), median_text_kwargs=mappingproxy({}), figsize=(5.5, 4.5), title=None, color=None, show_median=True, show_std=True, ylabel=None)#
Plot a QC metric histogram 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. IfNone, all observations intable_nameare used.column (
str(default:'total_counts')) – QC metric column to plot. The column is searched in.obsand/or.vardepending ondataframe.display_column (
str|None(default:None)) – Display name used for the title and x-axis label. IfNone,columnis converted into a readable label.dataframe (
Literal['obs','var','auto'] (default:'auto')) – Which annotation dataframe to search forcolumn. With"auto", the function first checksadata.obsandadata.varand raises if the column is ambiguous or absent.ax (
Axes|None(default:None)) – Matplotlib axes to draw on. IfNone, a new figure and axes are created.bins (
int|str(default:'auto')) – Histogram bin specification passed toseaborn.histplot(). The default"auto"uses NumPy’s automatic bin estimator.range (
tuple[float,float] |None(default:None)) – Lower and upper bounds of the histogram x-axis. Values outside this range are excluded from the plotted histogram, but are still included when calculating the median and standard deviation annotations.quantile_range (
tuple[float,float] |None(default:None)) – Quantile interval used to derive the histogram x-axis automatically whenrangeisNone. Values outside this interval are excluded from the plotted histogram, but are still included when calculating the median and standard deviation annotations.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()for the median guide line.median_text_kwargs (
Mapping[str,Any] (default:mappingproxy({}))) – Keyword arguments passed tomatplotlib.axes.Axes.text()for the median annotation.figsize (
tuple[float,float] (default:(5.5, 4.5))) – Figure size used whenaxisNone.title (
str|None(default:None)) – Plot title. Defaults todisplay_column.color (
str|None(default:None)) – Histogram color. IfNone, a metric-specific default is used when available.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.ylabel (
str|None(default:None)) – Y-axis label. IfNone, a label is chosen based on the selected dataframe.
- Return type:
- Returns:
:
matplotlib.axes.Axescontaining the histogram.
Examples
import harpy as hp sdata = hp.datasets.xenium_human_ovarian_cancer( subset=True, processed=True, ) hp.qc.metric_histogram( sdata, table_name="table_transcriptomics_preprocessed", labels_name="nucleus_segmentation_mask", column="total_counts", dataframe="obs", quantile_range=(0.1, 0.99), )