Mercurial > repos > jdv > nanopore_qc
diff nanopore_qc.R @ 6:0cf41189f086 draft
planemo upload for repository https://github.com/jvolkening/galaxy-tools/tree/master/tools/nanopore_qc commit 0d8d1ec70b450f96a29a98e4dec9688b18170d32
author | jdv |
---|---|
date | Sun, 12 Aug 2018 13:21:30 -0400 |
parents | 4b7d1bcf210c |
children |
line wrap: on
line diff
--- a/nanopore_qc.R Mon Mar 12 19:55:54 2018 -0400 +++ b/nanopore_qc.R Sun Aug 12 13:21:30 2018 -0400 @@ -56,11 +56,20 @@ help="The cutoff value for the mean Q score of a read (default 7). Used to create separate plots for reads above and below this threshold" ) +parser <- add_option(parser, + opt_str = c("-d", "--discard_failed"), + type="logical", + default=FALSE, + dest = 'filt.failed', + help="Discard reads that failed Albacore filtering" + ) + opt = parse_args(parser) -input.file = opt$input.file -output.dir = opt$output.dir -q = opt$q +input.file = opt$input.file +output.dir = opt$output.dir +filt.failed = opt$filt.failed +q = opt$q # this is how we label the reads at least as good as q q_title = paste("Q>=", q, sep="") @@ -123,6 +132,7 @@ # by default the lowest value is -Inf, i.e. includes all reads. The # other value in min.q is set by the user at the command line d = read_tsv(filepath, col_types = cols_only(channel = 'i', + passes_filtering = 'c', num_events_template = 'i', sequence_length_template = 'i', mean_qscore_template = 'n', @@ -146,6 +156,10 @@ # ignore 0-length reads d <- d[d$sequence_length_template > 0,] + # ignore reads failing filtering + if (filt.failed) { + d <- d[d$passes_filtering == 'True',] + } d$events_per_base = d$num_events_template/d$sequence_length_template @@ -173,7 +187,6 @@ d = d[keep] d$start_bin = cut(d$start_time, 9,labels=c(1:9)) - write.table(d,"foo.tsv",sep="\t",quote=F) return(d) }