SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
extract strand information from bam file in a specific position paperblu Bioinformatics 2 07-15-2014 08:35 AM
Extract aligned reads from a BAM file above a certain threshold The Snow Bioinformatics 4 07-29-2013 03:02 AM
Extract reads from multiple regions from bam file meher Bioinformatics 7 12-14-2012 04:18 AM
Extract base from bam file empyrean Bioinformatics 4 07-03-2012 04:47 AM
Fastest way to extract differing positions from each alignment in a BAM file CHRYSES Bioinformatics 5 12-14-2011 12:28 PM

Reply
 
Thread Tools
Old 01-12-2015, 03:05 AM   #1
Anti
Junior Member
 
Location: Italy

Join Date: Sep 2014
Posts: 5
Default Samtools: extract multiple cromosomes/scaffolds from bam file

Hi,
I want to create a bam file containing three or four chromosomes/scaffolds.
I only know this command

samtools view -b align.sort.bam Chr06 > chr06.bam

Last edited by Anti; 01-12-2015 at 03:10 AM.
Anti is offline   Reply With Quote
Old 01-12-2015, 03:16 AM   #2
dpryan
Devon Ryan
 
Location: Freiburg, Germany

Join Date: Jul 2011
Posts: 3,480
Default

You can just use samtools merge with process substitution:

Code:
samtools merge merged.bam <(samtools view -b foo.bam chr1) <(samtools view -b foo.bam chr2) ...
A likely faster method might be to just make a BED file containing those chromosomes/contigs and then just:
Code:
samtools view -b -L chromosomes.bed foo.bam > subset.bam
dpryan is offline   Reply With Quote
Old 01-12-2015, 04:42 AM   #3
Anti
Junior Member
 
Location: Italy

Join Date: Sep 2014
Posts: 5
Default

Thanks so much, dpryan! but this command don't create a bam from two cromosomes.

i used this :

samtools merge merged.bam <(samtools view -b SE.bam chr1) & (samtools view -b SE.bam chr2)

using your suggestion and works!

Last edited by Anti; 01-12-2015 at 06:26 AM.
Anti is offline   Reply With Quote
Old 01-12-2015, 04:46 AM   #4
dpryan
Devon Ryan
 
Location: Freiburg, Germany

Join Date: Jul 2011
Posts: 3,480
Default

Adding a random "&" into a command will tend to break things.
dpryan is offline   Reply With Quote
Reply

Tags
chromosomes, command, multiple, samtools, scaffolds

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 09:24 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO