NAME
Bio::ViennaNGS::Util - Utility routines for Next-Generation Sequencing data analysis
SYNOPSIS
use Bio::ViennaNGS::Util;
# make bigWig from BED or BAM
$type = "bam";
$strand = "+";
$bwfile = bed_or_bam2bw($type,$infile,$cs_in,$strand,$destdir,$wantnorm,$size_p,$scale,$logfile);
# make bigBed from BED
my $bb = bed2bigBed($bed_in,$cs_in,$destdir,$logfile);
# sort a BED file
sortbed($bed_in,$destdir,$bed_out,$rm_orig,$logfile)
# compute transcript abundance in TPM
$meanTPM = computeTPM($sample,$readlength);
# parse a bedtools multicov compatible file
$conds = parse_multicov($infile);
# write bedtools multicov compatible file
write_multicov("TPM",$destdir,$basename);
DESCRIPTION
Bio::ViennaNGS::Util is a collection of utility subroutines for building efficient Next-Generation Sequencing (NGS) data analysis pipelines.
ROUTINES
- bed_or_bam2bw($type,$infile,$chromsizes,$strand,$dest,$want_norm,$size,$scale,$log)
-
Creates stranded, normalized BigWig coverage profiles from strand-specific BAM or BED files (provided via
$infile). The routine expects a file type 'bam' or 'bed' via the$typeargument.$chromsizesis the chromosome.sizes files,$strandis either "+" or "-" and$destcontains the output path for results. For normlization of bigWig profiles, additional attributes are required:$want_normtriggers normalization with values 0 or 1.$sizeis the number of fragments/elements in the BAM or BED file and$scalegives the number to which data is normalized (ie. every bedGraph entry is multiplied by a factor ($scale/$size).$logis expected to contain either the full path and file name of log file or 'undef'. The routine returns the full file name of the newly generated bigWig file.While this routine can handle non-straned BAM/BED files (in which case
$strandshould be set to "+" and hence all coverage profiles will be created with a positive sign, even if they map to the negative strand), usage of strand-specific data is highly recommended. For BAM file, this is easily achieved by calling the bam_split routine (see above) prior to this one, thus creating dedicated BAM files containing exclusively reads mapped to the positive or negative strand, respectively.It is important to know that this routine does not extract reads mapped to either strand from a non-stranded BAM/BED file if the
$strandargument is given. It rather adjusts the sign of all mapped reads/features in a BAM/BED file and then creates bigWig files. See the split_bam routine for extracting reads mapped to either strand.Stranded bigWigs can easily be visualized via TrackHubs in the UCSC Genome Browser. Internally, the conversion from BAM/BED to bigWig is accomplished via two third-party applications: genomeCoverageBed and bedGraphToBigWig. Intermediate bedGraph files are removed automatically once the bigWig files are ready.
- sortbed($infile,$dest,$outfile,$rm_orig,$log)
-
Sorts BED file
$infilewith bedtools sortt.$destandoutfilename path and filename of the resulting sorted BED file.$rm_infileis either 1 or 0 and indicated whether the original$infileshould be deleted.$logholds path and name of log file. - bed2bigBed($infile,$chromsizes,$dest,$log)
-
Creates an indexed bigBed file from a BED file.
$infileis the BED file to be transformed,$chromsizesis the chromosome.sizes file and$destcontains the output path for results.$logis the name of a log file, or undef if no logging is reuqired. A '.bed', '.bed6' or '.bed12' suffix in$infilewill be replace by '.bb' in the output. Else, the name of the output bigBed file will be the value of$infileplus '.bb' appended.The conversion from BED to bigBed is done by a third-party utility (bedToBigBed), which is executed by IPC::Cmd.
- computeTPM($featCount_sample,$rl)
-
Computes expression in Transcript per Million (TPM) [Wagner et.al. Theory Biosci. (2012)].
$featCount_sampleis a reference to a Hash of Hashes data straucture where keys are feature names and values hold a hash that must at least contain length and raw read counts. Practically,$featCount_sampleis represented by _one_ element of@featCount, which is populated from a multicov file byparse_multicov().$rlis the read length of the sequencing run.Returns the mean TPM of the processed sample, which is invariant among samples. (TPM models relative molar concentration and thus fulfills the invariant average criterion.)
- parse_multicov($file)
-
Parse a bedtools multicov (multiBamCov) file, i.e. an extended BED6 file, into an Array of Hash of Hashes data structure (
@featCount).$fileis the input file. Returns the number of samples present in the multicov file, ie. the numner of columns extending the canonical BED6 columns in the input multicov file. - write_multicov($item,$dest,$base_name)
-
Write
@featCountdata to a bedtools multicov (multiBamCov)-type file.$itemspecifies the type of information from@featCountHoH entries, e.g. TPM or RPKM. These values must have been computed and inserted into@featCountbeforehand by e.g.computeTPM().$destgives the absolute path and$base_namethe basename (will be extended by$item.csv) of the output file.
DEPENDENCIES
- Bio::Perl >= 1.00690001
- BIO::DB::Sam >= 1.39
- File::Basename
- File::Temp
- Path::Class
- IPC::Cmd
- Carp
Bio::ViennaNGS uses third-party tools for computing intersections of BED files: bedtools intersect from the BEDtools suite is used to compute overlaps and bedtools sort is used to sort BED output files. Make sure that those third-party utilities are available on your system, and that hey can be found and executed by the Perl interpreter. We recommend installing the latest version of BEDtools on your system.
AUTHORS
COPYRIGHT AND LICENSE
Copyright (C) 2014 Michael T. Wolfinger <michael@wolfinger.eu>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.4 or, at your option, any later version of Perl 5 you may have available.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 681:
Non-ASCII character seen before =encoding in 'Jörg'. Assuming UTF-8