tfmindi.pl.region_contributions#
- tfmindi.pl.region_contributions(adata, example_idx=None, region_name=None, zoom_start=None, zoom_end=None, min_attribution=None, overlap_threshold=25, show_unannotated=False, dbd_names=None, cmap='tab20', **kwargs)#
Visualize contribution scores for a full genomic region with annotated seqlet regions.
Creates a two-panel plot showing contribution scores as sequence logos for the entire region on top, and DNA-binding domain annotations for detected seqlets overlaid below.
- Parameters:
adata (
AnnData) – AnnData object with seqlet data and region information. Must contain adata.uns[‘unique_examples’] with ‘oh’ and ‘contrib’ arrays, and adata.obs with ‘example_oh_idx’ and ‘example_contrib_idx’ columns.example_idx (
int|None(default:None)) – Index of the example/region to visualize. Mutually exclusive with region_name.region_name (
str|None(default:None)) – Name of the region to visualize (e.g., ‘chr1:1000-2000’). Mutually exclusive with example_idx. Requires ‘region_name’ column in adata.obs.zoom_start (
int|None(default:None)) – Start position for zooming into a specific subregion (0-based indexing). Must be used together with zoom_end.zoom_end (
int|None(default:None)) – End position for zooming into a specific subregion (0-based indexing, exclusive). Must be used together with zoom_start.min_attribution (
float|None(default:None)) – Minimum absolute attribution score for seqlets to be highlighted with colored boxes. Seqlets with an absolute attribution below this threshold will not show colored rectangles. If None, all seqlets are highlighted regardless of attribution score.overlap_threshold (default:
25) – Minimum distance (in base pairs) between seqlet labels to avoid overlap. Labels will be stacked vertically if they are too close together.show_unannotated (
bool(default:False)) – Whether to show rectangles for seqlets without DBD annotations (default: False). When True, unannotated seqlets are shown in gray.dbd_names (
str|list[str] |None(default:None)) – DNA-binding domain name(s) to display. Can be a single DBD name (string) or a list of DBD names. If None (default), all annotated DBDs are shown. Only seqlets with these specific DBD annotations will be highlighted and labeled.cmap (
str(default:'tab20')) – Colormap name for DNA-binding domain coloring (default: “tab20”).**kwargs – Additional arguments passed to render_plot() for styling and display options. Common options include width, height, title, xlabel, ylabel, show, save_path.
- Return type:
- Returns:
Figure with contribution score visualization, or None if show=True.
Examples
>>> import tfmindi as tm >>> # Plot saliency for example 0 >>> fig = tm.pl.region_contributions(adata, example_idx=0) >>> # Plot saliency by region name >>> fig = tm.pl.region_contributions(adata, region_name="chr1:1000-2000") >>> # Zoom into a specific subregion (positions 50-150) >>> fig = tm.pl.region_contributions(adata, example_idx=0, zoom_start=50, zoom_end=150) >>> # Only show seqlets with high contribution scores >>> fig = tm.pl.region_contributions(adata, example_idx=0, min_attribution=0.5) >>> # Show only specific DBDs >>> fig = tm.pl.region_contributions(adata, example_idx=0, dbd_names="bZIP") >>> fig = tm.pl.region_contributions(adata, example_idx=0, dbd_names=["bZIP", "HLH"]) >>> # Custom styling >>> tm.pl.region_contributions(adata, example_idx=0, width=15, height=6)