No project description provided
Project description
CNV From BAM
cnv_from_bam
is a Rust library developed to efficiently calculate dynamic Copy Number Variation (CNV) profiles from sequence alignments contained in BAM files. It seamlessly integrates with Python using PyO3, making it an excellent choice for bioinformatics workflows involving genomic data analysis.
Features
- Efficient Processing: Optimized for handling large genomic datasets in BAM format.
- Python Integration: Built with PyO3 for easy integration into Python-based genomic analysis workflows.
- Multithreading Support: Utilizes Rust's powerful concurrency model for improved performance.
- Dynamic Binning: Bins the genome dynamically based on total read counts and genome length.
- CNV Calculation: Accurately calculates CNV values for each bin across different contigs.
Installation
To use cnv_from_bam
in your Rust project, add the following to your Cargo.toml
file:
[dependencies]
cnv_from_bam = "0.1.0" # Replace with the latest version
Usage
Here's a quick example of how to use the iterate_bam_file
function:
use cnv_from_bam::iterate_bam_file;
use std::path::PathBuf;
let bam_path = PathBuf::from("path/to/bam/file.bam");
// Iterate over the BAM file and calculate CNV values for each bin. Number of threads is set to 4 and mapping quality filter is set to 60.
// If number of threads is not specified, it defaults to the number of logical cores on the machine.
let result = iterate_bam_file(bam_path, Some(4), Some(60));
// Process the result...
The results in this case are returned as a CnvResult, which has the following structure:
pub struct CnvResult {
pub cnv: FnvHashMap<String, Vec<f64>>,
pub bin_width: usize,
pub genome_length: usize,
}
Where result.cnv
is a hash map containing the Copy Number for each bin of bin_width
bases for each contig in the reference genome, result.bin_width
is the width of the bins in bases, and result.genome_length
is the total length of the genome.
Note that only the main primary mapping alignment start is binned, Supplementary and Secondary alignments are ignored.
Example simple plot in python
from matplotlib import pyplot as plt
import matplotlib as mpl
import numpy as np
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8, 3))
total = 0
let bam_path = PathBuf::from("path/to/bam/file.bam");
# Iterate over the BAM file and calculate CNV values for each bin. Number of threads is set to 4 and mapping quality filter is set to 60.
# If number of threads is not specified, it defaults to the number of logical cores on the machine.
let result = iterate_bam_file(bam_path, Some(4), Some(60));
for contig, cnv in result.cnv.items():
ax.scatter(x=np.arange(len(cnv)) + total, y=cnv, s =0.1)
total += len(cnv)
ax.set_ylim((0,8))
ax.set_xlim((0, total))
Should look something like this. Obviously the cnv data is just a dictionary of lists, so you can do whatever you want with it vis a vis matplotlib, seaborn, etc.
Documentation
To generate the documentation, run:
cargo doc --open
Contributing
Contributions to cnv_from_bam
are welcome!
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for cnv_from_bam-0.1.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db3d08cb0a0a92db61eb4e846c4a843c769249294785c4b78fb239c0c84cb2ef |
|
MD5 | c388efe3018c753297044e4282628486 |
|
BLAKE2b-256 | 8d348d4a2f25d8cbfdd7d7431e54f7acafdddd5112f9988627cf0c9b93edc2a1 |
Hashes for cnv_from_bam-0.1.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2167e4f9230345baed87e1828dd2bba5f3f7da57db066d7297a61067a12c12c |
|
MD5 | 7c58f5865b7c0bc9d23f17c467cf7dcb |
|
BLAKE2b-256 | 24e10bcad9bd1317e6572e02fae95176815bcf16627a6f1b8c19fa33cadbd0dd |
Hashes for cnv_from_bam-0.1.0-pp310-pypy310_pp73-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87a9f21317d8b2371b1185f60dcf0ff290daf8adf3b2f597da94abf81b585da1 |
|
MD5 | 1c0074624295f05911dabce150e3b881 |
|
BLAKE2b-256 | 6229500ef588ec6541019c87130691e93e938a1fc5e95d438e8e767203bcd5ea |
Hashes for cnv_from_bam-0.1.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddf558e52f2c241b9b8d2ea692f5ab23ae2261c5354402b9825bb61497ca3025 |
|
MD5 | f45101b648a23599f899c56d2580c75e |
|
BLAKE2b-256 | e54f104c832ced23d87b5352192da6b82e18f8a5f01d41bd51be45e72c2943f4 |
Hashes for cnv_from_bam-0.1.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af31b492f594ccea7b8dadf9ef2a3b82aae5ab21dbfda6cc3374d2a78de39735 |
|
MD5 | 3fb4fec95828c44f6e33619102f7d1cd |
|
BLAKE2b-256 | 7a5f0d594901890ee2305a7f33dea8a357dbc943d425afad6e1725f8fbb6b124 |
Hashes for cnv_from_bam-0.1.0-pp39-pypy39_pp73-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 779cd42d3d3f80b82cff3c3e28ca0c17ed01cd93ccd423cd01ef2c608d15a980 |
|
MD5 | 4f296dd849e736166ed3ea103af5075d |
|
BLAKE2b-256 | f2ebcb64944ef575b2e660c20def852ea3b81bdd6a1cb3adb4c17b9dca5eb599 |
Hashes for cnv_from_bam-0.1.0-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1904f58f24ead5c767fae540bae0294b4fea22ecc1e8e3f82dcfb7934e773697 |
|
MD5 | 1e35e273eaff1c2e6a8394a766139a98 |
|
BLAKE2b-256 | 395349fcbfe997fe646f57467643ed52a9716d4c688467e23b535948547d206e |
Hashes for cnv_from_bam-0.1.0-pp38-pypy38_pp73-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ee425583eaf9a5d85a2ceb22c741482e3660715530f19771d455225c9822bd2 |
|
MD5 | b3509a964482120be322c5ca8981f0a6 |
|
BLAKE2b-256 | aa94d9aaffe071389801e76c8311cc5a6af30226afe1390e8ba905ef1161de6f |
Hashes for cnv_from_bam-0.1.0-pp38-pypy38_pp73-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dc0f1754f43a527a3a2976b747b410951c23733daee84d655f4431ebafd90d3 |
|
MD5 | 2a5d880a6e370e59e324420098439a7b |
|
BLAKE2b-256 | c5eda439766d6a5917c7c0af3e2745d25e6c78656c3c11cc1107876969e87d57 |
Hashes for cnv_from_bam-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 169461a21213588acdbf8050245b443b5de8adeb4737ad24a8b8822855392dff |
|
MD5 | 214ce4969af26403603f248773e0fb12 |
|
BLAKE2b-256 | 3f020e21c64e6f9cc8fb913fe911b9b52ca7cf4d21545a3d3a380d283d300018 |
Hashes for cnv_from_bam-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2434b1009e9b05eb7fc0ece11896e9902a1975b9ed528f5a77ce8b09e7b7740c |
|
MD5 | 7407278fc810ef682c3e57554bdf6226 |
|
BLAKE2b-256 | 1c4b90fa9bc7f4126864cac96f247731f67592f8f529cd8dc2d6fa7a97616ccb |
Hashes for cnv_from_bam-0.1.0-cp312-cp312-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54ec0d6bb2becf68b124f7e26ec5c0a77c2b192d44e80f0ad54ebfb6eaf62bfd |
|
MD5 | 40c43bd89ea83dc6afa3316254b2e8f6 |
|
BLAKE2b-256 | a2bfc9ae8fdd006baee267fd6a4d8dd633d79c4f3a15306bb155f9d9b9a6fc71 |
Hashes for cnv_from_bam-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d0e5d9b37dc9ebee74351dcd24ffee4034a2759b3c92fb941f7c7640b91b1e8 |
|
MD5 | 93bfcb1b8a2667f09f0bec42e3578c04 |
|
BLAKE2b-256 | 42cff15c259a97bab6d11c0fda06c286af96df640eaae3cf38046598d55a9134 |
Hashes for cnv_from_bam-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6eca63132ad4c29cd92d930ac4d2cdf3fe16daf062855083563452bfe0192ad6 |
|
MD5 | c6ef07aa86c39aa5345e7cea6bcd2e8c |
|
BLAKE2b-256 | f84a40e808e0b644530b1cc6a08eb38747ff350e793eb44f936b8c4155c62dd8 |
Hashes for cnv_from_bam-0.1.0-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89bc67467295abedcafb01ee5aa23576cfe0592592016a04d45c29d43f5266df |
|
MD5 | 07c36ba6a5dd37f02bfff912322e311d |
|
BLAKE2b-256 | d9b1a883cf8e27bc152de54fe46d8e8b19bdcc1f39f11f8ae85d5cffb0b18b57 |
Hashes for cnv_from_bam-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7100b213ee48ddefe6f6592b76799f754f80d7e9d245607b750293484c9436cc |
|
MD5 | f2416cab42c13c772a487163a4d36491 |
|
BLAKE2b-256 | c5564a24e724db402472d8ce38fd3f77fc44364351050ebf43d451f32934119c |
Hashes for cnv_from_bam-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 906a8749f1dbdeb6a3b45a0a0fa61e59dc69fcd139ac2ec1f8d8e73dcc0779d5 |
|
MD5 | 3db6971fbaae814d0d206895aaf3207a |
|
BLAKE2b-256 | faa2e5bc3eb02390284e20550e62987c1c284fb96a6a1ec3360233fa88b2a1ec |
Hashes for cnv_from_bam-0.1.0-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0b46a411e7b976cbaf74da4517f191962606870d3864188923e4757dd6e7391 |
|
MD5 | f95ef383d118ba4fa5efb4593022adab |
|
BLAKE2b-256 | c50ad2ac9de1457eb93e6d9465e707487e9d4e15775b3f515a88c62a6a693cfe |
Hashes for cnv_from_bam-0.1.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aab6e4f60398be75bbb6b9015ce868e32cf1ca30624b7f84cc4394ad435f4805 |
|
MD5 | 8f4a7de6dfee7d8f8608d8175a124be4 |
|
BLAKE2b-256 | 0b122fdff180791b208661d0bed57914485c0223ea57793310ea9d5e6dbb313c |
Hashes for cnv_from_bam-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8d859f70924e885851819befb2018be16860e1a51a9c7d519f72050dea4cf2e |
|
MD5 | 0a70fd65a3da134f05d34a96308c78c0 |
|
BLAKE2b-256 | 3efc610fa5cdd6ddd9e8fc6038a6509946dc949100dbfb35c8d9b030017821c4 |
Hashes for cnv_from_bam-0.1.0-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbda30bbf0dbcfef90f1085bf931309908d42dcbb9ce25491543763f429b3730 |
|
MD5 | e515ce6dfaa937f7d653d29858c44e6e |
|
BLAKE2b-256 | 1341ffbf493826c440ab8579c07ad756435c1692b8f479673ae697ea3f26d8d3 |
Hashes for cnv_from_bam-0.1.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0383c0c9cb1bd0d844f64fe992f8a7dac04807e9090fffbb6a26839b469e2df |
|
MD5 | 28e479a5e380bfaf93c784a09671697e |
|
BLAKE2b-256 | ed85fc38e3c81e78ef5a659a91f559dcc4d55215380b6d7c3f027f8f9efd1925 |
Hashes for cnv_from_bam-0.1.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e713c94c9e8e263907b4bd3b6f85310b72f9f17a2ec15cad7c7a82a1258c9d8 |
|
MD5 | 62d12290b6ecb2279904a5cb2ab0901e |
|
BLAKE2b-256 | 338315076c66b73813f00eac06ca32c70e59ba8f78a1004d25f33a8077c2134a |
Hashes for cnv_from_bam-0.1.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86e76df8c802457c9ec29e930a00db542420a2a2044d92bbb32a21a23eafecc3 |
|
MD5 | 3206d95ce05e8e19d19b0c60ad0d1242 |
|
BLAKE2b-256 | e4f24bf27050d964273c986274592f25d91a3365e38bb37eeb2577aee25687ad |