dada2 icon indicating copy to clipboard operation
dada2 copied to clipboard

Returning the name of samples not matchin the reverse files

Open SgtVil opened this issue 2 years ago • 2 comments

Hello, while running a lot of different projects with some project downloaded from SRA having more than 3000 fastq files I realised that mismatch files can occurs quite often. It would be of great use to return the names of fastq that are not matching between forward and reverse. I've wrote a little function on my side but it's redundant to perform this step and then the filtering.

Moreover, is it possible to make a trycatch approach for this step in order to not break the function when running a big data ?

Thx a lot

SgtVil avatar May 10 '22 11:05 SgtVil

The recommended solution here would be to make a little custom R code prior to running the workflow, so it sounds like you are doing the right thing. If you'd like to post the code you wrote, that could be helpful for others that run in to a similar problem.

Moreover, is it possible to make a trycatch approach for this step in order to not break the function when running a big data ?

I don't understand this bit.

benjjneb avatar May 10 '22 16:05 benjjneb

The code is clearly inspirated from your function FastqPairedFilter and is therefore "redundant", I basically just add a message().

search_mismatch = function(fastq_list_fwd, fastq_list_rev){
  fF <- FastqStreamer(fastq_list_fwd, n = 1e+06)
  fR <- FastqStreamer(fastq_list_rev, n = 1e+06)
  
  fqF <- suppressMessages(yield(fF, qualityType = "Auto"))
  fqR <- suppressMessages(yield(fR, qualityType = "Auto"))
  
  if(length(fqF) != length(fqR)){
    message(paste(fastq_list_fwd[[1]], "doesn't match rev"))
    return(fastq_list_fwd[[1]])
  }
}

For the tryCatch part, I was referring to a way of letting the function deal with errors such as mismatch fastq in order to let the function running despite the errors encountered. In my example only one sample out of 2800 was mismatched with his reverse counterpart.

Anyway, thx for the response and for the package Have a great day

SgtVil avatar May 10 '22 16:05 SgtVil