Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • rwness
    Junior Member
    • Mar 2010
    • 6

    mpileup consensus behaviour

    I am wondering if anyone has any experience calling a consensus genotype from mpileup data. I am curious how the suggested command from samtools documentation treats indels and what it does with 'heterozygous' indels.

    Code:
    samtools mpileup -uf ref.fa aln.bam | bcftools view -cg - | vcfutils.pl vcf2fq > cns.fq
    Thanks
  • rwness
    Junior Member
    • Mar 2010
    • 6

    #2
    If anyone is curious - the answer to my question is that this consensus will include NO indels. Any lines in the VCF/BCF that contain indels -- heterozygous or homozygous -- will be ignored.

    I wrote a parser for the vcf created by this command:

    Code:
    $samtools mpileup -uf ref.fa aln.bam | bcftools view -cg -
    that will generate a consensus sequence where heterozygous indels are ignored and heterozygous sites are represented with ambiguity codes. It will also output 2 additional consensus sequences in which heterozygous SNPs and indels are included with gaps to keep the sequences aligned.
    Last edited by rwness; 06-02-2011, 07:32 AM.

    Comment

    • abeeaton
      Junior Member
      • Jun 2009
      • 1

      #3
      I've been sticking with the old pileup -c, so I can get the heterozygous sites with ambiguity codes and genotype quality scores. How were you able to get this out of the mpileup/vcf output?

      Comment

      • swbarnes2
        Senior Member
        • May 2008
        • 910

        #4
        The new way posted above, using the all-points vcf and vcfutils.pl will get make ambiguous letters in the consensus. Here's the relevant part of the code:

        my %het = (AC=>'M', AG=>'R', AT=>'W', CA=>'M', CG=>'S', CT=>'Y',
        GA=>'R', GC=>'S', GT=>'K', TA=>'W', TC=>'Y', TG=>'K');


        $q = $1 if ($t[7] =~ /FQ=(-?[\d\.]+)/);
        if ($q < 0) {
        $_ = ($t[7] =~ /AF1=([\d\.]+)/)? $1 : 0;
        $b = ($_ < .5 || $alt eq '.')? $ref : $alt;
        $q = -$q;
        } else {
        $b = $het{"$ref$alt"};
        $b ||= 'N';
        }
        In English, the first line means "check the FQ"; the FQ is negative when the SNP is homozygous, and positive when it's mixed, and the bigger the absolute value, the more confident the SNP.

        So if it's < 0, it does the first part of code (it checks against the AF1, and if the AF1 is > 0.5, which it should be for a homozygous SNP, it sets $b as the alternate letter, if for some reason the AF1 is < .5, it sets $b as the old reference letter.)

        If the FQ is positive, then the SNP should be mixed, and it concatenates the two letters, and checks the hash above to know what single letter to set $b to. Then it adds $b to the growing sequence.

        $q, which is derived from the FQ, ends up being the quality score, though it gets tweaked a little; it adds 33.449 to the figure, then converts it to a letter, capping it at a quality of 126.

        $q = int($q + 33 + .499);
        $q = chr($q <= 126? $q : 126);

        Gaps are handled as they were in the old program, where they are NOT added in, there is just a window of lowercase letters around them. Personally, I made a little perl script, and I feed it the genome, and a conservatively filtered list of SNPs, and I put the changes in that way.

        Comment

        • lh3
          Senior Member
          • Feb 2008
          • 686

          #5
          Thanks for the nice explanation, swbarnes2. Just want to add that the key purpose of generating consensus is to distinguish regions that cannot be called and regions that are called confidently as homozygous reference. Heterozygotes found in the consensus sequence actually have lower accuracy because fewer filters were applied.

          Comment

          • nupurgupta
            Member
            • Aug 2010
            • 29

            #6
            I am trying to understand how to set $q. In the line

            $q = $1 if ($t[7] =~ /FQ=(-?[\d\.]+)/);

            Does it mean get $q from command line (1st paramter) in case there is an FQ value?

            Thanks very much
            Last edited by nupurgupta; 07-24-2012, 09:59 AM.

            Comment

            Latest Articles

            Collapse

            • SEQadmin2
              From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
              by SEQadmin2


              Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


              The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
              ...
              Yesterday, 10:05 AM
            • SEQadmin2
              Single-Cell Sequencing at an Inflection Point: Early Impacts of New Platforms and Emerging Trends
              by SEQadmin2


              With the launch of new single-cell sequencing platforms in 2026, the field stands at an exciting inflection point. This article surveys the most impactful advances in the field and discusses how they’re reshaping research in cancer, immunology, and beyond.


              Introduction

              Single-cell sequencing technologies have undergone remarkable advances over the past decade, transitioning from low-throughput experimental approaches to highly scalable platforms capable of...
              05-22-2026, 06:42 AM
            • SEQadmin2
              Environmental Genomics in the Age of NGS: From Microbes to Conservation Strategies
              by SEQadmin2

              Studying ecosystems means dealing with complex, multi-species communities that are hard to observe at scale. This complexity, however, hides many important questions to be answered, from how biogeochemical cycles work and how climate change can affect species distribution to how conservation strategies can work best.


              Genomics, particularly since the expansion of NGS, has transformed ecosystem ecology. By sequencing environmental DNA, we can now assess biodiversity without direct...
              05-06-2026, 09:04 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by SEQadmin2, Yesterday, 12:03 PM
            0 responses
            17 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, Yesterday, 11:40 AM
            0 responses
            13 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 05-28-2026, 11:40 AM
            0 responses
            29 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 05-26-2026, 10:12 AM
            0 responses
            31 views
            0 reactions
            Last Post SEQadmin2  
            Working...