Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Naarkhoo
    Member
    • Jan 2013
    • 11

    merging two fastq files from exome sequencing

    One sample, is whole exome sequenced, twice to reach the required coverage as these samples had some issues. The sequencing in both samples are same (batch, machine and the vendor) I wonder, if it makes sense to merge these two fastq files at the beginning in order to reach the adequate coverage, and do variant calling once afterward ?! if so, how should I merge them.

    I appreciate other suggestion for this case, thanks
  • Shingo
    Junior Member
    • Mar 2012
    • 6

    #2
    I often merge fastq files from same sample but different sequence run like this using unix command.

    Single-end
    cat same_sample_1st.fastq same_sample_2nd.fastq > merged.fastq

    Paired-end
    cat same_sample_1st_R1.fastq same_sample_2nd_R1.fastq > merged_R1.fastq
    cat same_sample_1st_R2.fastq same_sample_2nd_R2.fastq > merged_R2.fastq

    I hope this is the answer.

    Comment

    • Apexy
      Member
      • Apr 2011
      • 62

      #3
      Intuitively, merging would be appropriate given that you will need to map reads to a reference. When you say "samples had some issues", I begin to wonder what kind of issue and how this might affect results (read quality, contamination, subtle error profile). I am not particularly use to SNP analysis but coverage around a nucleotide (mapped read density) would normally play a rule is deciding what is a variant.

      "..........The sequencing in both samples are same ".... are these sample different? is yes, then you may not merge files.

      cat 1.fastq 2.fastq > merge.fastq should work. if not then use the following:

      #!/usr/bin/perl
      use strict;
      use warnings;

      if (@ARGV != 3 ) {
      #pirnts this message and note on usage
      print STDERR "\nusage: perl fastq_concatenate.pl fastq1 fastq2 output\n\n";
      exit(1);
      }

      my $fq1 = $ARGV[0];
      my $fq2 = $ARGV[1];
      my $fq3 = $ARGV[2];
      open (PE, $fq1) || &ErrorMessage($fq1);
      open (PF, $fq2) || &ErrorMessage($fq2);
      open (PH, ">$fq3") || &ErrorMessage($fq3);

      while(<PE>) {
      print PH $_;
      }
      close PE;
      while(<PF>) {
      print PH $_;
      }
      close PF;
      close PH;

      sub ErrorMessage {
      my $err = shift;
      return "Fatal error: $err does not exist\n";
      exit(1);
      }


      Hope that helps

      Comment

      • rohan_1925
        Junior Member
        • Dec 2013
        • 7

        #4
        Concatenate paired end samples

        Hi Shingo,

        I have 50 samples,each having paired end files,Do you know of using "cat" command of merging samples in one command? for example merging the 2 files below in one command using some regular expression?

        Else I have to merge each sample one by one.

        Thanks,
        Rohan


        Originally posted by Shingo View Post
        I often merge fastq files from same sample but different sequence run like this using unix command.

        Single-end
        cat same_sample_1st.fastq same_sample_2nd.fastq > merged.fastq

        Paired-end
        cat same_sample_1st_R1.fastq same_sample_2nd_R1.fastq > merged_R1.fastq
        cat same_sample_1st_R2.fastq same_sample_2nd_R2.fastq > merged_R2.fastq

        I hope this is the answer.

        Comment

        • Shingo
          Junior Member
          • Mar 2012
          • 6

          #5
          Hi Rohan,

          I usually use illumina HiSeq. Output fastq files from HiSeq are compressed by *.gz and their formats are “sample_name”_”index”_”lane_no”_”mate_no”_”file_no”.fastq.gz. I think the perl’s regular expression of the HiSeq fastq is
          $file_name =~ /^(.+)_([ATGC]{6,})_(L\d\d\d)_(R1|R2)_(\d\d\d).fastq.gz$/.

          If you use illumine HiSeq and the format is same as above, the attached perl script may be useful. fastqs will be concatenated by each sample and the result files will be moved to ‘original_fastq’ directory in the current.

          Please try below.

          00_zcat_fastq_files.pl [Top directory in which there are all FASTQ files (must be *.fastq.gz)]

          It is OK that fastqs of samples divided into different sub directories.

          Top directory
          |
          |- Sample_1_dir (1_*_R1.001.fastq, 1_*_R1.002.fastq, 1_*_R2.001.fastq, 1_*_R2.002.fastq, …)
          |- Sample_2_dir (2_*_R1.001.fastq, 2_*_R1.002.fastq, 2_*_R2.001.fastq, 2_*_R2.002.fastq, …)
          |- Sample_3_dir
          .
          .

          I hope you get a solution.

          Shingo


          Originally posted by rohan_1925 View Post
          Hi Shingo,

          I have 50 samples,each having paired end files,Do you know of using "cat" command of merging samples in one command? for example merging the 2 files below in one command using some regular expression?

          Else I have to merge each sample one by one.

          Thanks,
          Rohan

          Comment

          • Shingo
            Junior Member
            • Mar 2012
            • 6

            #6
            Hi Rohan,

            Sorry, I forgot to attach the file.

            Shingo


            Originally posted by rohan_1925 View Post
            Hi Shingo,

            I have 50 samples,each having paired end files,Do you know of using "cat" command of merging samples in one command? for example merging the 2 files below in one command using some regular expression?

            Else I have to merge each sample one by one.

            Thanks,
            Rohan
            Attached Files

            Comment

            • rohan_1925
              Junior Member
              • Dec 2013
              • 7

              #7
              Hi Shingo,

              Thanks for your quick response and the script.Following are some of my sample files.


              51772BL1_R1.fastq
              51772BL1_R2.fastq
              51805BL1_R1.fastq
              51805BL1_R2.fastq
              52451BL1_R1.fastq
              52451BL1_R2.fastq

              I think I would have to modify the regex in that case.

              Thanks,
              Rohan

              Comment

              • Shingo
                Junior Member
                • Mar 2012
                • 6

                #8
                Hi Rohan,

                51772BL1_R1.fastq
                51772BL1_R2.fastq
                51805BL1_R1.fastq
                51805BL1_R2.fastq
                52451BL1_R1.fastq
                52451BL1_R2.fastq

                These files look like BL1 is the sample name and the forward numeric is serial number. Is that correct? If so, the regex should be $file_name =~ /^(\d+)(\w+)_(R1|R2).fastq$/.
                I modified the previous script. Please try it. The new script doesn’t read *.fastq.gz just read *.fastq.

                Shingo
                Attached Files

                Comment

                • volks
                  Member
                  • Jun 2010
                  • 80

                  #9
                  what is the benefit of merging the fastq files? you could merge bam files, e.g. using Picard MergeSamFiles or MarkDuplicates (if required, can be performed in a single step). then you could remove bad quality lanes completely without redoing the alignment.

                  Comment

                  Latest Articles

                  Collapse

                  • SEQadmin2
                    From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
                    by SEQadmin2


                    Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


                    The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
                    ...
                    06-02-2026, 10:05 AM
                  • SEQadmin2
                    Single-Cell Sequencing at an Inflection Point: Early Impacts of New Platforms and Emerging Trends
                    by SEQadmin2


                    With the launch of new single-cell sequencing platforms in 2026, the field stands at an exciting inflection point. This article surveys the most impactful advances in the field and discusses how they’re reshaping research in cancer, immunology, and beyond.


                    Introduction

                    Single-cell sequencing technologies have undergone remarkable advances over the past decade, transitioning from low-throughput experimental approaches to highly scalable platforms capable of...
                    05-22-2026, 06:42 AM
                  • SEQadmin2
                    Environmental Genomics in the Age of NGS: From Microbes to Conservation Strategies
                    by SEQadmin2

                    Studying ecosystems means dealing with complex, multi-species communities that are hard to observe at scale. This complexity, however, hides many important questions to be answered, from how biogeochemical cycles work and how climate change can affect species distribution to how conservation strategies can work best.


                    Genomics, particularly since the expansion of NGS, has transformed ecosystem ecology. By sequencing environmental DNA, we can now assess biodiversity without direct...
                    05-06-2026, 09:04 AM

                  ad_right_rmr

                  Collapse

                  News

                  Collapse

                  Topics Statistics Last Post
                  Started by SEQadmin2, Yesterday, 08:59 AM
                  0 responses
                  13 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 06-02-2026, 12:03 PM
                  0 responses
                  22 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 06-02-2026, 11:40 AM
                  0 responses
                  19 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 05-28-2026, 11:40 AM
                  0 responses
                  31 views
                  0 reactions
                  Last Post SEQadmin2  
                  Working...