Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • dnusol
    Senior Member
    • Jul 2009
    • 136

    samtools specific region

    I have downloaded all fasta files for human chromosomes and merged them with cat. In order to use the "region" option in samtools view command, do I have to specify the exact header of the fasta file?

    so for example if I want to analyse only a specific region in chromosome 12:

    $ samtools view gi|89161190|ref|NC_000012.10|NC_000012 Homo sapiens chromosome 12, reference assembly, complete sequence:1000000-2000000

    I guess it's better then to modify the header to something like ">chr12".

    Any suggestions?

    Thanks
  • krobison
    Senior Member
    • Nov 2007
    • 734

    #2
    I would modify the header; if you don't you'll always need to put quotes around & type that whole mess. I don't believe in any case you would need the description information -- just the text up to the first space (but my samtools-indexed FASTA files lack descriptions, so I can't be sure)

    How did you convert FASTA to SAM? Or did you mean to say "samtools index"?

    Comment

    • bioinfosm
      Senior Member
      • Jan 2008
      • 483

      #3
      definitely, some sed commands to remove the ugly string and put >chr10 as header. Helps later on as well, when using UCSC or IGV!
      --
      bioinfosm

      Comment

      • dnusol
        Senior Member
        • Jul 2009
        • 136

        #4
        Thanks for your help

        I indexed the fasta reference using bwa, but before doing that I changed the headers using sed. If after aligning against the whole genome, just wanted to get subalignments for a specific region, I have to use the samtools view command with the region option, right?
        Last edited by dnusol; 03-17-2010, 12:30 AM.

        Comment

        • dnusol
          Senior Member
          • Jul 2009
          • 136

          #5
          Actually, just found out that the samtools view command does not work with the "region" option unless you feed an indexed BAM file, or so it seems:

          $ samtools view -uS /s_1/s_1.sam.gz chr6:136000000:146000000 | ./samtools sort - /s_1/s_1
          [samopen] SAM header is present: 25 sequences.
          [main_samview] random alignment retrieval only works for indexed BAM files.

          any suggestions?

          Comment

          • dnusol
            Senior Member
            • Jul 2009
            • 136

            #6
            I will answer myself.

            I first sorted and then indexed the BAM file. Then the region option seems to work.

            D.

            Comment

            • krobison
              Senior Member
              • Nov 2007
              • 734

              #7
              You just need to index (with "samtools index") the bam file that "samtools sort" generated -- then you are off to the races

              Comment

              • bioinfosm
                Senior Member
                • Jan 2008
                • 483

                #8
                I think its sort, and then index, but perhaps it works in the other order as well
                --
                bioinfosm

                Comment

                • genbio64
                  Member
                  • Dec 2009
                  • 42

                  #9
                  Does anyone know of a way to use Samtools to split off individual chromosomes for easier viewing? If I attempt to use samtools view <myfile.bam> chr1 I receive a bam file that I can no longer view because it does not associate with the indexed file it was derived from.

                  Comment

                  • nilshomer
                    Nils Homer
                    • Nov 2008
                    • 1283

                    #10
                    Originally posted by genbio64 View Post
                    Does anyone know of a way to use Samtools to split off individual chromosomes for easier viewing? If I attempt to use samtools view <myfile.bam> chr1 I receive a bam file that I can no longer view because it does not associate with the indexed file it was derived from.
                    Could you post the error message when it complains?
                    Try:
                    Code:
                    rm myfile.bam.bai
                    samtools index myfile.bam
                    samtools view -b myfile.bam chr1 > myfile.chr1.bam
                    samtools view -b myfile.bam chr2 > myfile.chr2.bam
                    ...

                    Comment

                    • genbio64
                      Member
                      • Dec 2009
                      • 42

                      #11
                      @nilshomer
                      I'll try that.

                      thanks

                      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
                      20 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 07-09-2026, 10:04 AM
                      0 responses
                      32 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 07-08-2026, 10:08 AM
                      0 responses
                      20 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...