Mercurial > repos > artbio > mapping_quality_stats
annotate mapping_quality_stats.r @ 2:ce2d8f611a51 draft default tip
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/mapping_quality_stats commit 2661225fdd0f533d4dc8e2561ea559fcc00b9128
author | artbio |
---|---|
date | Sat, 10 Feb 2024 01:32:48 +0000 |
parents | f00479673d47 |
children |
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, |
2
ce2d8f611a51
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/mapping_quality_stats commit 2661225fdd0f533d4dc8e2561ea559fcc00b9128
artbio
parents:
0
diff
changeset
|
3 error = function() { |
ce2d8f611a51
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/mapping_quality_stats commit 2661225fdd0f533d4dc8e2561ea559fcc00b9128
artbio
parents:
0
diff
changeset
|
4 cat(geterrmessage(), file = stderr()) |
ce2d8f611a51
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/mapping_quality_stats commit 2661225fdd0f533d4dc8e2561ea559fcc00b9128
artbio
parents:
0
diff
changeset
|
5 q("no", 1, FALSE) |
ce2d8f611a51
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/mapping_quality_stats commit 2661225fdd0f533d4dc8e2561ea559fcc00b9128
artbio
parents:
0
diff
changeset
|
6 } |
0
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") |
2
ce2d8f611a51
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/mapping_quality_stats commit 2661225fdd0f533d4dc8e2561ea559fcc00b9128
artbio
parents:
0
diff
changeset
|
17 ) |
0
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() |