#!/usr/bin/perl use warnings; use Getopt::Long; use Getopt::ArgvFile; use Math::Interpolate qw(derivatives robust_interpolate); use Math::Round; use List::Util qw(max); @peaks = $ARGV[0]; open ( IN, "@peaks" ) or die "Can't open file: $!"; while () { chomp; my @fields = split ("\t",$_); my @x=(0,$fields[4]*.25,$fields[4],($fields[3]-($fields[3]*0.25)),$fields[3]); # these are the training X-values my @y=(0,$fields[6]*0.4,$fields[6],$fields[6]*0.4,0); # these are the training Y-values my @dy = derivatives(\@x, \@y); my $iter=1; print "fixedStep chrom=$fields[0] start=$fields[1] step=1\n"; while ($iter <= $fields[3]) { my ($r_y, $r_dy) = robust_interpolate($iter, \@x, \@y); my @ynew2 = nearest(0.01,($r_y)); print "@ynew2\n"; $iter ++; } } close IN;