Ngs Question ~ Consensus
3
1
Entering edit mode
12.8 years ago

Could anybody point towards the direction in how to generate a “consensus” fasta sequence file including indels from a BAM file? Thanks

next-gen consensus bam • 4.3k views
ADD COMMENT
3
Entering edit mode
12.8 years ago
Zhu ▴ 110

samtools mpileup -uf ref.fa aln.bam | bcftools view -cg - | vcfutils.pl vcf2fq > cns.fq

seqtk fq2fa cns.fq >cns.fa

seqtk was released in the latest samtools verion.

ADD COMMENT
0
Entering edit mode

I am fairly sure that this method will only include SNVs, but not INDELs. Please correct me if I'm wrong!

ADD REPLY
2
Entering edit mode
12.8 years ago
Vitis ★ 2.6k

The GATK package has a utility called AlternateReferenceMaker to do this.

ADD COMMENT
2
Entering edit mode
10.1 years ago

bcftools view -cg is now deprecated (version 1.1). bcftools call -vm should be used instead.

samtools mpileup -uf hg19.fa in.bam \
| bcftools call -vm -Oz - > out.vcf.gz
tabix -p vcf out.vcf.gz

bcftools consensus seems to be deprecated too (version 1.1). vcf-consensus may be used as an alternative:

samtools faidx hg19.fa chr22:29000000-29200000 \
| vcf-consensus out.vcf.gz \
| bgzip > out.fasta.gz

chr22:29000000-29200000 may be changed for any other region/s of interest

ADD COMMENT
0
Entering edit mode

Coming in 4 year later, I've tried these lines of code for my single-end BAM file but the consensus sequence fills in gaps with bases from the reference.fasta file. Is there a way to just get a consensus of the BAM file or even the mpileup file to also keep gaps where there was no depth of coverage against the reference.fasta?

ADD REPLY

Login before adding your answer.

Traffic: 1750 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6