https://github.com/mfcovington/read_counter
https://github.com/mfcovington/read_counter
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/mfcovington/read_counter
- Owner: mfcovington
- Created: 2012-12-25T02:16:27.000Z (over 13 years ago)
- Default Branch: develop
- Last Pushed: 2016-10-25T16:28:43.000Z (over 9 years ago)
- Last Synced: 2025-02-14T15:14:55.346Z (over 1 year ago)
- Language: Perl
- Size: 30.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Read Counting Scripts
- [Count number of reads mapped to each reference sequence](#count-number-of-reads-mapped-to-each-reference-sequence)
- [`simple_counts.pl`](#simple_countspl)
- [`counts_per_seq.pl`](#counts_per_seqpl)
- [Differences between `simple_counts.pl` and `counts_per_seq.pl`](#differences-between-simple_countspl-and-counts_per_seqpl)
- [Summarize counts files](#summarize-counts-files)
- [`count_summary.pl`](#count_summarypl)
- [Get quick, simple summary of mapped, unmapped, and total reads in SAM file](#get-quick-simple-summary-of-mapped-unmapped-and-total-reads-in-sam-file)
- [`count-reads-in-sam.pl`](#count-reads-in-sampl)
- [Downsample reads in an alignment file](#downsample-reads-in-an-alignment-file)
- [`down-sample-reads-auto.pl`](#down-sample-reads-autopl)
- [`down-sample-reads.pl`](#down-sample-readspl)
## Count number of reads mapped to each reference sequence
### `simple_counts.pl`
- Read through the specified SAM/BAM files
- Count the number of reads mapping to each reference sequence
- For each alignment file, write an output file with # of reads per sequence
Usage:
perl simple_counts.pl [options]
Options:
-o, --out_dir Output directory [.]
-c, --csv Output comma-delimited file (Default is tab-delimited)
-t, --threads Number of files to process simultaneously [1]
-v, --verbose Report current progress
-h, --help Display this usage information
### `counts_per_seq.pl`
- Read through the BAM files in a directory
- Count the number of reads mapping to each reference sequence
- For each BAM file, write output file(s) with # of reads per sequence (sorted by sequence name and/or # of counts)
Usage:
perl counts_per_seq.pl
--bam_dir Directory containing .bam files [./]
--out_dir Output directory [./]
--seq_list File containing sequences to count (Default: all sequences)
--no_zero Ignore sequences with zero counts
--consolidate Delimiter between Sample ID and Rep ID *
--prefix Filename prefix †
--suffix Filename suffix † [.bam]
--alpha_only Sort by sequence name ‡
--num_only Sort by number of counts ‡
--verbose
--help
* Optionally used to consolidate related samples. For example,
to consolidate 'sample_1.rep_1.bam' and 'sample_1.rep_2.bam',
use: "--consolidate ."
† A custom prefix/suffix combo can be used to restrict input files
‡ If no sorting options are chosen, two files are output for each
input (one sorted by sequence name and the other by # of counts)
### Differences between `simple_counts.pl` and `counts_per_seq.pl`
`simple_counts.pl` and `counts_per_seq.pl` are functionally similar to one another. The main differences are as follows:
- Unique to `simple_counts.pl`:
- Potentially must faster, since alignment files can be analyzed in parallel
- Works for SAM files, in addition to BAM files
- Unique to `counts_per_seq.pl`:
- Counts files can be sorted by number of counts, in addition to sequence name
- The number of unmapped reads is included in the counts file (labeled as as '*')
- Provides the option to consolidate related samples (e.g. multiple replicates of a sample)
## Summarize counts files
### `count_summary.pl`
- Import multiple counts files created by `simple_counts.pl` or `counts_per_seq.pl`
- Output a summary:
- Counts for each file
- Minimum, maximum, and mean counts for set of files
Usage:
perl count_summary.pl path/to/sample.counts ...
## Get quick, simple summary of mapped, unmapped, and total reads in SAM file
### `count-reads-in-sam.pl`
This is a very simple script that takes a single SAM file and reports the numbers of mapped reads, unmapped reads, and total reads.
Usage:
perl count-reads-in-sam.pl path/to/file.sam
## Downsample reads in an alignment file
The following scripts downsample alignment files using a [samtools](http://www.htslib.org)-based approach (i.e., `samtools view -s`).
### `down-sample-reads-auto.pl`
Given a list of SAM files, automatically down-sample reads to match the lowest coverage.
Usage:
perl down-sample-reads-auto.pl [options]
Options and Arguments:
-o, --out_dir Output directory [.]
-s, --seed Random seed for down-sampling [0 aka -1]
-v, --verbose Report current progress
-h, -?, --help Display information about usage, options, and arguments
-m, --man Display man page
### `down-sample-reads.pl`
Given a list of SAM files, down-sample reads based on a specified fraction value.
Usage:
perl down-sample-reads.pl [options] -f
Options and Arguments:
-f, --fraction Fraction to use for downsampling
-o, --out_dir Output directory [.]
-s, --seed Random seed for down-sampling [0 aka -1]
*Version 0.5.1*