grassp.pl.umap#
- umap(adata, highlight=None, annotate_by=None, highlight_edgecolor='black', highlight_linewidth=1.5, annotate_fontsize=8, annotate_color='black', annotate_offset=(5, 5), annotate_fontoutline=2, annotate_adjust=True, adjust_text_kwargs=None, ax=None, show=None, save=None, **kwargs)[source]#
Wrapper around sc.pl.umap that highlights specific observations with outlined markers.
This function creates a UMAP plot using scanpy’s plotting function and adds the ability to highlight specific observations (e.g., proteins) with a black outline and optionally annotate them with text labels from a specified column.
- Parameters:
- adata
AnnData Annotated data matrix with UMAP coordinates in .obsm[‘X_umap’].
- highlight
Optional[Sequence[str]] (default:None) List of observation names (from adata.obs_names) to highlight with outlines. If None, no observations are highlighted.
- annotate_by
str|None(default:None) Column name in adata.obs to use for annotating highlighted observations. If None, no annotations are added. Only highlighted observations are annotated.
- highlight_edgecolor
str(default:'black') Color of the outline around highlighted points.
- highlight_linewidth
float(default:1.5) Width of the outline around highlighted points.
- annotate_fontsize
float|int(default:8) Font size for annotation text.
- annotate_color
str(default:'black') Color of annotation text.
- annotate_offset
tuple[float,float] (default:(5, 5)) Tuple of (x, y) offset in points for annotation text positioning relative to the highlighted markers. Only used if annotate_adjust is False.
- annotate_fontoutline
int|None(default:2) Width of the white outline drawn around annotation text, or None for no outline.
- annotate_adjust
bool(default:True) If True, uses the adjustText library to automatically adjust label positions to avoid overlaps. If False, uses fixed offset positioning.
- adjust_text_kwargs
dict|None(default:None) Additional keyword arguments passed to adjust_text(). Defaults to grey connector arrows. min_arrow_len is derived from the axes width unless given explicitly.
- ax
Axes|None(default:None) A matplotlib axes object. If None, uses current axes.
- show
bool|None(default:None) Whether to show the figure. If None, uses scanpy settings.
- save
bool|str|None(default:None) If True or a string, save the figure. A string is used as filename.
- **kwargs
Additional keyword arguments passed to sc.pl.umap().
- adata
- Return type:
Axes|None- Returns:
If show==False, returns matplotlib axes object. Otherwise returns None.
Examples
>>> import grassp as gr >>> adata = gr.datasets.itzhak_2016() >>> adata.obs.set_index("Lead ID", inplace=True) >>> # Highlight specific proteins with annotation >>> gr.pl.umap( ... adata, ... color="compartment", ... highlight=["P00533", "P29353"], ... annotate_by="Lead gene name")