Question: Reduce Bam File With Specific Loci In Bedfile
0
gravatar for marcodpc
6.1 years ago by
marcodpc30
marcodpc30 wrote:

I want to reduce my bam file, obtaining a new bam file that contain

only loci in the bed file in input like

chr1 30498890 34983248

chr2 30398890 31483248

chr3 10492890 14983248

chr4 30492890 34283248

I try with:

samtools view -L test.bed test.bam | awk '$2 != 4 {print}'

and

intersectBed -abam file.bam -b test.bed

but the source bam file isn't reduce dimension.

How can I do ?

bam • 1.6k views
ADD COMMENTlink modified 2.7 years ago by Biostar ♦♦ 20 • written 6.1 years ago by marcodpc30
1
gravatar for marcodpc
6.1 years ago by
marcodpc30
marcodpc30 wrote:

I easily solved with BEDtools intersectBed -abam file.bam -b test.bed > reduced.bam

ADD COMMENTlink written 6.1 years ago by marcodpc30
0
gravatar for Sukhdeep Singh
6.1 years ago by
Sukhdeep Singh9.8k
Netherlands
Sukhdeep Singh9.8k wrote:

You can use the bedOps utiltiy's tool sam2bed and then modify the command as

sam2bed <(samtools view -L test.bed test.bam | awk '$2 != 4 {print}') output.bed

ADD COMMENTlink written 6.1 years ago by Sukhdeep Singh9.8k
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: 1286 users visited in the last hour