annotate mapping_quality_stats.r @ 0:f00479673d47 draft

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
author artbio
date Wed, 15 Jun 2022 10:43:07 +0000
parents
children ce2d8f611a51
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
1 ## Setup R error handling to go to stderr
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
2 options(show.error.messages = FALSE,
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
3 error = function() {
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
4 cat(geterrmessage(), file = stderr())
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
5 q("no", 1, FALSE)
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
6 }
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
7 )
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
8
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
9
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
10 warnings()
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
11 library(optparse)
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
12 library(ggplot2)
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
13
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
14 option_list <- list(
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
15 make_option(c("-i", "--input"), type = "character", help = "Path to tabular file"),
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
16 make_option(c("-o", "--output"), type = "character", help = "path to the pdf plot")
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
17 )
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
18
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
19 parser <- OptionParser(usage = "%prog [options] file", option_list = option_list)
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
20 args <- parse_args(parser)
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
21
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
22 # data frame implementation
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
23 table <- read.delim(args$input, header = TRUE)
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
24 colnames(table) <- c("MAPQ", "Counts")
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
25
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
26
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
27 # Barplot
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
28 pdf(file = args$output)
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
29 ggplot(table, aes(x = MAPQ, y = Counts)) +
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
30 geom_bar(stat = "identity")
f00479673d47 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mapping_quality_stats commit e4b37874b820a2ac48732667128a08e5755b7c4b
artbio
parents:
diff changeset
31 devname <- dev.off()