Question: Extract Bamfile using samtools
gravatar for clear.choi
4.3 years ago by
United States
clear.choi30 wrote:


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.


sam samtools bam • 1.5k views
ADD COMMENTlink modified 4.3 years ago by Pierre Lindenbaum127k • written 4.3 years ago by clear.choi30
gravatar for Pierre Lindenbaum
4.3 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum127k wrote:

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 COMMENTlink modified 4 months ago by RamRS26k • written 4.3 years ago by Pierre Lindenbaum127k

awesome :) Thank you! I

ADD REPLYlink written 4.3 years ago by clear.choi30
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1817 users visited in the last hour