{"id":15113787,"url":"https://github.com/jubayer98/vcf-toolkit","last_synced_at":"2026-01-19T11:32:22.700Z","repository":{"id":252224166,"uuid":"839802947","full_name":"jubayer98/VCF-Toolkit","owner":"jubayer98","description":"This repository outlines steps to manage VCF files, including compressing, indexing, querying chromosomes, counting variants, and comparing multiple VCF files using BCFTools.","archived":false,"fork":false,"pushed_at":"2024-08-08T11:02:50.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T18:16:16.478Z","etag":null,"topics":["bash-script","bcftools"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/jubayer98.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-08T11:00:37.000Z","updated_at":"2024-08-08T11:02:53.000Z","dependencies_parsed_at":"2024-08-08T13:10:57.223Z","dependency_job_id":"c50c3179-d302-4885-ac8f-efd345eec973","html_url":"https://github.com/jubayer98/VCF-Toolkit","commit_stats":null,"previous_names":["jubayer98/vcf-toolkit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubayer98%2FVCF-Toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubayer98%2FVCF-Toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubayer98%2FVCF-Toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubayer98%2FVCF-Toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jubayer98","download_url":"https://codeload.github.com/jubayer98/VCF-Toolkit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378140,"owners_count":20929296,"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":["bash-script","bcftools"],"created_at":"2024-09-26T01:23:15.927Z","updated_at":"2026-01-19T11:32:22.673Z","avatar_url":"https://github.com/jubayer98.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Working with VCF Files using BCFTools\n\nThis documentation outlines steps to manage VCF files, including compressing, indexing, querying chromosomes, counting variants, and comparing multiple VCF files using BCFTools. The provided instructions are formatted for use on an HPC (High-Performance Computing) environment.\n\n#### 1. Creating and Activating a Conda Environment\nFirst, create and activate a Conda environment for installing and running BCFTools.\n\n```bash\n# Create a Conda environment\nconda create --name myenv\n\n# Activate the Conda environment\nconda activate myenv\n\n# Install BCFTools\nconda install -c bioconda bcftools\n```\n\n#### 2. Compressing and Indexing VCF Files\nTo efficiently manage large VCF files, compress and index them using bgzip and tabix.\n\n```bash\n# Compress the .vcf file using bgzip\nbgzip filename.vcf\n\n# Create a tabix index file for the bgzip-compressed VCF\ntabix -p vcf filename.vcf.gz\n\n# Create an index for the VCF file\nbcftools index filename.vcf.gz\n```\n\n#### 3. Querying Chromosomes from VCF Files\nRetrieve and save the list of unique chromosomes present in the VCF file.\n\n```bash\n# Query all chromosomes list\nbcftools query -f '%CHROM\\n' filename.vcf.gz\n\n# Count the total number of unique chromosomes\nbcftools query -f '%CHROM\\n' filename.vcf.gz | uniq | wc -l\n\n# Save the list of unique chromosomes in a text file\nbcftools query -f '%CHROM\\n' filename.vcf.gz | uniq \u003e chromosomes.txt\n\n# Display the contents of the text file\ncat chromosomes.txt\n```\n\n#### 4. Counting Variants per Chromosome\nCreate a shell script to count all variants/mutations per chromosome and save it as `chromosome_count.sh`.\n\n```bash\n# Create a .sh file\ntouch chromosome_count.sh\n\n# Edit the .sh file using nano\nnano chromosome_count.sh\n\n# Add the following content to the file\n#!/bin/bash\nchromlist=($(cat chromosomes.txt))\nfor chrom in ${chromlist[@]}; do\n    count=$(bcftools view -r $chrom filename.vcf.gz | grep -v -c '^#')\n    echo \"$chrom:$count\"\ndone\n```\n\n#### 5. Finding Common Variants Among Multiple VCF Files\nUse BCFTools to find common variants among multiple VCF files.\n\n```bash\n# Find common variants among three VCF files\nbcftools isec -n=3 filename1.snps.vcf.gz filename2.snps.vcf.gz filename3.snps.vcf.gz | wc -l\n```\n\n#### 6. Filtering Variants with a \"PASS\" Status\nRetain only the variants that have a filter status of \"PASS\".\n\n```bash\n# Filter variants with \"PASS\" status\nbcftools view -f PASS input.vcf \u003e output.vcf\n```\n\n#### 7. Comparing Records Across VCF Files\nCompare all records (variants) in the input VCF files for intersection.\n\n```bash\n# Compare records for intersection\nbcftools isec -n=2 -c all -o normal_tumor_common.vcf normal_sample.vcf.gz tumor_sample.vcf.gz\n```\n\n#### 8. Merging VCF Files\nMerge multiple VCF files into one.\n\n```bash\n# Merge VCF files\nbcftools merge --merge all normal_sample.vcf.gz tumor_sample.vcf.gz -O v \u003e normal_tumor_merge.vcf\n```\n\n#### 9. Finding Unique Variants Between VCF Files\nCompare VCF files and find the unique variants between them.\n\n```bash\n# Find unique variants between two VCF files\nbcftools isec -C normal_sample.vcf.gz tumor_sample.vcf.gz \u003e normal_tumor_unique.vcf\n```\n\nThis guide should help you manage VCF files effectively using BCFTools in an HPC environment. For more advanced usage and options, refer to the [BCFTools documentation](http://samtools.github.io/bcftools/bcftools.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjubayer98%2Fvcf-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjubayer98%2Fvcf-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjubayer98%2Fvcf-toolkit/lists"}