Question: extracting reads from BAM files for gene coordinates Tx start Txs end
0
gravatar for amitpande74
4.6 years ago by
amitpande740 wrote:

Hi,

      I have a list of Refseq annotated gene coordinates and I would like to extract the reads for the same in one go. I have read many posts here and at Seqanswers, but those are restricted to a particular region. for example samtools view input.bam "Chr10:18000-45500" > output.bam.

How can one do this for a list of genes with the Transcription start and end positions?

I tried doing this by extracting theit extr Refseq gene names and the associated coordinates from the genome browser at UCSC. Then using samtolls view input.BAM "mygenes.bed" > output.bam. But it extracts the reads and the format is not BAM.

I am new to NGS can someone help.

rna-seq samtools • 2.1k views
ADD COMMENTlink modified 4.6 years ago by Alex Reynolds29k • written 4.6 years ago by amitpande740
1
gravatar for geek_y
4.6 years ago by
geek_y9.9k
Barcelona
geek_y9.9k wrote:
samtools view -b -L regions.bed input.bam > selected.bam

You should be careful with 0-based and 1-based coordinates

ADD COMMENTlink modified 12 months ago by RamRS24k • written 4.6 years ago by geek_y9.9k
1
gravatar for Alex Reynolds
4.6 years ago by
Alex Reynolds29k
Seattle, WA USA
Alex Reynolds29k wrote:

Given a sorted file called genes.bed with your Tx starts and ends, you can use BEDOPS bedops and bam2bed running in a bash environment:

$ bedops --element-of 1 <(bam2bed < input.bam) genes.bed > answer.bed

Fast and memory efficient, and useful if you want BED as output for downstream ops.

ADD COMMENTlink modified 12 months ago by RamRS24k • written 4.6 years ago by Alex Reynolds29k
0
gravatar for swbarnes2
4.6 years ago by
swbarnes26.7k
United States
swbarnes26.7k wrote:

Another possibility; use IntersectBed from BEDTools.

ADD COMMENTlink modified 12 months ago by RamRS24k • written 4.6 years ago by swbarnes26.7k
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: 1721 users visited in the last hour