scdef.pl.factor_gene_uncertainty_boxplot ¶
factor_gene_uncertainty_boxplot(model: scDEF, factor: Union[int, str], layer_idx: int = 0, max_genes: Optional[int] = 50, mc_samples: int = 100, random_seed: int = 0, whisker_quantiles: Tuple[float, float] = (0.05, 0.95), sort_by: Literal['mean', 'confidence'] = 'mean', color_by_confidence: bool = False, confidence_tau_quantile: float = 0.99, confidence_cmap: str = 'viridis', confidence_vmin: float = 0.0, confidence_vmax: float = 1.0, add_confidence_colorbar: bool = True, show_confidence_cutoff_line: bool = False, confidence_include_threshold: float = 0.9, confidence_cutoff_line_kwargs: Optional[Dict[str, Any]] = None, show_tau_quantile_line: bool = False, tau_quantile_line_kwargs: Optional[Dict[str, Any]] = None, xtick_rotation: float = 90.0, figsize: Tuple[float, float] = (12, 4), ax: Optional[Axes] = None, show: bool = True) -> Optional[Axes]
Plot per-gene uncertainty boxes for a factor using posterior mean/variance.
Genes are sorted by posterior mean loading or confidence for the selected factor.
For each gene, a box is drawn from an approximated posterior distribution of
W using the stored posterior mean and variance:
- box: 25th to 75th percentile
- median: 50th percentile
- whiskers: configurable quantiles (default 5th/95th)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
scDEF
|
scDEF model instance |
required |
factor
|
Union[int, str]
|
factor index (within kept factors of the layer) or factor name |
required |
layer_idx
|
int
|
layer index to visualize |
0
|
max_genes
|
Optional[int]
|
maximum number of genes to plot; if None, plot all genes |
50
|
mc_samples
|
int
|
number of posterior samples for |
100
|
random_seed
|
int
|
random seed for upper-layer posterior sampling |
0
|
whisker_quantiles
|
Tuple[float, float]
|
lower/upper quantiles for whiskers |
(0.05, 0.95)
|
sort_by
|
Literal['mean', 'confidence']
|
sorting criterion for genes; |
'mean'
|
color_by_confidence
|
bool
|
whether to color each box by posterior confidence
|
False
|
confidence_tau_quantile
|
float
|
factor-wise quantile used to define |
0.99
|
confidence_cmap
|
str
|
matplotlib colormap name for confidence coloring |
'viridis'
|
confidence_vmin
|
float
|
lower bound of confidence colormap normalization |
0.0
|
confidence_vmax
|
float
|
upper bound of confidence colormap normalization |
1.0
|
add_confidence_colorbar
|
bool
|
whether to add a confidence colorbar when
|
True
|
show_confidence_cutoff_line
|
bool
|
whether to draw a vertical line marking the
last plotted gene with confidence >= |
False
|
confidence_include_threshold
|
float
|
confidence threshold used for the cutoff line (default 0.9) |
0.9
|
confidence_cutoff_line_kwargs
|
Optional[Dict[str, Any]]
|
optional kwargs passed to |
None
|
show_tau_quantile_line
|
bool
|
whether to draw a horizontal line at |
False
|
tau_quantile_line_kwargs
|
Optional[Dict[str, Any]]
|
optional kwargs passed to |
None
|
xtick_rotation
|
float
|
x tick label rotation in degrees |
90.0
|
figsize
|
Tuple[float, float]
|
figure size if ax is None |
(12, 4)
|
ax
|
Optional[Axes]
|
matplotlib axis to draw on |
None
|
show
|
bool
|
whether to show the plot |
True
|
Returns:
| Type | Description |
|---|---|
Optional[Axes]
|
Axes object if show is False, None otherwise. |