annotate DrawMapOfOccurences.pl @ 0:e94de0ea3351 draft default tip

Uploaded
author dereeper
date Wed, 11 Sep 2013 09:08:15 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
1 #!/usr/bin/perl
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
2
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
3 use strict;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
4 use Switch;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
5 use Getopt::Long;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
6 use lib ".";
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
7
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
8 my $usage = qq~Usage:$0 <args>
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
9 where <args> are:
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
10 -c, --count <SNP count SNiPloid output>
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
11 -a, --annotation <annotation file in GFF3>
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
12 -o, --output_png <output PNG file>
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
13 -s, --scale <scale. Default:100000>
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
14 -t, --type_analysis <type of analysis: polyploid_diploid or polyploid_polyploid. Default:polyploid_diploid>
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
15 -m, --max_nb_chrom <maximum number of chromomsome to display. Default:20>
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
16 -n, --nb_min_snp <minimal number of SNP to calculate ratio. Default:10>
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
17 -d, --display_cat <display ratio for each category instead of intra-polyploid and inter-diploid (yes/no). Default:no>
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
18 ~;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
19 $usage .= "\n";
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
20
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
21 my ($snp_count,$annotation,$output_png,$global_scale,$max_nb_chrom,$type_analysis);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
22
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
23 my $global_scale = 10000;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
24 my $max_nb_chrom = 20;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
25 my $nb_min_snp = 10;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
26 my $display_cat = "no";
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
27
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
28
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
29 GetOptions(
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
30 "count=s" => \$snp_count,
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
31 "annotation=s" => \$annotation,
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
32 "output_png=s" => \$output_png,
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
33 "scale=s" => \$global_scale,
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
34 "max_nb_chrom=s" => \$max_nb_chrom,
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
35 "type_analysis=s" => \$type_analysis,
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
36 "nb_min_snp=s" => \$nb_min_snp,
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
37 "display_cat=s" => \$display_cat
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
38 );
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
39
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
40
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
41 die $usage
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
42 if ( !$snp_count || !$annotation || !$output_png || !$type_analysis);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
43
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
44 my %proportions_categories;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
45 my %ratios;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
46 my %ratios_poly_diploid;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
47 my %nb_snps;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
48 open(my $COUNT,$snp_count);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
49 <$COUNT>;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
50 while(<$COUNT>)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
51 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
52 my $line =$_;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
53 chomp($line);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
54 my @infos = split(/\t/,$line);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
55
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
56
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
57 if ($type_analysis eq "polyploid_diploid")
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
58 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
59 my $gene = $infos[0];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
60 my $nb_snp = $infos[2];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
61 my $nb_1 = $infos[3];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
62 my $nb_2 = $infos[4];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
63 my $nb_3or4 = $infos[5];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
64 my $nb_3 = $infos[6];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
65 my $nb_4 = $infos[7];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
66 my $nb_5 = $infos[8];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
67 my $nb_other = $infos[9];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
68 my $nb_heterozygot_diploid = $infos[10];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
69 my $nb_snp_diploid = $infos[11];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
70 my $nb_snp_polyploid = $infos[12];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
71
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
72 $nb_snps{$gene} = $nb_snp;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
73 my $sum = $nb_1 + $nb_2 + $nb_3or4 + $nb_5 + $nb_3 + $nb_4 + $nb_other + $nb_heterozygot_diploid;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
74
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
75 if ($nb_snp >= $nb_min_snp)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
76 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
77 if ($nb_1)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
78 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
79 $proportions_categories{$gene}{"1"} = $nb_1/$nb_snp;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
80 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
81 if ($nb_2)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
82 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
83 $proportions_categories{$gene}{"2"} = $nb_2/$nb_snp;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
84 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
85 if ($nb_5)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
86 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
87 $proportions_categories{$gene}{"5"} = $nb_5/$nb_snp;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
88 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
89 if ($nb_3or4)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
90 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
91 $proportions_categories{$gene}{"3or4"} = $nb_3or4/$nb_snp;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
92 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
93 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
94
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
95 my $ratio_g1 = $infos[13];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
96 my $ratio_g2 = $infos[14];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
97
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
98 if ($ratio_g1)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
99 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
100 $ratios{$gene} = $ratio_g1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
101 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
102 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
103
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
104 if ($type_analysis eq "polyploid_polyploid")
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
105 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
106 my $gene = $infos[0];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
107 my $nb_snp = $infos[2];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
108 my $nb_equal = $infos[3] + $infos[4];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
109 my $nb_diff = $infos[7];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
110 $nb_snps{$gene} = $nb_snp;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
111 if ($nb_snp >= $nb_min_snp)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
112 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
113 if ($nb_equal)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
114 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
115 $proportions_categories{$gene}{"equal"} = $nb_equal/$nb_snp;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
116 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
117 if ($nb_diff)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
118 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
119 $proportions_categories{$gene}{"difference"} = $nb_diff/$nb_snp;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
120 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
121 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
122 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
123
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
124 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
125 close($COUNT);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
126
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
127
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
128
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
129
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
130 my $max_pos = 0;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
131 my %chrom_sizes;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
132 my $chrom_particule;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
133 my %genes;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
134 my %gene_positions;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
135
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
136 open(my $ANNOT,$annotation);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
137 while(<$ANNOT>)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
138 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
139 my $line =$_;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
140 chomp($line);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
141 if (!/^#/ && /gene/)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
142 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
143 my @infos = split(/\t/,$line);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
144 my $chrom = $infos[0];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
145 if ($chrom =~/^(\w+_)(\d+)$/)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
146 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
147 $chrom_particule = $1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
148 $chrom = $2;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
149 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
150
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
151 my $attributes = $infos[8];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
152 my $gene_name;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
153 if ($attributes =~/Name=([^;]+);/)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
154 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
155 $gene_name = $1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
156 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
157 if (!$gene_name && $attributes =~/ID=([^;]+);/)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
158 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
159 $gene_name = $1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
160 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
161 if ($gene_name =~/(.*)_G1/)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
162 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
163 $gene_name = $1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
164 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
165 else
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
166 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
167 next;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
168 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
169 if (not defined $nb_snps{$gene_name})
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
170 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
171 next;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
172 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
173
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
174 my $start = $infos[3];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
175 my $end = $infos[4];
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
176 my $pos = sprintf("%.0f", ($start + (($end - $start) / 2)));
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
177
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
178 $end = $end / $global_scale;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
179 if ($chrom_sizes{$chrom})
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
180 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
181 if ($end > $chrom_sizes{$chrom})
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
182 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
183 $chrom_sizes{$chrom} = $end;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
184 if ($end > $max_pos)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
185 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
186 $max_pos = $end;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
187 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
188 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
189 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
190 else
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
191 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
192 $chrom_sizes{$chrom} = $end;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
193 if ($end > $max_pos)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
194 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
195 $max_pos = $end;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
196 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
197 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
198 $genes{$gene_name} = "$chrom:$pos";
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
199 $gene_positions{$chrom}{$pos}= $gene_name;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
200 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
201 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
202 close($ANNOT);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
203
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
204
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
205
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
206 use GD;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
207 use GD::Simple;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
208 use GD::Image;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
209
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
210
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
211
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
212
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
213 ####################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
214 # drawing
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
215 ####################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
216
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
217 my $scale = 800 / $max_pos;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
218
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
219 my $margin_left = 80;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
220 my $margin_right = 50;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
221 my $margin_top = 50;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
222 my $margin_legend = 100;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
223 my $margin_bottom = 10;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
224 my $margin_between_chromosomes = 25;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
225 my $margin_between_section = 50;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
226 my $chrom_width = 10;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
227 my $gene_width = 1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
228
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
229 my $nb_group = 1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
230
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
231 my $width_of_picture = scalar keys(%gene_positions);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
232 if (scalar keys(%gene_positions) > $max_nb_chrom)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
233 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
234 $width_of_picture = $max_nb_chrom;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
235 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
236
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
237 my $diagram_img = GD::Simple->new(($margin_left + $margin_right + ($max_pos*$scale)),
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
238 ($margin_top + ((($chrom_width * $nb_group) + ($margin_between_chromosomes * ($nb_group-1))) * $width_of_picture) + ($margin_between_section * $width_of_picture) + $margin_bottom + $margin_legend)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
239 );
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
240
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
241 my $yellow = $diagram_img->colorAllocate(247,254,46);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
242 my $orange_light = $diagram_img->colorAllocate(250,204,46);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
243 my $red_light = $diagram_img->colorAllocate(254,100,46);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
244 my $red = $diagram_img->colorAllocate(254,46,46);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
245 my $orange = $diagram_img->colorAllocate(254,154,46);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
246
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
247
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
248 # draw chromosomes
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
249 my $num_chrom = 0;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
250 my @sorted_chrom = sort {$a <=> $b} keys(%gene_positions);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
251
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
252 my $nombre_genes = 0;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
253 my $y_end;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
254 foreach my $chrom(@sorted_chrom)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
255 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
256 if (!$chrom)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
257 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
258 next;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
259 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
260
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
261 if ($num_chrom > ($max_nb_chrom - 1))
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
262 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
263 last;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
264 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
265 my $ref_hash = $gene_positions{$chrom};
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
266 my %hash = %$ref_hash;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
267
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
268 my $section_size = $chrom_width + (($margin_between_chromosomes + $chrom_width) * ($nb_group - 1));
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
269
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
270 # draw chromosome (X number of groups)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
271
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
272 $diagram_img->fgcolor('black');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
273 $diagram_img->bgcolor('white');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
274 $diagram_img->setThickness(1);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
275 my $chrom_chain = $chrom_particule . $chrom;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
276
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
277 $diagram_img->rectangle( $margin_left,
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
278 $margin_top + (($section_size + $margin_between_section) * $num_chrom),
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
279 $margin_left + ($chrom_sizes{$chrom}*$scale),
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
280 $margin_top + $chrom_width + (($section_size + $margin_between_section) * $num_chrom)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
281 );
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
282
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
283 $diagram_img->fgcolor('black');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
284 $diagram_img->moveTo(5,$margin_top + $chrom_width + (($section_size + $margin_between_section) * $num_chrom) - 1);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
285 $y_end = $margin_top + $chrom_width + (($section_size + $margin_between_section) * ($num_chrom+1)) - 1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
286 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
287 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
288 $diagram_img->string($chrom_particule . $chrom);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
289
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
290
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
291 my $previous_x_5;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
292 my $previous_x_1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
293 my $previous_x_2;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
294 my $previous_x_3or4;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
295 my $previous_y_5;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
296 my $previous_y_1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
297 my $previous_y_2;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
298 my $previous_y_3or4;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
299
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
300 my $previous_x_equal;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
301 my $previous_x_diff;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
302 my $previous_y_equal;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
303 my $previous_y_diff;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
304
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
305 my $previous_x_snp_diplo;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
306 my $previous_x_snp_poly;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
307 my $previous_y_snp_diplo;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
308 my $previous_y_snp_poly;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
309
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
310 my $previous_x_ratio_diplo_poly;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
311 my $previous_y_ratio_diplo_poly;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
312
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
313 # draw genes
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
314 foreach my $pos(sort{$a <=> $b}keys(%hash))
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
315 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
316 my $gene = $gene_positions{$chrom}{$pos};
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
317 if (not defined $nb_snps{$gene} or $nb_snps{$gene} < $nb_min_snp)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
318 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
319 next;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
320 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
321
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
322 if ($type_analysis eq "polyploid_diploid")
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
323 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
324 #####################################################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
325 # draw ratio (subgenomic contribution)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
326 #####################################################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
327 my $color = "gray";
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
328 if ($ratios{$gene})
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
329 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
330 my $ratio_g1 = $ratios{$gene};
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
331 if ($ratio_g1 <= 30)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
332 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
333 $color = $red;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
334 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
335 elsif ($ratio_g1 > 30 && $ratio_g1 <= 40)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
336 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
337 $color = $red_light;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
338 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
339 elsif ($ratio_g1 > 40 && $ratio_g1 <= 60)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
340 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
341 $color = $orange;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
342 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
343 elsif ($ratio_g1 > 60 && $ratio_g1 <= 70)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
344 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
345 $color = $orange_light;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
346 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
347 elsif ($ratio_g1 > 70)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
348 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
349 $color = $yellow;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
350 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
351 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
352
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
353 $pos = $pos / $global_scale;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
354
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
355 $diagram_img->fgcolor($color);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
356 $diagram_img->bgcolor($color);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
357 $diagram_img->rectangle( $margin_left + ($pos*$scale) - ($gene_width / 2),
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
358 $margin_top + (($section_size + $margin_between_section) * $num_chrom) + 1,
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
359 $margin_left + ($pos*$scale) + ($gene_width / 2),
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
360 $margin_top + $chrom_width + (($section_size + $margin_between_section) * $num_chrom) - 1
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
361 );
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
362
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
363
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
364
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
365 #####################################################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
366 # draw SNP categories
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
367 #####################################################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
368
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
369 my $proportion_5 = $proportions_categories{$gene}{"5"};
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
370 my $proportion_1 = $proportions_categories{$gene}{"1"};
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
371 my $proportion_2 = $proportions_categories{$gene}{"2"};
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
372 my $proportion_3or4 = $proportions_categories{$gene}{"3or4"};
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
373 my $ratio_poly_diplo = $ratios_poly_diploid{$gene};
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
374
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
375 my $draw = 0;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
376 if (defined $previous_x_5)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
377 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
378 $draw = 1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
379 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
380
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
381
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
382 #######################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
383 # SNP category 5
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
384 #######################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
385 if ($draw)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
386 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
387 $diagram_img->moveTo($previous_x_5,$previous_y_5);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
388 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
389 $previous_x_5 = $margin_left + ($pos*$scale) - 1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
390 $diagram_img->setThickness(2);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
391 $diagram_img->fgcolor("red");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
392 $diagram_img->bgcolor("red");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
393 $previous_y_5 = $margin_top + (($section_size + $margin_between_section) * $num_chrom) + 1 - ($proportion_5 * 20) - 7;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
394 if ($draw)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
395 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
396 $diagram_img->lineTo($previous_x_5,$previous_y_5);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
397 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
398
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
399 if ($display_cat eq "yes")
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
400 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
401 #######################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
402 # SNP category 1
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
403 #######################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
404 if ($draw)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
405 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
406 $diagram_img->moveTo($previous_x_1,$previous_y_1);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
407 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
408 $previous_x_1 = $margin_left + ($pos*$scale) - 1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
409 $diagram_img->fgcolor("orange");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
410 $diagram_img->bgcolor("orange");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
411 $previous_y_1 = $margin_top + (($section_size + $margin_between_section) * $num_chrom) + 1 - ($proportion_1 * 20) - 7;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
412 if ($draw)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
413 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
414 $diagram_img->lineTo($previous_x_1,$previous_y_1);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
415 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
416
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
417
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
418 #######################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
419 # SNP category 2
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
420 #######################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
421 if ($draw)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
422 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
423 $diagram_img->moveTo($previous_x_2,$previous_y_2);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
424 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
425 $previous_x_2 = $margin_left + ($pos*$scale) - 1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
426 $diagram_img->fgcolor("purple");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
427 $diagram_img->bgcolor("purple");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
428 $previous_y_2 = $margin_top + (($section_size + $margin_between_section) * $num_chrom) + 1 - ($proportion_2 * 20) - 7;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
429 if ($draw)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
430 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
431 $diagram_img->lineTo($previous_x_2,$previous_y_2);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
432 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
433
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
434
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
435 #######################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
436 # SNP category 3 or 4
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
437 #######################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
438 if ($draw)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
439 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
440 $diagram_img->moveTo($previous_x_3or4,$previous_y_3or4);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
441 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
442 $previous_x_3or4 = $margin_left + ($pos*$scale) - 1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
443 $diagram_img->fgcolor("green");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
444 $diagram_img->bgcolor("green");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
445 $previous_y_3or4 = $margin_top + (($section_size + $margin_between_section) * $num_chrom) + 1 - ($proportion_3or4 * 20) - 7;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
446 if ($draw)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
447 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
448 $diagram_img->lineTo($previous_x_3or4,$previous_y_3or4);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
449 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
450 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
451
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
452 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
453
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
454 if ($type_analysis eq "polyploid_polyploid")
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
455 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
456 my $color = "gray";
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
457 $pos = $pos / $global_scale;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
458
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
459 $diagram_img->fgcolor($color);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
460 $diagram_img->bgcolor($color);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
461 $diagram_img->rectangle( $margin_left + ($pos*$scale) - ($gene_width / 2),
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
462 $margin_top + (($section_size + $margin_between_section) * $num_chrom) + 1,
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
463 $margin_left + ($pos*$scale) + ($gene_width / 2),
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
464 $margin_top + $chrom_width + (($section_size + $margin_between_section) * $num_chrom) - 1
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
465 );
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
466
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
467
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
468
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
469 my $proportion_equal = $proportions_categories{$gene}{"equal"};
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
470 my $proportion_diff = $proportions_categories{$gene}{"difference"};
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
471
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
472 my $draw = 0;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
473 if (defined $previous_x_equal)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
474 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
475 $draw = 1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
476 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
477
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
478
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
479 ##################################################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
480 # SNP category : equality between 2 polyploids
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
481 ##################################################
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
482 if ($draw)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
483 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
484 $diagram_img->moveTo($previous_x_equal,$previous_y_equal);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
485 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
486 $previous_x_equal = $margin_left + ($pos*$scale) - 1;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
487 $diagram_img->setThickness(2);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
488 $diagram_img->fgcolor("red");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
489 $diagram_img->bgcolor("red");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
490 $previous_y_equal = $margin_top + (($section_size + $margin_between_section) * $num_chrom) + 1 - ($proportion_equal * 20) - 7;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
491 if ($draw)
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
492 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
493 $diagram_img->lineTo($previous_x_equal,$previous_y_equal);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
494 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
495 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
496
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
497 $nombre_genes++;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
498 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
499
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
500 $num_chrom++;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
501 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
502
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
503 if ($type_analysis eq "polyploid_polyploid")
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
504 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
505 $diagram_img->moveTo(5,$y_end);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
506 $diagram_img->setThickness(2);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
507 $diagram_img->fgcolor("red");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
508 $diagram_img->bgcolor("red");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
509 $diagram_img->lineTo(25,$y_end);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
510 $diagram_img->fgcolor("black");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
511 $diagram_img->moveTo(30,$y_end + 5);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
512 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
513 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
514 $diagram_img->string("% SNP where P1 = P2");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
515 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
516 elsif ($type_analysis eq "polyploid_diploid")
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
517 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
518 if ($display_cat eq "yes")
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
519 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
520 $diagram_img->moveTo(5,$y_end);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
521 $diagram_img->setThickness(2);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
522 $diagram_img->fgcolor("orange");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
523 $diagram_img->bgcolor("orange");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
524 $diagram_img->lineTo(25,$y_end);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
525 $diagram_img->fgcolor("black");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
526 $diagram_img->moveTo(30,$y_end + 5);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
527 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
528 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
529 $diagram_img->string("% SNP type 1");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
530
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
531 $diagram_img->moveTo(5,$y_end + 20);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
532 $diagram_img->setThickness(2);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
533 $diagram_img->fgcolor("purple");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
534 $diagram_img->bgcolor("purple");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
535 $diagram_img->lineTo(25,$y_end + 20);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
536 $diagram_img->fgcolor("black");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
537 $diagram_img->moveTo(30,$y_end + 25);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
538 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
539 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
540 $diagram_img->string("% SNP type 2");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
541
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
542 $diagram_img->moveTo(5,$y_end + 40);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
543 $diagram_img->setThickness(2);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
544 $diagram_img->fgcolor("green");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
545 $diagram_img->bgcolor("green");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
546 $diagram_img->lineTo(25,$y_end + 40);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
547 $diagram_img->fgcolor("black");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
548 $diagram_img->moveTo(30,$y_end + 45);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
549 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
550 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
551 $diagram_img->string("% SNP type 3 or 4");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
552
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
553 $diagram_img->moveTo(5,$y_end + 60);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
554 $diagram_img->setThickness(2);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
555 $diagram_img->fgcolor("red");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
556 $diagram_img->bgcolor("red");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
557 $diagram_img->lineTo(25,$y_end + 60);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
558 $diagram_img->fgcolor("black");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
559 $diagram_img->moveTo(30,$y_end + 65);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
560 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
561 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
562 $diagram_img->string("% SNP type 5");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
563 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
564 else
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
565 {
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
566 $diagram_img->moveTo(5,$y_end);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
567 $diagram_img->setThickness(2);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
568 $diagram_img->fgcolor("red");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
569 $diagram_img->bgcolor("red");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
570 $diagram_img->lineTo(25,$y_end);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
571 $diagram_img->fgcolor("black");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
572 $diagram_img->moveTo(30,$y_end + 5);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
573 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
574 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
575 $diagram_img->string("% SNP Class 5 per gene (SNP Intra-Diploids = SNP Intra-Polyploid)");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
576 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
577
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
578 $diagram_img->moveTo(5,$y_end + 30);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
579 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
580 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
581 $diagram_img->string("Estimate of subgenomic contribution to the transcriptome for each gene (%G2)");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
582
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
583
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
584 $diagram_img->moveTo(25,$y_end + 45);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
585 $diagram_img->setThickness(10);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
586 $diagram_img->fgcolor($red);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
587 $diagram_img->bgcolor($red);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
588 $diagram_img->lineTo(30,$y_end + 45);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
589 $diagram_img->fgcolor("black");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
590 $diagram_img->moveTo(35,$y_end + 50);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
591 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
592 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
593 $diagram_img->string("0-30%");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
594
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
595 $diagram_img->moveTo(95,$y_end + 45);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
596 $diagram_img->setThickness(10);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
597 $diagram_img->fgcolor($red_light);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
598 $diagram_img->bgcolor($red_light);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
599 $diagram_img->lineTo(100,$y_end + 45);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
600 $diagram_img->fgcolor("black");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
601 $diagram_img->moveTo(105,$y_end + 50);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
602 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
603 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
604 $diagram_img->string("30-40%");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
605
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
606 $diagram_img->moveTo(165,$y_end + 45);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
607 $diagram_img->setThickness(10);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
608 $diagram_img->fgcolor($orange);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
609 $diagram_img->bgcolor($orange);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
610 $diagram_img->lineTo(170,$y_end + 45);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
611 $diagram_img->fgcolor("black");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
612 $diagram_img->moveTo(175,$y_end + 50);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
613 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
614 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
615 $diagram_img->string("40-60%");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
616
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
617 $diagram_img->moveTo(235,$y_end + 45);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
618 $diagram_img->setThickness(10);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
619 $diagram_img->fgcolor($orange_light);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
620 $diagram_img->bgcolor($orange_light);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
621 $diagram_img->lineTo(240,$y_end + 45);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
622 $diagram_img->fgcolor("black");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
623 $diagram_img->moveTo(245,$y_end + 50);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
624 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
625 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
626 $diagram_img->string("60-70%");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
627
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
628 $diagram_img->moveTo(305,$y_end + 45);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
629 $diagram_img->setThickness(10);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
630 $diagram_img->fgcolor($yellow);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
631 $diagram_img->bgcolor($yellow);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
632 $diagram_img->lineTo(310,$y_end + 45);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
633 $diagram_img->fgcolor("black");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
634 $diagram_img->moveTo(315,$y_end + 50);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
635 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
636 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
637 $diagram_img->string("70-100%");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
638
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
639 $diagram_img->moveTo(25,$y_end + 60);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
640 $diagram_img->setThickness(10);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
641 $diagram_img->fgcolor("gray");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
642 $diagram_img->bgcolor("gray");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
643 $diagram_img->lineTo(30,$y_end + 60);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
644 $diagram_img->fgcolor("black");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
645 $diagram_img->moveTo(35,$y_end + 65);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
646 $diagram_img->fontsize(12);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
647 $diagram_img->font('Times');
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
648 $diagram_img->string("No ratio information, no SNP class 5 in this gene");
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
649
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
650 }
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
651
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
652
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
653 open( DIAGRAM_PICT, ">$output_png" );
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
654 binmode(DIAGRAM_PICT);
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
655 print DIAGRAM_PICT $diagram_img->png;
e94de0ea3351 Uploaded
dereeper
parents:
diff changeset
656 close DIAGRAM_PICT;