Answers.Body: <p>You can drastically simplify your effort because FASTQ files are simple text files; therefore, standard UNIX test file tools work:</p>
  
  <pre class="lang-bash prettyprint-override"><code>cat refs/*.fastq &gt; combined.fastq
  </code></pre>
  
  <p>And this even works with <code>.fastq.gz</code> files — no unzipping required.</p>
  
  <hr>
  
  <p>Apart from this, your R code contains several errors. For instance, your variable names change throughout, and you’re using the <code>fsep</code> parameter wrongly. In fact it’s unclear to me what the code is supposed to do. At an approximation (and untested), the following should work:</p>
  
  <pre class="lang-r prettyprint-override"><code>fastq_dir = file.path(getwd(), "refs")
  fastq_files = dir(fastq_dir, pattern = "\\.fastq$", full.names = TRUE)
  outfile = file.path(dirname(fastq_dir), "combined.fastq")
  
  for (file in fastq_files) {
      fq = readFastq(file)
      writeFastq(fq, outfile, mode = "a")
  }
  </code></pre>
  
  <p>This is equivalent to running the shell command shown above, just in a more convoluted way (parsing and re-generating the FASTQ files).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T04:45:52.290Z
Answers.Text: @Konard : Thanks for pointing out my mistake. As I am beginner so my codes are not as much good. I have changes this. Can you tell me what is the proper use of fsep. I though using file path, fsep is the way to choose only specific type of file (may be I am wrong). And how can I use cat within for loop because it is giving `unexpected symbol` error by trying `cat fq > combine.fastq` Thanks again. I'll try my best to improve. keep pointing my mistakes. :)
Answers.UserDisplayName: Lot_to_learn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-14T10:09:54.423Z
Answers.LastActivityDate: 2018-02-14T10:20:59.917Z
Answers.LastEditDate: 2018-02-14T10:20:59.917Z
Answers.UserDisplayName: Konrad Rudolph
Body: <p>Currently I have 4 fastq file for each patient as WES data. For WES pipeline, I want to combine those fastq files. I am using writeFastq from ShortRead package in Bioconductor.But I think this function is not working properly. </p>
  
  <p>The reason of my doubt is the the size the next step is quality check using FastQC tool. This tool is working on individual file but not on combined file and shows the error that ID line doesn't start with "@" . So I want to know what are the other effective tool for combining multiple fastq files without any loss of information. </p>
  
  <p>Let me know if I am doing something wrong. Thanks</p>
  
  <p><strong>[EDIT-1]</strong> : The codes for combining multiple fastq files into one is as follows:</p>
  
  <pre><code>reference_fastq = file.path(paste(getwd(),"refs",sep = "/", collapse = " "), fsep = ".fasta")
  fastqDir &lt;- file.path(dataDir, fsep = ".fastq")
  outfile_temp &lt;- paste(dirname(dataDir),basename(fastqDir),    paste(basename(fastqDir),"combined","fastq", sep = "."),sep = "/", collapse = " ")
  fls &lt;- list.files(fastqDir, "fastq$", full=TRUE)
  for (fl in fls) {
    fq &lt;- readFastq(fl)
    writeFastq(fq,outfile_temp, mode="a")
  }
  </code></pre>
  
  <p>First four lines of my fastq file (one of 4 indivual file) are as follows :</p>
  
  <pre><code>@D00239:185:C9KELANXX:2:2201:1088:2107 1:N:0:TCCTGAGC
  GTACAAGAAGCATAACATCAGCATGTGTTTTGGTGAGAACCTTAGGAAGTTTGCAATCATGACAGAAGGTGAAGG
  +
  /&lt;BBBFFFBFFFFFFFFFFFBF&lt;FFBF&lt;B&lt;FFFFFFFFFFB/B/&lt;////&lt;&lt;&lt;FF&lt;B&lt;FF&lt;FFFFFFFFF/FFFFF
  </code></pre>
  
  <p>First four lines of combines fastq file are as follows: </p>
  
  <pre><code>@D00239:185:C9KELANXX:2:2201:1088:2107 1:N:0:TCCTGAGC
  GTACAAGAAGCATAACATCAGCATGTGTTTTGGTGAGAACCTTAGGAAGTTTGCAATCATGACAGAAGGTGAAGG
  +
  /&lt;BBBFFFBFFFFFFFFFFFBF&lt;FFBF&lt;B&lt;FFFFFFFFFFB/B/&lt;////&lt;&lt;&lt;FF&lt;B&lt;FF&lt;FFFFFFFFF/FFFFF
  </code></pre>
  
  <p>It is pretty clear that combined fastq file is also starting wiht proper identifier but why FastQC tool is saying that identifier '@' is missing. Here is the screen shot of the error message:</p>
  
  <p><a href="https://i.sstatic.net/aZ3E2.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/aZ3E2.png" alt="Screen shot of error message"></a></p>
  
  <p>Thanks.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-14T07:07:17.283Z
Comments.Text: Can you please show the first and last lines of the input FASTQ files, and the first and last line of whatever writeFastq has created?
Comments.UserDisplayName: gringer
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-14T07:47:49.633Z
Comments.Text: Could you paste the command you used from ShortRead to combine the files? (And the version of the package, just in case there is a bug in that version). If you have the fastq files compressed you can simply `cat` them to a new .tar.gz file and you'll have them combined
Comments.UserDisplayName: llrs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-14T09:58:54.673Z
Comments.Text: @Lot, please instead of images paste the text in code formatting. Also could you, answer to gringer?
Comments.UserDisplayName: llrs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-15T04:08:51.353Z
Comments.Text: @gringer: I have shown the first 4 lines of input fastq file and output fastq file. What else you want to check..let me know.
Comments.UserDisplayName: Lot_to_learn
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-15T04:10:34.943Z
Comments.Text: @Llopis: Actually I tried to copy the text instead the image but I am working on server and on right click after text selection, I did not find any option like copy. That's why I took screen shot. Sorry for this.
Comments.UserDisplayName: Lot_to_learn
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-15T04:15:08.857Z
Comments.Text: @Llopis: ShortRead package version is 1.28.0, R version 3.4.3 and bioconductor version is 3.2.
Comments.UserDisplayName: Lot_to_learn
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-15T09:10:37.000Z
Comments.Text: You have a 2 year's old version of Bioconductor, you might be interested in upgrading it (just in case some other errors are already solved in the updated version).
Comments.UserDisplayName: llrs
Tags: <r><bioconductor><sequence-analysis>
Title: Combine Fastq by writeFastq is not working properly
ThreadText: # Combine Fastq by writeFastq is not working properly
  
  (Asked by: username_0 on 2018-02-14)
  
  Currently I have 4 fastq file for each patient as WES data. For WES pipeline, I want to combine those fastq files. I am using writeFastq from ShortRead package in Bioconductor.But I think this function is not working properly.
  
  The reason of my doubt is the the size the next step is quality check using FastQC tool. This tool is working on individual file but not on combined file and shows the error that ID line doesn't start with "@" . So I want to know what are the other effective tool for combining multiple fastq files without any loss of information.
  
  Let me know if I am doing something wrong. Thanks
  
  **[EDIT-1]** : The codes for combining multiple fastq files into one is as follows:
  
  ```
  reference_fastq = file.path(paste(getwd(),"refs",sep = "/", collapse = " "), fsep = ".fasta")
  fastqDir <- file.path(dataDir, fsep = ".fastq")
  outfile_temp <- paste(dirname(dataDir),basename(fastqDir),    paste(basename(fastqDir),"combined","fastq", sep = "."),sep = "/", collapse = " ")
  fls <- list.files(fastqDir, "fastq$", full=TRUE)
  for (fl in fls) {
    fq <- readFastq(fl)
    writeFastq(fq,outfile_temp, mode="a")
  }
  
  ```
  
  First four lines of my fastq file (one of 4 indivual file) are as follows :
  
  ```
  @D00239:185:C9KELANXX:2:2201:1088:2107 1:N:0:TCCTGAGC
  GTACAAGAAGCATAACATCAGCATGTGTTTTGGTGAGAACCTTAGGAAGTTTGCAATCATGACAGAAGGTGAAGG
  +
  /<BBBFFFBFFFFFFFFFFFBF<FFBF<B<FFFFFFFFFFB/B/<////<<<FF<B<FF<FFFFFFFFF/FFFFF
  
  ```
  
  First four lines of combines fastq file are as follows:
  
  ```
  @D00239:185:C9KELANXX:2:2201:1088:2107 1:N:0:TCCTGAGC
  GTACAAGAAGCATAACATCAGCATGTGTTTTGGTGAGAACCTTAGGAAGTTTGCAATCATGACAGAAGGTGAAGG
  +
  /<BBBFFFBFFFFFFFFFFFBF<FFBF<B<FFFFFFFFFFB/B/<////<<<FF<B<FF<FFFFFFFFF/FFFFF
  
  ```
  
  It is pretty clear that combined fastq file is also starting wiht proper identifier but why FastQC tool is saying that identifier '@' is missing. Here is the screen shot of the error message:
  
  [![Screen shot of error message](https://i.sstatic.net/aZ3E2.png)](https://i.sstatic.net/aZ3E2.png)
  
  Thanks.
  
  **Tags:** r, bioconductor, sequence-analysis
  
  > **Comments:**
  > **username_1**: Can you please show the first and last lines of the input FASTQ files, and the first and last line of whatever writeFastq has created?  
  > **username_2**: Could you paste the command you used from ShortRead to combine the files? (And the version of the package, just in case there is a bug in that version). If you have the fastq files compressed you can simply `cat` them to a new .tar.gz file and you'll have them combined  
  > **username_2**: @Lot, please instead of images paste the text in code formatting. Also could you, answer to username_1?  
  > **username_0**: @username_1: I have shown the first 4 lines of input fastq file and output fastq file. What else you want to check..let me know.  
  > **username_0**: @Llopis: Actually I tried to copy the text instead the image but I am working on server and on right click after text selection, I did not find any option like copy. That's why I took screen shot. Sorry for this.  
  > **username_0**: @Llopis: ShortRead package version is 1.28.0, R version 3.4.3 and bioconductor version is 3.2.  
  > **username_2**: You have a 2 year's old version of Bioconductor, you might be interested in upgrading it (just in case some other errors are already solved in the updated version).  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2018-02-14. Score: 4
  
  You can drastically simplify your effort because FASTQ files are simple text files; therefore, standard UNIX test file tools work:
  
  ```bash
  cat refs/*.fastq > combined.fastq
  
  ```
  
  And this even works with `.fastq.gz` files — no unzipping required.
  
  ---
  
  Apart from this, your R code contains several errors. For instance, your variable names change throughout, and you’re using the `fsep` parameter wrongly. In fact it’s unclear to me what the code is supposed to do. At an approximation (and untested), the following should work:
  
  ```r
  fastq_dir = file.path(getwd(), "refs")
  fastq_files = dir(fastq_dir, pattern = "\\.fastq$", full.names = TRUE)
  outfile = file.path(dirname(fastq_dir), "combined.fastq")
  
  for (file in fastq_files) {
      fq = readFastq(file)
      writeFastq(fq, outfile, mode = "a")
  }
  
  ```
  
  This is equivalent to running the shell command shown above, just in a more convoluted way (parsing and re-generating the FASTQ files).
  
  > **Comments:**
  > **username_0**: @Konard : Thanks for pointing out my mistake. As I am beginner so my codes are not as much good. I have changes this. Can you tell me what is the proper use of fsep. I though using file path, fsep is the way to choose only specific type of file (may be I am wrong). And how can I use cat within for loop because it is giving `unexpected symbol` error by trying `cat fq > combine.fastq` Thanks again. I'll try my best to improve. keep pointing my mistakes. :)  
  
  ---
  
  