Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • joe_stubbs
    Junior Member
    • Jul 2012
    • 4

    Problem with samtools view chr

    Hello,

    I am trying to create a .bam file for each chromosome from the single file "mutant.bam". I'm using the following script:

    for f in {1..25} ; do echo $f ; samtools view -b mutant.bam chr"$f" -o mutant_chr"$f".bam

    The script appears to run fine, 25 file new files are created, but they are the exact same size. From manual inspection in IGV, it appears that all files contain chromosome 1.

    I have run samtools idxstats on the mutant.bam file, and the read counts for the various chromosomes are different (though similar). Any help or suggestions would be greatly appreciated.

    Best regards
  • ersgupta
    Member
    • Jun 2011
    • 26

    #2
    it works fine for me... except u cant go till chr25.. u have to specify XY...
    can u post a snapshot of the IGV.. ?

    Comment

    • joe_stubbs
      Junior Member
      • Jul 2012
      • 4

      #3
      Thank you for your response. I should have mentioned that we are dealing with zebrafish and there are 25 chromosomes. I've attached screenshots of IGV for chromosomes 1 and 15. Any suggestions would be appreciated!
      Attached Files

      Comment

      • Richard Finney
        Senior Member
        • Feb 2009
        • 701

        #4
        Well , here's your hint ... tried your program on a human sample ...
        NOTE chr23, chr24, chr25 show up as same size ... similar to "chr1".
        So, "chr1...chr25" dont match the names in the bam file. The "index" for the passed chromosome is always evaluating to zero. Index zero is the first thing, which is "chr1". So invalid chrom names are defaulting to chr1.

        How about dumping the header for us ???


        -bash-3.00$ cat job.tmp
        for f in {1..25}; do echo $f ; /h1/finneyr/samtools-0.1.18/samtools view -b mutant.bam chr"$f" -o mutant_chr"$f".bam; done
        -bash-3.00$ ls -l mutant.ba*
        -rw-rw-r-- 1 finneyr finneyr 2382311392 Jul 9 14:59 mutant.bam
        -rw-rw-r-- 1 finneyr finneyr 3282168 Jul 9 15:00 mutant.bam.bai
        -bash-3.00$ for f in {1..25}; do echo $f ; /h1/finneyr/samtools-0.1.18/samtools view -b mutant.bam chr"$f" -o mutant_chr"$f".bam; done
        1
        2
        3
        4
        5
        ... [blah blah blah ] ...
        21
        22
        23
        24
        25

        -bash-3.00$ ls -ltra mutant_chr*.bam
        -rw-rw-r-- 1 finneyr finneyr 188544953 Jul 9 15:01 mutant_chr1.bam
        -rw-rw-r-- 1 finneyr finneyr 182304264 Jul 9 15:02 mutant_chr2.bam
        -rw-rw-r-- 1 finneyr finneyr 110355683 Jul 9 15:03 mutant_chr3.bam
        -rw-rw-r-- 1 finneyr finneyr 39704885 Jul 9 15:03 mutant_chr4.bam
        -rw-rw-r-- 1 finneyr finneyr 65711066 Jul 9 15:03 mutant_chr5.bam
        -rw-rw-r-- 1 finneyr finneyr 93410203 Jul 9 15:04 mutant_chr6.bam
        -rw-rw-r-- 1 finneyr finneyr 101683378 Jul 9 15:04 mutant_chr7.bam
        -rw-rw-r-- 1 finneyr finneyr 52687973 Jul 9 15:04 mutant_chr8.bam
        -rw-rw-r-- 1 finneyr finneyr 63029186 Jul 9 15:04 mutant_chr9.bam
        -rw-rw-r-- 1 finneyr finneyr 50675311 Jul 9 15:05 mutant_chr10.bam
        -rw-rw-r-- 1 finneyr finneyr 112430386 Jul 9 15:05 mutant_chr11.bam
        -rw-rw-r-- 1 finneyr finneyr 153721958 Jul 9 15:06 mutant_chr12.bam
        -rw-rw-r-- 1 finneyr finneyr 27555154 Jul 9 15:06 mutant_chr13.bam
        -rw-rw-r-- 1 finneyr finneyr 146768148 Jul 9 15:06 mutant_chr14.bam
        -rw-rw-r-- 1 finneyr finneyr 42938121 Jul 9 15:07 mutant_chr15.bam
        -rw-rw-r-- 1 finneyr finneyr 54046327 Jul 9 15:07 mutant_chr16.bam
        -rw-rw-r-- 1 finneyr finneyr 126879400 Jul 9 15:07 mutant_chr17.bam
        -rw-rw-r-- 1 finneyr finneyr 17673537 Jul 9 15:07 mutant_chr18.bam
        -rw-rw-r-- 1 finneyr finneyr 156792702 Jul 9 15:08 mutant_chr19.bam
        -rw-rw-r-- 1 finneyr finneyr 43187357 Jul 9 15:08 mutant_chr20.bam
        -rw-rw-r-- 1 finneyr finneyr 11786036 Jul 9 15:08 mutant_chr21.bam
        -rw-rw-r-- 1 finneyr finneyr 69096206 Jul 9 15:09 mutant_chr22.bam
        -rw-rw-r-- 1 finneyr finneyr 182304264 Jul 9 15:09 mutant_chr23.bam
        -rw-rw-r-- 1 finneyr finneyr 182304264 Jul 9 15:10 mutant_chr24.bam
        -rw-rw-r-- 1 finneyr finneyr 182304264 Jul 9 15:11 mutant_chr25.bam
        Last edited by Richard Finney; 07-09-2012, 11:39 AM.

        Comment

        • joe_stubbs
          Junior Member
          • Jul 2012
          • 4

          #5
          Thank you for the response! Here is the header:

          @SQ SN:1 LN:60348388
          @SQ SN:2 LN:60300536
          @SQ SN:3 LN:63268876
          @SQ SN:4 LN:62094675
          @SQ SN:5 LN:75682077
          @SQ SN:6 LN:59938731
          @SQ SN:7 LN:77276063
          @SQ SN:8 LN:56184765
          @SQ SN:9 LN:58232459
          @SQ SN:10 LN:46591166
          @SQ SN:11 LN:46661319
          @SQ SN:12 LN:50697278
          @SQ SN:13 LN:54093808
          @SQ SN:14 LN:53733891
          @SQ SN:15 LN:47442429
          @SQ SN:16 LN:58780683
          @SQ SN:17 LN:53984731
          @SQ SN:18 LN:49877488
          @SQ SN:19 LN:50254551
          @SQ SN:20 LN:55952140
          @SQ SN:21 LN:44544065
          @SQ SN:22 LN:42261000
          @SQ SN:23 LN:46386876
          @SQ SN:24 LN:43947580
          @SQ SN:25 LN:38499472
          @SQ SN:MT LN:16596

          I'm continuing to read through the spec (http://samtools.sourceforge.net/SAM1.pdf), but I haven't been able to determine how the individual chromosomes are generated. Does it look like the header is missing essential data/tags?

          Thank you!

          Comment

          • Richard Finney
            Senior Member
            • Feb 2009
            • 701

            #6
            You can give a "reference chromosome" any name you want.
            Just use "1" instead of "chr1" and "2" instead of "chr2", etc.
            hook 'em!

            Comment

            • joe_stubbs
              Junior Member
              • Jul 2012
              • 4

              #7
              Ah ha! That completely solved my problem. I really appreciate your help! hook 'em indeed!

              Comment

              Latest Articles

              Collapse

              • SEQadmin2
                Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                by SEQadmin2



                Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                ...
                07-09-2026, 11:10 AM
              • SEQadmin2
                Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                by SEQadmin2



                Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                07-08-2026, 05:17 AM
              • GATTACAT
                Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                by GATTACAT
                Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                07-01-2026, 11:43 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, 07-13-2026, 10:26 AM
              0 responses
              25 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-09-2026, 10:04 AM
              0 responses
              35 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-08-2026, 10:08 AM
              0 responses
              22 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-07-2026, 11:05 AM
              0 responses
              34 views
              0 reactions
              Last Post SEQadmin2  
              Working...