Alternative content
use strict;
use warnings;
use Statistics::R ;
use List::Util qw(sum);
#Usage perl clockPlot.pl Palindrome.palfc 1500
my $R = Statistics::R->new() ;
$R->startR ;
my $fileN=$ARGV[0];
my $mSize=$ARGV[1];
open (my $fh2, $fileN) or die "Could not open file $fileN $!";
my (@allKeys, @allFreq); my %pHash;
while(<$fh2>) {
chomp;
next if /^$/; #next if empty
my @arr = split("\t", $_);
if ($arr[7] eq "-") {
my $len=$arr[5]-$arr[4];
#next if $len < $mSize;
my @chr = split '\_', $arr[1];
$chr[0] =~ s/[a-z]//g;
my $newChr="$chr[0]"."_"."$arr[3]";
$pHash{$newChr}++;
}
}
foreach my $val (keys %pHash) {
#next if $pHash{$val} > 10;
my @sChr = split '\_', $val;
my $score=$pHash{$val}/$sChr[1];
push @allKeys, $sChr[0];
push @allFreq, $score;
}
my $allKeys=join ',', @allKeys;
my $allFreq=join ',', @allFreq;
my $hLen=scalar (@allKeys);
my $ll="$hLen".'L';
$R->run(qq`
d <- structure(list(Chromosome = c($allKeys), Frequency = c($allFreq)), .Names = c("Chromosome", "Frequency"
), row.names = c(NA, $ll), class = "data.frame")
str(d)
library(ggplot2)
ggplot(d , aes(x = Chromosome, y = Frequency, fill=Frequency)) +
coord_polar(theta = "x", start = -pi/5) +
geom_bar(stat = "identity") +
scale_x_continuous(breaks = seq(0, $hLen, 50))`);
$R->stopR() ;