Extract Bamfile using samtools
1
0
Entering edit mode
6.0 years ago
clear.choi ▴ 30

Hello

It's the first time try to use samtools and I wonder how I can extract bam file by sample.

I need to analyze bam file by Sample and make another BAM file by Sample.

In side of bam file there is sample ID like B1, B2, B3, ... B384.

I wonder if I want to extract only B3 sample from original bam file.

How can I command?

original bam file original.bam -> new bam file b3.bam.

Thank you.

 

bam samtools sam • 1.9k views
ADD COMMENT
2
Entering edit mode
6.0 years ago

using samtools view with the -r option. See the sam spec to understand what is a group-id in a SAM file.

-r STR   only include reads in read group STR [null]
  
samtool view -r B3 -b -o out.bam in.bam
ADD COMMENT
0
Entering edit mode

awesome :) Thank you! I

ADD REPLY

Login before adding your answer.

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