Commit fd9307b5 authored by Evangelia Petsalaki's avatar Evangelia Petsalaki
Browse files

Initial commit

parents
To run simply type:
./wrapperInteractomeCleannew.pl 20180426_stable_orbitrap
or any of the files starting with 20180426 and without the .data at the end
#!/usr/bin/perl
open (IN,"$ARGV[0]")||die;
while(<IN>)
{
chomp;
if ($_=~/Sample Name/)
{
next;
}
@a=split/\t/;
$sample=$a[1];
$prot=$a[5];
$mascot=$a[8];
$data{$sample}.=$prot."\t".$mascot."\n";
}
close IN;
%decoysall=0;
%otherall=0;
foreach $s (keys %data)
{
@hits=split(/\n/,$data{$s});
for($co=25;$co<=50;$co+=5)
{
$dec=0;
$oth=0;
foreach $a (@hits)
{
@tmp=split(/\t/,$a);
if ($tmp[1]>=$co)
{
if ($tmp[0]=~/DECOY/)
{
$dec++;
$decoysall{$co}++;
}
else
{
$oth++;
$otherall{$co}++;
}
}
}
$fdr=0;
if ($dec+$oth==0)
{
$fdr='NA';
}
else
{
$fdr=$dec/($dec+$oth);
}
$det{$s}[$co]=$fdr;
}
}
open (OUT,">$ARGV[0].fdr")||die;
print OUT "sample\t25\t30\t35\t40\t45\t50\n";
foreach $s(keys %det)
{
print OUT $s,"\t";
for($co=25;$co<=50;$co+=5)
{
print OUT $det{$s}[$co],"\t";
}
print OUT "\n";
}
close OUT;
#!/usr/bin/perl
open (IN,"$ARGV[1].carryover")||die; #carry overfile
while(<IN>)
{
chomp;
@a=split/\t/;
$carryover{$a[0]}=1;
}
close IN;
open (IN,"$ARGV[0].data")||die; #datafile
while(<IN>)
{
chomp;
@a1=split/\t/;
$a=$a1[1]."-".$a1[4];
if ($carryover{$a}==1)
{
next;
}
else
{
print $_,"\n";
}
}
close IN;
This diff is collapsed.
#!/usr/bin/perl
if ($ARGV[0]=~/ltq1/)
{
$co=40;
}
else
{
$co=25;
}
open (IN,"$ARGV[0].nco.fdr")||die ;#$ARGV[0]nco.fdr
while(<IN>)
{
chomp;
if ($_=~/^sample/)
{
@cutoffs=split/\t/;
}
else
{
@a=split/\t/;
$s=$a[0];
foreach $i(1..$#a)
{
if ($a[$i]<=0.01)
{
$cutoff{$s}=$cutoffs[$i];
$fdr{$s}=$a[$i];
#print $s,"\t",$cutoff{$s},"\n";
last;
}
}
if ($cutoff{$s} eq '')
{
$cutoff{$s}=$cutoffs[$#a];
$fdr{$s}=$a[$#a];
}
}
}
close IN;
#print '2115_239_FAM13A_V4560_M2',"\t",$cutoff{'2115_239_FAM13A_V4560_M2'},"\n";
# exit;
open (IN,"$ARGV[0].nco")||die;
open (OUTA,">$ARGV[0]$co")||die;
open (OUTB,">$ARGV[0].coind")||die;
while(<IN>)
{
chomp;
@a=split/\t/;
if ($a[8]>=$co)
{
print OUTA $_,"\n";
}
#print $a[1],"\t",$cutoff{$a[1]},"\n";
if ($a[8]>=$cutoff{$a[1]})
{
print OUTB $_,"\t",$cutoff{$a[1]},": $fdr{$a[1]}\n";
}
}
close IN;
close OUTA;
close OUTB;
\ No newline at end of file
#!/usr/bin/perl
$sample=1;
$hit1=4;
$hitd=7;
$bait=3;
$totpep=9;
open (IN,"$ARGV[0]")|| die;
while(<IN>)
{
chomp;
@a=split/\t/;
if ($_=~/^Bait/)
{
next;
}
$id=$a[$bait];
$p=$a[$hit1];
$a1="$id - $p";
if ($baits!~/^$id$/m)
{
$baits.=$id."\n";
}
if ($preys!~/^$p$/m)
{
$preys.=$p."\n";
}
$totpeps{$a1}+=$a[$totpep];
$count{$a1}++;
}
close IN;
@b=split(/\n/,$baits);
@p=split(/\n/,$preys);
$compasscount=$#b+1;
foreach $a (keys %totpeps)
{
@tmp=split(/ - /,$a);
$totpeps_2{$a}/=$count{$a};
$totpeps{$a}/=$compasscount;
$avgtotpeps+=$totpeps{$a};
$avgtotpepscompass{$tmp[1]}+=$totpeps{$a};
$scorestotpepscompass{$tmp[1]}.=$totpeps{$a}." ";
$count++;
push @alltotpeps,$totpeps{$a};
}
$avgtotpeps/=$count;
foreach $a (keys %avgtotpepscompass) #get stddev for all preys
{
@tmp=split(/ /,$scorestotpepscompass{$a});
$c=$#tmp+1;
$avgtotpepscompass{$a}/=$compasscount;
foreach $a1 (@tmp)
{
$stotpepscompass{$a}=$stotpepscompass{$a}+(($a1-$avgtotpepscompass{$a})**2);
}
$stotpepscompass{$a}=sqrt($stotpepscompass{$a}/$compasscount);
if ($avgtotpepscompass{$a}==0)
{
$omegacompass{$a}=0;
}
else
{
$omegacompass{$a}=$stotpepscompass{$a}/$avgtotpepscompass{$a};
}
}
print "Bait\tPrey\tZ-score\tS-Score\tD-score\tWDscore\n";
foreach $a (keys %totpeps)
{
@tmp=split(/ - /,$a);
if ($stotpepscompass{$tmp[1]}!=0)
{
$zscorecompass{$a}=($totpeps{$a}-$avgtotpepscompass{$tmp[1]})/$stotpepscompass{$tmp[1]};
}
else
{
$zscorecompass{$a}=($totpeps{$a}-$avgtotpepscompass{$tmp[1]});
}
@tmp1=split(/ /,$scorestotpepscompass{$tmp[1]});
$n=$#tmp1+1;
$sscorecompass{$a}=sqrt(($compasscount/$n)*$totpeps{$a});
$dscorecompass{$a}=sqrt((($compasscount/$n)**$count{$a})*$totpeps{$a});
$wdscorecompass{$a}=sqrt((($compasscount*$omegacompass{$tmp[1]}/$n)**$count{$a})*$totpeps{$a});
print $tmp[0],"\t",$tmp[1],"\t",$zscorecompass{$a},"\t",$sscorecompass{$a},"\t",$dscorecompass{$a},"\t",$wdscorecompass{$a},"\n";
}
This diff is collapsed.
#!/usr/bin/perl
$file=$ARGV[0];
open (IN,"knownoverlaphippieall")||die;
while(<IN>)
{
chomp;
@a=split/\t/;
if ($a[0]>0.75)
{
$int=$a[2]."\t".$a[4];
$known{$int}=1;
$int=$a[4]."\t".$a[2];
$known{$int}=1;
}
}
close IN;
open (IN,"$file.coind")||die;
while(<IN>)
{
chomp;
@a=split/\t/;
$geneid{$a[3]}=$a[0];
$geneid{$a[4]}=$a[2];
}
close IN;
open (IN,"$ARGV[1].cherry")||die;
while(<IN>)
{
chomp;
$cherry{$_}=1;
}
close IN;
$maxscore=0;
$minscore=10000;
open (IN,"$file.clean.compass")||die;
while(<IN>)
{
chomp;
@a=split/\t/;
if ($a[0] eq 'Bait')
{
next;
}
$pair=$a[0]."\t".$a[1];
$int=$geneid{$a[0]}."\t".$geneid{$a[1]};
if ($a[1]=~/Cherry/i || $_=~/DECOY/)
{
next;
}
if ($a[2])
{
$a1=$a[2];
}
else
{
$a1=0;
}
if ($a1>$maxscore)
{
$maxscore=$a1;
}
if ($a1<$minscore)
{
$minscore=$a1;
}
if ($cherry{$a[1]}==1)
{
push @negall,$a[2];
}
else
{
push @allall,$a[2];
}
if($known{$int}==1)
{
push @knownall,$a[2];
}
}
close IN;
$step=($maxscore-$minscore)/30;
foreach $a (@negall)
{
for ($c=$minscore;$c<=$maxscore;$c+=$step)
{
if ($a>=$c)
{
$fpall{$c}++;
}
elsif ($a<$c )
{
$tnall{$c}++;
}
}
}
foreach $a (@knownall)
{
for ($c=$minscore;$c<=$maxscore;$c+=$step)
{
if ($a>=$c)
{
$tpall{$c}++;
}
elsif ($a<$c )
{
$fnall{$c}++;
}
}
}
foreach $a (@allall)
{
for ($c=$minscore;$c<=$maxscore;$c+=$step)
{
if ($a>=$c)
{
$tp1all{$c}++;
}
elsif ($a<$c)
{
$fn1all{$c}++;
}
}
}
for($c=$minscore;$c<=$maxscore;$c+=$step)
{
$tp1all{$c}/=($#allall+1);
$fn1all{$c}/=($#allall+1);
if ($#knownall==-1)
{
$tpall{$c}=0;
$fnall{$c}=0;
}
else
{
$tpall{$c}/=($#knownall+1);
$fnall{$c}/=($#knownall+1);
}
if ($#negall+1)
{
$tnall{$c}/=($#negall+1);
$fpall{$c}/=($#negall+1);
}
else
{
$tnall{$c}=0;
$fpall{$c}=0;
}
if ($fpall{$c}==0 && $tpall{$c}==0)
{
$precision=0;
}
else
{
$precision=$tpall{$c}/($tpall{$c}+$fpall{$c});
}
if ($tpall{$c}==0 && $fnall{$c}==0)
{
$precision=0;
}
else
{
$recall=$tpall{$c}/($tpall{$c}+$fnall{$c});
}
$abc=(sqrt(($tpall{$c}+$fpall{$c})*($tpall{$c}+$fnall{$c})*($tnall{$c}+$fpall{$c})*($tnall{$c}+$fnall{$c})));
if ($abc)
{
$mcc=($tpall{$c}*$tnall{$c}-$fpall{$c}*$fnall{$c})/(sqrt(($tpall{$c}+$fpall{$c})*($tpall{$c}+$fnall{$c})*($tnall{$c}+$fpall{$c})*($tnall{$c}+$fnall{$c})));
}
else
{
$mcc=0;
}
print $c,"\t",$precision,"\t",$recall,"\t",$mcc,"\n";
}
#!/usr/bin/perl
$file=$ARGV[0];
open (IN,"knownoverlaphippieall")||die;
while(<IN>)
{
chomp;
@a=split/\t/;
if ($a[0]>0.75)
{
$int=$a[2]."\t".$a[4];
$known{$int}=1;
$int=$a[4]."\t".$a[2];
$known{$int}=1;
}
}
close IN;
open (IN,"$file.coind")||die;
while(<IN>)
{
chomp;
@a=split/\t/;
$geneid{$a[3]}=$a[0];
$geneid{$a[4]}=$a[2];
}
close IN;
open (IN,"$ARGV[1].cherry")||die;
while(<IN>)
{
chomp;
$cherry{$_}=1;
}
close IN;
open (IN,"$file.outfreq")||die;
while(<IN>)
{
chomp;
@a=split/\t/;
$pair=$a[0]."\t".$a[1];
$int=$geneid{$a[0]}."\t".$geneid{$a[1]};
if ($a[1]=~/Cherry/i || $_=~/DECOY/)
{
next;
}
if ($cherry{$a[1]}==1)
{
push @negall,$a[$#a];
}
else
{
push @allall,$a[$#a];
}
if($known{$int}==1)
{
push @knownall,$a[$#a];
}
}
close IN;
foreach $a (@negall)
{
for ($c=0.00;$c<=1;$c+=0.01)
{
if ($a<$c)
{
$fpall{$c}++;
}
elsif ($a>=$c )
{
$tnall{$c}++;
}
}
}
foreach $a (@knownall)
{
for ($c=0.0;$c<=1;$c+=0.01)
{
if ($a<$c)
{
$tpall{$c}++;
}
elsif ($a>=$c )
{
$fnall{$c}++;
}
}
}
foreach $a (@allall)
{
for ($c=0.0;$c<=1;$c+=0.01)
{
if ($a<$c)
{
$tp1all{$c}++;
}
elsif ($a>=$c)
{
$fn1all{$c}++;
}
}
}