Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • swbarnes2
    replied
    Try:

    Code:
    samtools view whatever.bam | grep XT:A:U | grep -v XA: > unique.sam
    If a read maps equally well to multiple places, bwa will pick one site, and only output that alignment. And it's never going to assign the 256 flag, that's why filtering based on it won't work. XT:R is assigned if the reads maps to multiple places, and the XA tag shows where those alternate alignment sites are (well the first few such sites, anyway)

    So the above command line will filter away reads that have indications of being mapped multiple ways.
    Last edited by swbarnes2; 05-10-2013, 11:16 AM.

    Leave a comment:


  • Chipper
    replied
    Samtools view -q 10

    Leave a comment:


  • pbluescript
    replied
    Haha... that's what I get for reading your posts too quickly. Something is a bit odd about your flag fields. I've never had this particular problem before.

    What happens if you use samtools view -f 4?

    What are in the X0 fields of the mapped and unmapped reads?

    Leave a comment:


  • albireo
    replied
    Ok, we agree on that. My original question was: how do I get the proportion of lines in the BWA .bam which map only to one location of the genome? It is certainly not the output of your line, because that gives me 2307803, which includes

    1-uniquely mapped
    2-multiply mapped
    3-unmapped.

    1+2+3 = 2307803 = 100%
    1+2=2103778 = 91.1593%
    1=?

    Leave a comment:


  • pbluescript
    replied
    BWA outputs mapped as well as unmapped reads to the SAM file.

    Leave a comment:


  • albireo
    replied
    Thanks, so is the following bamtools output wrong, or am I misunderstanding something?

    Total reads: 2307803
    Mapped reads: 2103778 (91.1593%)

    Leave a comment:


  • pbluescript
    replied
    You are getting those results because BWA only gave you unique alignments.

    Leave a comment:


  • albireo
    replied
    Hi, thanks for this. I do get 0 with this command. However I still don't understand why

    Code:
    samtools view -F 256 your_file.bam | wc -l
    gives me the total number of reads, and not the uniquely mapped ones. The other program, bamtools, shows that these two numbers should not be the same.

    Leave a comment:


  • pbluescript
    replied
    How do you know it's not working? If you get 0 from this command, it is working.

    Code:
    samtools view -f 256 your_file.bam | wc -l
    BWA can do soft clipping while the original Bowtie does not. Maybe you have some adapter contamination or low quality reads that can be mapped with BWA that can't be mapped with Bowtie.

    Leave a comment:


  • albireo
    replied
    Hi thanks, but this is not working. If I use it with a .bam file obtained with bwa, It just gives me the total number of reads in the .bam, 2307803 (corresponding to the "reads processed" in the bowtie output). What am I doing wrong?

    Btw, I found a utility called bamtools with has a "stats" option. If I use it on the bowtie alignment, it yields

    **********************************************
    Stats for BAM file(s):
    **********************************************

    Total reads: 2307803
    Mapped reads: 1653076 (71.6299%)
    Forward strand: 1481385 (64.1903%)
    Reverse strand: 826418 (35.8097%)
    Failed QC: 0 (0%)
    Duplicates: 0 (0%)
    Paired-end reads: 0 (0%)

    which agrees with Bowtie's own output. If I use it with the BWA alignment of the same file, it yields

    Total reads: 2307803
    Mapped reads: 2103778 (91.1593%)
    Forward strand: 1255418 (54.3988%)
    Reverse strand: 1052385 (45.6012%)
    Failed QC: 0 (0%)
    Duplicates: 0 (0%)
    Paired-end reads: 0 (0%)

    So it's telling me that 91.1% of my reads have been mapped. However I imagine this includes also those mapped to multiple locations (because I've used bwa with default options). Is there an easy way to remove them from this statistics, and get an output comparable to that 71.63% from bowtie? Thanks once more for your help.
    Last edited by albireo; 05-10-2013, 03:58 AM.

    Leave a comment:


  • pbluescript
    replied
    There are many ways to do this. Here's one you can use if you have a BAM file of reads aligned with BWA.

    Code:
    samtools view -F 256 your_file.bam | wc -l
    This will remove all the reads that are not primary alignments and then count the lines of output. The number you get will be the number of unique alignments.

    BWA also outputs an X0 tag that tells you how many "best" alignments there are. You could count the reads where X0 = 1 to get your answer as well.

    Leave a comment:


  • albireo
    started a topic How to count uniquely mapping reads with BWA?

    How to count uniquely mapping reads with BWA?

    Apologies if this has been asked before.

    I'm quite familiar with Bowtie, which I use with the following options:

    --best --strata -m 1

    To retrieve only "uniquely" mapping chip-seq reads. On completion of an alignment, Bowtie provides an output similar to this:

    # reads processed: 2307803
    # reads with at least one reported alignment: 1653076 (71.63%)
    # reads that failed to align: 236689 (10.26%)
    # reads with alignments suppressed due to -m: 418038 (18.11%)
    Reported 1653076 alignments to 1 output stream(s)

    Where I interpret that 71.63% as the number of uniquely mapping reads.

    Now I would like to do the same with BWA. I have ran BWA with default options and would like to generate similar statistics. Is there a tool that allows me to do that? I understand that, having used default options, I will have "multiply" mapping reads, but these reads are given a MAPQ=0 by bwa.

    Any suggestions would be appreciated. Thanks!

Latest Articles

Collapse

  • seqadmin
    Exploring the Dynamics of the Tumor Microenvironment
    by seqadmin




    The complexity of cancer is clearly demonstrated in the diverse ecosystem of the tumor microenvironment (TME). The TME is made up of numerous cell types and its development begins with the changes that happen during oncogenesis. “Genomic mutations, copy number changes, epigenetic alterations, and alternative gene expression occur to varying degrees within the affected tumor cells,” explained Andrea O’Hara, Ph.D., Strategic Technical Specialist at Azenta. “As...
    07-08-2024, 03:19 PM
  • seqadmin
    Exploring Human Diversity Through Large-Scale Omics
    by seqadmin


    In 2003, researchers from the Human Genome Project (HGP) announced the most comprehensive genome to date1. Although the genome wasn’t fully completed until nearly 20 years later2, numerous large-scale projects, such as the International HapMap Project and 1000 Genomes Project, continued the HGP's work, capturing extensive variation and genomic diversity within humans. Recently, newer initiatives have significantly increased in scale and expanded beyond genomics, offering a more detailed...
    06-25-2024, 06:43 AM

ad_right_rmr

Collapse

News

Collapse

Topics Statistics Last Post
Started by seqadmin, 07-19-2024, 07:20 AM
0 responses
144 views
0 likes
Last Post seqadmin  
Started by seqadmin, 07-16-2024, 05:49 AM
0 responses
117 views
0 likes
Last Post seqadmin  
Started by seqadmin, 07-15-2024, 06:53 AM
0 responses
111 views
0 likes
Last Post seqadmin  
Started by seqadmin, 07-10-2024, 07:30 AM
0 responses
44 views
0 likes
Last Post seqadmin  
Working...
X