# haaselab/picb architecture

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

- Interactive diagram: https://gitdiagram.com/haaselab/picb
- Repository: https://github.com/haaselab/picb

## Overview

PICB is an R toolkit for assembling and characterizing piRNA clusters. Its documented main workflow loads mapped piRNA alignments from a BAM against a reference genome, then builds seeds, cores, and clusters through stepwise integration. The package also exposes reference FASTA loading, annotation, optimization, strand analysis, chromosome lookup, and Excel import/export. Those capabilities are represented as separate entry points because their wiring is not established by the available README excerpt or source; edges show only the documented main workflow.

Main entry points: [`R/PICBbuild.R`](https://github.com/haaselab/picb/blob/main/R/PICBbuild.R) (Cluster builder), [`R/PICBload.R`](https://github.com/haaselab/picb/blob/main/R/PICBload.R) (Alignment loader), [`R/PICBloadfasta.R`](https://github.com/haaselab/picb/blob/main/R/PICBloadfasta.R) (FASTA loader), [`R/PICBexporttoexcel.R`](https://github.com/haaselab/picb/blob/main/R/PICBexporttoexcel.R) (Excel export)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Inputs"]
  node_bam["Mapped BAM"]
  node_reference["Reference genome"]
  node_fasta_loader["FASTA loader<br/>[PICBloadfasta.R]"]
end

subgraph group_assembly["Cluster assembly"]
  node_align_loader["Alignment loader<br/>[PICBload.R]"]
  node_alignments["Loaded alignments"]
  node_builder["Cluster builder<br/>[PICBbuild.R]"]
  node_seeds["Seeds<br/>[PICBbuild.R]"]
  node_cores["Cores<br/>[PICBbuild.R]"]
  node_clusters["Clusters<br/>[PICBbuild.R]"]
end

subgraph group_analysis["Cluster analysis"]
  node_annotator["Cluster annotation<br/>[PICBannotate.R]"]
  node_optimizer["Cluster optimization<br/>[PICBoptimize.R]"]
  node_strand_analysis["Strand analysis"]
  node_chromosome_lookup["Chromosome lookup"]
end

subgraph group_exchange["Data exchange"]
  node_excel_import["Excel import"]
  node_excel_export["Excel export"]
  node_excel_file["Excel workbook"]
end

node_researcher(("PICB user"))

node_researcher -->|"loads data"| node_align_loader
node_bam -->|"reads alignments"| node_align_loader
node_reference -->|"uses reference"| node_align_loader
node_researcher -->|"loads reference"| node_fasta_loader
node_fasta_loader -->|"provides reference"| node_reference
node_align_loader -->|"returns alignments"| node_alignments
node_researcher -->|"builds clusters"| node_builder
node_alignments -->|"provides alignments"| node_builder
node_reference -->|"uses reference"| node_builder
node_builder -->|"produces seeds"| node_seeds
node_builder -->|"produces cores"| node_cores
node_builder -->|"produces clusters"| node_clusters
node_researcher -->|"runs annotation"| node_annotator
node_researcher -->|"runs optimization"| node_optimizer
node_researcher -->|"analyzes strands"| node_strand_analysis
node_researcher -->|"looks up chromosomes"| node_chromosome_lookup
node_researcher -->|"imports data"| node_excel_import
node_excel_file -->|"provides workbook"| node_excel_import
node_researcher -->|"exports data"| node_excel_export
node_excel_export -->|"writes workbook"| node_excel_file

click node_fasta_loader "https://github.com/haaselab/picb/blob/main/R/PICBloadfasta.R"
click node_align_loader "https://github.com/haaselab/picb/blob/main/R/PICBload.R"
click node_builder "https://github.com/haaselab/picb/blob/main/R/PICBbuild.R"
click node_seeds "https://github.com/haaselab/picb/blob/main/R/PICBbuild.R"
click node_cores "https://github.com/haaselab/picb/blob/main/R/PICBbuild.R"
click node_clusters "https://github.com/haaselab/picb/blob/main/R/PICBbuild.R"
click node_annotator "https://github.com/haaselab/picb/blob/main/R/PICBannotate.R"
click node_optimizer "https://github.com/haaselab/picb/blob/main/R/PICBoptimize.R"
click node_strand_analysis "https://github.com/haaselab/picb/blob/main/R/PICBstrandanalysis.R"
click node_chromosome_lookup "https://github.com/haaselab/picb/blob/main/R/PICBgetchromosomes.R"
click node_excel_import "https://github.com/haaselab/picb/blob/main/R/PICBimportfromexcel.R"
click node_excel_export "https://github.com/haaselab/picb/blob/main/R/PICBexporttoexcel.R"

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_bam,node_reference,node_fasta_loader,node_researcher toneBlue
class node_align_loader,node_alignments,node_builder,node_seeds,node_cores,node_clusters toneAmber
class node_annotator,node_optimizer,node_strand_analysis,node_chromosome_lookup toneMint
class node_excel_import,node_excel_export,node_excel_file toneRose
```

## Components

### Inputs

- **Mapped BAM**
- **Reference genome**
- [FASTA loader](https://github.com/haaselab/picb/blob/main/R/PICBloadfasta.R): `R/PICBloadfasta.R`

### Cluster assembly

- [Alignment loader](https://github.com/haaselab/picb/blob/main/R/PICBload.R): `R/PICBload.R`
- **Loaded alignments**
- [Cluster builder](https://github.com/haaselab/picb/blob/main/R/PICBbuild.R): `R/PICBbuild.R`
- [Seeds](https://github.com/haaselab/picb/blob/main/R/PICBbuild.R): `R/PICBbuild.R`
- [Cores](https://github.com/haaselab/picb/blob/main/R/PICBbuild.R): `R/PICBbuild.R`
- [Clusters](https://github.com/haaselab/picb/blob/main/R/PICBbuild.R): `R/PICBbuild.R`

### Cluster analysis

- [Cluster annotation](https://github.com/haaselab/picb/blob/main/R/PICBannotate.R): `R/PICBannotate.R`
- [Cluster optimization](https://github.com/haaselab/picb/blob/main/R/PICBoptimize.R): `R/PICBoptimize.R`
- [Strand analysis](https://github.com/haaselab/picb/blob/main/R/PICBstrandanalysis.R): `R/PICBstrandanalysis.R`
- [Chromosome lookup](https://github.com/haaselab/picb/blob/main/R/PICBgetchromosomes.R): `R/PICBgetchromosomes.R`

### Data exchange

- [Excel import](https://github.com/haaselab/picb/blob/main/R/PICBimportfromexcel.R): `R/PICBimportfromexcel.R`
- [Excel export](https://github.com/haaselab/picb/blob/main/R/PICBexporttoexcel.R): `R/PICBexporttoexcel.R`
- **Excel workbook**

### Other components

- **PICB user**

## Connections

- PICB user → Alignment loader: loads data
- Mapped BAM → Alignment loader: reads alignments
- Reference genome → Alignment loader: uses reference
- PICB user → FASTA loader: loads reference
- FASTA loader → Reference genome: provides reference
- Alignment loader → Loaded alignments: returns alignments
- PICB user → Cluster builder: builds clusters
- Loaded alignments → Cluster builder: provides alignments
- Reference genome → Cluster builder: uses reference
- Cluster builder → Seeds: produces seeds
- Cluster builder → Cores: produces cores
- Cluster builder → Clusters: produces clusters
- PICB user → Cluster annotation: runs annotation
- PICB user → Cluster optimization: runs optimization
- PICB user → Strand analysis: analyzes strands
- PICB user → Chromosome lookup: looks up chromosomes
- PICB user → Excel import: imports data
- Excel workbook → Excel import: provides workbook
- PICB user → Excel export: exports data
- Excel export → Excel workbook: writes workbook
