# ssenci97/scambrian architecture

> Architecture diagram of the GitHub repository ssenci97/scambrian, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ssenci97/scambrian
- Repository: https://github.com/ssenci97/scambrian

## Overview

SCambrian analyzes target proteomes alongside optional probe proteins, producing sequence- and embedding-based cluster assignments, summary tables, species/probe reports, an interactive viewer, and provenance metadata. The main workflow begins with configured UniProt or local FASTA inputs, then validates and deduplicates sequences before branching into MMseqs2 clustering and ESMC embedding/projection. The README documents the broad pipeline; sampled source excerpts confirm key data dependencies. Some implementation details and the report-to-viewer enrichment handoff are documented but not fully sampled.

Main entry points: [`src/h5ad_interactive.py`](https://github.com/ssenci97/scambrian/blob/main/src/h5ad_interactive.py) (Interactive viewer), [`src/h5ad_scanpy.py`](https://github.com/ssenci97/scambrian/blob/main/src/h5ad_scanpy.py) (Species analysis), [`src/compile_summary.py`](https://github.com/ssenci97/scambrian/blob/main/src/compile_summary.py) (Cluster summary), [`src/ro_crate.py`](https://github.com/ssenci97/scambrian/blob/main/src/ro_crate.py) (RO-Crate metadata)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Inputs and preprocessing"]
  node_query_config["Sample configuration<br/>[query_configs.tsv]"]
  node_sequence_acquisition["Sequence acquisition<br/>[dw_uniprot_seqs.py]"]
  node_feature_acquisition["Feature acquisition"]
  node_preprocessing["Sequence preprocessing"]
  node_dedup_fasta["Deduplicated FASTA"]
end

subgraph group_clustering["Clustering and projection"]
  node_mmseqs["MMseqs2 clustering<br/>[run_mmseqs2.py]"]
  node_embedding["ESMC embeddings"]
  node_projection["Projection and clustering<br/>[npz_scanpy.py]"]
  node_projections["Projection data"]
end

subgraph group_results["Analysis results"]
  node_summary["Cluster summary<br/>[compile_summary.py]"]
  node_summary_data["Summary tables"]
  node_species_report["Species analysis<br/>[h5ad_scanpy.py]"]
  node_interactive_viewer["Interactive viewer"]
  node_viewer_template["Viewer template"]
end

subgraph group_provenance["Provenance"]
  node_crate["RO-Crate metadata<br/>[ro_crate.py]"]
  node_analysis_outputs["Analysis artifacts"]
end

node_researcher(("Researcher"))
node_uniprot{{"UniProtKB"}}

node_researcher -->|"configures samples"| node_query_config
node_query_config -->|"defines queries"| node_sequence_acquisition
node_query_config -->|"defines queries"| node_feature_acquisition
node_uniprot -->|"provides sequences"| node_sequence_acquisition
node_uniprot -->|"provides annotations"| node_feature_acquisition
node_sequence_acquisition -->|"supplies FASTA"| node_preprocessing
node_preprocessing -->|"writes cleaned inputs"| node_dedup_fasta
node_dedup_fasta -->|"clusters sequences"| node_mmseqs
node_dedup_fasta -->|"embeds sequences"| node_embedding
node_embedding -->|"supplies embeddings"| node_projection
node_projection -->|"writes layouts"| node_projections
node_mmseqs -->|"supplies cluster assignments"| node_summary
node_projections -->|"supplies layout clusters"| node_summary
node_preprocessing -->|"supplies metadata"| node_summary
node_summary -->|"writes tables"| node_summary_data
node_projections -->|"reads projections"| node_species_report
node_summary_data -->|"reads cluster names"| node_species_report
node_projections -->|"renders layouts"| node_interactive_viewer
node_summary_data -->|"provides cluster labels"| node_interactive_viewer
node_species_report -.->|"provides enrichment"| node_interactive_viewer
node_viewer_template -.->|"renders viewer"| node_interactive_viewer
node_summary_data -.->|"describes outputs"| node_crate
node_species_report -.->|"describes outputs"| node_crate
node_interactive_viewer -.->|"describes outputs"| node_crate
node_crate -->|"writes provenance"| node_analysis_outputs

click node_query_config "https://github.com/ssenci97/scambrian/blob/main/configs/query_configs.tsv"
click node_sequence_acquisition "https://github.com/ssenci97/scambrian/blob/main/src/dw_uniprot_seqs.py"
click node_feature_acquisition "https://github.com/ssenci97/scambrian/blob/main/src/dw_uniprot_features.py"
click node_preprocessing "https://github.com/ssenci97/scambrian/blob/main/src/preprocess_sequences.py"
click node_mmseqs "https://github.com/ssenci97/scambrian/blob/main/src/run_mmseqs2.py"
click node_embedding "https://github.com/ssenci97/scambrian/blob/main/src/extract_reps_biohub.py"
click node_projection "https://github.com/ssenci97/scambrian/blob/main/src/npz_scanpy.py"
click node_summary "https://github.com/ssenci97/scambrian/blob/main/src/compile_summary.py"
click node_species_report "https://github.com/ssenci97/scambrian/blob/main/src/h5ad_scanpy.py"
click node_interactive_viewer "https://github.com/ssenci97/scambrian/blob/main/src/h5ad_interactive.py"
click node_viewer_template "https://github.com/ssenci97/scambrian/blob/main/src/templates/h5ad_interactive.html"
click node_crate "https://github.com/ssenci97/scambrian/blob/main/src/ro_crate.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_query_config,node_sequence_acquisition,node_feature_acquisition,node_preprocessing,node_dedup_fasta toneBlue
class node_mmseqs,node_embedding,node_projection,node_projections toneAmber
class node_summary,node_summary_data,node_species_report,node_interactive_viewer,node_viewer_template toneMint
class node_crate,node_analysis_outputs toneRose
class node_researcher,node_uniprot toneIndigo
```

## Components

### Inputs and preprocessing

- [Sample configuration](https://github.com/ssenci97/scambrian/blob/main/configs/query_configs.tsv): `configs/query_configs.tsv`
- [Sequence acquisition](https://github.com/ssenci97/scambrian/blob/main/src/dw_uniprot_seqs.py): `src/dw_uniprot_seqs.py`
- [Feature acquisition](https://github.com/ssenci97/scambrian/blob/main/src/dw_uniprot_features.py): `src/dw_uniprot_features.py`
- [Sequence preprocessing](https://github.com/ssenci97/scambrian/blob/main/src/preprocess_sequences.py): `src/preprocess_sequences.py`
- **Deduplicated FASTA**

### Clustering and projection

- [MMseqs2 clustering](https://github.com/ssenci97/scambrian/blob/main/src/run_mmseqs2.py): `src/run_mmseqs2.py`
- [ESMC embeddings](https://github.com/ssenci97/scambrian/blob/main/src/extract_reps_biohub.py): `src/extract_reps_biohub.py`
- [Projection and clustering](https://github.com/ssenci97/scambrian/blob/main/src/npz_scanpy.py): `src/npz_scanpy.py`
- **Projection data**

### Analysis results

- [Cluster summary](https://github.com/ssenci97/scambrian/blob/main/src/compile_summary.py): `src/compile_summary.py`
- **Summary tables**
- [Species analysis](https://github.com/ssenci97/scambrian/blob/main/src/h5ad_scanpy.py): `src/h5ad_scanpy.py`
- [Interactive viewer](https://github.com/ssenci97/scambrian/blob/main/src/h5ad_interactive.py): `src/h5ad_interactive.py`
- [Viewer template](https://github.com/ssenci97/scambrian/blob/main/src/templates/h5ad_interactive.html): `src/templates/h5ad_interactive.html`

### Provenance

- [RO-Crate metadata](https://github.com/ssenci97/scambrian/blob/main/src/ro_crate.py): `src/ro_crate.py`
- **Analysis artifacts**

### Other components

- **Researcher**
- **UniProtKB**

## Connections

- Researcher → Sample configuration: configures samples (evidence: `README.md`)
- Sample configuration → Sequence acquisition: defines queries (evidence: `README.md`)
- Sample configuration → Feature acquisition: defines queries (evidence: `README.md`)
- UniProtKB → Sequence acquisition: provides sequences (evidence: `src/dw_uniprot_seqs.py`)
- UniProtKB → Feature acquisition: provides annotations (evidence: `src/dw_uniprot_features.py`)
- Sequence acquisition → Sequence preprocessing: supplies FASTA (evidence: `README.md`)
- Sequence preprocessing → Deduplicated FASTA: writes cleaned inputs (evidence: `src/preprocess_sequences.py`)
- Deduplicated FASTA → MMseqs2 clustering: clusters sequences (evidence: `src/run_mmseqs2.py`)
- Deduplicated FASTA → ESMC embeddings: embeds sequences (evidence: `README.md`)
- ESMC embeddings → Projection and clustering: supplies embeddings (evidence: `src/npz_scanpy.py`)
- Projection and clustering → Projection data: writes layouts (evidence: `src/npz_scanpy.py`)
- MMseqs2 clustering → Cluster summary: supplies cluster assignments (evidence: `src/compile_summary.py`)
- Projection data → Cluster summary: supplies layout clusters (evidence: `src/compile_summary.py`)
- Sequence preprocessing → Cluster summary: supplies metadata (evidence: `src/compile_summary.py`)
- Cluster summary → Summary tables: writes tables (evidence: `src/compile_summary.py`)
- Projection data → Species analysis: reads projections (evidence: `src/h5ad_scanpy.py`)
- Summary tables → Species analysis: reads cluster names (evidence: `src/h5ad_scanpy.py`)
- Projection data → Interactive viewer: renders layouts (evidence: `src/h5ad_interactive.py`)
- Summary tables → Interactive viewer: provides cluster labels (evidence: `src/h5ad_interactive.py`)
- Species analysis → Interactive viewer: provides enrichment
- Viewer template → Interactive viewer: renders viewer
- Summary tables → RO-Crate metadata: describes outputs
- Species analysis → RO-Crate metadata: describes outputs
- Interactive viewer → RO-Crate metadata: describes outputs
- RO-Crate metadata → Analysis artifacts: writes provenance (evidence: `src/ro_crate.py`)
