Combine Fastq by writeFastq is not working properly 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 &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")
}


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
+
/&lt;BBBFFFBFFFFFFFFFFFBF&lt;FFBF&lt;B&lt;FFFFFFFFFFB/B/&lt;////&lt;&lt;&lt;FF&lt;B&lt;FF&lt;FFFFFFFFF/FFFFF


First four lines of combines fastq file are as follows: 

@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


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:



Thanks.
You can drastically simplify your effort because FASTQ files are simple text files; therefore, standard UNIX test file tools work:

cat refs/*.fastq &gt; 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:

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).