Repository navigation
Humans work in task directories too; shared conventions in CONVENTIONS.md #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # Conventions | ||
|
|
||
| How analysis is organized in this repo. Humans and coding agents follow the same rules; agents add their own on top | ||
| (a worktree, a session and a PR per task, sign-off on every write-back), from the | ||
| [analysis-workflow](https://github.com/quadbio/analysis-workflow) plugin. | ||
|
|
||
| > Everything here comes from the analysis template; change it there and pull it with `cruft update`. | ||
|
|
||
| ## Start a task | ||
|
|
||
| ```bash | ||
| pixi run analysis-workflow new analysis/<dataset>/<topic>/human_<name>_v1 --author <your initials> --notebook 01_<step> | ||
| ``` | ||
|
|
||
| This creates the task directory with its `README.md` and a starter notebook in `notebooks/`. Open the notebook, | ||
| fill in the README's question and inputs, and work. | ||
|
|
||
| ## Tasks | ||
|
|
||
| All analysis lives in task directories, `analysis/<dataset>/<topic>/<lane>_<name>_vN/`: | ||
|
|
||
| - `<dataset>` is there even when the repo has one dataset. Topics, such as `preprocessing/`, `annotation/` or | ||
| `spatial/`, can mostly be worked on in any order. | ||
| - `<lane>` is `human` or `agent`; the README's author line says who: initials, or the model. | ||
| - `vN` counts the answers to one question across both lanes: `human_markers_v1` may be followed by | ||
| `agent_markers_v2`. `analysis-workflow new` refuses any other version than the next. | ||
| - A task is edited freely until its first write-back to a shared object or until other tasks read its outputs (for | ||
| an agent's task: its merge). After that it is frozen, and a change is the next version, whose README names the | ||
| one it follows. | ||
|
|
||
| | in a task | tracked | holds | | ||
| | --- | --- | --- | | ||
| | `README.md` | yes | the question, inputs, deliverables, write-back; kept current | | ||
| | `notebooks/` | yes | `NN_<step>.ipynb`, numbered in run order; outputs committed, so keep them small | | ||
| | `scripts/` | yes | `NN_<step>.py`, numbered in run order; `_common.py` holds the task's paths | | ||
| | `results/` | yes | small evidence tables; past ~1 MB they belong in `outputs/` | | ||
| | `reports/` | yes | a report | | ||
| | `figures/` | no | figures | | ||
| | `outputs/` | no | data artifacts | | ||
| | `logs/` | no | batch-job logs | | ||
|
|
||
| Every output path comes from `task_paths`: `PATHS = task_paths()` in a notebook, `task_paths(__file__)` in a script; | ||
| `PATHS.ensure()` creates the directories. Dataset paths come from `FilePaths`: | ||
|
|
||
| ```python | ||
| from analysis_workflow import task_paths | ||
| from {{ cookiecutter.package_name }} import FilePaths | ||
|
|
||
| PATHS = task_paths().ensure() | ||
| working = FilePaths.EXAMPLE_DATASET / "processed" / "working" / "pbmc3k_2026-01-27.zarr" | ||
| fig.savefig(PATHS.figures / "umap.pdf") | ||
| ``` | ||
|
|
||
| ## Data | ||
|
|
||
| | `data/<dataset>/` | holds | | ||
| | --- | --- | | ||
| | `raw/` | bytes as they arrived, never changed | | ||
| | `resources/` | curated inputs that are not data: gene lists, marker tables | | ||
| | `processed/` | objects other tasks load: working objects in `working/`, others in descriptively named subdirectories | | ||
|
|
||
| A task writes into its own directory. An object other tasks will load goes to `processed/` (for an agent, after | ||
| sign-off), and the task README records its path. | ||
|
|
||
| ## Working objects | ||
|
|
||
| A working object is an AnnData zarr store, `processed/working/<name>_<YYYY-MM-DD>.zarr`, in which results from many | ||
| tasks accumulate. | ||
|
|
||
| - Read only what you need: `ad.io.read_elem(zarr.open_group(path)["obs"])`, or `ad.experimental.read_lazy`. | ||
| - Write back only through `commit_adata`, naming the keys you add. It refuses a key that is already there, so | ||
| nobody's results get overwritten: | ||
|
|
||
| ```python | ||
| from analysis_workflow import commit_adata | ||
|
|
||
| commit_adata(adata, path, keys={"obs": ["leiden_fine"]}) # dry run: shows what it would write | ||
| commit_adata(adata, path, keys={"obs": ["leiden_fine"]}, yes=True) # writes | ||
| ``` | ||
|
|
||
| - Never write an in-memory object over a working object: it erases what others added since you read it. Changing | ||
| or removing a key means a new dated copy. | ||
| - Give keys descriptive names, and list each in the task README's Write-back section. | ||
| - Labels: one categorical `obs` column, colours in `uns["<key>_colors"]`. | ||
| - A result that would grow the object materially (`analyze_anndata_size`) becomes a standalone AnnData on the same | ||
| `obs_names`, never a bare `.npy`. | ||
|
|
||
| ## Git | ||
|
|
||
| You work in the main checkout. A pull request is optional and encouraged for anything others build on: | ||
|
|
||
| ```bash | ||
| git switch -c <branch> | ||
| git add analysis/<dataset>/<topic>/<task> && git commit -m "<what>" | ||
| git push -u origin <branch> | ||
| gh pr create # its body starts from the PR template | ||
| ``` | ||
|
|
||
| It is reviewed against `REVIEW_GUIDE.md`. Switching | ||
| branches changes the main checkout that agents' sessions read, `pixi.toml` included: switch back to `main` when you | ||
| are done. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
....project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # human_scrna_workflow_v1 | ||
|
|
||
| **Date:** 2026-01-27 | ||
| **Author:** ML | ||
|
|
||
| <!-- Every heading below stays, in this order, and no others are added; a section with nothing to say reads "None." | ||
| The guidance comments stay too. --> | ||
|
|
||
| A demo of a complete scRNA-seq workflow on scanpy's PBMC 3k data, from QC to a working object, marking which | ||
| steps to run locally and which on a GPU cluster. | ||
|
|
||
| ## Deliverables | ||
|
|
||
| <!-- What the task delivers. An agent agrees them with the human at the start, from the default unless they chose | ||
| otherwise; a later change is recorded here too. --> | ||
|
|
||
| | deliverable | where | | ||
| | --- | --- | | ||
| | UMAP overviews | `figures/` (gitignored) | | ||
| | a new working object | Write-back, below | | ||
|
|
||
| ## Inputs | ||
|
|
||
| <!-- The actual files, not concepts: this is what makes the task re-runnable. --> | ||
|
|
||
| - scanpy's PBMC 3k dataset, downloaded to `data/example_dataset/raw/` | ||
| - CellTypist's `Immune_All_High.pkl` model | ||
|
|
||
| ## Write-back | ||
|
|
||
| <!-- What went into a shared object, under which keys, and anything placed in `data/<dataset>/processed/` with its | ||
| final path. --> | ||
|
|
||
| - `data/example_dataset/processed/working/pbmc3k_2026-01-27.zarr`, a new working object, holding: | ||
| - `obsm["X_scVI"]`, `obsm["X_umap"]`: scVI latent space and its UMAP | ||
| - `obs["leiden"]`: Leiden clusters at resolution 0.5 | ||
| - `obs["cell_type"]`: CellTypist labels, majority-voted | ||
|
|
||
| ## Running | ||
|
|
||
| <!-- The notebooks in `notebooks/` and scripts in `scripts/`, in run order, on the main checkout's environment. Batch | ||
| jobs get `MAIN=<main checkout>` at submit and log to `PATHS.logs`. --> | ||
|
|
||
| `notebooks/01_scrna_workflow.ipynb`, top to bottom; its scVI section is faster on a GPU. | ||
|
|
||
| ## Jobs | ||
|
|
||
| <!-- Batch jobs this task launched, counted at the end. --> | ||
|
|
||
| None. | ||
|
|
||
| ## PRs and issues | ||
|
|
||
| <!-- Every PR and issue this task opened, in any repo, added when opened, with a short summary of each; the details | ||
| are in the PR. --> | ||
|
|
||
| None. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| # Dataset structure | ||
|
|
||
| `raw/`, `resources/`, `processed/` and `results/`, as described under *Data and notebook | ||
| conventions* in the top-level `README.md`. | ||
| `raw/`, `resources/` and `processed/`, as described under *Data* in the top-level `CONVENTIONS.md`. |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the demo is rerun after another task has added keys to this working object through
commit_adata, this unconditionalwrite_zarrreplaces the store with the demo's in-memory object and deletes those additions. The new fixed path is explicitly advertised as a shared working object, so rerunning the documented top-to-bottom workflow can now erase downstream results. Refuse creation when the destination already exists, or require a new dated destination rather than overwriting it. This also violates the working-object preservation convention referenced by the agent guidance.AGENTS.md reference: {{cookiecutter.project_name}}/AGENTS.md:L8-L9
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in bc55f6f: the demo now raises if the working object already exists, and says to write a new dated copy instead.