Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 03:10 AM.

  • #2
    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

    Comment


    • #3
      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, 06:26 AM.

      Comment


      • #4
        Adding a random "&" into a command will tend to break things.

        Comment


        • #5
          You are right.
          Command works but show this:
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.
          [bam_header_read] EOF marker is absent. The input is probably truncated.


          But the output bam is correct.

          Thanks so much, dpryan.

          Comment

          Latest Articles

          Collapse

          • seqadmin
            The Impact of AI in Genomic Medicine
            by seqadmin



            Artificial intelligence (AI) has evolved from a futuristic vision to a mainstream technology, highlighted by the introduction of tools like OpenAI's ChatGPT and Google's Gemini. In recent years, AI has become increasingly integrated into the field of genomics. This integration has enabled new scientific discoveries while simultaneously raising important ethical questions1. Interviews with two researchers at the center of this intersection provide insightful perspectives into...
            02-26-2024, 02:07 PM
          • seqadmin
            Multiomics Techniques Advancing Disease Research
            by seqadmin


            New and advanced multiomics tools and technologies have opened new avenues of research and markedly enhanced various disciplines such as disease research and precision medicine1. The practice of merging diverse data from various ‘omes increasingly provides a more holistic understanding of biological systems. As Maddison Masaeli, Co-Founder and CEO at Deepcell, aptly noted, “You can't explain biology in its complex form with one modality.”

            A major leap in the field has
            ...
            02-08-2024, 06:33 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, Yesterday, 06:12 AM
          0 responses
          19 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 02-23-2024, 04:11 PM
          0 responses
          67 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 02-21-2024, 08:52 AM
          0 responses
          74 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 02-20-2024, 08:57 AM
          0 responses
          66 views
          0 likes
          Last Post seqadmin  
          Working...
          X