annotate sRNA_plot.pl @ 51:3202911efdae draft

Uploaded
author big-tiandm
date Fri, 05 Dec 2014 01:14:28 -0500
parents 7b5a48b972e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
1 #!/usr/bin/perl -w
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
2 #==========================================================================================
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
3 # Date:
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
4 # Title:
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
5 # Comment: Program to plot gene structure
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
6 # Input: 1.
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
7 # 2.
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
8 # 3.
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
9 # Output: output file of gene structure graph by html or svg formt
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
10 # Test Usage:
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
11 #========================================================================================
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
12 #use strict;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
13 my $version=1.00;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
14 use SVG;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
15 use Getopt::Long;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
16 my %opt;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
17 GetOptions(\%opt,"g=s","l=s","span=s","c=s","o=s","out=s","cen:s","mark=s","h");
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
18 if (!( defined $opt{o}) || defined $opt{h}) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
19 &usage;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
20 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
21 my $span=$opt{span};
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
22 #my $sample_cloumn=$opt{n};
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
23 my $mark=$opt{mark};
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
24 my @mark=split/\#/,$mark;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
25 my $genelist=$opt{g};
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
26 #===============================Define Attribute==========================================
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
27 my %attribute=(
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
28 canvas=>{
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
29 'width'=>1500,
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
30 'height'=>1800
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
31 },
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
32 text=>{
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
33 'stroke'=>"#000000",
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
34 'fill'=>"none",
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
35 'stroke-width'=>0.5
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
36 },
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
37 line=>{
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
38 'stroke'=>"black",
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
39 'stroke-width'=>1
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
40 },
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
41 csv=>{
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
42 'stroke'=>"red",
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
43 'stroke-width'=>0.5
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
44 },
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
45 exon=>{
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
46 'stroke'=>"black",
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
47 'stroke-width'=>1
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
48 },
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
49 intron=>{
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
50 'stroke'=>"black",
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
51 'stroke-width'=>1.5
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
52 },
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
53 font=>{
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
54 'fill'=>"#000000",
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
55 'font-size'=>12,
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
56 'font-size2'=>10,
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
57 #'font-weight'=>'bold',
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
58 'font-family'=>"Arial"
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
59 #'font-family'=>"ArialNarrow-bold"
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
60 },
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
61 rect=>{
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
62 'fill'=>"lightgreen",
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
63 'stroke'=>"black",
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
64 'stroke-width'=>0.5
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
65 },
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
66 readwidth=>0.5
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
67 );
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
68 #############################s#define start coordinate and scale
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
69 open(TXT,">$opt{out}");
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
70 open(LENGTH,"$opt{l}")||die"cannot open the file $opt{l}";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
71 my %length;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
72 while (my $aline=<LENGTH>) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
73 chomp $aline;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
74 next if($aline=~/^\#/);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
75 my @temp=split/\t/,$aline;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
76 $temp[0]=~s/^c/C/;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
77 $length{$temp[0]}=$temp[1];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
78 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
79 close LENGTH;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
80 #---------------------------------------------------------------
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
81 open(GENE,"$opt{g}")||die"cannot open the file $opt{g}";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
82 my %genelist;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
83 while (my $aline=<GENE>) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
84 chomp $aline;#LOC_Os01g01280 Chr1 133291 134685 +
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
85 next if($aline=~/^\#/);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
86 my @temp=split/\t/,$aline;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
87 if ($temp[1]=~/^Chr(\d)$/) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
88 $temp[1]="Chr0$1";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
89 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
90 push @{$genelist{$temp[1]}},[$temp[0],$temp[2],$temp[3]];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
91
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
92 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
93 close GENE;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
94 #my %have_gene;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
95 #foreach my $chr (sort keys %genelist) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
96 # my @genelist=sort{$a->[1] <=> $b->[1]}@{$genelist{$chr}};
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
97 # my $start=$genelist[0][1];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
98 # my $end=$genelist[0][2];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
99 # for (my $i=0;$i<@genelist ;$i++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
100 # if ($gene) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
101 # }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
102 # }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
103 #}
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
104
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
105 my %gene_desity;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
106 foreach my $chr (sort keys %genelist) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
107 my @genelist=sort{$a->[1] <=> $b->[1]}@{$genelist{$chr}};
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
108 for (my $i=0;$i<@genelist ;$i++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
109 my $start=int($genelist[$i][1]/$span);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
110 my $end=int($genelist[$i][2]/$span);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
111 #my @t_rpkm=split/\t/,$target_rpkm{$genelist[$i][0]};
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
112 if ($start==$end) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
113 $gene_desity{$chr}[$start]++;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
114 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
115 else{
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
116 for (my $k=$start;$k<=$end ;$k++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
117 $gene_desity{$chr}[$k]++;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
118 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
119 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
120 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
121 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
122 #------------------------------------------region_gene_number-------------------------
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
123 my $max_gene_number=0;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
124 my $total=0;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
125 foreach my $chr (sort keys %genelist) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
126 for (my $i=0;$i<@{$gene_desity{$chr}} ;$i++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
127 if (!(defined($gene_desity{$chr}[$i]))) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
128 $gene_desity{$chr}[$i]=0;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
129 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
130 if ($gene_desity{$chr}[$i]>$max_gene_number) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
131 $max_gene_number=$gene_desity{$chr}[$i];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
132 #print "$gene_desity{$chr}[$i]\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
133 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
134 #print TXT "$i\t$gene_desity[$i]\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
135 $total+=$gene_desity{$chr}[$i];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
136 #print "$chr\t$i\t$gene_desity{$chr}[$i]\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
137 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
138 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
139 #print "Gene max:$max_gene_number\ntotal:$total\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
140
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
141 #---------------------------------------------------------------
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
142 my %centromere;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
143 if (defined($opt{cen})) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
144 open CEN,"$opt{cen}";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
145 while (my $aline=<CEN>) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
146 chomp $aline;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
147 next if($aline=~/^\#/);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
148 my @temp=split/\t/,$aline;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
149 $temp[0]=~s/^c/C/;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
150 $centromere{$temp[0]}[0]=$temp[1];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
151 $centromere{$temp[0]}[1]=$temp[2];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
152 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
153 close CEN;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
154 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
155
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
156 #---------------------------------------------------------------
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
157 my $max_length=0;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
158 foreach my $chr (keys %length) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
159 if ($max_length<$length{$chr}) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
160 $max_length=$length{$chr};
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
161 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
162 print "$chr\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
163 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
164 #====================================cluster data=======================================
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
165 open(CLUSTER,"$opt{c}")||die"cannot open the file $opt{c}";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
166 my %cluster;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
167 my %cluster_density;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
168 #my @sample=qw(39B3 3PA3 3LC3);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
169 my @cluster_non_add;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
170 while (my $aline=<CLUSTER>) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
171 next if($aline=~/^\#/);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
172 chomp $aline;##Chr MajorLength Percent end 19B1
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
173 my @temp=split/\t/,$aline;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
174 my @ID=split/\:/,$temp[0];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
175 my @posi=split/\-/,$ID[1];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
176 my @all_rpkm=@temp;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
177 shift @all_rpkm;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
178 shift @all_rpkm;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
179 shift @all_rpkm;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
180 # for (my $s=0;$s<@all_rpkm ;$s++) {#log transfer
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
181 # $all_rpkm[$s]=log2($all_rpkm[$s]);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
182 # }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
183 push @{$cluster{$ID[0]}},[$temp[0],$posi[0],$posi[1],@all_rpkm];#ID start end rpkm(19B1,1PA1,1LC1);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
184 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
185 close CLUSTER;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
186 my %max_cluster;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
187 my $chr_number=0;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
188 print "@mark\n$mark\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
189 foreach my $chr (sort keys %cluster) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
190 for (my $i=0;$i<@mark ;$i++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
191 $max_cluster{$chr}[$i]=0;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
192 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
193 $chr_number++;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
194 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
195 foreach my $chr (sort keys %cluster) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
196 @{$cluster{$chr}}=sort{$a->[1] <=> $b->[1]}@{$cluster{$chr}};
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
197 for (my $i=0;$i<$#{$cluster{$chr}} ;$i++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
198 for (my $s=0;$s<@mark;$s++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
199 if ($cluster{$chr}[$i][3+$s]>$max_cluster{$chr}) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
200 $max_cluster{$chr}[$s]=$cluster{$chr}[$i][3+$s];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
201 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
202 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
203 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
204
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
205 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
206 foreach my $chr (sort keys %max_cluster) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
207 for (my $s=0; $s<@mark;$s++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
208 # print "$max_cluster{$chr}[$s]\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
209 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
210 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
211 #---------------------------------------------------------------------------------------
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
212 foreach my $chr(keys %cluster) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
213 for(my $i=0;$i<$#{$cluster{$chr}};$i++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
214 my $start=int($cluster{$chr}[$i][1]/$span);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
215 my $end=int($cluster{$chr}[$i][2]/$span);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
216 if ($start==$end) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
217 for (my $s=0;$s<@mark ;$s++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
218 $cluster_density{$chr}[$start][$s]+=$cluster{$chr}[$i][3+$s];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
219 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
220
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
221 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
222 else{
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
223 for (my $m=$start;$m<=$end ;$m++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
224 for (my $s=0;$s<@mark ;$s++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
225 $cluster_density{$chr}[$m][$s]+=$cluster{$chr}[$i][3+$s];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
226 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
227 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
228 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
229 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
230 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
231 my %max_cluster_density;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
232 my $max_all_density=0;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
233 foreach my $chr (sort keys %cluster) {#
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
234 for (my $s=0;$s<@mark ;$s++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
235 for (my $i=0;$i<$#{$cluster{$chr}} ;$i++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
236 $max_cluster_density{$chr}[$s]=0;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
237 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
238 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
239
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
240 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
241 foreach my $chr (sort keys %cluster_density) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
242 print "$#{$cluster_density{$chr}}\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
243 for (my $k=0;$k<$#{$cluster_density{$chr}} ;$k++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
244 print TXT "$chr\t$k";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
245 for (my $s=0;$s<@mark;$s++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
246 if (!(defined($cluster_density{$chr}[$k][$s]))) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
247 $cluster_density{$chr}[$k][$s]=0;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
248 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
249 if ($cluster_density{$chr}[$k][$s]>$max_cluster_density{$chr}[$s]) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
250 $max_cluster_density{$chr}[$s]=$cluster_density{$chr}[$k][$s];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
251 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
252 if ($cluster_density{$chr}[$k][$s]>$max_all_density) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
253 $max_all_density=$cluster_density{$chr}[$k][$s];
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
254 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
255 print TXT "\t$cluster_density{$chr}[$k][$s]";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
256 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
257 print TXT "\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
258 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
259 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
260 print "max density: $max_all_density\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
261 #--------------------------------------------------------------------
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
262 my $top_margin=30;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
263 my $tail_margin=30;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
264 my $XOFFSET=50;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
265 my $YOFFSET=60;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
266 my $chr_length=600;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
267 my $Xscale=$chr_length/$max_length;#¶¨ÒåXÖá±ÈÀý³ß 1:1000 xÖáµÄ×ø±ê³¤¶È¶¼Òª°´Õմ˱ÈÀý³ß»»Ëã
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
268 #my $high_cov=$high_cov9B1=0.5;#¶¨Òå·åͼ×î¸ß·å
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
269 #my $Yscale=1/$high_cov;#¶¨ÒåYÖá±ÈÀý³ß 1:60 yÖáµÄ×ø±ê³¤¶È¶¼Òª°´Õմ˱ÈÀý³ß»»Ëã
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
270 #========================================New canvas============================
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
271 #### Starting ####
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
272 #н¨»­²¼
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
273 my $width=1000;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
274 my $heigth=100+130*$chr_number;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
275 my $svg=SVG->new(width=>$width, height=>$heigth);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
276 #»­Í¼Æðʼµã
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
277 my $canvas_start_x=$XOFFSET;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
278 my $canvas_end_x=$XOFFSET+$max_length*$Xscale;#°´ÕÕ±ÈÀý³ß »­Ïß
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
279 my $canvas_start_y=$YOFFSET;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
280 my $canvas_end_y=$YOFFSET;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
281 my $chr_heigth=$heigth-$YOFFSET-$tail_margin;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
282 print "chr number:$chr_number\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
283 my $one_chr_heigth=$chr_heigth/$chr_number;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
284 my $Yscale=($one_chr_heigth-15)/$max_all_density;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
285 #my $chr_width=$YOFFSET;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
286 #my $chr_start_y;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
287 #my $chr_end_y;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
288 #my $Yscale=0.01;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
289 #=======================================title of the graph===============================
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
290 #my $span_k=$span/1000;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
291 #$svg->text('x',$width/2,'y',$YOFFSET-20,'style','fill:black;text-anchor:middle','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',15,'font-family',$attribute{font}{'font-family'},'-cdata',"Clusters rpkm/"."$span_k"."kb Distribution");
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
292 #=======================================the top max chr line=============================
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
293 $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'});
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
294 $long_scale=int ($max_length/10);#Ê®µÈ·Ö ´ó¿Ì¶È
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
295 #´ó×ø±ê¿Ì¶È
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
296 for ($i=0;$i<=10;$i++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
297 my $long_x_start=$XOFFSET+$long_scale*$i*$Xscale;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
298 my $long_x_end=$long_x_start;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
299 my $long_y_start=$YOFFSET;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
300 my $long_y_end=$YOFFSET-5;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
301 $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'});
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
302 my $Bscale=$long_scale*$i;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
303 my $cdata=int ($Bscale/1000000);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
304 $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");
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
305 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
306 #=========================================================================================
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
307 my $cc=1;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
308 foreach my $chr (sort keys %length) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
309 my $chr_end_x=$XOFFSET+$length{$chr}*$Xscale;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
310 my $chr_start_x=$XOFFSET;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
311 my $chr_start_y=$YOFFSET+$cc*$one_chr_heigth;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
312 my $chr_end_y=$chr_start_y;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
313 #$chr_start_y+=$chr_width;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
314 #$chr_end_y+=$chr_width;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
315 # for (my $i=0;$i<@{$gene_desity{$chr}};$i++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
316 # print "$chr\t$i\t$gene_desity{$chr}[$i]\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
317 # my $red=$gene_desity{$chr}[$i]/$max_gene_number*255;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
318 # my $green=$gene_desity{$chr}[$i]/$max_gene_number*255;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
319 # print "$red\t$green\t0\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
320 # $svg->rect('x',$chr_start_x+$i*$span*$Xscale,'y',$chr_start_y,'width',$span*$Xscale,'height',8,'stroke',"rgb($red,$green,0)",'stroke-width',0.1,'fill',"rgb($red,$green,0)");
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
321 # }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
322
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
323 $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'});
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
324 $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);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
325 my $m_length=$length{$chr}%1000000;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
326 $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',$m_length."M");
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
327
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
328
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
329 if (defined($centromere{$chr}[0])) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
330 $svg->rect('x',$XOFFSET+$centromere{$chr}[0]*$Xscale,'y',$chr_start_y-2,'width',($centromere{$chr}[1]-$centromere{$chr}[0]+1)*$Xscale,'height',5,'stroke',"blue",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"blue");
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
331 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
332 for (my $s=0;$s<@mark ;$s++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
333 for (my $i=0;$i<$#{$cluster_density{$chr}}-1 ;$i++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
334 #if ($cluster_density{$chr}[$i]*$Yscale>40) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
335 #$cluster_density{$chr}[$i]=40/$Yscale;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
336 #$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");
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
337 #}
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
338 #print "$i\t$cluster_density{$chr}[$i][$s]\t$cluster_density{$chr}[$i+1][$s]\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
339 my $cluster_density_start_x=$XOFFSET+$i*$span*$Xscale;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
340 my $cluster_density_end_x=$XOFFSET+($i+1)*$span*$Xscale;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
341 my $cluster_density_start_y=$chr_start_y-$cluster_density{$chr}[$i][$s]*$Yscale;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
342 my $cluster_density_end_y=$chr_start_y-$cluster_density{$chr}[$i+1][$s]*$Yscale;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
343 my $c_red=($s+1)/@mark*255;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
344 $svg->line('x1',$cluster_density_start_x,'y1',$cluster_density_start_y,'x2',$cluster_density_end_x,'y2',$cluster_density_end_y,'stroke',"rgb($c_red,125,0)",'stroke-width',0.3);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
345 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
346
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
347 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
348 #=======Y axis
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
349 $svg->line(x1=>$chr_start_x,y1=>$chr_start_y,x2=>$chr_start_x,y2=>$chr_start_y-$one_chr_heigth+15,'stroke',$attribute{line}{'stroke'},'stroke-width',$attribute{line}{'stroke-width'});
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
350 #=======Y axis ===>3 xiaoge
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
351 my $s10=1;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
352 my $e10=0;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
353 my $chr_max=$max_all_density;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
354 while ($chr_max>10) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
355 $chr_max=int($chr_max/10);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
356 $s10=$s10*10;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
357 $e10++;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
358 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
359 $chr_max=$chr_max/2;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
360 #print "*****$max_all_density\t$chr_max\t$s10\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
361 for (my $i=1;$i<3 ;$i++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
362 my $y1=$chr_start_y-$chr_max*$s10*$Yscale*$i;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
363 my $xiaoge_Y=$chr_max*$i;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
364 $svg->line('x1',$chr_start_x,'y1',$y1,'x2',$chr_start_x+3,'y2',$y1,'stroke',$attribute{line}{'stroke'},'stroke-width',$attribute{line}{'stroke-width'});
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
365 $svg->text('x',$chr_start_x-26,'y',$y1+4,'style','fill:black;text-anchor:left','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',8,'font-family',$attribute{font}{'font-family'},'-cdata',$xiaoge_Y."e".$e10);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
366 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
367 $cc++;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
368 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
369
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
370 for (my $s=0;$s<@mark ;$s++) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
371 my $c_red=($s+1)/@mark*255;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
372 print "**$c_red\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
373 $svg->line('x1',$canvas_end_x+100,'y1',$YOFFSET+$s*20+30,'x2',$canvas_end_x+130,'y2',$YOFFSET+$s*20+30,'stroke',"rgb($c_red,125,0)",'stroke-width',1);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
374 $svg->text('x',$canvas_end_x+150,'y',$YOFFSET+$s*20+5+30,'style','fill:black;text-anchor:left','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',10,'font-family',$attribute{font}{'font-family'},'-cdata',$mark[$s]);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
375 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
376 #
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
377 #
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
378 if (defined($opt{cen})) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
379 $svg->rect('x',$canvas_end_x+100,'y',$YOFFSET+@mark*20+30,'width',30,'height',5,'stroke',"blue",'stroke-width',$attribute{intron}{'stroke-width'},'fill',"blue");
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
380 $svg->text('x',$canvas_end_x+150,'y',$YOFFSET+@mark*20+30+5,'style','fill:black;text-anchor:left','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',10,'font-family',$attribute{font}{'font-family'},'-cdata',"centromere");
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
381 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
382
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
383 close TXT;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
384
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
385 open (OUT,">$opt{o}");
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
386 print OUT $svg->xmlify();
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
387
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
388 sub log2 {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
389 my $n = shift;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
390 return log($n)/log(2);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
391 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
392
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
393 sub usage{
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
394 print <<"USAGE";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
395 Version $version
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
396 Usage:
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
397 $0
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
398 options:
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
399 -g genelist
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
400 -span
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
401 -n sample cloumn
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
402 -mark sample name
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
403 -o output graph file name with html or svg extension
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
404 -c cluster file input
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
405 -out txt output
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
406 -l length of chr
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
407 -cen centromere
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
408 -h help
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
409 USAGE
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
410 exit(1);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
411 }