smftools.plotting.qc_plotting#
Functions
|
Plot a grid of QC histograms: rows = samples (from sample_key), columns = obs_keys. |
|
Summarize the deaminase PCR-chimera rate per reference and barcode. |
- smftools.plotting.qc_plotting.plot_read_qc_histograms(adata, outdir, obs_keys, sample_key, bins=60, clip_quantiles=(0.0, 0.995), min_non_nan=10, rows_per_fig=6, topn_categories=15, figsize_cell=(3.6, 2.6), dpi=150)#
Plot a grid of QC histograms: rows = samples (from sample_key), columns = obs_keys.
Numeric columns -> histogram per sample. Categorical columns -> bar chart of top categories per sample.
Saves paginated PNGs to outdir.
Parameters#
- adataAnnData
AnnData object with the columns in obs_keys/sample_key in .obs.
- outdirstr
Directory to write output figures into.
- obs_keyslist[str]
Columns in adata.obs to plot, one column of panels per key.
- sample_keystr
Column in adata.obs defining rows (samples/barcodes).
- binsint
Histogram bins for numeric metrics.
- clip_quantilestuple or None
Clip numeric data globally per metric for consistent axes, e.g. (0.0, 0.995).
- min_non_nanint
Minimum finite values to plot a panel.
- rows_per_figint
Number of samples per page.
- topn_categoriesint
For categorical metrics, show top-N categories (per sample).
- figsize_cell(float, float)
Size of each subplot cell (width, height).
- dpiint
Figure resolution.
- smftools.plotting.qc_plotting.plot_reference_barcode_chimera_rate(obs, outdir, *, barcode_column='barcode', reference_column='Reference_strand', min_events_per_span=3, min_segment_purity=0.9, max_single_strand_fraction=0.8, filename='reference_barcode_chimera_rate.png', dpi=150)#
Summarize the deaminase PCR-chimera rate per reference and barcode.
Applies the same strand-switch thresholds used by the preprocess labeling step to the raw per-read metrics (
ct_event_count,ga_event_count,strand_segment_purity), then plots a reference x barcode heatmap of the fraction of reads flagged as chimeric (cells annotated with rate and read count). A*.csvcompanion table is written alongside the PNG.- Parameters:
obs -- DataFrame with the strand-switch metric columns plus
barcode_columnandreference_column(e.g. the raw spineobsor ragged frame).outdir -- Directory to write the plot and summary table into.
barcode_column (default:
'barcode') -- Column holding the per-read barcode/sample label.reference_column (default:
'Reference_strand') -- Column holding the mapped reference (strand) label.min_events_per_span (default:
3) -- Minimum C->T and G->A events required on each side.min_segment_purity (default:
0.9) -- Minimum best two-segment purity to accept a clean switch.max_single_strand_fraction (default:
0.8) -- Maximum one-sidedness for a read to qualify.filename (default:
'reference_barcode_chimera_rate.png') -- Output PNG filename.dpi (default:
150) -- Figure resolution.
- Returns:
Path to the written PNG, or
Noneif required columns are missing or there is nothing to plot.- Return type:
str | None