Question: Using Samtools With Many Positions
1
gravatar for Zhshqzyc
8.3 years ago by
Zhshqzyc490
Zhshqzyc490 wrote:

Hi,

If one position such as chr8:125976061-125976501, then the command is prety straight forward. In Linux:

samtools view -o out input.sam chr8:125976061-125976501

However I have many positions in a list file, is there a batch way to do it? The list file format likes

Chr      start      end
15       10000    20000
15       20000    30000
15       30000    40000
15       40000    50000

Thanks for help.

samtools • 3.0k views
ADD COMMENTlink written 8.3 years ago by Zhshqzyc490
3
gravatar for brentp
8.3 years ago by
brentp23k
Salt Lake City, UT
brentp23k wrote:

If it's bed format (and yours appears to be other than the header):

samtools view -L some.bed some.bam

EDIT:

though I get different results between the 2 calls:

$ cat t.bed 
chr1    1000    2000

$ samtools view -L t.bed methylcoded.bam | wc -l
1

$ samtools view methylcoded.bam chr1:1000-2000 | wc -l
22

I dont know why that is.

ADD COMMENTlink modified 8.3 years ago • written 8.3 years ago by brentp23k

Thanks, I wrote a script to reslove it.

ADD REPLYlink written 8.3 years ago by Zhshqzyc490

Perhaps it's because bed files are 0 based and samtools positions are 1-based?

ADD REPLYlink written 8.3 years ago by Gww2.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: 1509 users visited in the last hour