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 in adata.obsm[embedding_key].

  • output_path (str | Path) – Path where the HTML file will be written.

  • model_key (str) – Key in adata.varm for encoder weight matrix.

  • embedding_key (str) – Key in adata.obsm for 2D embedding (e.g. UMAP). Must be pre-computed.

  • spatial_key (str | None) – Key in adata.obsm for spatial coordinates. Set to None to 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.obsm for latent representation. If None, defaults to "X_bae".

  • layers (list[str] | None) – Which expression layers to include. None includes adata.X (as "X") plus all keys in adata.layers.

  • obs_keys (list[str] | None) – Categorical obs columns to include as color-by options. None auto-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_obs exceeds this, randomly subsample with a warning.

  • annotations_key (str | None) – Key in adata.uns for dimension annotations. If None, 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_key or model_key are not found.

Return type:

Path