Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#!/usr/bin/env Rscript
args = commandArgs(trailingOnly=TRUE)
require(plyr, quietly = TRUE)
require(data.table, quietly = TRUE)
require(grid, quietly = TRUE)
require(gridExtra, quietly = TRUE)
path = args[1]
outfile = args[2]
chr <- args[3]
start <- args[4] ## 137189494
end <- args[5] ## 142385639
sample_name <- args[6]
reds.bed <- data.table::fread(path, header = FALSE, sep = "\t")
region_pairs <- subset(reds.bed, (V1 == chr & V2 >= start & V4 == chr & V6 <= end))
colnames(region_pairs) <- c("Chromosome_1", "Start_1", "End_1", "Chromosome_2", "Start_2", "End_2", "Strand", "Score" )
if(nrow(region_pairs) == 0){
stop("ERROR: No Interaktions found in Target Region")
}
count <- ddply(region_pairs,.(Chromosome_1, Start_1, End_1, Chromosome_2, Start_2, End_2, Strand , Score),nrow)
mean_interactions <- round(mean(count[,9]))
median_interactions <- median(count[,9])
interactions <- nrow(unique(region_pairs))
stats <- data.table::data.table(c(interactions),
c(mean_interactions))
rownames(stats) <- c(sample_name)
colnames(stats) <- c("Number of all Interactions", "Average Number of Read-Pairs per Interaction")
pdf(outfile, height=10, width=12.5)
grid.table(stats)
dev.off()
graphics.off()