annotate sRNA_rpkm_distribution_along_genome.pl @ 27:f2e18b4b1f3a draft

Uploaded
author big-tiandm
date Thu, 06 Nov 2014 02:49:50 -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.
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
7 # 2.
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
8 # 3.
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,"span=s","c=s","o=s","out=s","l=s","cen:s","n=s","mark=s","h");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
18 if (!( 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 my $sample_cloumn=$opt{n};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
23 my $mark=$opt{mark};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
24 #===============================Define Attribute==========================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
25 my %attribute=(
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
26 canvas=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
27 'width'=>1500,
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
28 'height'=>1800
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
29 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
30 text=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
31 'stroke'=>"#000000",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
32 'fill'=>"none",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
33 'stroke-width'=>0.5
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
34 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
35 line=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
36 'stroke'=>"black",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
37 'stroke-width'=>1
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
38 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
39 csv=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
40 'stroke'=>"red",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
41 'stroke-width'=>0.5
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
42 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
43 exon=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
44 'stroke'=>"black",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
45 'stroke-width'=>1
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
46 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
47 intron=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
48 'stroke'=>"black",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
49 'stroke-width'=>1.5
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
50 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
51 font=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
52 'fill'=>"#000000",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
53 'font-size'=>12,
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
54 'font-size2'=>10,
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
55 #'font-weight'=>'bold',
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
56 'font-family'=>"Arial"
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
57 #'font-family'=>"ArialNarrow-bold"
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
58 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
59 rect=>{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
60 'fill'=>"lightgreen",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
61 'stroke'=>"black",
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
62 'stroke-width'=>0.5
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
63 },
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
64 readwidth=>0.5
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
65 );
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
66 #############################s#define start coordinate and scale
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
67 open(TXT,">$opt{out}");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
68 open(LENGTH,"$opt{l}")||die"cannot open the file $opt{l}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
69 my %length;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
70 while (my $aline=<LENGTH>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
71 chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
72 next if($aline=~/^\#/);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
73 my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
74 $temp[0]=~s/^c/C/;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
75 $length{$temp[0]}=$temp[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
76 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
77 close LENGTH;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
78 #---------------------------------------------------------------
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
79 my %centromere;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
80 if (defined($opt{cen})) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
81 open(CEN,"$opt{cen}")||die"cannot open the file $opt{cen}";
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 $temp[0]=~s/^c/C/;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
87 $centromere{$temp[0]}[0]=$temp[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
88 $centromere{$temp[0]}[1]=$temp[2];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
89 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
90 close CEN;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
91 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
92
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
93 #---------------------------------------------------------------
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
94 my $max_length=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
95 foreach my $chr (keys %length) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
96 if ($max_length<$length{$chr}) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
97 $max_length=$length{$chr};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
98 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
99 print "$chr\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
100 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
101 #====================================cluster data=======================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
102 open(CLUSTER,"$opt{c}")||die"cannot open the file $opt{c}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
103 my %cluster;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
104 my %cluster_density;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
105 #my @sample=qw(39B3 3PA3 3LC3);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
106 my @cluster_non_add;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
107 while (my $aline=<CLUSTER>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
108 next if($aline=~/^\#/);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
109 chomp $aline;##ID chr strand start end 19B1
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
110 my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
111 my @ID=split/\:/,$temp[0];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
112 my @posi=split/\-/,$ID[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
113 push @{$cluster{$ID[0]}},[$temp[0],$posi[0],$posi[1],$temp[2+$sample_cloumn]];#ID start end rpkm(19B1,1PA1,1LC1);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
114 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
115 close CLUSTER;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
116 my %max_cluster;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
117 foreach my $chr (sort keys %cluster) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
118 # for (my $i=0;$i<3 ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
119 # $max_cluster{$chr}[$i]=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
120 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
121 $max_cluster{$chr}=0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
122 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
123 foreach my $chr (sort keys %cluster) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
124 @{$cluster{$chr}}=sort{$a->[1] <=> $b->[1]}@{$cluster{$chr}};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
125 #for (my $s=0;$s<3;$s++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
126 for (my $i=0;$i<$#{$cluster{$chr}} ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
127 if ($cluster{$chr}[$i][3]>$max_cluster{$chr}) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
128 $max_cluster{$chr}=$cluster{$chr}[$i][3];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
129 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
130 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
131 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
132
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
133 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
134 #---------------------------------------------------------------------------------------
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
135 foreach my $chr(keys %cluster) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
136 for(my $i=0;$i<$#{$cluster{$chr}};$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
137 my $start=int($cluster{$chr}[$i][1]/$span);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
138 my $end=int($cluster{$chr}[$i][2]/$span);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
139 if ($start==$end) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
140 #for (my $j=0;$j<3 ;$j++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
141 $cluster_density{$chr}[$start]+=$cluster{$chr}[$i][3];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
142 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
143
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
144 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
145 else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
146 for (my $m=$start;$m<=$end ;$m++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
147 #for (my $j=0;$j<3 ;$j++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
148 $cluster_density{$chr}[$m]+=$cluster{$chr}[$i][3];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
149 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
150 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
151 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
152 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
153 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
154 my %max_cluster_density;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
155 foreach my $chr (sort keys %cluster) {#
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
156 #for (my $i=0;$i<3 ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
157 for (my $i=0;$i<$#{$cluster{$chr}} ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
158 $max_cluster_density{$chr}=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
159 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
160 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
161 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
162 foreach my $chr (sort keys %cluster) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
163 #for (my $i=0;$i<3;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
164 for (my $k=0;$k<$#{$cluster_density{$chr}} ;$k++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
165 if (!(defined($cluster_density{$chr}[$k]))) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
166 $cluster_density{$chr}[$k]=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
167 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
168 if ($cluster_density{$chr}[$k]>$max_cluster_density{$chr}) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
169 $max_cluster_density{$chr}=$cluster_density{$chr}[$k];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
170 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
171 print TXT "$chr\t$k\t$cluster_density{$chr}[$k]\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
172 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
173 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
174 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
175 #--------------------------------------------------------------------
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
176 my $XOFFSET=50;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
177 my $YOFFSET=60;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
178 #my $length=$end-$start+1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
179 my $Xscale=600/$max_length;#定义X轴比例尺 1:1000 x轴的坐标长度都要按照此比例尺换算
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
180 #my $high_cov=$high_cov9B1=0.5;#定义峰图最高峰
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
181 #my $Yscale=1/$high_cov;#定义Y轴比例尺 1:60 y轴的坐标长度都要按照此比例尺换算
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
182 #========================================New canvas============================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
183 #### Starting ####
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
184 #新建画布
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
185 my $svg=SVG->new();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
186 #画图起始点
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
187 my $canvas_start_x=$XOFFSET;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
188 my $canvas_end_x=$XOFFSET+$max_length*$Xscale;#按照比例尺 画线
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
189 my $canvas_start_y=$YOFFSET;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
190 my $canvas_end_y=$YOFFSET;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
191
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
192 my $chr_width=$YOFFSET;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
193 my $chr_start_y;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
194 my $chr_end_y;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
195 my $Yscale=0.01;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
196 foreach my $chr (sort keys %length) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
197 my $chr_start_x=$XOFFSET;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
198 my $chr_end_x=$XOFFSET+$length{$chr}*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
199 $chr_start_y+=$chr_width;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
200 $chr_end_y+=$chr_width;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
201 $svg->line(x1=>$chr_start_x,y1=>$chr_start_y,x2=>$chr_end_x,y2=>$chr_end_y,'stroke',$attribute{line}{'stroke'},'stroke-width',$attribute{line}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
202 $svg->text('x',$XOFFSET-40,'y',$chr_start_y,'style','fill:black;text-anchor:left','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',12,'font-family',$attribute{font}{'font-family'},'-cdata',$chr);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
203 $svg->text('x',$chr_end_x+20,'y',$chr_start_y,'style','fill:black;text-anchor:left','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',12,'font-family',$attribute{font}{'font-family'},'-cdata',$length{$chr});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
204
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
205
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
206 if (defined($centromere{$chr}[0])) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
207 $svg->rect('x',$XOFFSET+$centromere{$chr}[0]*$Xscale,'y',$chr_start_y,'width',($centromere{$chr}[1]-$centromere{$chr}[0]+1)*$Xscale,'height',5,'stroke',"blue",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"blue");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
208 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
209 for (my $i=0;$i<$#{$cluster_density{$chr}} ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
210 if ($cluster_density{$chr}[$i]*$Yscale>40) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
211 $cluster_density{$chr}[$i]=40/$Yscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
212 $svg->rect('x',$XOFFSET+$i*$span*$Xscale,'y',$chr_start_y-45,'width',$span*$Xscale,'height',5,'stroke',"green",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"green");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
213 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
214 my $cluster_density_start_x=$XOFFSET+$i*$span*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
215 my $cluster_density_end_x=$XOFFSET+($i+1)*$span*$Xscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
216 my $cluster_density_start_y=$chr_start_y-$cluster_density{$chr}[$i]*$Yscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
217 #my $cluster_density_end_y=$chr_start_y-$cluster_density{$chr}[$i+1][0]*$Yscale;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
218 #$svg->line('x1',$cluster_density_start_x,'y1',$cluster_density_start_y,'x2',$cluster_density_end_x,'y2',$cluster_density_end_y,'stroke',"red",'stroke-width',$attribute{csv}{'stroke-width'});
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
219 $svg->rect('x',$cluster_density_start_x,'y',$chr_start_y-$cluster_density{$chr}[$i]*$Yscale,'width',$span*$Xscale,'height',$cluster_density{$chr}[$i]*$Yscale,'stroke',"red",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"red");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
220 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
221
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
222 $chr_width=50;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
223
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
224 #$svg->rect('x',$c_non_add_start_x,'y',$c_non_add_start_y,'width',$cluster_non_add_width,'height',$cluster_non_add_heigth,'stroke',"blue",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"blue");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
225 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
226
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
227 my $span_k=$span/1000;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
228 $svg->text('x',200,'y',$chr_start_y+20,'style','fill:black;text-anchor:left','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',12,'font-family',$attribute{font}{'font-family'},'-cdata',"$mark sRNA rpmk \/ $span_k kb");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
229
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
230 $svg->rect('x',600,'y',500,'width',10,'height',10,'stroke',"red",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"red");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
231 $svg->text('x',620,'y',510,'style','fill:black;text-anchor:left','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',12,'font-family',$attribute{font}{'font-family'},'-cdata',"sRNA rpkm");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
232
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
233 if (defined($opt{cen})) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
234 $svg->rect('x',600,'y',520,'width',10,'height',10,'stroke',"blue",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"blue");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
235 $svg->text('x',620,'y',530,'style','fill:black;text-anchor:left','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',12,'font-family',$attribute{font}{'font-family'},'-cdata',"centromere");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
236 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
237
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
238 close TXT;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
239 open (OUT,">$opt{o}");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
240 print OUT $svg->xmlify();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
241
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
242 sub log2 {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
243 my $n = shift;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
244 return log($n)/log(2);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
245 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
246
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
247 sub usage{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
248 print <<"USAGE";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
249 Version $version
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
250 Usage:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
251 $0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
252 options:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
253 -span
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
254 -n sample cloumn
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
255 -mark sample name
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
256 -o output graph file name with html or svg extension
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
257 -c cluster file input
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
258 -out txt output
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
259 -l length of chr
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
260 -cen centromere
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
261 -h help
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
262 USAGE
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
263 exit(1);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
264 }