Thank you all for your comments and answers. They are definitely helpful for my work.
Dear all,
Previously I thought when the -g/--max-multihits option in tophat was set to 1, then I acquired the unique mapped reads. However, after careful thinking, I am probably wrong.
Now my idea is: when doing mapping, set the -g/--max-multihits option to 2 or above 2, and then write a script to eliminate those reads occurring twice or more times. Am I right? Are there any tools or simple approach to obtain unique mapped reads? I appreciate any of your comments and answers. THANKS A LOT!
3 answers
This has been asked before a few times - here's one discussion about bowtie2 (since tophat uses bowtie2 internally you could use the same points)
How to extract unique mapped results from Bowtie2 bam results?
Most notably:
You're better served by simply filtering on a meaningful MAPQ (5 or 10 are often reasonable choices), which has the benefit of actually doing what you want, namely filtering according the the likelihood that an alignment is correct.
So using samtools view -q 10 input > filtered_output (or even higher? check your distribution of scores)
samtools view -f 0x02 in.bam | sort | uniq >unique_mapped_reads.txt
Obviously you would want to specify a region
samtools view -f 0x02 in.bam 15:20000000-30000000 | sort | uniq >unique_mapped_praderWilliLocus_reads.txt
for example.
you work on CNVs too mate ;)
On thing you could do is to examine the NH tag in the tophat output file (accepted_hits.bam). It lists the number of alignments for that read, and thus you could filter out reads with NH > 1.
Log in to answer this question.
Using BBMap, you can set the flag
ambig=tosswhich will ensure all mapped reads have unique mappings. Reads that multimap will instead be marked as unmapped (and discarded, if you useoutminstead ofout).You can
fgrepall the reads with tagNH:i:1, which filter outs only unique mapped reads.