Skip to content

Step 5: Filtering (bcftools filter)

rsalani13 edited this page Oct 15, 2026 · 3 revisions

We did both gentle filtering and more stingent filtering.

Gentle: exclude variants with a QUAL less than 20 or less than 5 total read depth across all samples.

Stringent: exclude variants with a QUAL less than 30 or less than 10 total read depth across all samples or a site level mapping quality (root mean square) of less than 40

Commands

cd ../
mkdir filtering_5
cd filerting_5/
ln -s ../variant_calling_4/* .

nano filtering.sh

I did all this in one script so here's how the sections split up:

Gentle filtering:

#Gentle filtering:
#Exclude variants with QUAL < 20 or total site depth < 5

bcftools filter \
  -e 'QUAL<20 || INFO/DP<5' \
  -Oz \
  -o variant_gentle.vcf.gz \
  variant_script_output.raw.vcf.gz

Gentle filtering stats:

#Generate statistics for gentle filtering
bcftools stats variant_gentle.vcf.gz > variant_gentle.stats.txt

Stringent filtering:

#Stringent filtering:
#Exclude variants with QUAL < 30, total site depth < 10, or RMS mapping quality < 40

bcftools filter \
  -e 'QUAL<30 || INFO/DP<10 || INFO/MQ<40' \
  -Oz \
  -o variant_stringent.vcf.gz \
  variant_script_output.raw.vcf.gz

Stringent filtering stats:

#Generate statistics for stringent filtering
bcftools stats variant_stringent.vcf.gz > variant_stringent.stats.txt

And then run it, of course:

bash filtering.sh

Results

bcftools stats report path and name for gentle filtering: /lustre/isaac24/proj/UTK0505/rsalani/exam2/analyses/filtering_5/variant_gentle.stats.txt

bcftools stats report path and name: for stringent filtering: /lustre/isaac24/proj/UTK0505/rsalani/exam2/analyses/filtering_5/variant_stringent.stats.txt

VCF number of SNPs
raw 4920
gentle 4869
stringent 4774

Clone this wiki locally