annotate chr_plot.pl @ 33:09fefe8db1d0 draft default tip

Uploaded
author big-tiandm
date Sat, 15 Nov 2014 01:33:45 -0500
parents 07745c0958dd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
1 #!/usr/bin/perl -w
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
2 #==========================================================================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
3 # Date:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
4 # Title:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
5 # Comment: Program to plot gene structure
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
6 # Input: 1. input file of Gene region annotation which format like GenePred
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
7 # 2. input file of Transcripts region annotation which format like GenePred
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
8 # 3. input file of gene snp detail info
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
9 # Output: output file of gene structure graph by html or svg formt
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
10 # Test Usage:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
11 #========================================================================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
12 #use strict;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
13 my $version=1.00;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
14 use SVG;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
15 use Getopt::Long;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
16 my %opt;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
17 GetOptions(\%opt,"g=s","l=s","chro=s","mark=s","span=s","te=s","t=s","cen=s","c=s","o=s","out=s","h");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
18 if (!(defined $opt{g} and defined $opt{c} and defined $opt{l} and defined $opt{chro} and defined $opt{mark} and defined $opt{o}) || defined $opt{h}) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
19 &usage;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
20 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
21 my $span=$opt{span};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
22 #===============================Define Attribute==========================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
23 my %attribute=(
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
24 canvas=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
25 'width'=>1500,
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
26 'height'=>1800
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
27 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
28 text=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
29 'stroke'=>"#000000",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
30 'fill'=>"none",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
31 'stroke-width'=>0.5
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
32 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
33 line=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
34 'stroke'=>"black",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
35 'stroke-width'=>1
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
36 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
37 csv=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
38 'stroke'=>"red",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
39 'stroke-width'=>0.5
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
40 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
41 exon=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
42 'stroke'=>"black",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
43 'stroke-width'=>1
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
44 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
45 intron=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
46 'stroke'=>"black",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
47 'stroke-width'=>1.5
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
48 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
49 font=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
50 'fill'=>"#000000",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
51 'font-size'=>12,
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
52 'font-size2'=>10,
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
53 #'font-weight'=>'bold',
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
54 'font-family'=>"Arial"
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
55 #'font-family'=>"ArialNarrow-bold"
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
56 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
57 rect=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
58 'fill'=>"lightgreen",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
59 'stroke'=>"black",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
60 'stroke-width'=>0.5
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
61 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
62 readwidth=>0.5
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
63 );
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
64 #############################s#define start coordinate and scale
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
65
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
66 my $length=$opt{"l"};#11
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
67 #my @target_e_value=qw(1.78 1.83 1.92 2.00 1.92 2.00 1.93 2.11 2.05 2.03 1.92 1.91 1.54 1.72 1.67);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
68
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
69 my $chr=$opt{"chro"};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
70 my $start=1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
71 my $XOFFSET=50;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
72 my $YOFFSET=60;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
73 #my $length=$end-$start+1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
74 my $Xscale=600/$length;#定义X轴比例尺 1:1000 x轴的坐标长度都要按照此比例尺换算
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
75 #my $high_cov=$high_cov9B1=0.5;#定义峰图最高峰
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
76 #my $Yscale=1/$high_cov;#定义Y轴比例尺 1:60 y轴的坐标长度都要按照此比例尺换算
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
77 #========================================New canvas============================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
78 #---------------------------------------------------------------
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
79 if (defined($opt{cen})) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
80 open(CEN,"$opt{cen}")||die"cannot open the file $opt{cen}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
81 my %centromere;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
82 while (my $aline=<CEN>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
83 chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
84 next if($aline=~/^\#/);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
85 my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
86 $centromere{$temp[0]}[0]=$temp[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
87 $centromere{$temp[0]}[1]=$temp[2];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
88 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
89 close CEN;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
90 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
91
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
92 #### Starting ####
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
93 #新建画布
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
94 my $svg=SVG->new();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
95 #画图起始点
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
96 my $canvas_start_x=$XOFFSET;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
97 my $canvas_end_x=$XOFFSET+$length*$Xscale;#按照比例尺 画线
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
98 my $canvas_start_y=$YOFFSET;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
99 my $canvas_end_y=$YOFFSET;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
100 #Draw a straight line between two points start(x1,y1) and end(x2,y2).
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
101 #location attribute
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
102 $svg->line(id=>'l1',x1=>$canvas_start_x,y1=>$canvas_start_y,x2=>$canvas_end_x,y2=>$canvas_end_y,'stroke',$attribute{line}{'stroke'},'stroke-width',$attribute{line}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
103 $long_scale=int ($length/10);#十等分 大刻度
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
104 #大坐标刻度
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
105 for ($i=0;$i<=10;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
106 my $long_x_start=$XOFFSET+$long_scale*$i*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
107 my $long_x_end=$long_x_start;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
108 my $long_y_start=$YOFFSET;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
109 my $long_y_end=$YOFFSET-5;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
110 $svg->line('x1',$long_x_start,'y1',$long_y_start,'x2',$long_x_end,'y2',$long_y_end,'stroke',$attribute{line}{'stroke'},'stroke-width',$attribute{line}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
111 my $Bscale=$start+$long_scale*$i;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
112 my $cdata=int ($Bscale/1000000);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
113 $svg->text('x',$long_x_start,'y',$long_y_start-10,'style','fill:black;text-anchor:middle','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',12,'font-family',$attribute{font}{'font-family'},'-cdata',$cdata."M");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
114 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
115
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
116 if (defined($opt{cen})) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
117 $svg->rect('x',$XOFFSET+$centromere{$chr2}[0]*$Xscale,'y',$YOFFSET-2,'width',($centromere{$chr2}[1]-$centromere{$chr2}[0]+1)*$Xscale,'height',5,'stroke',"black",'stroke-width',"5",'fill',"black");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
118
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
119 $svg->rect('x',$XOFFSET+$length*$Xscale+15,'y',$YOFFSET+20,'width',10,'height',5,'stroke',"black",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"black");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
120 $svg->text('x',$XOFFSET+$length*$Xscale+35,'y',$YOFFSET+20+5,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size'},'font-family',$attribute{font}{'font-family'},'-cdata',"Centromere");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
121 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
122
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
123 $svg->text('x',$XOFFSET+$length*$Xscale*0.42,'y',$YOFFSET-30,'stroke',"black",'stroke-width',1,'font-size',15,'font-family',$attribute{font}{'font-family'},'-cdata',$chr);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
124 #====================================================MAIN PROGRAM========================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
125
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
126 #===========================================gene list data================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
127 #open (TXT,">$opt{out}");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
128 #open(TE,"$opt{te}")||die"cannot open the file $opt{te}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
129 #my %te;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
130 #while (my $aline=<TE>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
131 # chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
132 # my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
133 # if ($temp[2] eq "Y") {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
134 # $te{$temp[0]}=1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
135 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
136 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
137 #close TE;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
138 #===================================Exp gene list data =================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
139 #open(TARGET,"$opt{t}")||die"cannot open the file $opt{t}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
140 #my %target_e;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
141 #my %target_rpkm;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
142 #while (my $aline=<TARGET>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
143 # chomp $aline;##Gene 19B1 1PA1 1LC1 29B2 2PA2 2LC2 39B3 3PA3 3LC3 93-4C PA-4C LY-4C 9343 PA43 LY43 19B1_VS_1LC1 19B1_VS_1PA1 1PA1_VS_1LC1 29B2_VS_2LC2 29B2_VS_2PA2 2PA2_VS_2LC2 39B3_VS_3LC3 39B3_VS_3PA3 3PA3_VS_3LC3 934C_LY4C 934C_PA4C PA4C_LY4C 9343_VS_LY43 9343_VS_PA43 PA43_VS_LY43 mpv_1 fold_1 mpv_2 fold_2 mpv_3 fold_3 mpv_4_B fold_4_B mpv_leaf fold_lead
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
144 # next if($aline=~/^\#/);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
145 # my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
146 # $target_rpkm{$temp[0]}="$temp[7]\t$temp[8]\t$temp[9]";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
147 # if ($temp[7]>$target_e_value[6]||$temp[8]>$target_e_value[7]||$temp[9]>$target_e_value[8]) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
148 # $target_e{$temp[0]}="$temp[7]\t$temp[8]\t$temp[9]";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
149 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
150 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
151 #close TARGET;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
152 #====================================================================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
153 my @genelist;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
154 #my @te_genelist;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
155 my @target_e;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
156 open(GENE,"$opt{g}")||die"cannot open the file $opt{g}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
157 while (my $aline=<GENE>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
158 chomp $aline;#LOC_Os01g01280 Chr1 133291 134685 +
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
159 my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
160 #my $te;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
161 if ($temp[1]=~/^Chr(\d)$/) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
162 $temp[1]="Chr0$1";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
163 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
164 next if($temp[1] ne $chr);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
165 #push @genelist,[$temp[0],$temp[3],$temp[4]];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
166 push @genelist,[$temp[0],$temp[2],$temp[3]];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
167 # if ($te{$temp[0]}) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
168 # push @te_genelist,[$temp[0],$temp[3],$temp[4]];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
169 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
170 # else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
171 # push @genelist,[$temp[0],$temp[3],$temp[4]];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
172 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
173 # if ($target_e{$temp[0]}) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
174 # push @target_e,[$temp[0],$temp[3],$temp[4]];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
175 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
176
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
177 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
178 close GENE;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
179 my @gene_desity;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
180 #my @region_target_rpkm;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
181 @genelist=sort{$a->[1] <=> $b->[1]}@genelist;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
182 for (my $i=0;$i<@genelist ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
183 # if ($genelist[$i][1]>($num1+1)*$span) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
184 # $num1++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
185 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
186 # if ($genelist[$i][1]>$num1*$span&&$genelist[$i][1]<=($num1+1)*$span) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
187 # $gene_desity[$num1]++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
188 #
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
189 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
190 my $start=int($genelist[$i][1]/$span);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
191 my $end=int($genelist[$i][2]/$span);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
192 #my @t_rpkm=split/\t/,$target_rpkm{$genelist[$i][0]};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
193 if ($start==$end) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
194 $gene_desity[$start]++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
195 #for (my $rs=0;$rs<3 ;$rs++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
196 #print TXT "$rs\t$i\t$genelist[$i][0]\t$target_rpkm{$genelist[$i][0]}\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
197 #$region_target_rpkm[$start][$rs]+=$t_rpkm[$rs];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
198 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
199
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
200 #$target_rpkm_desity[$start][0]+=$temp[0];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
201 #$target_rpkm_desity[$start][1]+=$temp[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
202 #$target_rpkm_desity[$start][2]+=$temp[2];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
203 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
204 else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
205 for (my $k=$start;$k<=$end ;$k++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
206 $gene_desity[$k]++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
207 #for (my $rs=0;$rs<3 ;$rs++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
208 #$region_target_rpkm[$k][$rs]+=$t_rpkm[$rs];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
209 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
210 #$target_rpkm_desity[$k][0]+=$temp[0];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
211 #$target_rpkm_desity[$k][1]+=$temp[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
212 #$target_rpkm_desity[$k][2]+=$temp[2];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
213 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
214 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
215 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
216 #------------------------------------------region_gene_number-------------------------
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
217 my $max_gene_number=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
218 my $total=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
219 for (my $i=0;$i<@gene_desity ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
220 if (!(defined($gene_desity[$i]))) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
221 $gene_desity[$i]=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
222 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
223 if ($gene_desity[$i]>$max_gene_number) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
224 $max_gene_number=$gene_desity[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
225 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
226 #print TXT "$i\t$gene_desity[$i]\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
227 $total+=$gene_desity[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
228 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
229 print "Gene max:$max_gene_number\ntotal:$total\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
230 my $abc=@genelist;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
231 #my $cba=@te_genelist;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
232 print "aaaaaa:$abc\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
233 #print "bbbbbb:$cba\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
234 #---------------------------------------------region_gene_rpkm------------------------
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
235 #my $max_region_gene_rpkm=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
236 #my @max_region_gene_rpkm=qw(0 0 0);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
237 #my @total_region_gene_rpkm=qw(0 0 0);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
238 #for (my $i=0;$i<@region_target_rpkm ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
239 # for (my $s=0; $s<3;$s++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
240 #
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
241 # if (!(defined($region_target_rpkm[$i][$s]))) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
242 # $region_target_rpkm[$i][$s]=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
243 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
244 # $total_region_gene_rpkm[$s]+=$region_target_rpkm[$i][$s];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
245 # if ($max_region_gene_rpkm<$region_target_rpkm[$i][$s]) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
246 # $max_region_gene_rpkm=$region_target_rpkm[$i][$s];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
247 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
248 # if ($max_region_gene_rpkm[$s]<$region_target_rpkm[$i][$s]) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
249 # $max_region_gene_rpkm[$s]=$region_target_rpkm[$i][$s];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
250 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
251 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
252 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
253 #my @ave_region_gene_rpkm=qw(0 0 0);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
254 #my $max_ave_rpkm=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
255 #for (my $i=0;$i<3;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
256 # $ave_region_gene_rpkm[$i]=$total_region_gene_rpkm[$i]/($#region_target_rpkm+1);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
257 # if ($max_ave_rpkm<$ave_region_gene_rpkm[$i]) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
258 # $max_ave_rpkm=$ave_region_gene_rpkm[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
259 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
260 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
261 #
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
262 #print "***max region gene rpkm :$max_region_gene_rpkm\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
263 #print "@max_region_gene_rpkm\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
264 #if ($max_region_gene_rpkm>10*$max_ave_rpkm) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
265 # $max_region_gene_rpkm=10*$max_ave_rpkm;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
266 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
267 #my @max_region_rpkm;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
268 #----------------------------------------------------------------------------------
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
269 #my @te_gene_desity;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
270 #@te_genelist=sort{$a->[1] <=> $b->[1]}@te_genelist;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
271 ##my $num2=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
272 #for (my $i=0;$i<@te_genelist ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
273 ## if ($te_genelist[$i][1]>($num2+1)*$span) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
274 ## $num2=int($te_genelist[$i][1]/$span);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
275 ## }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
276 ## if ($te_genelist[$i][1]>$num2*$span&&$te_genelist[$i][1]<=($num2+1)*$span) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
277 ## $te_gene_desity[$num2]++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
278 ## }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
279 # my $start=int($te_genelist[$i][1]/$span);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
280 # my $end=int($te_genelist[$i][2]/$span);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
281 # if ($start==$end) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
282 # $te_gene_desity[$start]++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
283 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
284 # else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
285 # for (my $k=$start;$k<=$end ;$k++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
286 # $te_gene_desity[$k]++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
287 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
288 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
289 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
290 #$max_te_gene_number=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
291 #$total=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
292 #for (my $i=0;$i<@te_gene_desity ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
293 # if (!(defined($te_gene_desity[$i]))) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
294 # $te_gene_desity[$i]=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
295 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
296 # if ($te_gene_desity[$i]>$max_te_gene_number) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
297 # $max_te_gene_number=$te_gene_desity[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
298 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
299 # print TXT "$i\t$te_gene_desity[$i]\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
300 # $total+=$te_gene_desity[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
301 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
302 #
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
303 #print "TE gene max:$max_te_gene_number\ntotal:$total\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
304 #-------------------------------------------------------
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
305 #my @target_e_desity;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
306 #@target_e=sort{$a->[1] <=> $b->[1]}@target_e;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
307 #for (my $i=0;$i<@target_e ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
308 # my $start=int($target_e[$i][1]/$span);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
309 # my $end=int($target_e[$i][2]/$span);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
310 # if ($start==$end) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
311 # $target_e_desity[$start]++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
312 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
313 # else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
314 # for (my $k=$start;$k<=$end ;$k++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
315 # $target_e_desity[$k]++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
316 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
317 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
318 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
319 #my $max_target_e_number=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
320 #$total=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
321 #for (my $i=0;$i<@target_e_desity ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
322 # if (!(defined($target_e_desity[$i]))) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
323 # $target_e_desity[$i]=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
324 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
325 # if ($target_e_desity[$i]>$max_target_e_number) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
326 # $max_target_e_number=$target_e_desity[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
327 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
328 # print TXT "$i\t$target_e_desity[$i]\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
329 # $total+=$target_e_desity[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
330 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
331 #
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
332 #print "Target max:$max_target_e_number\ntotal:$total\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
333
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
334 #====================================cluster data=======================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
335 open(CLUSTER,"$opt{c}")||die"cannot open the file $opt{c}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
336 my $mark="$opt{mark}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
337 my @sample=split/\#/,$mark;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
338 my $sample_num=@sample;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
339 my @cluster;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
340 my @cluster_density;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
341 my @max_cluster_read=(0)x$sample_num;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
342 while (my $aline=<CLUSTER>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
343 next if($aline=~/^\#/);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
344 chomp $aline;##ID chr strand start end 19B1
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
345 #clusterID major_length percent sample1 sample2 sample3
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
346 #Chr01:192429-192452 24nt 1.00 0.00 97222.22 0.00
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
347 my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
348 my @id=split/\:/,$temp[0];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
349 my @posit=split/\-/,$id[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
350 next if($id[0] ne $chr);#Chr.01 chr04
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
351 push @cluster,[$id[0],$posit[0],$posit[1],@temp[3..3+$sample_num+1]];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
352 #push @cluster,[$temp[0],$temp[3],$temp[4],$temp[11],$temp[12],$temp[13]];#ID start end rpkm(19B1,1PA1,1LC1);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
353 for (my $i=0;$i<@sample ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
354 if($temp[3+$i]>$max_cluster_read[$i]){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
355 $max_cluster_read[$i]=$temp[3+$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
356 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
357 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
358 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
359 close CLUSTER;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
360 @cluster=sort{$a->[1] <=> $b->[1]}@cluster;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
361 for(my $i=0;$i<$#cluster;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
362 my $start=int($cluster[$i][1]/$span);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
363 my $end=int($cluster[$i][2]/$span);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
364 if ($start==$end) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
365 for (my $j=0;$j<$sample_num ;$j++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
366 $cluster_density[$start][$j]+=$cluster[$i][$j+$sample_num];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
367 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
368
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
369 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
370 else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
371 for (my $m=$start;$m<=$end ;$m++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
372 for (my $j=0;$j<$sample_num ;$j++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
373 $cluster_density[$m][$j]+=$cluster[$i][$j+$sample_num];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
374 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
375 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
376 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
377 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
378 my @max_cluster_density=(0)x$sample_num;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
379 my @total_cluster_density=(0)x$sample_num;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
380 my $max_cluster_density=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
381 for (my $i=0;$i<@sample;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
382 for (my $k=0;$k<$#cluster_density ;$k++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
383
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
384 if (!(defined($cluster_density[$k][$i]))) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
385 $cluster_density[$k][$i]=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
386 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
387 $total_cluster_density[$i]+=$cluster_density[$k][$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
388 if ($cluster_density[$k][$i]>$max_cluster_density[$i]) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
389 $max_cluster_density[$i]=$cluster_density[$k][$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
390 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
391 if ($cluster_density[$k][$i]>$max_cluster_density) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
392 $max_cluster_density=$cluster_density[$k][$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
393
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
394 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
395 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
396 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
397 my @ave_cluster_density=(0)x$sample_num;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
398 my $max_ave=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
399 for (my $i=0;$i<@sample;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
400 $ave_cluster_density[$i]=$total_cluster_density[$i]/($#cluster_density+1);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
401 if ($max_ave<$ave_cluster_density[$i]) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
402 $max_ave=$ave_cluster_density[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
403 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
404 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
405
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
406 print "max cluster reads:@max_cluster_read\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
407 print "max cluster density:@max_cluster_density\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
408 if ($max_cluster_density>10*$max_ave) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
409 $max_cluster_density=10*$max_ave;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
410 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
411 #===================================== plot gene desity =================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
412 #===row
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
413 my $Y1scale=5;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
414 my $y1_gene_density=$YOFFSET+$max_gene_number*$Y1scale+10;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
415 for (my $i=0;$i<@gene_desity-1 ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
416 my $density_start_x=$XOFFSET+$i*$span*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
417 my $density_start_y=$y1_gene_density-$gene_desity[$i]*$Y1scale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
418 my $density_end_x=$XOFFSET+($i+1)*$span*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
419 my $density_end_y=$y1_gene_density-$gene_desity[$i+1]*$Y1scale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
420 my $heigth=$gene_desity[$i]/$max_gene_number;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
421 $svg->rect('x',$density_start_x,'y',$density_start_y,'width',$span*$Xscale,'height',$y1_gene_density-$density_start_y,'stroke',"read",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"green");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
422 #$svg->line('x1',$density_start_x,'y1',$density_start_y,'x2',$density_end_x,'y2',$density_end_y,'stroke',"red",'stroke-width',$attribute{csv}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
423
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
424 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
425 $svg->line('x1',$XOFFSET,'y1',$y1_gene_density,'x2',$XOFFSET+$length*$Xscale,'y2',$y1_gene_density,'stroke',"black",'stroke-width',"black");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
426
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
427 #====clomun
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
428 $svg->line('x1',$XOFFSET,'y1',$y1_gene_density,'x2',$XOFFSET,'y2',$y1_gene_density-$max_gene_number*$Y1scale,'stroke',"black",'stroke-width',"black");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
429 $svg->text('x',$XOFFSET-15,'y',$y1_gene_density,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size2'},'font-family',$attribute{font}{'font-family'},'-cdata',"0");#min gene number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
430 $svg->text('x',$XOFFSET-20,'y',$y1_gene_density-$max_gene_number*$Y1scale,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size2'},'font-family',$attribute{font}{'font-family'},'-cdata',$max_gene_number);#max gene number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
431 #=========================================================================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
432 #=============================plot TE gene desity=========================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
433 #===row
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
434 =cut
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
435 my $Y2scale=$Y1scale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
436 my $y2_te_gene_density=$y1_gene_density;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
437 for (my $i=0;$i<@te_gene_desity-1 ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
438 my $te_density_start_x=$XOFFSET+$i*$span*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
439 my $te_density_start_y=$y2_te_gene_density+$te_gene_desity[$i]*$Y2scale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
440 my $te_density_end_x=$XOFFSET+($i+1)*$span*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
441 my $te_density_end_y=$y2_te_gene_density+$te_gene_desity[$i+1]*$Y2scale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
442 #my $te_heigth=$te_gene_desity[$i]/$max_gene_number;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
443 $svg->rect('x',$te_density_start_x,'y',$y2_te_gene_density,'width',$span*$Xscale,'height',$te_density_start_y-$y2_te_gene_density,'stroke',"read",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"green");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
444 #$svg->line('x1',$density_start_x,'y1',$density_start_y,'x2',$density_end_x,'y2',$density_end_y,'stroke',"red",'stroke-width',$attribute{csv}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
445
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
446 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
447 #column
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
448 $svg->line('x1',$XOFFSET,'y1',$y2_te_gene_density,'x2',$XOFFSET,'y2',$y2_te_gene_density+$max_te_gene_number*$Y2scale,'stroke',"black",'stroke-width',"black");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
449 $svg->text('x',$XOFFSET-20,'y',$y2_te_gene_density+$max_te_gene_number*$Y2scale,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size2'},'font-family',$attribute{font}{'font-family'},'-cdata',$max_te_gene_number);#min gene number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
450 =cut
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
451 #=======================gene density txt==================================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
452 my $md=$span/1000;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
453 #$svg->text('x',$XOFFSET-30,'y',$YOFFSET+10,'width',"698",'height',"298",'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size2'},'font-family',$attribute{font}{'font-family'},'-cdata',"Number per \\30 kb","rotate","90",'writing-mode',"tb-rl");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
454
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
455 $svg->rect('x',$XOFFSET+$length*$Xscale+15,'y',$y1_gene_density-$max_gene_number*$Y1scale*0.7,'width',10,'height',5,'stroke',"green",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"green");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
456 $svg->text('x',$XOFFSET+$length*$Xscale+35,'y',$y1_gene_density-$max_gene_number*$Y1scale*0.7+5,'stroke',"green",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size'},'font-family',$attribute{font}{'font-family'},'-cdata',"Genes");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
457
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
458 #$svg->rect('x',$XOFFSET+$length*$Xscale+15,'y',$y1_gene_density-$max_gene_number*$Y1scale*0.7+20,'width',10,'height',5,'stroke',"green",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"green");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
459 #$svg->text('x',$XOFFSET+$length*$Xscale+35,'y',$y1_gene_density-$max_gene_number*$Y1scale*0.7+20+5,'stroke',"green",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size'},'font-family',$attribute{font}{'font-family'},'-cdata',"TE Genes");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
460
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
461 $svg->text('x',$XOFFSET+$length*$Xscale+35,'y',$y1_gene_density-$max_gene_number*$Y1scale*0.7+20,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size'},'font-family',$attribute{font}{'font-family'},'-cdata',"genes number \/ $md kb");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
462 #=========================================================================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
463 #=============================plot exp gene desity=========================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
464 =cut
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
465 my $y3_target_e_density=$y2_te_gene_density+$max_te_gene_number*$Y2scale+$max_target_e_number*$Y2scale+20;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
466 #my $Y3scale=$Y1scale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
467 for (my $i=0;$i<@target_e_desity-1 ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
468 my $target_e_density_start_x=$XOFFSET+$i*$span*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
469 my $target_e_density_start_y=$y3_target_e_density-$target_e_desity[$i]*$Y2scale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
470 my $target_e_density_end_x=$XOFFSET+($i+1)*$span*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
471 my $target_e_density_end_y=$y3_target_e_density-$target_e_desity[$i+1]*$Y2scale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
472 $svg->rect('x',$target_e_density_start_x,'y',$target_e_density_start_y,'width',$span*$Xscale,'height',$y3_target_e_density-$target_e_density_start_y,'stroke',"read",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"red");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
473
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
474 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
475 $svg->line('x1',$XOFFSET,'y1',$y3_target_e_density,'x2',$XOFFSET+$length*$Xscale,'y2',$y3_target_e_density,'stroke',"black",'stroke-width',"black");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
476 #column
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
477 $svg->line('x1',$XOFFSET,'y1',$y3_target_e_density,'x2',$XOFFSET,'y2',$y3_target_e_density-$max_te_gene_number*$Y2scale,'stroke',"black",'stroke-width',"black");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
478 $svg->text('x',$XOFFSET-15,'y',$y3_target_e_density,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size2'},'font-family',$attribute{font}{'font-family'},'-cdata',0);#max gene number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
479 $svg->text('x',$XOFFSET-20,'y',$y3_target_e_density-$max_te_gene_number*$Y2scale+10,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size2'},'font-family',$attribute{font}{'font-family'},'-cdata',$max_target_e_number);#max gene number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
480 #=========================================exp gene indensity txt==========================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
481 $svg->rect('x',$XOFFSET+$length*$Xscale+15,'y',$y3_target_e_density-$max_target_e_number*$Y2scale*0.7,'width',10,'height',5,'stroke',"red",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"red");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
482 $svg->text('x',$XOFFSET+$length*$Xscale+35,'y',$y3_target_e_density-$max_target_e_number*$Y2scale*0.7+5,'stroke',"red",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size'},'font-family',$attribute{font}{'font-family'},'-cdata',"Exp Genes");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
483 $svg->text('x',$XOFFSET+$length*$Xscale+35,'y',$y3_target_e_density-$max_target_e_number*$Y2scale*0.7+20,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size'},'font-family',$attribute{font}{'font-family'},'-cdata',"genes number \/ 50kb");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
484 #calculate the different
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
485 =cut
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
486 #========================================================================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
487 my $Y3scale=0.04/$max_cluster_density*2500;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
488 #my $y3_cluster_density=$y2_te_gene_density+$max_te_gene_number*5+$max_cluster_density*$Y3scale+10;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
489 my $y3_cluster_density=$y1_gene_density+20;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
490 my $y3_total=$y1_gene_density+10;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
491 my @cluster_color=qw(fuchsia violet tomato);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
492 for (my $s=0;$s<3 ;$s++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
493 $y3_total=$y3_total+$max_cluster_density*$Y3scale+5;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
494 $svg->line('x1',$XOFFSET,'y1',$y3_total,'x2',$XOFFSET+$length*$Xscale,'y2',$y3_total,'stroke',"black",'stroke-width',$attribute{csv}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
495 $svg->line('x1',$XOFFSET,'y1',$y3_total,'x2',$XOFFSET,'y2',$y3_total-$max_cluster_density*$Y3scale,'stroke',"black",'stroke-width',$attribute{csv}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
496
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
497 $svg->text('x',$XOFFSET-15,'y',$y3_total,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size2'},'font-family',$attribute{font}{'font-family'},'-cdata',"0");#min gene number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
498
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
499 if ($max_cluster_density[$s]>$max_cluster_density) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
500 $svg->text('x',$XOFFSET-40,'y',$y3_total-$max_cluster_density*$Y3scale+10,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size2'},'font-family',$attribute{font}{'font-family'},'-cdata',$max_cluster_density[$s]);#max gene number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
501 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
502 else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
503 $svg->text('x',$XOFFSET-40,'y',$y3_total-$max_cluster_density[$s]*$Y3scale+10,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size2'},'font-family',$attribute{font}{'font-family'},'-cdata',$max_cluster_density[$s]);#max gene number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
504 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
505
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
506 for (my $i=0;$i<$#cluster_density ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
507 my $cluster_density_start_x=$XOFFSET+$i*$span*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
508 my $cluster_density_end_x=$XOFFSET+($i+1)*$span*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
509 if ($cluster_density[$i][$s]>$max_cluster_density) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
510 $cluster_density[$i][$s]=$max_cluster_density;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
511 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
512 if ($cluster_density[$i+1][$s]>$max_cluster_density) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
513 $cluster_density[$i+1][$s]=$max_cluster_density;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
514 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
515 my $cluster_density_start_y=$y3_total-$cluster_density[$i][$s]*$Y3scale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
516 my $cluster_density_end_y=$y3_total-$cluster_density[$i+1][$s]*$Y3scale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
517 $svg->line('x1',$cluster_density_start_x,'y1',$cluster_density_start_y,'x2',$cluster_density_end_x,'y2',$cluster_density_end_y,'stroke',$cluster_color[$s],'stroke-width',$attribute{csv}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
518 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
519 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
520 for (my $s=0;$s<@sample ;$s++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
521 $svg->line('x1',$XOFFSET+$length*$Xscale+10,'y1',$y3_cluster_density+($y3_total-$y3_cluster_density)*0.3+30*$s,'x2',$XOFFSET+$length*$Xscale+30,'y2',$y3_cluster_density+($y3_total-$y3_cluster_density)*0.3+30*$s,'stroke',$cluster_color[$s],'stroke-width',$attribute{csv}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
522 $svg->text('x',$XOFFSET+$length*$Xscale+35,'y',$y3_cluster_density+($y3_total-$y3_cluster_density)*0.3+30*$s+5,'stroke',$cluster_color[$s],'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size'},'font-family',$attribute{font}{'font-family'},'-cdata',"Small RNAs ".$sample[$s]);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
523 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
524
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
525 $svg->text('x',$XOFFSET+$length*$Xscale+35,'y',$y3_cluster_density+($y3_total-$y3_cluster_density)*0.3+30*3-5,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size'},'font-family',$attribute{font}{'font-family'},'-cdata',"indensity of sRNA \/ $md kb");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
526 #===================================plot region target gene rpkm================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
527 =cut
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
528 my $y4_region_gene_rpkm_1=$y3_total+10;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
529 my $y4_region_gene_rpkm=$y4_region_gene_rpkm_1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
530 my $Y4scale=0.1/$max_region_gene_rpkm*1000;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
531 my @cluster_color_t=qw(blue slateblue steelblue);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
532 for (my $s=0;$s<3 ;$s++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
533 $y4_region_gene_rpkm+=$max_region_gene_rpkm*$Y4scale+5;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
534
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
535 $svg->line('x1',$XOFFSET,'y1',$y4_region_gene_rpkm,'x2',$XOFFSET+$length*$Xscale,'y2',$y4_region_gene_rpkm,'stroke',"black",'stroke-width',$attribute{csv}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
536
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
537 $svg->line('x1',$XOFFSET,'y1',$y4_region_gene_rpkm,'x2',$XOFFSET,'y2',$y4_region_gene_rpkm-$max_region_gene_rpkm*$Y4scale,'stroke',"black",'stroke-width',$attribute{csv}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
538
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
539 $svg->text('x',$XOFFSET-15,'y',$y4_region_gene_rpkm,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size2'},'font-family',$attribute{font}{'font-family'},'-cdata',"0");#min gene number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
540
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
541 if ($max_region_gene_rpkm[$s]>$max_region_gene_rpkm) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
542 $svg->text('x',$XOFFSET-40,'y',$y4_region_gene_rpkm-$max_region_gene_rpkm*$Y4scale+10,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size2'},'font-family',$attribute{font}{'font-family'},'-cdata',$max_region_gene_rpkm[$s]);#max gene number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
543 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
544 else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
545 $svg->text('x',$XOFFSET-40,'y',$y4_region_gene_rpkm-$max_region_gene_rpkm[$s]*$Y4scale+10,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size2'},'font-family',$attribute{font}{'font-family'},'-cdata',$max_region_gene_rpkm[$s]);#max gene number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
546 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
547 for (my $i=0;$i<$#region_target_rpkm ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
548 my $region_target_rpkm_start_x=$XOFFSET+$i*$span*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
549 my $region_target_rpkm_end_x=$XOFFSET+($i+1)*$span*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
550 if ($region_target_rpkm[$i][$s]>$max_region_gene_rpkm) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
551 $region_target_rpkm[$i][$s]=$max_region_gene_rpkm;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
552 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
553 if ($region_target_rpkm[$i+1][$s]>$max_region_gene_rpkm) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
554 $region_target_rpkm[$i+1][$s]=$max_region_gene_rpkm;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
555 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
556 my $region_target_rpkm_start_y=$y4_region_gene_rpkm-$region_target_rpkm[$i][$s]*$Y4scale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
557 my $region_target_rpkm_end_y=$y4_region_gene_rpkm-$region_target_rpkm[$i+1][$s]*$Y4scale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
558 $svg->line('x1',$region_target_rpkm_start_x,'y1',$region_target_rpkm_start_y,'x2',$region_target_rpkm_end_x,'y2',$region_target_rpkm_end_y,'stroke',$cluster_color_t[$s],'stroke-width',$attribute{csv}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
559 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
560
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
561 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
562 for (my $s=0;$s<3 ;$s++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
563 $svg->line('x1',$XOFFSET+$length*$Xscale+10,'y1',$y4_region_gene_rpkm_1+($y4_region_gene_rpkm-$y4_region_gene_rpkm_1)*0.3+30*$s,'x2',$XOFFSET+$length*$Xscale+30,'y2',$y4_region_gene_rpkm_1+($y4_region_gene_rpkm-$y4_region_gene_rpkm_1)*0.3+30*$s,'stroke',$cluster_color_t[$s],'stroke-width',$attribute{csv}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
564 $svg->text('x',$XOFFSET+$length*$Xscale+35,'y',$y4_region_gene_rpkm_1+($y4_region_gene_rpkm-$y4_region_gene_rpkm_1)*0.3+30*$s+5,'stroke',$cluster_color_t[$s],'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size'},'font-family',$attribute{font}{'font-family'},'-cdata',"Target Genes ".$sample[$s]);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
565 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
566 $svg->text('x',$XOFFSET+$length*$Xscale+35,'y',$y4_region_gene_rpkm_1+($y4_region_gene_rpkm-$y4_region_gene_rpkm_1)*0.3+30*3-5,'stroke',"black",'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size'},'font-family',$attribute{font}{'font-family'},'-cdata',"indensity of genes \/ 50kb");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
567 =cut
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
568 #for (my $s=0;$s<3 ;$s++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
569 # $svg->line('x1',$XOFFSET+$length*$Xscale+10,'y1',$y4_region_gene_rpkm_1+($y4_region_gene_rpkm-$y3_cluster_density)*0.3+30*$s,'x2',$XOFFSET+$length*$Xscale+30,'y2',$y4_region_gene_rpkm_1+($y4_region_gene_rpkm-$y3_cluster_density)*0.3+30*$s,'stroke',$cluster_color[$s],'stroke-width',$attribute{csv}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
570 # $svg->text('x',$XOFFSET+$length*$Xscale+35,'y',$y4_region_gene_rpkm_1+($y4_region_gene_rpkm-$y3_cluster_density)*0.3+30*$s+5,'stroke',$cluster_color[$s],'stroke-width',$attribute{text}{'stroke-width'},'font-size',$attribute{font}{'font-size'},'font-family',$attribute{font}{'font-family'},'-cdata',$sample[$s]);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
571 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
572 #=========================================================================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
573
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
574 #sub ExpG_number {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
575 #
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
576 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
577 #sub ExpCluster_number{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
578 #
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
579 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
580
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
581
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
582 #========================================================================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
583 open (OUT,">$opt{o}");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
584 print OUT $svg->xmlify();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
585
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
586 sub log2 {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
587 my $n = shift;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
588 return log($n)/log(2);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
589 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
590
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
591 sub usage{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
592 print <<"USAGE";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
593 Version $version
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
594 Usage:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
595 $0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
596 options:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
597 -l centromere length
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
598 -chro
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
599 -mark \#
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
600 -g input file of Gene region annotation which format like GenePred
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
601 -span
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
602 -c cluster file input
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
603 -o svg output
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
604 -h help
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
605 USAGE
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
606 exit(1);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
607 }