{"id":18246158,"url":"https://github.com/mfcovington/read_counter","last_synced_at":"2025-04-08T18:55:59.468Z","repository":{"id":6086478,"uuid":"7313223","full_name":"mfcovington/read_counter","owner":"mfcovington","description":null,"archived":false,"fork":false,"pushed_at":"2016-10-25T16:28:43.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-02-14T15:14:55.346Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mfcovington.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-25T02:16:27.000Z","updated_at":"2019-04-01T13:39:43.000Z","dependencies_parsed_at":"2022-09-22T07:21:08.782Z","dependency_job_id":null,"html_url":"https://github.com/mfcovington/read_counter","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfcovington%2Fread_counter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfcovington%2Fread_counter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfcovington%2Fread_counter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfcovington%2Fread_counter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mfcovington","download_url":"https://codeload.github.com/mfcovington/read_counter/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247909161,"owners_count":21016478,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T09:24:46.130Z","updated_at":"2025-04-08T18:55:59.397Z","avatar_url":"https://github.com/mfcovington.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Read Counting Scripts\n\n\u003c!-- MarkdownTOC --\u003e\n\n- [Count number of reads mapped to each reference sequence](#count-number-of-reads-mapped-to-each-reference-sequence)\n    - [`simple_counts.pl`](#simple_countspl)\n    - [`counts_per_seq.pl`](#counts_per_seqpl)\n    - [Differences between `simple_counts.pl` and `counts_per_seq.pl`](#differences-between-simple_countspl-and-counts_per_seqpl)\n- [Summarize counts files](#summarize-counts-files)\n    - [`count_summary.pl`](#count_summarypl)\n- [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)\n    - [`count-reads-in-sam.pl`](#count-reads-in-sampl)\n- [Downsample reads in an alignment file](#downsample-reads-in-an-alignment-file)\n    - [`down-sample-reads-auto.pl`](#down-sample-reads-autopl)\n    - [`down-sample-reads.pl`](#down-sample-readspl)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n## Count number of reads mapped to each reference sequence\n\n### `simple_counts.pl`\n\n- Read through the specified SAM/BAM files\n- Count the number of reads mapping to each reference sequence\n- For each alignment file, write an output file with # of reads per sequence\n\nUsage:\n\n    perl simple_counts.pl [options] \u003cAlignment file(s)\u003e\n\n    Options:\n      -o, --out_dir    Output directory [.]\n      -c, --csv        Output comma-delimited file (Default is tab-delimited)\n      -t, --threads    Number of files to process simultaneously [1]\n      -v, --verbose    Report current progress\n      -h, --help       Display this usage information\n\n### `counts_per_seq.pl`\n\n- Read through the BAM files in a directory\n- Count the number of reads mapping to each reference sequence\n- For each BAM file, write output file(s) with # of reads per sequence (sorted by sequence name and/or # of counts)\n\nUsage:\n\n    perl counts_per_seq.pl\n\n        --bam_dir        Directory containing .bam files [./]\n        --out_dir        Output directory [./]\n        --seq_list       File containing sequences to count (Default: all sequences)\n        --no_zero        Ignore sequences with zero counts\n        --consolidate    Delimiter between Sample ID and Rep ID *\n        --prefix         Filename prefix †\n        --suffix         Filename suffix † [.bam]\n        --alpha_only     Sort by sequence name ‡\n        --num_only       Sort by number of counts ‡\n        --verbose\n        --help\n\n        * Optionally used to consolidate related samples. For example,\n          to consolidate 'sample_1.rep_1.bam' and 'sample_1.rep_2.bam',\n          use: \"--consolidate .\"\n        † A custom prefix/suffix combo can be used to restrict input files\n        ‡ If no sorting options are chosen, two files are output for each\n          input (one sorted by sequence name and the other by # of counts)\n\n### Differences between `simple_counts.pl` and `counts_per_seq.pl`\n\n`simple_counts.pl` and `counts_per_seq.pl` are functionally similar to one another. The main differences are as follows:\n\n- Unique to `simple_counts.pl`:\n    - Potentially must faster, since alignment files can be analyzed in parallel\n    - Works for SAM files, in addition to BAM files\n- Unique to `counts_per_seq.pl`:\n    - Counts files can be sorted by number of counts, in addition to sequence name\n    - The number of unmapped reads is included in the counts file (labeled as as '*')\n    - Provides the option to consolidate related samples (e.g. multiple replicates of a sample)\n\n## Summarize counts files\n\n### `count_summary.pl`\n\n- Import multiple counts files created by `simple_counts.pl` or `counts_per_seq.pl`\n- Output a summary:\n    - Counts for each file\n    - Minimum, maximum, and mean counts for set of files\n\nUsage:\n\n    perl count_summary.pl path/to/sample.counts ...\n\n## Get quick, simple summary of mapped, unmapped, and total reads in SAM file\n\n### `count-reads-in-sam.pl`\n\nThis is a very simple script that takes a single SAM file and reports the numbers of mapped reads, unmapped reads, and total reads.\n\nUsage:\n\n    perl count-reads-in-sam.pl path/to/file.sam\n\n## Downsample reads in an alignment file\n\nThe following scripts downsample alignment files using a [samtools](http://www.htslib.org)-based approach (i.e., `samtools view -s`).\n\n### `down-sample-reads-auto.pl`\n\nGiven a list of SAM files, automatically down-sample reads to match the lowest coverage.\n\nUsage:\n\n    perl down-sample-reads-auto.pl [options] \u003cAlignment file(s)\u003e\n\n    Options and Arguments:\n          -o, --out_dir     Output directory [.]\n          -s, --seed        Random seed for down-sampling [0 aka -1]\n          -v, --verbose     Report current progress\n          -h, -?, --help    Display information about usage, options, and arguments\n          -m, --man         Display man page\n\n### `down-sample-reads.pl`\n\nGiven a list of SAM files, down-sample reads based on a specified fraction value.\n\nUsage:\n\n    perl down-sample-reads.pl [options] -f \u003cfraction\u003e \u003cAlignment file(s)\u003e\n\n    Options and Arguments:\n          -f, --fraction    Fraction to use for downsampling\n          -o, --out_dir     Output directory [.]\n          -s, --seed        Random seed for down-sampling [0 aka -1]\n\n*Version 0.5.1*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfcovington%2Fread_counter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmfcovington%2Fread_counter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfcovington%2Fread_counter/lists"}