kmerPaPa
Tool to calculate a "k-mer pattern partition" from position specific k-mer counts. This can for instance be used to train a mutation rate model.
Requirements
kmerPaPa requires Python 3.8 or above.
Installation
kmerPaPa can be installed using pip:
pip install kmerpapa
or using pipx:
pipx install kmerpapa
Test data
The test data files used in the usage examples below can be downloaded from the test_data directory in the project's github repository:
wget https://github.com/BesenbacherLab/kmerPaPa/raw/main/test_data/mutated_5mers.txt
wget https://github.com/BesenbacherLab/kmerPaPa/raw/main/test_data/background_5mers.txt
Usage
If we want to train a mutation rate model then the input data should specifiy the number of times each k-mer is observed mutated and unmutated. One option is to have one file with the mutated k-mer counts (positive) and one file with the count of k-mers in the whole genome (background). We can then run kmerpapa like this:
kmerpapa --positive mutated_5mers.txt \
--background background_5mers.txt \
--penalty_values 3 5 7
The above command will first use cross validation to find the best penalty value between the values 3,5 and 7. Then it will find the optimal k-mer patter partiton using that penalty value. If both a list of penalty values and a list of pseudo-counts are specified then all combinations of values will be tested during cross validation:
kmerpapa --positive mutated_5mers.txt \
--background background_5mers.txt \
--penalty_values 3 5 6 \
--pseudo_counts 0.5 1 10
If only a single combination of penalty_value and pseudo_count is provided then the default is not to run cross validation unless "--n_folds" option or the "CV_only" is used. The "CV_only" option can be used together with "--CVfile" option to parallelize grid search. Fx. using bash:
for c in 3 5 6; do
for a in 0.5 1 10; do
kmerpapa --positive mutated_5mers.txt \
--background background_5mers.txt \
--penalty_values $c \
--pseudo_counts $a \
--CV_only --CVfile CV_results_c${c}_a${a}.txt &
done
done
Creating input data
Input files with k-mer counts can be created using kmer_counter. Given a file of point mutations in a file that contain the CHROM, POS, REF and ALT columns from a vcf file:
chr1 1000000 G A
chr1 1000100 G A
chr1 1000200 C T
chr1 1000300 C T
chr1 1000400 C T
We can count the 5-mers around each mutation using this command:
kmer_counter snv --radius 2 {genome}.2bit {point_mutations_file} > mutated_5mers.txt
Given a bed file with regions that are sufficiently covered by sequencing we can count the background 5-mers using this command:
kmer_counter background --bed {regions}.bed -radius 2 {genome}.2bit > background_5mers.txt
The file {genome}.2bit should be a 2bit file of the same reference genome that were used for calling the mutations. 2bit files can be downloaded from: https://hgdownload.cse.ucsc.edu/goldenpath/{genome}/bigZips/{genome}.2bit where {genome} is a valid UCSC genome assembly name (fx. "hg38").
Metadata
Release files for kmerpapa 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kmerpapa-0.2.4.tar.gz | 21.5 kB | Without provenance | Details for kmerpapa-0.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kmerpapa-0.2.4-py3-none-any.whl | Python 3 | none | any | Details for kmerpapa-0.2.4-py3-none-any.whl |
Total release size: 47.3 kB
Release files / kmerpapa-0.2.4.tar.gz
| Download URL | kmerpapa-0.2.4.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eae8662512a136deb53f13002b2bf94fa30306e9e3f1786be7beb4c07664742f
|
|
BLAKE2b-256 checksum How to use checksums |
cf0ad2c3271267edbf5e0af4344caf82dbcd66e004a1fd028e4991907ccf1f53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.9.15 Darwin/23.6.0
|
Release files / kmerpapa-0.2.4-py3-none-any.whl
| Download URL | kmerpapa-0.2.4-py3-none-any.whl |
|---|---|
| Size | 25.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa81e7cd3d0f39125f51d36dc90c7cea992f7a6d15ddf1385681264594dfb98f
|
|
BLAKE2b-256 checksum How to use checksums |
e2991d34de1e56365c89c0c82751d846f8a1bbc669c2babe094fe2438f9077fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.9.15 Darwin/23.6.0
|
Security for kmerpapa 0.2.4
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.