# Utils


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Counts to log2 fold change

Each plasmid’s depletion is the log2 ratio of its share of the recipient
sample to its share of the donor library, normalised so that the
sample’s median plasmid sits at 0. Four details matter:

- **The pseudocount is added to raw counts, before normalisation**:
  `(n+1)/Σ(n+1)` per sample, then the ratio. Normalised counts are far
  below 1, so adding 1 after normalising would flatten every ratio
  towards 1.
- **Shares are over the plasmids that pass the count filter**, not over
  every molecule sequenced. That is a per-sample constant: it shifts all
  log2FC of a sample by the same amount, and the median normalisation
  below removes it.
- **Each sample is normalised to its median plasmid**
  (`normalize="median"`, the default): each column’s median log2FC is
  subtracted, so the median plasmid has log2FC 0, a fold change of 1.
  This is median-ratio normalisation, as in DESeq2; on the log2 scale,
  subtracting the median is the same as rescaling the counts by the
  median ratio. Shares alone are not enough: when a few plasmids take a
  large share of a sample’s reads, every other plasmid’s share shrinks
  and its log2FC falls below 0, by an amount that differs from strain to
  strain. Against the median plasmid, a depletion threshold of −0.5
  means the same in every strain. `normalize="total"` stops at the
  shares.
- **The filter is `reference count > count_threshold`** (default 20), in
  the one reference column.

`count_threshold` filters on *donor* abundance, not on depletion, so
raising it costs power but does not choose which motifs are called. It
does set how many plasmids carry each motif, so `num_sequences` is
comparable between experiments only at the same threshold.

------------------------------------------------------------------------

<a
href="https://github.com/dbikard/randseq/blob/main/randseq/utils.py#L53"
target="_blank" style="float:right; font-size:smaller">source</a>

### calculate_log2fc

log2 fold change of each insert against the reference column,
median-normalised by default.

``` python
calculate_log2fc(df, reference_column='MFDpir', count_threshold=20,
                 pseudocount=1, normalize='median')
```

<table>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>df</code></td>
<td>DataFrame</td>
<td></td>
<td>read counts, one row per insert, one column per sample; NaN counts
as 0</td>
</tr>
<tr>
<td><code>reference_column</code></td>
<td>str</td>
<td><code>'MFDpir'</code></td>
<td>the input-library column every sample is compared with</td>
</tr>
<tr>
<td><code>count_threshold</code></td>
<td>int</td>
<td><code>20</code></td>
<td>an insert is kept when its reference count is strictly above
this</td>
</tr>
<tr>
<td><code>pseudocount</code></td>
<td>float</td>
<td><code>1</code></td>
<td>added to the raw counts, before normalisation</td>
</tr>
<tr>
<td><code>normalize</code></td>
<td>str</td>
<td><code>'median'</code></td>
<td>“median”: each sample’s median insert at 0; “total”: shares
only</td>
</tr>
<tr>
<td><em>returns</em></td>
<td>DataFrame</td>
<td></td>
<td>one column per sample, reference dropped; None without it, empty if
none pass</td>
</tr>
</tbody>
</table>

``` python
# Four plasmids, a reference and one sample. 'd' sits exactly at the threshold and is dropped:
# the filter is strict. By default the median plasmid, 'c', is at 0; "total" leaves the shares.
_toy = pd.DataFrame({'ref': [30, 90, 60, 20], 's': [0, 99, 40, 5]}, index=['a', 'b', 'c', 'd'])
_fc = calculate_log2fc(_toy, reference_column='ref', count_threshold=20, pseudocount=1)
_fc_total = calculate_log2fc(_toy, reference_column='ref', count_threshold=20, pseudocount=1,
                             normalize="total")
pd.DataFrame({"median": _fc['s'], "total": _fc_total['s']})
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">median</th>
<th data-quarto-table-cell-role="th">total</th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">a</td>
<td>-4.381011</td>
<td>-4.588244</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">b</td>
<td>0.709247</td>
<td>0.502014</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">c</td>
<td>0.000000</td>
<td>-0.207233</td>
</tr>
</tbody>
</table>

</div>

``` python
# The smaller example library, against its MFDpir donor: the lowest log2FC in each strain.
counts_file="countsTable.csv.gz"
file_path=os.path.join(data_path,counts_file)
counts=pd.read_csv(file_path, index_col=0)
counts = counts[[col for col in counts.columns if ("_T0" in col) or ("MFDpir" in col)]]

log2fc_df = calculate_log2fc(counts, reference_column='MFDpir', count_threshold=20, pseudocount=1)
log2fc_df.min(axis=0)
```

    K12_T0       -2.834854
    HS_T0        -3.317345
    E1114_T0     -4.534150
    E1167_T0     -3.642206
    H120_T0      -3.562062
    TA054_T0     -3.306746
    TA447_T0     -3.579671
    E101_T0      -8.109654
    41-1Ti9_T0   -4.247928
    TA280_T0     -4.802508
    M114_T0      -4.146918
    TA249_T0     -4.933508
    ROAR8_T0     -4.611930
    JJ1886_T0    -9.238267
    CFT073_T0    -3.881944
    APECO1_T0    -6.538809
    UTI89_T0     -8.534175
    S88_T0       -8.607330
    MG1655_T0    -4.738110
    dtype: float64

------------------------------------------------------------------------

<a
href="https://github.com/dbikard/randseq/blob/main/randseq/utils.py#L126"
target="_blank" style="float:right; font-size:smaller">source</a>

### revcomp

Reverse complement of a DNA sequence or an IUPAC motif: `R` becomes `Y`,
`N` stays `N`.

``` python
revcomp(seq)
```

<table>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>seq</code></td>
<td>str</td>
<td></td>
<td>a DNA sequence or an IUPAC motif; bracketed classes are
accepted</td>
</tr>
<tr>
<td><em>returns</em></td>
<td>str</td>
<td></td>
<td>the reverse complement, upper-cased, classes written as IUPAC
letters</td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/dbikard/randseq/blob/main/randseq/utils.py#L105"
target="_blank" style="float:right; font-size:smaller">source</a>

### normalise_motif

`motif` in upper-case IUPAC letters; anything else raises `ValueError`.

``` python
normalise_motif(motif)
```

<table>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>motif</code></td>
<td>str</td>
<td></td>
<td>IUPAC letters and/or bracketed classes such as <code>[AG]</code>, in
any case</td>
</tr>
<tr>
<td><em>returns</em></td>
<td>str</td>
<td></td>
<td>upper-cased, each class written as its IUPAC letter:
<code>'[AG]TAC'</code> -&gt; <code>'RTAC'</code></td>
</tr>
</tbody>
</table>

[`normalise_motif`](https://dbikard.github.io/randseq/utils.html#normalise_motif)
rejects anything that is neither an IUPAC letter nor a class of A, C, G
and T, so a misspelt motif fails loudly instead of matching nothing.

``` python
# Degenerate letters are complemented too: Y (C/T) pairs with R (A/G), so JJ1886's Type I site
# read on the other strand is REBASE's RTACNNNNGTG. A bracketed class is written as its IUPAC letter.
revcomp("CACNNNNGTAY"), normalise_motif("[ag]tacnnnngtg")
```

    ('RTACNNNNGTG', 'RTACNNNNGTG')

## Choosing which strand to report a motif on

A recognition site and its reverse complement are the same site. The
library is scanned on both strands, so a motif and its reverse
complement always get **identical** statistics — same number of
supporting sequences, same depletion score, same average log2FC. They
are one answer, and which spelling to report is a tie that has to be
broken the same way every time, or two result tables cannot be compared
(`GAGACC` in one, `GGTCTC` in the other).

[`canonical_motif`](https://dbikard.github.io/randseq/utils.html#canonical_motif)
reports the strand REBASE uses, so results line up with the literature
and with enzyme names (`GGTCTC` is BsaI/Eco31I). For motifs REBASE does
not know, which includes most of what a discovery screen finds, it falls
back to the alphabetically first strand: arbitrary, but the same on
every run and machine. A motif REBASE lists on both strands takes the
alphabetically first too.

------------------------------------------------------------------------

<a
href="https://github.com/dbikard/randseq/blob/main/randseq/utils.py#L153"
target="_blank" style="float:right; font-size:smaller">source</a>

### canonical_motif

The strand to report `motif` on: the one REBASE uses, else the
alphabetically first.

``` python
canonical_motif(motif, rebase_motifs=None)
```

<table>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>motif</code></td>
<td>str</td>
<td></td>
<td>an IUPAC motif, e.g. <code>'GAGACC'</code>; bracketed classes are
accepted</td>
</tr>
<tr>
<td><code>rebase_motifs</code></td>
<td>set | None</td>
<td><code>None</code></td>
<td>motifs to match; default the REBASE Gold Standard set shipped</td>
</tr>
<tr>
<td><em>returns</em></td>
<td>str</td>
<td></td>
<td><code>motif</code> or its reverse complement, in IUPAC letters (<a
href="https://dbikard.github.io/randseq/utils.html#normalise_motif"><code>normalise_motif</code></a>)</td>
</tr>
</tbody>
</table>

``` python
# REBASE spells the BsaI / Eco31I site GGTCTC, so that is the strand we report; a motif unknown
# to REBASE is reported on its alphabetically first strand.
canonical_motif('GAGACC'), canonical_motif('AACNNNNCTTT'), canonical_motif('TGGCCGC', rebase_motifs=set())
```

    ('GGTCTC', 'AAAGNNNNGTT', 'GCGGCCA')

------------------------------------------------------------------------

<a
href="https://github.com/dbikard/randseq/blob/main/randseq/utils.py#L170"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_lib_seq_context

Each insert inside its vector flanks, as motifs are searched: a site can
span the junction.

``` python
get_lib_seq_context(seqs, left, right)
```

<table>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>seqs</code></td>
<td>list</td>
<td></td>
<td>the inserts</td>
</tr>
<tr>
<td><code>left</code></td>
<td>str</td>
<td></td>
<td>vector sequence 5’ of the insert</td>
</tr>
<tr>
<td><code>right</code></td>
<td>str</td>
<td></td>
<td>vector sequence 3’ of the insert</td>
</tr>
<tr>
<td><em>returns</em></td>
<td>list</td>
<td></td>
<td><code>left + insert + right</code> for each insert, upper-cased, in
input order</td>
</tr>
</tbody>
</table>

``` python
left, right = "GTCCTAGGTATAATACTAGT", "GTTTTAGAGCTAGAAATAGC"
lib=get_lib_seq_context(log2fc_df.index,left,right)
lib[:2]
```

    ['GTCCTAGGTATAATACTAGTCGGAGGTACTGGGTACATTTGTTTTAGAGCTAGAAATAGC',
     'GTCCTAGGTATAATACTAGTTGGCGATAATGCCGGCTATCGTTTTAGAGCTAGAAATAGC']

``` python
_custom_motif_to_regex("RTACNNNNGTG")
```

    '[AG]TAC[ATGC][ATGC][ATGC][ATGC]GTG'

## The search space

A pattern `(d1, spacer, d2)` is the shape of a site: defined bases,
undefined gap, defined bases.
[`get_patterns`](https://dbikard.github.io/randseq/utils.html#get_patterns)
returns the shapes the scan searches by default, each in the one form
the scan uses.

The default is 43 patterns: contiguous sites of 5–7 bases, and gapped
sites whose halves are 2–4 bases, with 5–8 defined bases in all and a
gap of 1–8. It fits 837 of the 983 distinct motifs in the REBASE Gold
Standard set shipped with the package. The arguments widen it:
`get_patterns(contiguous=(4, 8), halves=(2, 5), max_spacer=9)` (68
patterns) fits 902, and adding `max_defined=9` (77) fits 911, at about 8
times the motifs tested (3.6 million against 460,000 on the larger
example library). That is not the default because, at the default
thresholds, a wider search adds one-base-longer descriptions of weak or
degenerate sites that steps 3 and 4 do not yet catch.

A site whose half has an undefined base inside it, such as
`CNGTANNNNNNTTC`, has two gaps, and no pattern describes it: 47 of the
983 Gold Standard motifs are of this kind, almost all Type I. Each
concrete variant of such a site has a one-gap shape, here `(5, 6, 3)`,
which can be passed in `patterns` to find the site. The variants are
then reported as separate rows (`CAGTANNNNNNTTC`, `CCGTANNNNNNTTC`, …),
because writing N inside a half would give a shape the scan does not
search.

------------------------------------------------------------------------

<a
href="https://github.com/dbikard/randseq/blob/main/randseq/utils.py#L204"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_patterns

The search space: every motif architecture the scan looks for by
default.

``` python
get_patterns(contiguous=(5, 7), halves=(2, 4), max_spacer=8, min_defined=5,
             max_defined=8)
```

<table>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>contiguous</code></td>
<td>tuple</td>
<td><code>(5, 7)</code></td>
<td>shortest and longest contiguous site</td>
</tr>
<tr>
<td><code>halves</code></td>
<td>tuple</td>
<td><code>(2, 4)</code></td>
<td>shortest and longest half of a gapped site</td>
</tr>
<tr>
<td><code>max_spacer</code></td>
<td>int</td>
<td><code>8</code></td>
<td>longest gap of a gapped site; the shortest is 1</td>
</tr>
<tr>
<td><code>min_defined</code></td>
<td>int</td>
<td><code>5</code></td>
<td>fewest defined bases of a gapped site, both halves together</td>
</tr>
<tr>
<td><code>max_defined</code></td>
<td>int</td>
<td><code>8</code></td>
<td>most defined bases of a gapped site</td>
</tr>
<tr>
<td><em>returns</em></td>
<td>list</td>
<td></td>
<td><code>(d1, spacer, d2)</code> in canonical form, by number of
defined bases, then spacer</td>
</tr>
</tbody>
</table>

``` python
patterns = get_patterns()
patterns[:5], patterns[-5:]
```

    ([(5, 0, 0), (2, 1, 3), (2, 2, 3), (2, 3, 3), (2, 4, 3)],
     [(4, 4, 4), (4, 5, 4), (4, 6, 4), (4, 7, 4), (4, 8, 4)])

### Custom motifs

Presence and log2FC lookups for a hand-picked list of motifs,
independent of
[`find_restricted_motifs`](https://dbikard.github.io/randseq/core.html#find_restricted_motifs).
A motif may use IUPAC codes (`N`, `R`, `Y`, …) and regex character
classes (`[AG]`) interchangeably, and is searched on both strands of the
insert with its context. An empty or non-string entry of the list gives
a column of False; a misspelt motif raises `ValueError`
([`normalise_motif`](https://dbikard.github.io/randseq/utils.html#normalise_motif)).

``` python
_seqs = pd.Series(1, index=["AAGGTCTCAA", "AAGAGACCAA", "TCTCAAAA", "TTTTTTTT"])
# GGTCTC on the forward strand, on the reverse strand, and across the left junction
# ("GG" + "TCTC...", once the flank is restored).
_get_filter_for_motif(_seqs, "GGTCTC", "GG", "")
```

    AAGGTCTCAA     True
    AAGAGACCAA     True
    TCTCAAAA       True
    TTTTTTTT      False
    dtype: bool

------------------------------------------------------------------------

<a
href="https://github.com/dbikard/randseq/blob/main/randseq/utils.py#L248"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_custom_motif_presence_in_library

Which of `motif_list` each insert carries, searched with its flanks and
on both strands.

``` python
get_custom_motif_presence_in_library(short_sequences_list, left_context,
                                     right_context, motif_list)
```

<table>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>short_sequences_list</code></td>
<td>list</td>
<td></td>
<td>the inserts</td>
</tr>
<tr>
<td><code>left_context</code></td>
<td>str</td>
<td></td>
<td>vector sequence 5’ of the insert</td>
</tr>
<tr>
<td><code>right_context</code></td>
<td>str</td>
<td></td>
<td>vector sequence 3’ of the insert</td>
</tr>
<tr>
<td><code>motif_list</code></td>
<td>list</td>
<td></td>
<td>motifs in IUPAC letters and/or classes,
e.g. <code>'[AG]TACNNNNGTG'</code></td>
</tr>
<tr>
<td><em>returns</em></td>
<td>DataFrame</td>
<td></td>
<td>a boolean column per motif; a row per insert, indexed by insert
<em>with flanks</em></td>
</tr>
</tbody>
</table>

``` python
_p = get_custom_motif_presence_in_library(["TCTCAA", "AAGAGA", "CCCCCC"], "gg", "CC", ["GGTCTC", "[AG]AGA"])
_p
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">GGTCTC</th>
<th data-quarto-table-cell-role="th">[AG]AGA</th>
</tr>
<tr>
<th data-quarto-table-cell-role="th">full_sequence</th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">GGTCTCAACC</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">GGAAGAGACC</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">GGCCCCCCCC</td>
<td>False</td>
<td>False</td>
</tr>
</tbody>
</table>

</div>

------------------------------------------------------------------------

<a
href="https://github.com/dbikard/randseq/blob/main/randseq/utils.py#L291"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_log2fc_distribution_by_motif

Each plasmid’s log2FC labelled by the motif it carries, in long format
for plotting.

``` python
get_log2fc_distribution_by_motif(log2fc_df, left_context, right_context,
                                 motif_list, sample_columns=None)
```

<table>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>log2fc_df</code></td>
<td>DataFrame</td>
<td></td>
<td>log2FC indexed by insert, one column per sample</td>
</tr>
<tr>
<td><code>left_context</code></td>
<td>str</td>
<td></td>
<td>vector sequence 5’ of the insert</td>
</tr>
<tr>
<td><code>right_context</code></td>
<td>str</td>
<td></td>
<td>vector sequence 3’ of the insert</td>
</tr>
<tr>
<td><code>motif_list</code></td>
<td>list</td>
<td></td>
<td>motifs as for <a
href="https://dbikard.github.io/randseq/utils.html#get_custom_motif_presence_in_library"><code>get_custom_motif_presence_in_library</code></a></td>
</tr>
<tr>
<td><code>sample_columns</code></td>
<td>list | None</td>
<td><code>None</code></td>
<td>the samples to include; default every column</td>
</tr>
<tr>
<td><em>returns</em></td>
<td>DataFrame</td>
<td></td>
<td>‘sequence’, ‘Motif_Category’ (a motif or ‘Other’), ‘sample’,
‘log2fc’</td>
</tr>
</tbody>
</table>

A plasmid carrying several motifs is labelled with the last of them in
`motif_list`, as in
[`plot_motif_depletion`](https://dbikard.github.io/randseq/plotting.html#plot_motif_depletion).
With no insert to search the function prints an error and returns None.

``` python
_l = pd.DataFrame({'s1': [-3.0, -2.0, 0.1], 's2': [-1.0, 0.0, 0.2]}, index=["GGTCTCAAA", "GGTCTCAAAA", "CCCCCC"])
_d = get_log2fc_distribution_by_motif(_l, "", "", ["GGTCTC", "CAAAA"])
_d
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">sequence</th>
<th data-quarto-table-cell-role="th">Motif_Category</th>
<th data-quarto-table-cell-role="th">sample</th>
<th data-quarto-table-cell-role="th">log2fc</th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">0</td>
<td>GGTCTCAAA</td>
<td>GGTCTC</td>
<td>s1</td>
<td>-3.0</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">1</td>
<td>GGTCTCAAAA</td>
<td>CAAAA</td>
<td>s1</td>
<td>-2.0</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">2</td>
<td>CCCCCC</td>
<td>Other</td>
<td>s1</td>
<td>0.1</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">3</td>
<td>GGTCTCAAA</td>
<td>GGTCTC</td>
<td>s2</td>
<td>-1.0</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">4</td>
<td>GGTCTCAAAA</td>
<td>CAAAA</td>
<td>s2</td>
<td>0.0</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">5</td>
<td>CCCCCC</td>
<td>Other</td>
<td>s2</td>
<td>0.2</td>
</tr>
</tbody>
</table>

</div>

### Example: JJ1886’s motifs in the 150 nt panel

JJ1886 replicate R1 against `Control_R1` in `counts_panel.csv.gz`, with
the panel’s flanks and JJ1886’s three RM motifs as the list:

``` python
counts_panel = pd.read_csv(os.path.join(data_path, "counts_panel.csv.gz"), index_col=0)
left_panel, right_panel = "GTCTAGGGCGGCGGTAAAAC", "ACTAGAGCACCAGAAGTCTA"
log2fc_panel = calculate_log2fc(counts_panel[["Control_R1", "JJ1886_R1"]], reference_column="Control_R1",
                                count_threshold=20, pseudocount=1)
log2fc_panel.describe()
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">JJ1886_R1</th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">count</td>
<td>3.010800e+04</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">mean</td>
<td>-1.928490e-01</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">std</td>
<td>9.257199e-01</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">min</td>
<td>-7.591883e+00</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">25%</td>
<td>-2.366480e-01</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">50%</td>
<td>-3.469447e-18</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">75%</td>
<td>2.150265e-01</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">max</td>
<td>2.108241e+00</td>
</tr>
</tbody>
</table>

</div>

``` python
jj1886_motifs = ["AAAGNNNNGTT", "[AG]TACNNNNGTG", "GGTCTC"]  # JJ1886 cognate RM motifs
presence_jj1886 = get_custom_motif_presence_in_library(log2fc_panel.index.tolist(), left_panel, right_panel, jj1886_motifs)
presence_jj1886.sum()
```

    AAAGNNNNGTT       913
    [AG]TACNNNNGTG    963
    GGTCTC             55
    dtype: int64

Number of plasmids, median log2FC and fraction depleted (log2FC \< −1)
per motif:

``` python
dist_jj1886 = get_log2fc_distribution_by_motif(log2fc_panel, left_panel, right_panel, jj1886_motifs, sample_columns=["JJ1886_R1"])
dist_jj1886.dropna(subset="log2fc").groupby("Motif_Category")["log2fc"].agg(n="size", median="median", frac_depleted=lambda x: (x < -1).mean())
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">n</th>
<th data-quarto-table-cell-role="th">median</th>
<th data-quarto-table-cell-role="th">frac_depleted</th>
</tr>
<tr>
<th data-quarto-table-cell-role="th">Motif_Category</th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">AAAGNNNNGTT</td>
<td>882</td>
<td>-3.402149</td>
<td>0.996599</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">GGTCTC</td>
<td>55</td>
<td>-2.983074</td>
<td>0.945455</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">Other</td>
<td>28209</td>
<td>0.024746</td>
<td>0.014003</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">[AG]TACNNNNGTG</td>
<td>962</td>
<td>-3.311400</td>
<td>0.997921</td>
</tr>
</tbody>
</table>

</div>

`RTACNNNNGTG` (R = A/G) matches exactly the same plasmids as
`[AG]TACNNNNGTG`:

``` python
iupac_check = get_custom_motif_presence_in_library(log2fc_panel.index.tolist(), left_panel, right_panel,
                                                    ["[AG]TACNNNNGTG", "RTACNNNNGTG"])
iupac_check.sum()
```

    [AG]TACNNNNGTG    963
    RTACNNNNGTG       963
    dtype: int64

## Is a motif’s depletion more than the sample’s own noise?

The scan in `00_core` tests a great many motifs (about 330,000 with the
default 5 or more supporting plasmids on the smaller example library,
460,000 on the larger), so some will look perfect by luck alone. How
many supporting plasmids a call needs before that stops being a
plausible explanation depends on the sample, not on a constant.

Under the null, a motif’s depleted count is `Binomial(n, p)` where **`p`
is the rate at which its carriers would deplete in this sample if no
site were involved**: their background. A noisy sample has a higher `p`
and therefore needs more evidence for the same claim, automatically. How
`p` is estimated for each motif is the next section; first, the binomial
form itself.

Shuffled data bear this out. With each sample’s log2FC shuffled across
its plasmids, 20 times for each of six strains of the two example
libraries,
[`find_restricted_motifs`](https://dbikard.github.io/randseq/core.html#find_restricted_motifs)
at the defaults calls nothing, at any `min_support` from 2 to 6; the
smallest q in any shuffle is 0.005, on a row the confidence bound
rejects.

**What this does not model.** The binomial treats the plasmids carrying
a motif as independent draws. They are not: motifs co-occur, which is
the whole subject of step 4 of the core pipeline. So the p-value is a
screen against chance, not a complete model of how a spurious call
arises: a shadow of a real site is highly significant by this test and
still needs explaining away.

``` python
# BH: p*n/rank is 0.04 for all four here, so all four q-values are 0.04.
_benjamini_hochberg([0.01, 0.02, 0.03, 0.04])
```

    array([0.04, 0.04, 0.04, 0.04])

### The background depends on the insert’s GC content

Within one sample, the chance that a plasmid looks depleted is not the
same for every insert. On the 20 nt library, AT-rich inserts deplete far
more often than GC-rich ones in some strains, for no reason a site could
explain (possibly a fitness cost of such inserts; the cause is unknown).
Fraction of plasmids below −0.5, on log2FC as
[`calculate_log2fc`](https://dbikard.github.io/randseq/utils.html#calculate_log2fc)
returns them:

``` python
_c = pd.read_csv(os.path.join(get_example_data_dir(), "countsTable.csv.gz"), index_col=0)
_l2 = calculate_log2fc(_c[["MFDpir", "E1114_T0", "H120_T0", "JJ1886_T0"]], reference_column="MFDpir")
_gc = pd.Series([(s.count("G") + s.count("C")) / len(s) for s in _l2.index], index=_l2.index)
_bins = pd.cut(_gc, [0, .25, .35, .45, .55, .65, 1], include_lowest=True)
_by_gc = (_l2 < -0.5).groupby(_bins, observed=True).mean().T.round(2)
_by_gc.loc["(plasmids)"] = _bins.value_counts().reindex(_by_gc.columns).values
_by_gc
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">(-0.001, 0.25]</th>
<th data-quarto-table-cell-role="th">(0.25, 0.35]</th>
<th data-quarto-table-cell-role="th">(0.35, 0.45]</th>
<th data-quarto-table-cell-role="th">(0.45, 0.55]</th>
<th data-quarto-table-cell-role="th">(0.55, 0.65]</th>
<th data-quarto-table-cell-role="th">(0.65, 1.0]</th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">E1114_T0</td>
<td>0.58</td>
<td>0.31</td>
<td>0.17</td>
<td>0.11</td>
<td>0.06</td>
<td>0.07</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">H120_T0</td>
<td>0.46</td>
<td>0.19</td>
<td>0.10</td>
<td>0.06</td>
<td>0.03</td>
<td>0.02</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">JJ1886_T0</td>
<td>0.04</td>
<td>0.05</td>
<td>0.07</td>
<td>0.07</td>
<td>0.06</td>
<td>0.06</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">(plasmids)</td>
<td>267.00</td>
<td>1126.00</td>
<td>3170.00</td>
<td>3910.00</td>
<td>2370.00</td>
<td>660.00</td>
</tr>
</tbody>
</table>

</div>

E1114 depletes 0.58 of the inserts with GC ≤ 25% and 0.07 of those above
65%; H120 0.46 against 0.02. JJ1886 hardly varies. Against one
sample-wide rate, any motif made of A and T inherits the excess of the
inserts that carry it and is called: 42 calls in E1114 and 39 in H120,
almost all AT-rich.

The fix is the standard one in motif enrichment (HOMER’s GC-matched
background): compare a motif’s carriers with plasmids of the same GC
content.
[`plasmid_background`](https://dbikard.github.io/randseq/utils.html#plasmid_background)
gives each plasmid the depletion rate of the plasmids in its insert-GC
decile, and a motif’s null rate is the mean of its carriers’
backgrounds. GC is counted on the insert alone: the flanks are the same
in every plasmid. The bins are deciles, fixed rather than a parameter:
fine enough to follow the trend above, coarse enough that every rate
rests on hundreds of plasmids. A 20 nt insert has only 21 possible GC
contents, so deciles that would share an edge merge: the 20 nt library
has 8 bins of 660–2,020 plasmids, the 150 nt panel library 10 of
1,805–3,858.

------------------------------------------------------------------------

<a
href="https://github.com/dbikard/randseq/blob/main/randseq/utils.py#L357"
target="_blank" style="float:right; font-size:smaller">source</a>

### plasmid_background

Each plasmid’s background: the depletion rate of the plasmids in its
insert-GC decile.

``` python
plasmid_background(sequences, log2fc, log2fc_thr=-1)
```

<table>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>sequences</code></td>
<td>list</td>
<td></td>
<td>the inserts, without the vector flanks</td>
</tr>
<tr>
<td><code>log2fc</code></td>
<td></td>
<td></td>
<td>log2FC per insert, in the same order, median-normalised as <a
href="https://dbikard.github.io/randseq/utils.html#calculate_log2fc"><code>calculate_log2fc</code></a>
does</td>
</tr>
<tr>
<td><code>log2fc_thr</code></td>
<td>float</td>
<td><code>-1</code></td>
<td>a plasmid is depleted below this</td>
</tr>
<tr>
<td><em>returns</em></td>
<td>ndarray</td>
<td></td>
<td>one rate per plasmid, strictly between 0 and 1</td>
</tr>
</tbody>
</table>

``` python
# E1114: the bins plasmid_background uses, and each one's background. An AT-rich insert's is
# several times a GC-rich one's, as in the table above.
_bg = plasmid_background(_l2.index, _l2["E1114_T0"], -0.5)
(pd.DataFrame({"insert GC": _gc.to_numpy(), "background": _bg}).groupby("background")["insert GC"]
   .agg(["min", "max", "size"]).sort_values("min").round(3))
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">min</th>
<th data-quarto-table-cell-role="th">max</th>
<th data-quarto-table-cell-role="th">size</th>
</tr>
<tr>
<th data-quarto-table-cell-role="th">background</th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">0.363963</td>
<td>0.10</td>
<td>0.35</td>
<td>1393</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">0.199697</td>
<td>0.40</td>
<td>0.40</td>
<td>1317</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">0.148408</td>
<td>0.45</td>
<td>0.45</td>
<td>1853</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">0.124257</td>
<td>0.50</td>
<td>0.50</td>
<td>2020</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">0.096296</td>
<td>0.55</td>
<td>0.55</td>
<td>1890</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">0.065505</td>
<td>0.60</td>
<td>0.60</td>
<td>1435</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">0.057754</td>
<td>0.65</td>
<td>0.65</td>
<td>935</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">0.069697</td>
<td>0.70</td>
<td>0.90</td>
<td>660</td>
</tr>
</tbody>
</table>

</div>

``` python
# One rate per motif: the same 10/10 is far less surprising for AT-rich carriers whose background
# is 0.5 (0.5**10) than for carriers whose background is 0.05 (0.05**10).
_motif_pvalues([10, 10], [1.0, 1.0], [0.5, 0.05])
```

    array([9.765625e-04, 9.765625e-14])

## Helpers for analysis scripts

The pipeline does not use these; they serve analysis scripts that build
pattern lists by hand or merge results across strains.
[`get_patterns`](https://dbikard.github.io/randseq/utils.html#get_patterns)
is the usual way to get the search space;
[`generate_tuple_combinations`](https://dbikard.github.io/randseq/utils.html#generate_tuple_combinations)
builds patterns in bulk, and
[`filter_symmetric_tuples`](https://dbikard.github.io/randseq/utils.html#filter_symmetric_tuples)
keeps one of each mirror pair, the first met: `(3, 4, 4)` and
`(4, 4, 3)` find the same sites, because the scan reads both strands.

------------------------------------------------------------------------

<a
href="https://github.com/dbikard/randseq/blob/main/randseq/utils.py#L375"
target="_blank" style="float:right; font-size:smaller">source</a>

### generate_tuple_combinations

`(d1, spacer, d2)` patterns in bulk: every `(a, b, c)` with each element
in its range.

``` python
generate_tuple_combinations(a1, a2, b1, b2, c1, c2)
```

<table>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>a1</code></td>
<td>int</td>
<td></td>
<td>smallest first element</td>
</tr>
<tr>
<td><code>a2</code></td>
<td>int</td>
<td></td>
<td>largest first element</td>
</tr>
<tr>
<td><code>b1</code></td>
<td>int</td>
<td></td>
<td>smallest second element</td>
</tr>
<tr>
<td><code>b2</code></td>
<td>int</td>
<td></td>
<td>largest second element</td>
</tr>
<tr>
<td><code>c1</code></td>
<td>int</td>
<td></td>
<td>smallest third element</td>
</tr>
<tr>
<td><code>c2</code></td>
<td>int</td>
<td></td>
<td>largest third element</td>
</tr>
<tr>
<td><em>returns</em></td>
<td>list</td>
<td></td>
<td>every <code>(a, b, c)</code> in the ranges, ends included, in
lexicographic order</td>
</tr>
</tbody>
</table>

``` python
patterns = generate_tuple_combinations(2,4,1,8,2,4)
patterns[:5], patterns[-5:]
```

    ([(2, 1, 2), (2, 1, 3), (2, 1, 4), (2, 2, 2), (2, 2, 3)],
     [(4, 7, 3), (4, 7, 4), (4, 8, 2), (4, 8, 3), (4, 8, 4)])

------------------------------------------------------------------------

<a
href="https://github.com/dbikard/randseq/blob/main/randseq/utils.py#L390"
target="_blank" style="float:right; font-size:smaller">source</a>

### filter_symmetric_tuples

Drop a tuple when its mirror (first and third elements swapped) came
earlier in the list.

``` python
filter_symmetric_tuples(list_of_tuples)
```

<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>list_of_tuples</code></td>
<td>list</td>
<td></td>
<td><code>(d1, spacer, d2)</code> tuples</td>
</tr>
<tr>
<td><em>returns</em></td>
<td>list</td>
<td></td>
<td>the tuples kept, in input order</td>
</tr>
</tbody>
</table>

``` python
# The first of a mirror pair is kept, in input order; a self-mirror tuple stays.
filter_symmetric_tuples([(4, 4, 3), (3, 4, 4), (4, 4, 4)])
```

    [(4, 4, 3), (4, 4, 4)]

### Merging motifs by spelling

[`find_iupac_equivalent_motifs`](https://dbikard.github.io/randseq/utils.html#find_iupac_equivalent_motifs)
groups same-length motifs that differ at ≤ `max_mismatches` positions (N
positions skipped, reverse complements considered) and merges each group
into one IUPAC motif, the union of bases at each position. It works on
spelling alone, on any results table — across strains, say. Within one
sample
[`find_restricted_motifs`](https://dbikard.github.io/randseq/core.html#find_restricted_motifs)
already merges a degenerate site on the data, a variant joining only
when its own carriers deplete like the site’s.

Groups are connected components: A~B and B~C merge all three, even when
A and C are further apart. A motif that matched through its reverse
complement is flipped before merging, and the merged motif is spelled on
the strand of the group’s first row. Each row of the result, one per
group with singletons included, gives `merged_motif`; `original_motifs`
and `original_motifs_oriented` (as given, and on the merged strand);
`n_merged`; `max_pairwise_mismatches`, over linked pairs; and `rc_used`,
after `sample_col` when one is given. When `df` has them,
`num_sequences`, `avg_log2fc` and `fraction_depleted` add
`total_sequences` (their sum), `avg_log2fc_weighted` (weighted by
`num_sequences` when present) and `avg_fraction_depleted` (unweighted
mean).

------------------------------------------------------------------------

<a
href="https://github.com/dbikard/randseq/blob/main/randseq/utils.py#L511"
target="_blank" style="float:right; font-size:smaller">source</a>

### find_iupac_equivalent_motifs

Merge same-length motifs a few mismatches apart into one IUPAC motif
each.

``` python
find_iupac_equivalent_motifs(df, max_mismatches=2, motif_col='motif',
                             sample_col=None, consider_rc=True)
```

<table>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>df</code></td>
<td>DataFrame</td>
<td></td>
<td>a table of motifs, e.g. from <a
href="https://dbikard.github.io/randseq/core.html#find_restricted_motifs"><code>find_restricted_motifs</code></a></td>
</tr>
<tr>
<td><code>max_mismatches</code></td>
<td>int</td>
<td><code>2</code></td>
<td>motifs this many mismatches apart or fewer are linked; 1 or 2
advised</td>
</tr>
<tr>
<td><code>motif_col</code></td>
<td>str</td>
<td><code>'motif'</code></td>
<td>the column holding the motifs</td>
</tr>
<tr>
<td><code>sample_col</code></td>
<td>str | None</td>
<td><code>None</code></td>
<td>the sample column, each sample merged on its own; None: one
sample</td>
</tr>
<tr>
<td><code>consider_rc</code></td>
<td>bool</td>
<td><code>True</code></td>
<td>also compare each motif with the other’s reverse complement</td>
</tr>
<tr>
<td><em>returns</em></td>
<td>DataFrame</td>
<td></td>
<td>one row per group of linked motifs, singletons included</td>
</tr>
</tbody>
</table>

Merging a results table with JJ1886’s motifs as the scan spells them
(the statistics are illustrative): `ATACNNNNGTG` and `CACNNNNGTAC` are
one mismatch apart once `CACNNNNGTAC` is flipped, and merge into
REBASE’s `RTACNNNNGTG`:

``` python
called_jj1886 = pd.DataFrame({
    "motif":             ["GGTCTC", "ATACNNNNGTG", "CACNNNNGTAC", "AAAGNNNNGTT"],
    "fraction_depleted": [0.94, 1.00, 1.00, 0.99],
    "num_sequences":     [49, 97, 78, 867],
    "avg_log2fc":        [-2.77, -3.22, -3.26, -3.37],
})
merged_jj1886 = find_iupac_equivalent_motifs(called_jj1886, max_mismatches=2)
merged_jj1886
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">merged_motif</th>
<th data-quarto-table-cell-role="th">original_motifs</th>
<th data-quarto-table-cell-role="th">original_motifs_oriented</th>
<th data-quarto-table-cell-role="th">n_merged</th>
<th data-quarto-table-cell-role="th">max_pairwise_mismatches</th>
<th data-quarto-table-cell-role="th">rc_used</th>
<th data-quarto-table-cell-role="th">total_sequences</th>
<th data-quarto-table-cell-role="th">avg_log2fc_weighted</th>
<th data-quarto-table-cell-role="th">avg_fraction_depleted</th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">0</td>
<td>GGTCTC</td>
<td>GGTCTC</td>
<td>GGTCTC</td>
<td>1</td>
<td>0</td>
<td>False</td>
<td>49</td>
<td>-2.770000</td>
<td>0.94</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">1</td>
<td>RTACNNNNGTG</td>
<td>ATACNNNNGTG | CACNNNNGTAC</td>
<td>ATACNNNNGTG | GTACNNNNGTG</td>
<td>2</td>
<td>1</td>
<td>True</td>
<td>175</td>
<td>-3.237829</td>
<td>1.00</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">2</td>
<td>AAAGNNNNGTT</td>
<td>AAAGNNNNGTT</td>
<td>AAAGNNNNGTT</td>
<td>1</td>
<td>0</td>
<td>False</td>
<td>867</td>
<td>-3.370000</td>
<td>0.99</td>
</tr>
</tbody>
</table>

</div>
