Rustynetics
Rustynetics is a high-performance Rust library designed for bioinformatics applications, offering efficient and scalable handling of common genomic file formats. It supports reading and writing of widely used formats such as bigWig, bedGraph, BED, and GFF, making it an essential tool for genomic data processing pipelines.
The library excels in computing coverage tracks, summarizing sequence alignments or read counts across the genome, allowing users to generate coverage profiles over specified the genome. In addition, it offers advanced statistical features, such as the calculation of cross-correlations, which can be used to assess relationships between different genomic datasets, for example, in ChIP-seq or RNA-seq analysis.
One of the library's core strengths is its efficient handling of genomic ranges. It offers a highly optimized data structure for manipulating large genomic intervals, ensuring that operations like querying, merging, or intersecting genomic regions are performed with minimal overhead. Moreover, the library provides a pretty print feature for easily displaying genomic ranges in human-readable formats, facilitating better visualization and interpretation of complex data.
Designed with performance and usability in mind, this library is ideal for large-scale genomics projects requiring both speed and precision, whether for research in genomics, epigenetics, or other related fields.
Documentation
Please find the API documentation here.
Tools
The package contains the following command line tools:
Tool | Description |
---|---|
bam-check-bin | check bin records of a bam file |
bam-genome | print the genome (sequence table) of a bam file |
bam-to-bigwig | convert bam to bigWig (estimate fragment length if required) |
bam-view | print contents of a bam file |
bigwig-genome | print the genome (sequence table) of a bigWig file |
bigwig-info | print information about a bigWig file |
bigwig-query | retrieve data from a bigWig file |
bigwig-query-sequence | retrieve sequences from a bigWig file |
Examples
Import genes from UCSC
use crate Genes;
// Import from local file
if let Ok = import_genes
// Retrieve from USCS server
if let Ok = import_genes_from_ucsc
The result is:
|
) | )
) | )
) | )
) | )
) | )
|
) | )
) | )
) | )
) | )
) | )
Read GTF files
use crate GRanges;
let granges = import_gtf.unwrap;
The result is:
|
) |
) |
Read a BAM file into a GRanges object
use crate BamReaderOptions;
use crate GRanges;
let mut options = default;
options.read_cigar = true;
options.read_qual = true;
if let Ok = import_bam_single_end
The result is:
|
) |
) |
) |
) |
) |
|
) | ;
) |
) |
) | ; ) );
) |
Reading BigWig files
BigWig files contain data in a binary format optimized for fast random access. In addition to the raw data, bigWig files typically contain several zoom levels for which the data has been summarized. The BigWigReader class allows to query data and it automatically selects an appropriate zoom level for the given binsize:
let seqname = "chrY"; // (can be a regular expression)
let from = 1838100;
let to = 1838600;
let binsize = 100;
// The reader accepts either a local file or a file
// hosted on a HTTP server
if let Ok = new_reader
The result is:
(data=(chrom_id=chrY, from=1838100, to=1838200, statistics=(valid=1, min=1.0000, max=1.0000, sum=1.0000, sum_squares=1.0000)) )
(data=(chrom_id=chrY, from=1838200, to=1838300, statistics=(valid=1, min=1.0000, max=1.0000, sum=1.0000, sum_squares=1.0000)) )
(data=(chrom_id=chrY, from=1838300, to=1838400, statistics=(valid=1, min=0.0000, max=0.0000, sum=0.0000, sum_squares=0.0000)) )
(data=(chrom_id=chrY, from=1838400, to=1838500, statistics=(valid=1, min=0.0000, max=0.0000, sum=0.0000, sum_squares=0.0000)) )
(data=(chrom_id=chrY, from=1838500, to=1838600, statistics=(valid=1, min=0.0000, max=0.0000, sum=0.0000, sum_squares=0.0000)) )
Compute coverage tracks from BAM files
We download a BAM file from a ChIP-seq experiment in Homo sapiens A549 with FOXS1 as target (ENCFF504WRM) in addition to the control data (ENCFF739ECZ):
use bam_coverage;
let tracks_treatment = vec!;
let tracks_control = vec!;
// Set fragment length to 0, which means that fragments will not be extended.
// Setting this to None will trigger automatic fragment length estimation
let fraglen_treatment = vec!;
let fraglen_control = vec!;
let = bam_coverage.unwrap;
if let Err = track.export_bigwig