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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
---
title: bartab
emoji: 🍹
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: "5.50.0"
app_file: app.py
pinned: true
short_description: Fitness from pooled competition experiments.
tags:
  - biology
  - sequencing
  - pooled-screen
  - fitness
  - gradio
---

# 🍹 bartab

**Estimate strain fitness from sequencing-based pooled competition experiments.**

`bartab` analyses pooled barcode sequencing experiments in which multiple strains,
mutants, guides, or constructs are grown together and quantified by NGS over time.
It estimates the relative fitness of each barcode compared with a reference strain,
typically WT.

[![Open in Spaces](https://huggingface.co/datasets/huggingface/badges/resolve/main/open-in-hf-spaces-md-dark.svg)](https://huggingface.co/spaces/scbirlab/bartab)

---

## What this app does

Upload three tables:

1. **Count table**  
   Read or UMI counts for each barcode in each sequencing sample.

2. **Sample sheet**  
   Metadata describing each sample: sample ID, culture/replicate ID, timepoint,
   optional concentration, optional growth measurement, and optional sampled volume.

3. **Barcode sheet**  
   Barcode or strain identifiers, plus optional strain-level metadata.

`bartab` then estimates how each barcode changes relative to a reference barcode as
the culture expands.

---

### Option 1: Spike-in normalisation

Use this when your experiment includes a non-growing spike-in barcode, such as a
heat-killed strain, plasmid-only control, or other fitness-zero control.

If the spike-in does not grow, then changes in the spike-in:WT count ratio report how
much WT has expanded.

For a non-growing spike-in:

$$
\log \left(
\frac{c_{spike}(t)}{c_{wt}(t)}
\frac{c_{wt}(0)}{c_{spike}(0)}
\right)
=
-
\log
\frac{n_{wt}(t)}{n_{wt}(0)}
$$

Substituting this into the barcode model gives:

$$
\log \left(
\frac{c_i(t)}{c_{wt}(t)}
\frac{c_{wt}(0)}{c_i(0)}
\right)
=
\left(
1 - \frac{w_i}{w_{wt}}
\right)
\log \left(
\frac{c_{spike}(t)}{c_{wt}(t)}
\frac{c_{wt}(0)}{c_{spike}(0)}
\right)
$$

So, when using spike-in normalisation, `bartab` estimates relative fitness from the
relationship between:

- the barcode:WT log-ratio change
- the spike-in:WT log-ratio change

---

### Option 2: Growth-based normalisation

Use this when you have measured culture growth directly, for example:

- OD600
- CFU/mL
- estimated generations
- another density-like growth measurement

In this mode, `bartab` uses the supplied growth column as the culture expansion axis
instead of estimating expansion from a spike-in barcode.

---

## Analysis modes

### 👟 Fitness in a single condition

This is the standard mode for pooled competition assays.

`bartab` fits a weighted least-squares model to estimate relative fitness for each
barcode.

Main outputs:

| Column | Meaning |
|---|---|
| `fitness` | relative fitness compared with the reference barcode |
| `fitness_low` | lower confidence interval bound |
| `fitness_high` | upper confidence interval bound |
| `slope_p` | p-value for deviation from neutral fitness |

Interpretation:

| Fitness | Interpretation |
|---|---|
| `1` | grows like the reference |
| `< 1` | growth disadvantage |
| `> 1` | growth advantage |

---

### 📉 Dose response

Use this when the sample sheet contains a concentration column.

`bartab` first estimates barcode fitness across concentrations, then fits a
two-parameter Hill model to estimate dose-response parameters.

Main outputs:

| Column | Meaning |
|---|---|
| `log_ic50` | log10 concentration giving 50% inhibition |
| `log_ic50_p` | p-value associated with the IC50 estimate |

Lower IC50 values indicate greater sensitivity to the inducer or drug.

---

## Required input tables

The app lets you select the relevant columns after upload.

Supported file formats:

- `.csv`
- `.tsv`
- `.txt`
- `.xlsx`

---

### 1. Count table

One row per barcode per sample.

Required columns:

| Meaning | Example |
|---|---|
| barcode / strain identifier | `strain_id` |
| sample identifier | `sample_id` |
| read or UMI count | `count` |

Example:

| strain_id | sample_id | count |
|---|---:|---:|
| wt | sample_0 | 12034 |
| mutant_A | sample_0 | 8312 |
| spike | sample_0 | 5021 |
| wt | sample_1 | 18420 |
| mutant_A | sample_1 | 6420 |
| spike | sample_1 | 2100 |

---

### 2. Barcode sheet

One row per barcode.

Required columns:

| Meaning | Example |
|---|---|
| barcode / strain identifier | `strain_id` |

Optional metadata columns are carried through to the output.

Example:

| strain_id | gene | annotation |
|---|---|---|
| wt | WT | reference |
| mutant_A | geneA | deletion mutant |
| spike | spike | non-growing spike-in |

---

### 3. Sample sheet

One row per sequencing sample.

Required columns:

| Meaning | Example |
|---|---|
| sample identifier | `sample_id` |
| culture / biological replicate | `replicate` |
| timepoint | `timepoint` |

Optional columns:

| Meaning | Example | Used for |
|---|---|---|
| concentration | `dose` | dose-response analysis |
| growth measurement | `growth` | growth-based normalisation |
| sampled volume | `volume` | adaptive-volume sampling |

Example:

| sample_id | replicate | timepoint | dose | growth | volume |
|---|---|---:|---:|---:|---:|
| sample_0 | rep1 | 0 | 0 | 0.05 | 1.0 |
| sample_1 | rep1 | 1 | 0 | 0.20 | 1.0 |
| sample_2 | rep1 | 2 | 0 | 0.80 | 1.0 |

---

## Example datasets

The Space includes synthetic example datasets for:

- single-concentration analysis using spike-in normalisation
- single-concentration analysis using growth-based normalisation
- dose-response analysis using spike-in normalisation
- dose-response analysis using growth-based normalisation

Start with these examples if you want to see the expected table structure.

---

## Outputs

After analysis, the app returns:

1. **Fitted parameter table**  
   A CSV file containing estimated fitness or dose-response parameters.

2. **Annotated `.h5ad` object**  
   A full `AnnData` object containing input data, metadata, transformations,
   fitted values, and model outputs.

3. **Diagnostic plots**

Depending on the analysis mode, plots include:

- time vs count
- expansion vs count
- time vs ratio
- expansion vs ratio
- predicted vs observed
- volcano plot
- dose-response curves

---

## Practical guidance

- Use consistent barcode and sample identifiers across all three tables.
- If using spike-in normalisation, include the spike-in barcode in both the count table
and barcode sheet.
- If using growth-based normalisation, include a numeric growth column in the sample sheet.
- For dose-response analysis, concentration values must be numeric.
- Low-count barcodes may give unstable estimates.
- Always inspect diagnostic plots before interpreting individual hits.

---

## The model

[Interactive tutorial on analysis principles](https://huggingface.co/spaces/scbirlab/tutorial-seq-fitness)

In a pooled growth experiment, strains compete in the same culture. Their absolute
growth curves may be complex because the pool eventually approaches carrying capacity.
However, if we compare every strain to a reference strain, the shared density-dependent
term cancels. The reference strain’s expansion can then be used as the effective
growth clock.

For strain $i$ relative to WT:

$$
\log n_i(t)
=
\frac{w_i}{w_{wt}}
\log \frac{n_{wt}(t)}{n_{wt}(0)}
+
\log n_i(0)
$$

where:

- $n_i(t)$ is the abundance of strain $i$ at time $t$
- $w_i$ is the intrinsic growth rate of strain $i$
- $w_i / w_{wt}$ is the relative fitness

So the problem becomes: estimate how barcode abundance changes relative to WT as WT
expands.

---

## From cells to sequencing counts

In practice, we do not observe cell numbers directly. We observe read counts:

$$
c_i(t)
$$

These are affected by sampling, library preparation, and sequencing depth. To remove
sample-specific sequencing depth effects, `bartab` works with ratios of barcode counts
to the reference barcode.

The key quantity is:

$$
\log \left(
\frac{c_i(t)}{c_{wt}(t)}
\frac{c_{wt}(0)}{c_i(0)}
\right)
$$

This is the log-change in the abundance of barcode $i$ relative to WT, normalised
to the starting timepoint.

Under the model:

$$
\log \left(
\frac{c_i(t)}{c_{wt}(t)}
\frac{c_{wt}(0)}{c_i(0)}
\right)
=
\left(
\frac{w_i}{w_{wt}} - 1
\right)
\log
\frac{n_{wt}(t)}{n_{wt}(0)}
$$

Thus, each barcode should follow an approximately straight line. The slope gives the
barcode’s fitness relative to WT.

---

## Estimating culture expansion

The remaining problem is that the true WT expansion,

$$
\frac{n_{wt}(t)}{n_{wt}(0)}
$$

is usually not directly observed. `bartab` supports two ways to estimate it.

---

## When this model is appropriate

`bartab` is designed for pooled competition experiments where:

- barcodes identify strains, mutants, guides, or constructs
- all barcodes are grown together in shared cultures
- barcode abundance is quantified by sequencing
- one barcode can be treated as a reference
- expansion can be estimated from a spike-in or measured growth

It is especially useful for:

- bacterial pooled competition assays
- barcoded mutant libraries
- CRISPRi or guide-based growth assays
- chemical-genetic pooled fitness experiments
- inducer or drug dose-response screens

---

## Limitations

`bartab` estimates relative fitness, not absolute growth rate.

Results may be unreliable when:

- the reference barcode is depleted or poorly counted
- the spike-in is not truly non-growing
- barcode counts are extremely low
- barcode identities are mismatched between tables
- bottlenecks dominate the experiment
- strong barcode-specific sequencing biases are present
- timepoints or concentrations are too sparse for model fitting

For dose-response fitting, IC50 estimates are most meaningful when the tested
concentration range brackets the transition from weak to strong inhibition.

---

## Local use

To run the app locally:

```bash
pip install -r requirements.txt
gradio app.py
```

For package and source code, see https://github.com/scbirlab/bartab