structboost.export_interactive_html¶
- structboost.export_interactive_html(adata, output_path, *, model_key='BAE_encoder_weights', embedding_key='X_umap', spatial_key='spatial', latent_key=None, layers=None, obs_keys=None, top_k=20, max_cells=50000, annotations_key=None, title='BAE Explorer', seed=42)[source]¶
Export interactive HTML explorer for BAE results.
Generates a self-contained HTML file with Plotly.js for interactive exploration of UMAP embeddings, gene expression overlays, encoder coefficient bar charts, and (optionally) spatial tissue plots and dimension annotations.
- Parameters:
adata – AnnData object with fitted BAE results. Must contain encoder weights in
adata.varm[model_key]and a 2D embedding inadata.obsm[embedding_key].output_path (str | Path) – Path where the HTML file will be written.
model_key (str) – Key in
adata.varmfor encoder weight matrix.embedding_key (str) – Key in
adata.obsmfor 2D embedding (e.g. UMAP). Must be pre-computed.spatial_key (str | None) – Key in
adata.obsmfor spatial coordinates. Set toNoneto disable the spatial tissue plot. If the key is not found in obsm, the spatial panel is silently omitted.latent_key (str | None) – Key in
adata.obsmfor latent representation. IfNone, defaults to"X_bae".layers (list[str] | None) – Which expression layers to include.
Noneincludesadata.X(as"X") plus all keys inadata.layers.obs_keys (list[str] | None) – Categorical obs columns to include as color-by options.
Noneauto-detects all categorical columns.top_k (int) – Number of top genes per sign group (positive/negative) per latent dimension.
max_cells (int) – If
adata.n_obsexceeds this, randomly subsample with a warning.annotations_key (str | None) – Key in
adata.unsfor dimension annotations. IfNone, auto-detected as"bae_dimension_annotations".title (str) – HTML page title.
seed (int) – Random seed for reproducible subsampling.
- Returns:
Path – The output file path.
- Raises:
KeyError – If
embedding_keyormodel_keyare not found.- Return type: