Question: How to remove reads associated with a specific region from bam file?
3
gravatar for noushin.farnoud
5.7 years ago by
United States
noushin.farnoud110 wrote:

Dear Members, 

Is there a way I can removes reads associated with a region (chr, start, end) from a .bam file (RNASeq data) prior to the application of HTSeq?

I will greatly appreciate your feedback,

Noushin

rna-seq samtools alignment • 6.4k views
ADD COMMENTlink modified 4.2 years ago by Ron1.0k • written 5.7 years ago by noushin.farnoud110
7
gravatar for Sergey Naumenko
4.2 years ago by
Sergey Naumenko380 wrote:
bedtools intersect -abam file.bam -b filter.bed -v > filtered.bam

filter.bed should contain

chr    start     end
ADD COMMENTlink written 4.2 years ago by Sergey Naumenko380

Thats perfect solutions !! Super cool ! thanks !!!

ADD REPLYlink written 4.0 years ago by abaluapuri0
4
gravatar for John
5.7 years ago by
John12k
Germany
John12k wrote:

You'll want to use NGSUtil's bamutils tool, specifically with -excludebed.

But, id recommend you dont :P
The BAM format is to store highly compressed alignment data. You should treat them like raw, virgin data, without normalization/filtering tweaks here and there to get it into shape.
All that kind of intersection stuff should be done on processed signal data - wigs and bedgraphs, etc - where its much easier to have multiple versions of things and to just dump it all and start afresh from the .bam if you have to.

Having said that, its your data, do what you like with it :)

ADD COMMENTlink modified 5.7 years ago • written 5.7 years ago by John12k
4
gravatar for sunhanice
4.7 years ago by
sunhanice230
United States
sunhanice230 wrote:

Just found, there is an option -U in samtools view. Use it like this:

samtools view input.bam -b -h -o output_inRegions.bam -U output_outRegions.bam -L Regions.bed

ADD COMMENTlink written 4.7 years ago by sunhanice230
1

Just to clarify, I used - samtools view in.sorted.bam -b -h -o inRegions.bam -U outRegions.bam "chr:start-stop"... So here the -o file excludes the regions "chr:start-stop" and has the rest, but the -U file only retains the "chr:start-stop"? Thank you for your help!

ADD REPLYlink modified 4.0 years ago • written 4.0 years ago by varsha61990
3
gravatar for igor
4.7 years ago by
igor12k
United States
igor12k wrote:

If you are filtering your BAM for HTSeq, then you are doing extra work. You should just modify the GTF file that you are giving to HTSeq to exclude regions you do not want.

ADD COMMENTlink written 4.7 years ago by igor12k
2
gravatar for Ron
4.2 years ago by
Ron1.0k
United States
Ron1.0k wrote:

Using this QC package for RNAseq http://rseqc.sourceforge.net

Split_bam.py would do the splitting of bam files.

ADD COMMENTlink written 4.2 years ago by Ron1.0k
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: 2451 users visited in the last hour
_