Artificial deletion in bam
2
0
Entering edit mode
25 days ago
enee ▴ 10

Hi everyone,

is there a way to introduce a specific artificial deletion in a bam file? I'm searching something that take a particular interval of coordinates and remove it from the bam file e.g. chrx:3122135-3425222

bam • 533 views
ADD COMMENT
0
Entering edit mode

A bam file is a representation of (typically) sequencing reads mapped against a reference genome. Is is not clear what you want. Do you want for the reference genome to have the deletion? Or do you want to remove the reads mapping to that region?

ADD REPLY
0
Entering edit mode

Forgive me if I wasn't very clear, I mean that I would need to remove the reads that map a certain chromosomal interval from the bam file. I need these samples with the artificial deletions to test a tool I'm developing.

ADD REPLY
2
Entering edit mode
24 days ago

Forgive me if I wasn't very clear, I mean that I would need to remove the reads that map a certain chromosomal interval from the bam file.

samtools view  -L deletions.bed  -O BAM --unoutput output.bam in.bam > /dev/null
ADD COMMENT
0
Entering edit mode

Thanks, I'll start with this! unfortunately the deletion in question is hemizygous and therefore I have to find a way that partially removes the reads and not all of them

ADD REPLY
0
Entering edit mode

e I have to find a way that partially removes the reads and not all of them

split your bam with

samtools view   --subsample 0.5  -O BAM --unoutput output1.bam -o output2.bam in.bam 

remove reads with deletion from output2.bam

and then samtools merge with output1.bam and output2.with_del.bam

ADD REPLY
1
Entering edit mode
24 days ago
Zhenyu Zhang ★ 1.2k

If you just want to remove the reads, it's relatively easy.

If you want to simulate a truncation, this is difficult, because you will need to modify instead of remove the reads so they can cross both breakpoints of a truncation.

ADD COMMENT

Login before adding your answer.

Traffic: 2608 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6