Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Figure renderer CI

on:
push:
pull_request:

jobs:
circos-and-catalog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: python -m pip install -r requirements.txt
- run: python -m unittest discover -s tests -v
- run: python scripts/test_catalog.py --out-dir /tmp/figstudio-catalog --limit 129
- run: >-
python scripts/figure_studio.py render --kind circos_lollipop_chord
--features examples/circos_v2/features.csv --links examples/circos_v2/links.csv
--sectors examples/circos_v2/sectors.csv --data-status demo --top-k 4 --width-mm 180
--formats pdf,svg,png --out /tmp/figstudio-circos/circos
- run: >-
python scripts/qc_figures.py /tmp/figstudio-circos
--output /tmp/figstudio-circos/qc.tsv --json /tmp/figstudio-circos/qc.json
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Scientific Figure Studio for high-impact biomedical and bioinformatics figures.

FigStudio integrates evidence-first figure planning, 128+ plot recipes, AI-assisted mechanism schematic prompts, journal-ready export, and high-impact visual QC for Nature/Cell/Science-style workflows.
FigStudio integrates evidence-first figure planning, 129 plot recipes, AI-assisted mechanism schematic prompts, journal-ready export, and high-impact visual QC for Nature/Cell/Science-style workflows.

## Included

- 128 registered plot recipes across distributions, comparisons, associations, multivariate plots, matrices, networks, survival, genomics, spatial, and mechanism diagrams.
- 129 registered plot recipes, including a data-driven `circos_lollipop_chord` composite.
- Vector-first PDF/SVG export plus RGB PNG/TIFF export with journal-oriented DPI checks.
- Pale accessible palettes, explicit figure contracts, source-data traceability, and claim-boundary review.
- AI image-generation guidance for text-free conceptual source assets; AI assets are never treated as quantitative evidence.
Expand All @@ -16,7 +16,8 @@ FigStudio integrates evidence-first figure planning, 128+ plot recipes, AI-assis
```bash
python scripts/figure_studio.py catalog
python scripts/figure_studio.py render --kind volcano_plot --out figure --seed 7
python scripts/figure_studio.py contact-sheet --out catalog_preview --limit 128
python scripts/figure_studio.py render --kind circos_lollipop_chord --features examples/circos_v2/features.csv --links examples/circos_v2/links.csv --sectors examples/circos_v2/sectors.csv --data-status demo --top-k 4 --width-mm 180 --formats pdf,svg,png --out results/circos_v2
python scripts/figure_studio.py contact-sheet --out catalog_preview --limit 129
python scripts/qc_figures.py path/to/figures --output audit/figure_qc.tsv --json audit/figure_qc.json
```

Expand All @@ -27,3 +28,9 @@ python -m pip install -r requirements.txt
```

The governing workflow is documented in [`SKILL.md`](SKILL.md).

The Circos example tables are synthetic test data only. They do not represent biological findings. The V2 recipe contract and link interpretation are documented in [`references/plot-catalog.md`](references/plot-catalog.md). Each render writes PDF/SVG/600 dpi PNG, normalized input snapshots, configuration, manifest, label-suppression table, and a QC report.

![Synthetic Circos V2 composite example](examples/circos_v2/circos_v2_180mm.png)

[Target / failed V1 / rebuilt V2 visual comparison](gallery/circos_v2_comparison.png)
12 changes: 8 additions & 4 deletions SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: scientific-figure-studio
description: Design, draw, export, and critically review traceable biomedical and bioinformatics figures for Nature/Cell/Science-style submission. Use for manuscript figures, mechanisms, graphical abstracts, multi-panel composites, journal TIFF/PDF/SVG export, AI-assisted conceptual schematics, or any request for publication-grade scientific plots. Includes a tested catalog of 128 plot recipes and a native Python renderer.
description: Design, draw, export, and critically review traceable biomedical and bioinformatics figures for Nature/Cell/Science-style submission. Use for manuscript figures, mechanisms, graphical abstracts, multi-panel composites, journal TIFF/PDF/SVG export, AI-assisted conceptual schematics, or any request for publication-grade scientific plots. Includes a tested catalog of 129 plot recipes and a native Python renderer.
---

# Scientific Figure Studio
Expand Down Expand Up @@ -35,16 +35,19 @@ Use the reading order `context → focal result → orthogonal validation → bo

### 2. Select a plot recipe

The bundled renderer exposes 128 registered recipes across distributions, comparisons, associations, multivariate views, matrices, networks/flows, temporal/survival analyses, genomics, spatial analysis, and mechanism diagrams. Inspect or render the catalog before inventing a new chart:
The bundled renderer exposes 129 recipes across distributions, comparisons, associations, multivariate views, matrices, networks/flows, temporal/survival analyses, genomics, spatial analysis, and mechanism diagrams. Inspect or render the catalog before inventing a new chart:

```bash
python scripts/figure_studio.py catalog
python scripts/figure_studio.py render --kind volcano_plot --out figure --seed 7
python scripts/figure_studio.py contact-sheet --out catalog_preview --limit 128
python scripts/figure_studio.py render --kind circos_lollipop_chord --features examples/circos_v2/features.csv --links examples/circos_v2/links.csv --sectors examples/circos_v2/sectors.csv --data-status demo --top-k 4 --width-mm 180 --formats pdf,svg,png --out results/circos_v2
python scripts/figure_studio.py contact-sheet --out catalog_preview --limit 129
```

Use the catalog as a starting point, not as a reason to force a template. Pass real source arrays through a native plotting script when the project provides them; demo data are only for smoke tests and examples.

For `circos_lollipop_chord`, follow the feature-anchored V2 CSV contract in [references/plot-catalog.md](references/plot-catalog.md). Links represent feature-level associations and do not establish causality. Missing feature anchors fail validation; sector-center substitutions are prohibited. The example CSVs are synthetic placeholders, never biological findings. Export includes editable PDF/SVG, 600 dpi PNG, source CSV snapshots, YAML configuration, run manifest, suppressed-label table, metadata, and a QC report.

### 3. Apply the visual system

- Default dimensions: 89 mm single-column or 183 mm double-column; keep height ≤247 mm unless the target journal specifies otherwise.
Expand All @@ -65,6 +68,7 @@ Use the bundled renderer for deterministic demo assets and the project’s nativ

```bash
python scripts/figure_studio.py render --kind mechanism_schematic --out mechanism --formats pdf,svg,png,tiff
python scripts/figure_studio.py render --kind circos_lollipop_chord --features examples/circos_v2/features.csv --links examples/circos_v2/links.csv --sectors examples/circos_v2/sectors.csv --data-status demo --top-k 4 --width-mm 180 --formats pdf,svg,png --out results/circos_v2
python scripts/qc_figures.py path/to/figures --output audit/figure_qc.tsv --json audit/figure_qc.json
```

Expand All @@ -86,7 +90,7 @@ Provide:

## Resource map

- [references/plot-catalog.md](references/plot-catalog.md): 128 registered recipes and selection guidance.
- [references/plot-catalog.md](references/plot-catalog.md): 129 registered recipes and selection guidance.
- [references/figure-contract.md](references/figure-contract.md): panel-level provenance and evidence-boundary template.
- [references/journal-export.md](references/journal-export.md): dimensions, typography, colour, raster/vector, and QC standards.
- `scripts/figure_studio.py`: catalog, deterministic rendering, mechanism fallback, export, and contact-sheet CLI.
Expand Down
45 changes: 45 additions & 0 deletions docs/CIRCOS_V2_ACCEPTANCE_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Circos composite rebuild V2 acceptance report

## Result

The native feature-anchored Circos renderer is implemented in FigStudio and FigFrame. Reference screenshots were supplied in `/Users/mingsmacbook/Downloads/FIGSTUDIO_CIRCOS_VISUAL_REFERENCES.zip`; the target panel, failed V1 render, and rebuilt V2 render are compared in `gallery/circos_v2_comparison.png`.

The included 12-sector, 240-feature tables and resulting figure are **synthetic demonstration data only**. The rendering workflow and geometric contract pass software acceptance; scientific acceptance on real data remains pending because no source study tables or evidence contract were supplied.

## Acceptance checks

| Area | Status | Evidence |
|---|---|---|
| Root-cause report | PASS | `docs/circos_v2_root_cause.md` records the V1 center-collapse, midpoint fallback, sparse synthetic inputs, excess bands, and unlabeled/signed score scale. |
| Shared feature geometry | PASS | Seven geometry tests establish one feature angle reused for score points, label leaders, and chord endpoints. |
| Open-center Bezier links | PASS | Cubic polar Beziers end at exact feature angles and shared inner score radius; tests assert every sampled curve remains above radius zero. Missing feature anchors fail validation. |
| V2 source contract | PASS | `features.csv` includes per-sector feature IDs, score, direction, labels and optional evidence ranking columns. `links.csv` has explicit feature endpoints and foreign-key validation. Duplicate handling is deterministic and conflicts fail. |
| Score semantics | PASS | Non-negative and signed maps are linear; signed baselines preserve the sign, and user scales reject overflow rather than clipping. Tick values and mapping are stated on-figure. |
| Density / labels | PASS | Renderer cases cover six asymmetric sectors and twelve sectors with 240 features, sparse/dense links, long labels, rank prioritization, bbox collision/clipping suppression, and a suppression-reason CSV. |
| Track styling | PASS | One pale sector band, a minimal score grid, semantic blue/coral/gray score markers, and neutral teal weighted links. No stack of decorative sector bands. |
| Fixed-size exports | PASS | 90 mm: 2125×2125 RGB PNG at 600 dpi; 180 mm: 4251×4251 RGB PNG at 600 dpi. Each has PDF and SVG siblings. |
| Reproducibility | PASS | Input snapshots, `.config.yaml`, `.manifest.json` with SHA-256 values, `.metadata.json`, `.suppressed_labels.csv`, and `.qc.json` are emitted per output stem. |
| Real-data scientific validity | HOLD | Synthetic examples prove renderer behavior only. Replace all example inputs with source-traceable real data and confirm the score definition, direction semantics, link evidence, ranking, and manuscript claim before scientific interpretation. |

## Reproduction and verification

```bash
python -m unittest discover -s tests -v
python scripts/figure_studio.py render --kind circos_lollipop_chord \
--features examples/circos_v2/features.csv \
--links examples/circos_v2/links.csv \
--sectors examples/circos_v2/sectors.csv --data-status demo \
--top-k 4 --width-mm 90 --formats pdf,svg,png \
--out examples/circos_v2/circos_v2_90mm
python scripts/figure_studio.py render --kind circos_lollipop_chord \
--features examples/circos_v2/features.csv \
--links examples/circos_v2/links.csv \
--sectors examples/circos_v2/sectors.csv --data-status demo \
--top-k 4 --width-mm 180 --formats pdf,svg,png \
--out examples/circos_v2/circos_v2_180mm
python scripts/qc_figures.py examples/circos_v2 \
--output examples/circos_v2/figure_qc.tsv \
--json examples/circos_v2/figure_qc.json
```

The V1 examples and exports in `examples/circos/` remain intact as historical comparison inputs. The new renderer uses a separate `examples/circos_v2/` output stem.
32 changes: 32 additions & 0 deletions docs/circos_v2_root_cause.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Circos V2 root-cause report

## Reproduction state

- Repository: `mingeric/FigStudio`
- Failed implementation commit: `f074cded14625ad352ec8cfa6501dbbc44492a36`
- Recipe: `circos_lollipop_chord`
- Reproduction command:

```bash
python scripts/figure_studio.py render --kind circos_lollipop_chord \
--scores examples/circos/gene_scores.csv --links examples/circos/links.csv \
--sectors examples/circos/sectors.csv --data-status demo \
--formats pdf,svg,png --out examples/circos/circos_lollipop_chord
```

The reference bundle supplied with V2 contains `01_TARGET_ORIGINAL_SCREENSHOT.jpg`, its cropped Circos panel `01_TARGET_CIRCOS_CROPPED.png` (945 × 875), and the failed rendering `02_FAILED_V1_OUTPUT.png` (1816 × 2048). The V1 repository preview is also 4104 × 4626 at 600 dpi.

## Findings

1. **The chord curve collapses to the origin.** `scripts/circos_recipe.py` computed `r(t) = (r_inner - 0.04) × (1 - sin(πt)^0.85)`. At `t=0.5`, the radius is exactly zero. Every edge therefore becomes a center-converging petal. Its endpoints are also fixed at the same inner radius, not at the plotted feature point.
2. **Feature anchors silently fall back to sector centers.** `anchors.get((sector, feature), mids[sector])` accepts an absent feature and substitutes a sector midpoint. The old `links.csv` contract only carried one feature string, so mismatched or absent identifiers could still render without a diagnostic.
3. **The output is sparse by contract and synthetic by construction.** The example contains six sectors × ten placeholder rows, while the renderer labels only four features per sector. Its scores follow a repeating modulo formula, and the old contract has no p-value/FDR/effect-size ranking. This explains the G01–G08-looking, repetitive annotation pattern; it is not real research data.
4. **The track hierarchy is overbuilt.** Two adjacent annular bars (`bottom=.99,height=.10` and `bottom=.90,height=.07`) create stacked sector bands, followed by four regular unlabeled grid segments per sector. The extra band and fixed grid dominate the score marks instead of matching the single pale sector band and ranked score arc in the reference.
5. **The score scale is not self-reading.** Grid arcs are fixed fractions, but no values are written at the ticks. Signed values are reduced to absolute deviations, so their sign is not represented by radius.
6. **Label placement is decoupled from the feature order.** The score points use evenly spaced feature angles, while the chosen labels are moved to evenly spaced display slots. Leader lines connect the two, but there is no collision test or suppressed-label record.

## V2 geometry constraints

V2 tests must establish, before final exports, that each feature has one stable sector-local angle; score points and label leaders use that angle; every chord endpoint has radius `r_inner` and the exact named feature angle; and every sampled chord remains outside a non-zero open-center radius. Missing feature anchors must fail validation. Any aggregate link must be explicitly typed and reported.

The V2 examples remain marked synthetic. The reference screenshot is a visual target only and is not treated as source data or evidence.
3 changes: 3 additions & 0 deletions examples/circos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Synthetic Circos example data

All rows in these CSV files are generated placeholders for software demonstration and test only. They are **not biological findings**, real cancer evidence, or causal relationships. The example links mean only synthetic shared-feature associations.
29 changes: 29 additions & 0 deletions examples/circos/circos_lollipop_chord.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"schema_version": "1.0",
"input_sha256": {
"examples/circos/gene_scores.csv": "156ad83ccf6fcc7d1123268e64143ce89f8968eb4aa80d7813ed2634b4027f67",
"examples/circos/links.csv": "80a60c2f165b0c52630faa02d811d0fdeacfde7d7f9700cb340241627cb317a5",
"examples/circos/sectors.csv": "ed64c28885a157782a6585ece0580529499ac3456407ff861af29ade00c55607"
},
"configuration": {
"recipe": "circos_lollipop_chord",
"seed": 0,
"top_n": 4,
"gap_degrees": 3,
"link_limit": 500,
"baseline": 0,
"signed_scores": false,
"figsize_inches": 8,
"label_orientation": "tangent",
"inner_radius": 0.48,
"outer_radius": 0.83,
"max_label_chars": 18,
"scale": "max_abs_deviation_from_baseline"
},
"software": {
"python": "3.14.6",
"matplotlib": "3.11.2",
"numpy": "2.5.4"
},
"data_status": "demo"
}
Binary file added examples/circos/circos_lollipop_chord.pdf
Binary file not shown.
Binary file added examples/circos/circos_lollipop_chord.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading