Question: Extract Only Paired-End Reads That Map A Specific Interval
1
gravatar for Nicolas Rosewick
6.3 years ago by
Belgium, Brussels
Nicolas Rosewick7.0k wrote:

Hi,

Is it possible to extract paired-end reads that map to a specific interval ( from a bam file ). I tried with intersectBed :

intersectBed -abam align.bam -b interval.gff3 -wa > result.bam

here's the result :

enter image description here

But I only want reads that map to the feature in bold blue (one of the paired reads is enough). For example, I don't want the reads that map either side of this feature (red arrow).

Is it possible with intersectbed or an other program ?

Thanks,

N.

bedtools extraction • 3.2k views
ADD COMMENTlink modified 9 weeks ago by pnatsidis0 • written 6.3 years ago by Nicolas Rosewick7.0k

The image link is broken, I cannot see it.

ADD REPLYlink written 6.3 years ago by JC7.0k
2
gravatar for Pierre Lindenbaum
6.3 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum115k wrote:

Use samtools view:

samtools view [options] in.bam "chr2:1000-078987"
ADD COMMENTlink written 6.3 years ago by Pierre Lindenbaum115k

Thanks, but I've also the same problem (reads that map either side of the feature (red arrow))

ADD REPLYlink written 6.3 years ago by Nicolas Rosewick7.0k
1
gravatar for Jorge Amigo
6.3 years ago by
Jorge Amigo11k
Santiago de Compostela, Spain
Jorge Amigo11k wrote:

for paired-end bams, you should use pairToBed instead of intersectBed. the syntax would be almost the same:

pairToBed -abam align.bam -b interval.gff3 > result.bam
ADD COMMENTlink written 6.3 years ago by Jorge Amigo11k

I tried pairToBed but I've an error with the bam file :

*****ERROR: BAM must be sorted by query name.
ADD REPLYlink modified 6.3 years ago • written 6.3 years ago by Nicolas Rosewick7.0k

from the BEDTools' pairToBed docs: "pairToBed will fail if an aligner does not report alignments in pairs". I guess that if this is the case, you'll have to work with a compatible aligners or to sort your read pairs as requested.

ADD REPLYlink modified 6.3 years ago • written 6.3 years ago by Jorge Amigo11k
0
gravatar for Alex Reynolds
3.3 years ago by
Alex Reynolds26k
Seattle, WA USA
Alex Reynolds26k wrote:

BEDOPS bedmap could probably solve this by only reporting overlapping reads ("reference" elements), when the read is contained entirely within the set of map elements (the intervals of interest).

The bedmap --fraction-ref 1 option applies this 100% reference-overlap criteria, while --echo reports any qualifying reference elements (reads). We can use bash substitutions and convert2bed convenience scripts bam2bed and gff2bed to convert the reads and intervals to BED.

$ bedmap --echo --fraction-ref 1 <(bam2bed < align.bam) <(gff2bed < interval.gff3) > answer.bed

The use of bam2bed generates sorted BED-formatted reads, which makes the reads in answer.bed sorted and ready to use in downstream BED operations.

ADD COMMENTlink modified 3.3 years ago • written 3.3 years ago by Alex Reynolds26k
0
gravatar for pnatsidis
9 weeks ago by
pnatsidis0
pnatsidis0 wrote:

Could you please provide the content of the interval.gff3 file? I might want to do a very similar analysis, any help is welcome

ADD COMMENTlink written 9 weeks ago by pnatsidis0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1586 users visited in the last hour