Skip to main content

randseq

Installation

$ pip install randseq

Optionally, with a compiled scan that is about 13x faster on 8 cores and gives identical results:

$ pip install "randseq[fast]"

The development version installs from the GitHub repository:

$ pip install git+https://github.com/dbikard/randseq.git

Usage

RandSeq conjugates a library of plasmids with random inserts from a donor into a recipient strain and counts each plasmid on both sides. A plasmid that carries a site the recipient’s defences recognise is lost. The example here, counts_panel.csv.gz, is a library of 150 nt random inserts counted in the donor (two replicates, Control_R1 and Control_R2) and in 8 recipient strains in two replicates each; counts_panel_key.csv says what each strain shows.

from randseq import calculate_log2fc, find_restricted_motifs, plot_motif_analysis, get_example_data_dir
import pandas as pd
# Read counts per plasmid: the donor library and 8 recipient strains, two replicates each
counts = pd.read_csv(os.path.join(get_example_data_dir(), "counts_panel.csv.gz"), index_col=0)
left, right = "GTCTAGGGCGGCGGTAAAAC", "ACTAGAGCACCAGAAGTCTA"   # vector sequence flanking the insert

# log2 fold change of each plasmid in each sample, against the first donor replicate
log2fc_df = calculate_log2fc(counts, reference_column="Control_R1")

find_restricted_motifs searches one sample’s log2 fold changes for the motifs whose carriers are depleted. It prints a log of its steps (not shown here) and returns the motifs it calls, in five columns. For JJ1886 these are its three restriction-modification sites, the Type I site written as one degenerate motif, RTACNNNNGTG:

motifs = find_restricted_motifs(log2fc_df["JJ1886_R1"], left, right)
motifs
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style>
motif num_sequences fraction_depleted avg_log2fc q_value
0 AAAGNNNNGTT 913 0.997809 -3.425663 0.000000e+00
1 RTACNNNNGTG 963 1.000000 -3.285517 0.000000e+00
2 GGTCTC 55 0.981818 -2.851532 2.999895e-43
  • num_sequences: the plasmids carrying the motif, of the 30,108 that pass the donor count filter.
  • fraction_depleted: the share of them depleted, at log2FC below −0.5 after normalising to the sample’s median.
  • avg_log2fc: the mean change of the carriers, relative to the sample’s median plasmid.
  • q_value: significance, adjusted for the false-discovery rate across the hundreds of thousands of motifs tested. A motif is called when q < 0.05 and most of its carriers are confidently depleted.

The plot shows the called motifs’ carriers among all plasmids, and their log2FC distribution:

fig, axes = plot_motif_analysis(counts, "JJ1886_R1", "Control_R1", motifs, left, right)

all_motifs=True also returns the motifs that were scored but not called, with diagnostic columns and the reason for each verdict. Reading the result table in the core documentation explains them, and The example panel at a glance there runs every strain of the panel.

Documentation

The documentation is at dbikard.github.io/randseq: one page per module, each a walkthrough of the code with examples. The changes between versions are in CHANGELOG.md.

Metadata

Release files for randseq 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for randseq 0.1.0
File Size Uploaded Provenance Actions
randseq-0.1.0.tar.gz 2.9 MB Without provenance Details for randseq-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for randseq 0.1.0
File Interpreter ABI Platform Actions
randseq-0.1.0-py3-none-any.whl Python 3 none any Details for randseq-0.1.0-py3-none-any.whl

Total release size: 5.9 MB

Release files / randseq-0.1.0.tar.gz

Download URL randseq-0.1.0.tar.gz
Size 2.9 MB
Tags Source
SHA-256 checksum
How to use checksums
d5fb58600f59ae08dd664ae1654d6e29cd6c90d54e161116163a994cef0f923f
BLAKE2b-256 checksum
How to use checksums
f7ab75b6957562c341e0d8601eb040056cb398444621491ee94f1a178b9fc963
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / randseq-0.1.0-py3-none-any.whl

Download URL randseq-0.1.0-py3-none-any.whl
Size 2.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
9444e45597469f0056e2d152e1b9abe628c32a6155f7e1fcc1d37672c61b30c7
BLAKE2b-256 checksum
How to use checksums
5f9e809f956d230c5ad5d18130b921637bc20e12a00df37871e0dad7b686c8a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Security for randseq 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page