Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
Skip sample if no reads survive length filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
MaestSi authored Sep 21, 2019
1 parent b11ede3 commit 3bbd41e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion MinION_mobile_lab.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ cat(text = "\n")

cat(text = paste0("Demultiplexing started at ", date()), file = logfile, sep = "\n", append = TRUE)
cat(text = paste0("Demultiplexing started at ", date()), sep = "\n")
system(paste0(demultiplexer, " -r -i ", d2_basecalling, " -t ", num_threads, " -s ", d2_preprocessing, " --barcode_kits \"", paste0(barcode_kits, collapse = " "), "\"", " --kit ", kit))
system(paste0(demultiplexer, " -r -i ", d2_basecalling, " -t ", num_threads, " -s ", d2_preprocessing, " --barcode_kits \"", paste0(barcode_kits, collapse = " "), "\""))
cat(text = paste0("Demultiplexing finished at ", date()), file = logfile, sep = "\n", append = TRUE)
cat(text = paste0("Demultiplexing finished at ", date()), sep = "\n")
cat(text = "\n", file = logfile, append = TRUE)
Expand Down Expand Up @@ -259,6 +259,15 @@ for (i in 1:length(demu_files)) {
cat(text = paste0("Now filtering out reads shorter than ", sprintf("%.0f", lb), " and longer than ", sprintf("%.0f", ub), " bp for sample BC", BC_val_curr), sep = "\n")
system(paste0("cat ", d2_preprocessing, "/BC", BC_val_curr, "_tmp2.fastq | ", remove_long_short, " ", lb, " ", ub, " > ", d3, "/BC", BC_val_curr, ".fastq"))
system(paste0(SEQTK, " seq -A ", d3, "/BC", BC_val_curr, ".fastq > ", d3, "/BC", BC_val_curr, ".fasta"))
if (length(grep(x = readLines(paste0( d3, "/BC", BC_val_curr, ".fasta")), pattern = "^>")) < 2) {
cat(text = paste0("WARNING: skipping sample BC", BC_val_curr, ", since no reads survived the length filtering!"), file = logfile, sep = "\n", append = TRUE)
cat(text = paste0("WARNING: skipping sample BC", BC_val_curr, ", since no reads survived the length filtering!"), sep = "\n")
cat(text = "\n", file = logfile, append = TRUE)
cat(text = "\n")
system(paste0("rm ", d3, "/BC", BC_val_curr, ".fastq"))
system(paste0("rm ", d3, "/BC", BC_val_curr, ".fasta"))
next
}
cat(text = paste0("Mean read length for sample BC", BC_val_curr, " after filtering: ", sprintf("%.0f", mean(ws_ok)), " (", sprintf("%.0f", sd(ws_ok)), ")"), file = logfile, sep = "\n", append = TRUE)
cat(text = paste0("Mean read length for sample BC", BC_val_curr, " after filtering: ", sprintf("%.0f", mean(ws_ok)), " (", sprintf("%.0f", sd(ws_ok)), ")"), sep = "\n")
png(paste0(d2, "/qc/hist_BC", BC_val_curr, "_unfiltered.png"))
Expand Down

0 comments on commit 3bbd41e

Please sign in to comment.