#!/usr/bin/env Rscript

#
# Script: plot_repeat_family_barplot.R
#
# Author: Matej Lexa 
# Year: 2021
#
# This script is part of the HiC-TE Analysis pipeline for Nextflow
#
# It takes a data frame filename as input (as its single argument).
# The data frame has to be saved under the name 'tab' in .Rdata save()  
# format) and plots a frequency barplot for all repeat families present.
# The plot is printed to a PNG file.
#

# parse the arguments
args = commandArgs(trailingOnly=TRUE)
print(args)

# load data frame
load(args[1])

# plot and save as a PNG file
png(file = paste0("repeat_family_barplot.png"), units="in", width=6, height=6, res=300)
barplot(table(tab$family1), xlab="Repeat family", ylab="count", las=2)
dev.off()

