extract region.txt from bam file
0
0
Entering edit mode
3.1 years ago

Hi,

I am extracting some regions(in txt file) from bam file using following command

      cat ref.txt | xargs samtools view -b in.bam -o out.bam

But it doesn't return whole list of reference instead miss few from the end. My question is:

  1. is there any limit on extracting references from bam file?
  2. is there any other way to do the same job

Replies on few posts suggested to use region in bed format, I couldn't figure out how to convert .txt file into .bed file.

Any lead would be appreciated :)

TIA

alignment Assembly rna-seq • 938 views
ADD COMMENT
1
Entering edit mode

Hi,

There should be no limit on extracting reads from bam file and you may find other ways to do the same job here.

The BED are presented in the form of columns separated by tabs or tab. The obligatory columns are chrom, chromStart e chromEnd. Depending on the format of your data you could use awk or even sed replacing ":" or "-" by "\t" to convert txt to bed format.

ADD REPLY
1
Entering edit mode

I did it using intersectbed from BED file. Thank you for your guidance.

ADD REPLY
0
Entering edit mode

Thank you for your response.

I think I can't use method involving bed file as I am using it in a pipeline so generating some extra files will give me overhead in terms of time.

The link you shared mostly refer to this samtools view -b -h input.bam "Chr10:18000-45500" > output.bam

But I have say Chr number in txt file separated by new lines. Does samtools accept "Chr10:18000-45500" in text file using any flag? I couldn't figure that out from their manual page.

ADD REPLY

Login before adding your answer.

Traffic: 1953 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