Skip to content

Commit ef06c06

Browse files
committed
docs(readme): flagship pipeline uses clonal_lineage (real BCR trees) instead of deprecated expand_clones
The 'everything in one place' example chained the deprecated expand_clones (+ a separate mutate) star model. Switch it to clonal_lineage: SHM is now internal (per-division S5F via rate=), each clone yields a ground-truth tree (lineage_trees), and corruption passes apply per sampled cell. Numbers updated to the real seed=42 output (len 415, ~76% productive, n_mutations 14/11). The deprecation table row for expand_clones is kept intentionally.
1 parent 304c532 commit ef06c06

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

README.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Headers use the AIRR record's `sequence_id` with the universally-portable `/1` a
9494

9595
## A realistic pipeline — everything in one place
9696

97-
The Experiment DSL is a fluent builder. Each step appends to the pipeline; the same `Experiment` is returned so calls chain. The example below uses every major feature GenAIRR offers — recombination, clonal expansion, per-descendant somatic hypermutation, primer-trimming, structural indels, PCR errors, N-base injection, custom metadata, and the productive constraint:
97+
The Experiment DSL is a fluent builder. Each step appends to the pipeline; the same `Experiment` is returned so calls chain. The example below uses every major feature GenAIRR offers — recombination, BCR clonal lineage trees with affinity maturation, per-division somatic hypermutation, primer-trimming, structural indels, PCR errors, N-base injection, custom metadata, and the productive constraint:
9898

9999
```python
100100
import GenAIRR as ga
@@ -103,49 +103,49 @@ result = (
103103
ga.Experiment.on("human_igh")
104104
# 1. V(D)J recombination — sample alleles, trim, fill NP1/NP2, assemble.
105105
.recombine()
106-
# 2. Clonal structure — 50 lineages × 20 sister sequences each.
107-
# Passes BEFORE this point apply to the parent rearrangement;
108-
# passes AFTER apply per-descendant. So each clone shares the
109-
# same V(D)J recombination but accumulates its own SHM + errors.
110-
# NOTE: expand_clones is the legacy fixed-size *star* model. For
111-
# real clonal trees and repertoires, see "Clonal lineages &
112-
# repertoires" below (clonal_lineage / clonal_repertoire).
113-
.expand_clones(n_clones=50, per_clone=20)
114-
# 3. Somatic hypermutation per descendant — S5F context-dependent
115-
# model at 5% per-base rate (matches memory-B-cell SHM).
116-
.mutate(rate=0.05)
117-
# 4. Sequencing artefacts per descendant: primer trimming, structural
106+
# 2. Clonal lineage trees — grow 50 real B-cell lineages from the
107+
# recombined founder: generation-synchronous birth–death over
108+
# 5 generations, per-division S5F somatic hypermutation at 0.75%
109+
# per base, affinity selection, then sample 20 cells per clone.
110+
# Passes BEFORE this point shape the founder rearrangement;
111+
# passes AFTER apply per sampled cell (library prep). Every clone
112+
# shares the founder's V(D)J but carries its own SHM + errors,
113+
# and you get a ground-truth tree per clone (see lineage_trees).
114+
.clonal_lineage(n_clones=50, max_generations=5, n_sample=20,
115+
rate=0.0075, selection_strength=10.0)
116+
# 3. Sequencing artefacts per sampled cell: primer trimming, structural
118117
# indels, PCR substitution errors, quality-driven N injection.
119118
.primer_trim_5prime(length=(0, 8))
120119
.primer_trim_3prime(length=(0, 4))
121120
.polymerase_indels(count=(0, 2), insertion_prob=0.5)
122121
.pcr_amplify(count=(0, 3))
123122
.ambiguous_base_calls(count=(0, 2))
124-
# 5. Stamp arbitrary metadata onto every record.
123+
# 4. Stamp arbitrary metadata onto every record.
125124
.with_metadata(experiment_id="exp001", tissue="peripheral_blood")
126-
# Constraint-aware sampling: the productive() bundle is enforced at
127-
# rearrangement + SHM time. Corruption passes can still introduce
128-
# stop codons / frameshifts post-hoc, so expect ~70% productive
129-
# when aggressive corruption is in the chain — that mirrors real
130-
# wet-lab data, where a productive B-cell can sequence as a
131-
# non-productive read because of an indel during library prep.
125+
# The founder is drawn under the productive() constraint. Accumulated
126+
# SHM and corruption passes can still introduce stop codons /
127+
# frameshifts in individual cells, so expect ~75% productive under
128+
# this SHM + corruption load — that mirrors real wet-lab data, where a
129+
# productive B-cell can sequence as a non-productive read.
132130
.productive_only().run_records(seed=42)
133131
)
134132

135-
len(result) # 1000 (= n_clones × size)
136-
sum(1 for r in result if r["productive"]) # 697 (~70% under this corruption load)
133+
len(result) # 415 (sampled live cells across 50 trees)
134+
sum(1 for r in result if r["productive"]) # 316 (~76% under this SHM + corruption load)
135+
len(result.lineage_trees) # 50 (one ground-truth tree per clone)
137136

138-
# Same clone, different descendantssame V(D)J recombination,
137+
# Same clone, different cellsshared founder V(D)J,
139138
# independent SHM + errors:
140139
result[0]["clone_id"], result[1]["clone_id"] # (0, 0)
141-
result[0]["v_call"], result[1]["v_call"] # both 'IGHVF10-G38*04'
142-
result[0]["n_mutations"], result[1]["n_mutations"] # (13, 15) — independent SHM
143-
result[0]["n_pcr_errors"], result[1]["n_pcr_errors"] # (1, 1) — independent errors
140+
result[0]["v_call"], result[1]["v_call"] # both 'IGHVF10-G51*05'
141+
result[0]["n_mutations"], result[1]["n_mutations"] # (14, 11) — independent SHM
142+
result[0]["n_pcr_errors"], result[1]["n_pcr_errors"] # (3, 0) — independent errors
144143

145144
# Custom metadata propagated:
146145
result[0]["experiment_id"], result[0]["tissue"] # ('exp001', 'peripheral_blood')
147146

148147
result.to_tsv("repertoire.tsv")
148+
newick = result.lineage_trees[0].to_newick() # ground-truth lineage for clone 0
149149
```
150150

151151
## Clonal lineages & repertoires

0 commit comments

Comments
 (0)