-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_checkm.R
More file actions
executable file
·33 lines (22 loc) · 1021 Bytes
/
Copy pathplot_checkm.R
File metadata and controls
executable file
·33 lines (22 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
if (!require("pacman")) install.packages("pacman")
pacman::p_load(argparse, tidyverse, ggplot2, reshape2)
parser <- ArgumentParser(description="Takes results from checkm (results.tsv) and gives you contamination/completeness as a bar plot.")
parser$add_argument("-r", "--results", type="character", nargs=1,
help="Path to results.tsv file.")
parser$add_argument("-p", "--pdf", type="character", nargs=1,
help="Name of output pdf (include .pdf extension please)")
parser$add_argument("-t", "--title", type="character", nargs=1,
help="Title for your plot.")
args <- parser$parse_args()
checkm <- args$results
pdfout <- args$pdf
title = args$title
results <- read.csv(checkm, sep='\t')
head(results)
dfm <- melt(results[,c('Bin.Id','Completeness','Contamination')],id.vars = 1)
p <- ggplot(dfm,aes(x = Bin.Id,y = value)) +
geom_bar(aes(fill = variable),stat = "identity",position = "dodge") +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
ggtitle(title)
pdf(pdfout)
print(p)