# zhaoqing-wang/slimr architecture

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

- Interactive diagram: https://gitdiagram.com/zhaoqing-wang/slimr
- Repository: https://github.com/zhaoqing-wang/slimr

## Overview

SlimR is an R package for marker-based cell-type annotation in single-cell and spatial transcriptomics. Its main workflow standardizes or filters marker inputs, derives data-adaptive parameters, then assigns cell types either by cluster or per cell; results can be reviewed with semi-automated plots. The README also documents mapping, gene-level evaluation, and visualization utilities. Relationships here follow those documented workflows and capabilities; source excerpts were unavailable, so internal call ownership and finer wiring are not asserted.

Main entry points: [`R/Probability_parameter.R`](https://github.com/zhaoqing-wang/slimr/blob/main/R/Probability_parameter.R) (Adaptive parameters), [`R/Celltype_Calculate.R`](https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Calculate.R) (Cluster scoring), [`R/Celltype_Calculate_PerCell.R`](https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Calculate_PerCell.R) (Per-cell scoring), [`R/Markers_filter_Cellmarker2.R`](https://github.com/zhaoqing-wang/slimr/blob/main/R/Markers_filter_Cellmarker2.R) (Filter CellMarker2)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_markers["Marker Inputs"]
  node_cellmarker[("CellMarker2")]
  node_panglao[("PanglaoDB")]
  node_sctype[("ScType<br/>[Database_ScType.R]")]
  node_celltypist[("CellTypist atlas")]
  node_builtin[("Built-in marker lists")]
  node_filter_cellmarker["Filter CellMarker2"]
  node_filter_panglao["Filter PanglaoDB"]
  node_filter_sctype["Filter ScType"]
  node_marker_readers["Marker import"]
  node_seurat_reader["Seurat marker import"]
end

subgraph group_annotation["Annotation"]
  node_parameters["Adaptive parameters"]
  node_cluster_calc["Cluster scoring"]
  node_cluster_annotate["Cluster annotation"]
  node_percell_calc["Per-cell scoring"]
  node_percell_annotate["Per-cell annotation"]
end

subgraph group_review["Review and Analysis"]
  node_verification["Annotation verification"]
  node_comparison["Annotation comparison<br/>[Celltype_Compare.R]"]
  node_auc["Gene AUC/ROC"]
end

subgraph group_visualization["Visualization"]
  node_features["Feature plots"]
  node_heatmap["Annotation heatmap"]
  node_combined["Combined plots"]
  node_hierarchy["Hierarchy proportions"]
  node_voronoi["Weighted Voronoi"]
  node_group_heatmap["Grouped gene heatmap"]
  node_palette["Colour palettes<br/>[paletteDiscrete.R]"]
end

node_user(("Analyst"))
node_seurat["Seurat object"]

node_user -->|"filters markers"| node_filter_cellmarker
node_cellmarker -->|"marker data"| node_filter_cellmarker
node_user -->|"filters markers"| node_filter_panglao
node_panglao -->|"marker data"| node_filter_panglao
node_user -->|"filters markers"| node_filter_sctype
node_sctype -->|"marker data"| node_filter_sctype
node_user -->|"imports markers"| node_marker_readers
node_user -->|"imports markers"| node_seurat_reader
node_seurat -->|"provides markers"| node_seurat_reader
node_user -->|"sets parameters"| node_parameters
node_seurat -->|"provides data"| node_parameters
node_user -->|"runs scoring"| node_cluster_calc
node_seurat -->|"provides expression"| node_cluster_calc
node_parameters -->|"parameterizes"| node_cluster_calc
node_user -->|"runs annotation"| node_cluster_annotate
node_cluster_calc -->|"scores candidates"| node_cluster_annotate
node_user -->|"runs scoring"| node_percell_calc
node_seurat -->|"provides expression"| node_percell_calc
node_parameters -->|"parameterizes"| node_percell_calc
node_user -->|"runs annotation"| node_percell_annotate
node_percell_calc -->|"scores candidates"| node_percell_annotate
node_user -->|"reviews labels"| node_verification
node_user -->|"compares labels"| node_comparison
node_user -->|"explores annotations"| node_features
node_user -->|"reviews annotations"| node_heatmap
node_user -->|"reviews annotations"| node_combined
node_user -->|"evaluates genes"| node_auc
node_user -->|"plots proportions"| node_hierarchy
node_user -->|"plots spatial data"| node_voronoi
node_user -->|"plots gene scores"| node_group_heatmap
node_user -->|"selects colours"| node_palette

click node_cellmarker "https://github.com/zhaoqing-wang/slimr/blob/main/R/Database_Cellmarker2.R"
click node_panglao "https://github.com/zhaoqing-wang/slimr/blob/main/R/Database_PanglaoDB.R"
click node_sctype "https://github.com/zhaoqing-wang/slimr/blob/main/R/Database_ScType.R"
click node_celltypist "https://github.com/zhaoqing-wang/slimr/blob/main/R/Database_CellTypist.R"
click node_builtin "https://github.com/zhaoqing-wang/slimr/blob/main/R/Database_Markers_list_PCTAM.R"
click node_filter_cellmarker "https://github.com/zhaoqing-wang/slimr/blob/main/R/Markers_filter_Cellmarker2.R"
click node_filter_panglao "https://github.com/zhaoqing-wang/slimr/blob/main/R/Markers_filter_PanglaoDB.R"
click node_filter_sctype "https://github.com/zhaoqing-wang/slimr/blob/main/R/Markers_filter_ScType.R"
click node_marker_readers "https://github.com/zhaoqing-wang/slimr/blob/main/R/Read_excel_markers.R"
click node_seurat_reader "https://github.com/zhaoqing-wang/slimr/blob/main/R/Read_seurat_markers.R"
click node_parameters "https://github.com/zhaoqing-wang/slimr/blob/main/R/Probability_parameter.R"
click node_cluster_calc "https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Calculate.R"
click node_cluster_annotate "https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Annotation.R"
click node_percell_calc "https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Calculate_PerCell.R"
click node_percell_annotate "https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Annotation_PerCell.R"
click node_verification "https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Verification.R"
click node_comparison "https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Compare.R"
click node_features "https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Annotation_Features.R"
click node_heatmap "https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Annotation_Heatmap.R"
click node_combined "https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Annotation_Combined.R"
click node_auc "https://github.com/zhaoqing-wang/slimr/blob/main/R/Compute_Gene_AUC_ROC.R"
click node_hierarchy "https://github.com/zhaoqing-wang/slimr/blob/main/R/Plot_Hierarchy_Proportion.R"
click node_voronoi "https://github.com/zhaoqing-wang/slimr/blob/main/R/Plot_Voronoi_Diagram.R"
click node_group_heatmap "https://github.com/zhaoqing-wang/slimr/blob/main/R/Plot_Group_Gene_Heatmap.R"
click node_palette "https://github.com/zhaoqing-wang/slimr/blob/main/R/paletteDiscrete.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_cellmarker,node_panglao,node_sctype,node_celltypist,node_builtin,node_filter_cellmarker,node_filter_panglao,node_filter_sctype,node_marker_readers,node_seurat_reader toneBlue
class node_parameters,node_cluster_calc,node_cluster_annotate,node_percell_calc,node_percell_annotate toneAmber
class node_verification,node_comparison,node_auc toneMint
class node_features,node_heatmap,node_combined,node_hierarchy,node_voronoi,node_group_heatmap,node_palette toneRose
class node_user,node_seurat toneIndigo
```

## Components

### Marker Inputs

- [CellMarker2](https://github.com/zhaoqing-wang/slimr/blob/main/R/Database_Cellmarker2.R): `R/Database_Cellmarker2.R`
- [PanglaoDB](https://github.com/zhaoqing-wang/slimr/blob/main/R/Database_PanglaoDB.R): `R/Database_PanglaoDB.R`
- [ScType](https://github.com/zhaoqing-wang/slimr/blob/main/R/Database_ScType.R): `R/Database_ScType.R`
- [CellTypist atlas](https://github.com/zhaoqing-wang/slimr/blob/main/R/Database_CellTypist.R): `R/Database_CellTypist.R`
- [Built-in marker lists](https://github.com/zhaoqing-wang/slimr/blob/main/R/Database_Markers_list_PCTAM.R): `R/Database_Markers_list_PCTAM.R`
- [Filter CellMarker2](https://github.com/zhaoqing-wang/slimr/blob/main/R/Markers_filter_Cellmarker2.R): `R/Markers_filter_Cellmarker2.R`
- [Filter PanglaoDB](https://github.com/zhaoqing-wang/slimr/blob/main/R/Markers_filter_PanglaoDB.R): `R/Markers_filter_PanglaoDB.R`
- [Filter ScType](https://github.com/zhaoqing-wang/slimr/blob/main/R/Markers_filter_ScType.R): `R/Markers_filter_ScType.R`
- [Marker import](https://github.com/zhaoqing-wang/slimr/blob/main/R/Read_excel_markers.R): `R/Read_excel_markers.R`
- [Seurat marker import](https://github.com/zhaoqing-wang/slimr/blob/main/R/Read_seurat_markers.R): `R/Read_seurat_markers.R`

### Annotation

- [Adaptive parameters](https://github.com/zhaoqing-wang/slimr/blob/main/R/Probability_parameter.R): `R/Probability_parameter.R`
- [Cluster scoring](https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Calculate.R): `R/Celltype_Calculate.R`
- [Cluster annotation](https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Annotation.R): `R/Celltype_Annotation.R`
- [Per-cell scoring](https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Calculate_PerCell.R): `R/Celltype_Calculate_PerCell.R`
- [Per-cell annotation](https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Annotation_PerCell.R): `R/Celltype_Annotation_PerCell.R`

### Review and Analysis

- [Annotation verification](https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Verification.R): `R/Celltype_Verification.R`
- [Annotation comparison](https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Compare.R): `R/Celltype_Compare.R`
- [Gene AUC/ROC](https://github.com/zhaoqing-wang/slimr/blob/main/R/Compute_Gene_AUC_ROC.R): `R/Compute_Gene_AUC_ROC.R`

### Visualization

- [Feature plots](https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Annotation_Features.R): `R/Celltype_Annotation_Features.R`
- [Annotation heatmap](https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Annotation_Heatmap.R): `R/Celltype_Annotation_Heatmap.R`
- [Combined plots](https://github.com/zhaoqing-wang/slimr/blob/main/R/Celltype_Annotation_Combined.R): `R/Celltype_Annotation_Combined.R`
- [Hierarchy proportions](https://github.com/zhaoqing-wang/slimr/blob/main/R/Plot_Hierarchy_Proportion.R): `R/Plot_Hierarchy_Proportion.R`
- [Weighted Voronoi](https://github.com/zhaoqing-wang/slimr/blob/main/R/Plot_Voronoi_Diagram.R): `R/Plot_Voronoi_Diagram.R`
- [Grouped gene heatmap](https://github.com/zhaoqing-wang/slimr/blob/main/R/Plot_Group_Gene_Heatmap.R): `R/Plot_Group_Gene_Heatmap.R`
- [Colour palettes](https://github.com/zhaoqing-wang/slimr/blob/main/R/paletteDiscrete.R): `R/paletteDiscrete.R`

### Other components

- **Analyst**
- **Seurat object**

## Connections

- Analyst → Filter CellMarker2: filters markers
- CellMarker2 → Filter CellMarker2: marker data
- Analyst → Filter PanglaoDB: filters markers
- PanglaoDB → Filter PanglaoDB: marker data
- Analyst → Filter ScType: filters markers
- ScType → Filter ScType: marker data
- Analyst → Marker import: imports markers
- Analyst → Seurat marker import: imports markers
- Seurat object → Seurat marker import: provides markers
- Analyst → Adaptive parameters: sets parameters
- Seurat object → Adaptive parameters: provides data
- Analyst → Cluster scoring: runs scoring
- Seurat object → Cluster scoring: provides expression
- Adaptive parameters → Cluster scoring: parameterizes
- Analyst → Cluster annotation: runs annotation
- Cluster scoring → Cluster annotation: scores candidates
- Analyst → Per-cell scoring: runs scoring
- Seurat object → Per-cell scoring: provides expression
- Adaptive parameters → Per-cell scoring: parameterizes
- Analyst → Per-cell annotation: runs annotation
- Per-cell scoring → Per-cell annotation: scores candidates
- Analyst → Annotation verification: reviews labels
- Analyst → Annotation comparison: compares labels
- Analyst → Feature plots: explores annotations
- Analyst → Annotation heatmap: reviews annotations
- Analyst → Combined plots: reviews annotations
- Analyst → Gene AUC/ROC: evaluates genes
- Analyst → Hierarchy proportions: plots proportions
- Analyst → Weighted Voronoi: plots spatial data
- Analyst → Grouped gene heatmap: plots gene scores
- Analyst → Colour palettes: selects colours
