-
Notifications
You must be signed in to change notification settings - Fork 5
/
Likelihood2long.pl
82 lines (77 loc) · 1.85 KB
/
Likelihood2long.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/perl
use strict;
use warnings;
#This script takes the likelihood input file and converts it to long format for R plotting
my %t;
$t{"Des1484"} = "Des";
$t{"des2458"} = "Des";
$t{"Sample-DES1476"} = "Des";
$t{"Ano1495"} = "Ano";
$t{"Sample-Ano1506"} = "Ano";
$t{"Sample-des1486"} = "Des";
$t{"Sample-Des2463"} = "Des";
$t{"Sample-desA2"} = "Des";
$t{"Sample-Goblinvalley"} = "Ano";
$t{"Sample-desc"} = "Des";
$t{"king141B"} = "Par";
$t{"king145B"} = "Par";
$t{"king147A"} = "Par";
$t{"King151"} = "Par";
$t{"king152"} = "Par";
$t{"King156B"} = "Par";
$t{"Sample-king1443"} = "Par";
$t{"Sample-king159B"} = "Par";
$t{"BOL1037"} = "Bol";
$t{"EXI2348"} = "Bol";
$t{"G111-14"} = "Bol";
$t{"ARG1805"} = "Arg";
$t{"ARG1820"} = "Arg";
$t{"btm10-5"} = "Arg";
$t{"RAR43"} = "Deb";
$t{"RAR57"} = "Deb";
$t{"btm30-4"} = "Deb";
$t{"RAR46"} = "Deb";
$t{"btm13-6"} = "Pra";
$t{"btm14-4"} = "Pra";
$t{"btm16-2"} = "Pra";
$t{"14TB-2"} = "Tex";
$t{"20TB-7"} = "Tex";
$t{"btm11-1"} = "Tex";
$t{"btm3-2"} = "Tex";
$t{"btm35-4"} = "Tex";
$t{"btm6-1"} = "Tex";
$t{"K111"} = "Tex";
$t{"TEX"} = "Tex";
my $in = $ARGV[0];
open IN, $in;
my %poplist;
while (<IN>){
chomp;
my @a = split(/\t/, $_);
if ($. == 1){
foreach my $i (4..$#a){
$poplist{$i} = $a[$i];
}
print "chrom\tstart\tend\tmidpoint\tn_sites\tspecies\tsample\tZscore\tassignment";
}else{
my $chrom = $a[0];
my $start = $a[1];
my $end = $a[2];
my $midpoint = ((($end - $start)/ 2) + $start);
my $n_sites = $a[3];
foreach my $i(4..$#a){
my $species = $t{$poplist{$i}};
my $sample = $poplist{$i};
my @info = split(/:/, $a[$i]);
my $Zscore = $info[1];
my $assignment = $info[0];
if ($assignment eq "NA"){
$assignment = "Unknown";
if ($Zscore eq "NA"){
$assignment = "NA";
}
}
print "\n$chrom\t$start\t$end\t$midpoint\t$n_sites\t$species\t$sample\t$Zscore\t$assignment";
}
}
}