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

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.

 

sam samtools bam • 1.2k views
ADD COMMENTlink modified 3.5 years ago by Pierre Lindenbaum120k • written 3.5 years ago by clear.choi30
2
gravatar for Pierre Lindenbaum
3.5 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum120k 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 3.5 years ago • written 3.5 years ago by Pierre Lindenbaum120k

awesome :) Thank you! I

ADD REPLYlink written 3.5 years ago by clear.choi30
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: 1104 users visited in the last hour