Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • #16
    Sorting bam file

    How can I sort my bam file according to read headers. Kindly Reply soon.

    Comment


    • #17
      using the '-n' option will sort by read name:

      Code:
      samtools sort -n <infile.bam> <out.prefix>
      Run 'samtools sort' without any options to see more help.

      Comment


      • #18
        Is there a single command to sort .bam output of tophat "samtools sort aln.bam aln.sorted"

        or there is a bunch of commands which I have to use... ?

        any idea please ?



        Originally posted by gringer View Post
        using the '-n' option will sort by read name:

        Code:
        samtools sort -n <infile.bam> <out.prefix>
        Run 'samtools sort' without any options to see more help.

        Comment


        • #19
          Originally posted by Charitra View Post
          Is there a single command to sort .bam output of tophat "samtools sort aln.bam aln.sorted"
          The tophat output should already be sorted... assuming you meant bowtie/bowtie2, all the samtools programs support piped input using '-' as a file name, so it's quite easy to sort your output without intermediate files using Linux pipes:

          Code:
          bowtie2 <options> | samtools view -S -b - | samtools sort - output.sorted

          Comment


          • #20
            Hi All

            I have a question. I wish to run bowtie over 3 cores and get an output of aligned sorted and indexed bam files.

            bowtie2 -p 3 -x ../genomes/hg38/hg38 -1 tg/1/S1R1_val_1.fq.gz -2 tg/1/S1R2_val_2.fq.gz | samtools view -Shu - | samtools sort - - | samtools index > bam/S1_srt.bam

            The above command just foes till sorted how can I also include a index via the pipe such that I get a sorted aligned bam and also the index in the same pipe?

            I look forward for your help.

            Thanks,

            Yaseen

            Comment


            • #21
              I don't think "samtools index" can handle piped input .

              Comment


              • #22
                It makes no sense to pipe the output of samtools sort to samtools index.
                You want to save the output of samtools sort.
                Just save the output of samtools sort, and then index.
                If you want a one line command, just put a semi-colon after the call to samtools sort, and them call samtools index.

                This is also a duplicate post.


                The same answer is posted just above your duplicated post on biostars.

                Comment


                • #23
                  Originally posted by Richard Finney View Post
                  I don't think "samtools index" can handle piped input .
                  Well, you can shoehorn around that by using anonymous files (and tee, where duplicated output is required):

                  Code:
                  samtools index <(samtools view -h ../out.aaa.bam | samtools view -Shu - | samtools sort -T . -O bam -o - | tee out.bam) out.bam.bai
                  Unfortunately, some programs still need to use seek for file processing, and that means code like this won't work. It seems like samtools index is failing for another reason here though:

                  Code:
                  Samtools-htslib-API: bam_index_build2() not yet implemented
                  Aborted

                  Comment


                  • #24
                    How can i sort multiple BAM files using samtools?

                    Hi,

                    Is there any way to sort multiple bam files at the same time using samtools?
                    Thanks.

                    Comment

                    Latest Articles

                    Collapse

                    • seqadmin
                      Current Approaches to Protein Sequencing
                      by seqadmin


                      Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
                      04-04-2024, 04:25 PM
                    • seqadmin
                      Strategies for Sequencing Challenging Samples
                      by seqadmin


                      Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
                      03-22-2024, 06:39 AM

                    ad_right_rmr

                    Collapse

                    News

                    Collapse

                    Topics Statistics Last Post
                    Started by seqadmin, 04-11-2024, 12:08 PM
                    0 responses
                    30 views
                    0 likes
                    Last Post seqadmin  
                    Started by seqadmin, 04-10-2024, 10:19 PM
                    0 responses
                    32 views
                    0 likes
                    Last Post seqadmin  
                    Started by seqadmin, 04-10-2024, 09:21 AM
                    0 responses
                    28 views
                    0 likes
                    Last Post seqadmin  
                    Started by seqadmin, 04-04-2024, 09:00 AM
                    0 responses
                    53 views
                    0 likes
                    Last Post seqadmin  
                    Working...
                    X