# ohlerlab/liam architecture

> Architecture diagram of the GitHub repository ohlerlab/liam, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ohlerlab/liam
- Repository: https://github.com/ohlerlab/liam

## Overview

##### Project type and purpose
- This is an open‑source Python library (liam) implementing an adversarial variational autoencoder for multimodal single‑cell data integration (scRNA‑seq, scATAC‑seq, ADT/CITE‑seq).
- It provides a programmatic API, tutorials, unit tests, and Sphinx‑based documentation.

##### File structure
- Top‑level modules and files:
- liam/ : the core Python package
– _mymodel.py : neural network definitions (encoders, decoders)
– _mymodule.py : wrapper around scvi‑tools Module, integrates adversarial and VAE patterns
– _trainingplans.py : training routines, loss functions, gradient reversal layer integration
- docs/ : Sphinx docs, templates, autogenerated API reference
- tutorials/ : example Jupyter notebooks and sample data
- tests/ : unit tests (basic skeleton test)
- config/build: pyproject.toml, setup.py, liam_dependencies.yml, CI config (codecov.yml, readthedocs.yml)
- THIRD‑PARTY‑LICENSES/: licenses for scvi‑tools, scvi‑tools‑skeleton, DANN, BAVARIA translation
- Patterns:
- Modular code separating model definition, training, and data setup
- Uses scvi‑tools skeleton for VAE infrastructure
- Integrates a gradient reversal layer (domain adversarial) for batch correction

##### README for additional insights
- Confirms the use of PyTorch and scvi‑tools as the base framework
- Highlights negative binomial reconstruction loss translated from BAVARIA
- Details GPU/CUDA environment and how to install via conda + pip
- Mentions tutorials for paired and mosaic integration

##### Final recommendations
- Layers: user entry point, core code, external libraries, documentation, deployment
- Don’t omit the adversarial path—show the gradient reversal layer’s role

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    subgraph "User Layer"
        UI["Jupyter Notebooks / Scripts"]:::user
    end

    %% Core Package
    subgraph "liam Core Package"
        subgraph "Data I/O & Setup"
            Setup["setup_anndata"]:::core
        end
        subgraph "Model Modules"
            Modules["Encoders, Decoders, VAE & Adversarial"]:::core
        end
        subgraph "Training Plans"
            Training["Loss, Gradient Reversal, Optimizers"]:::core
        end
        subgraph "Utilities & API"
            API["Public API & Utils"]:::core
        end
    end

    %% External Dependencies
    subgraph "External Dependencies"
        PT["PyTorch & CUDA"]:::external
        SCT["scvi-tools"]:::external
        ANN["AnnData"]:::external
        BAV["BAVARIA Loss"]:::external
        DANN["DANN Layer"]:::external
    end

    %% Documentation & Examples
    subgraph "Documentation & Examples"
        Docs["Sphinx Documentation"]:::doc
        Tuts["Tutorial Notebooks & Data"]:::doc
        Tests["Unit Tests"]:::doc
    end

    %% Deployment & CI
    subgraph "Deployment & CI"
        Package["Packaging & Build Configuration"]:::ci
        CIcfg["CI & Docs Deployment"]:::ci
        Licenses["Third‑Party Licenses"]:::ci
    end

    %% Data Flow and Dependencies
    UI -->|"AnnData object"| Setup
    Setup -->|"prepared data"| Modules
    Modules -->|"model components"| Training
    PT --> Modules
    SCT --> Modules
    ANN --> Setup
    DANN --> Training
    BAV --> Training
    Training -->|"trained model & embeddings"| API
    API --> UI
    Tests --> Modules
    Docs --> UI
    Tuts --> UI
    Package --> API
    CIcfg --> Package
    Licenses --> Package

    %% Click Events
    click UI "https://github.com/ohlerlab/liam/blob/main/tutorials/notebooks/Liam_usage_example.ipynb"
    click Setup "https://github.com/ohlerlab/liam/blob/main/liam/_mymodule.py"
    click Modules "https://github.com/ohlerlab/liam/blob/main/liam/_mymodel.py"
    click Training "https://github.com/ohlerlab/liam/blob/main/liam/_trainingplans.py"
    click API "https://github.com/ohlerlab/liam/blob/main/liam/__init__.py"
    click Docs "https://github.com/ohlerlab/liam/tree/main/docs/"
    click Tuts "https://github.com/ohlerlab/liam/tree/main/tutorials/data/"
    click Tests "https://github.com/ohlerlab/liam/blob/main/tests/test_skeleton.py"
    click Package "https://github.com/ohlerlab/liam/blob/main/pyproject.toml"
    click CIcfg "https://github.com/ohlerlab/liam/blob/main/codecov.yml"
    click Licenses "https://github.com/ohlerlab/liam/tree/main/THIRD-PARTY-LICENSES/"

    %% Styles
    classDef user fill:#a8f0a1,stroke:#333,stroke-width:1px
    classDef core fill:#a1c2f0,stroke:#333,stroke-width:1px
    classDef external fill:#f0a16b,stroke:#333,stroke-width:1px
    classDef doc fill:#c8f0a1,stroke:#333,stroke-width:1px
    classDef ci fill:#d0d0d0,stroke:#333,stroke-width:1px
```
