| 1 | package Bio::Graphics::Glyph::fb_shmiggle; | ||
| 2 | |||
| 3 | # [ to see proper formatting set tab==2 ] | ||
| 4 | # | ||
| 5 | # 2009-2010 Victor Strelets, FlyBase.org | ||
| 6 | |||
| 7 | use constant DEBUG => 0; | ||
| 8 | |||
| 9 | #use strict; | ||
| 10 | use GD; | ||
| 11 | use vars '@ISA'; | ||
| 12 | use Bio::Graphics::Glyph::generic; | ||
| 13 | BEGIN{ @ISA = 'Bio::Graphics::Glyph::generic'; | ||
| 14 | local($colors_selected,$black,$red,$white,$grey); | ||
| 15 | @colors= (); | ||
| 16 | @colcycle= ( | ||
| 17 | # red/orange | ||
| 18 | 'A62A2A', # + | ||
| 19 | 'CC3299', # + | ||
| 20 | 'FF7F00', # + | ||
| 21 | # yellow/brown | ||
| 22 | 'B87333', # + | ||
| 23 | # greenish | ||
| 24 | '6B8E23', # + | ||
| 25 | '238E68', # + | ||
| 26 | # blue/violet | ||
| 27 | '6982CA', # + | ||
| 28 | '2222AD', # + | ||
| 29 | ); | ||
| 30 | %Indices= (); | ||
| 31 | local(*DATF); | ||
| 32 | } | ||
| 33 | |||
| 34 | #-------------------------- | ||
| 35 | sub draw { | ||
| 36 | my $self = shift; | ||
| 37 | my $gd = shift; | ||
| 38 | my ($left,$top,$partno,$total_parts) = @_; | ||
| 39 | my $ft= $self->feature; | ||
| 40 | my $ftid= $ft->{id}; | ||
| 41 | my $pn= $self->panel; | ||
| 42 | my $fgc = $self->fgcolor; | ||
| 43 | my $bgc = $self->bgcolor; | ||
| 44 | my($r,$g,$b); | ||
| 45 | |||
| 46 | unless( $colors_selected ) { | ||
| 47 | $black= $gd->colorClosest(0,0,0); | ||
| 48 | $yellow= $gd->colorClosest(255,255,0); | ||
| 49 | $white= $gd->colorClosest(255,255,255); | ||
| 50 | $red= $gd->colorClosest(255,0,0); | ||
| 51 | $lightgrey= $gd->colorClosest(225,225,225); | ||
| 52 | $grey= $gd->colorClosest(200,200,200); | ||
| 53 | $darkgrey= $gd->colorClosest(125,125,125); | ||
| 54 | foreach my $ccc ( @colcycle ) { | ||
| 55 | if( $ccc=~/^[#]?(\S\S)(\S\S)(\S\S)$/ ) { | ||
| 56 | ($r,$g,$b)= ($1,$2,$3); | ||
| 57 | eval('$r=hex("0x'.$r.'");'); | ||
| 58 | eval('$g=hex("0x'.$g.'");'); | ||
| 59 | eval('$b=hex("0x'.$b.'");'); | ||
| 60 | } | ||
| 61 | my $c= $gd->colorClosest($r,$g,$b); | ||
| 62 | push(@colors,$c); | ||
| 63 | } | ||
| 64 | $colors_selected= 1; | ||
| 65 | } | ||
| 66 | |||
| 67 | my($pnstart,$pnstop)= ($pn->start,$pn->end); # in seq coordinates | ||
| 68 | my $nseqpoints= $pnstop - $pnstart + 1; | ||
| 69 | my($xf1,$yf1,$xf2,$yf2)= $self->calculate_boundaries($left,$top); | ||
| 70 | my $leftpad= $pn->pad_left; | ||
| 71 | my $datadir= $ENV{SERVER_PATH} . $ft->{datadir}; | ||
| 72 | |||
| 73 | my($start,$stop)= $pn->location2pixel(($ft->{start},$ft->{end})); | ||
| 74 | my $ftscrstop= $stop + $leftpad; | ||
| 75 | my $ftscrstart= $start + $leftpad; | ||
| 76 | |||
| 77 | my $chromosome= $ft->{ref}; | ||
| 78 | #warn("pn start stop leftpad nseq dir = $pnstart $pnstop $leftpad $datadir $chromosome\n"); | ||
| 79 | my $flipped= $self->{flip} ? 1 : 0; | ||
| 80 | my($subsets,$subsetsnames,$signals)= $self->getData($ft,$datadir,$chromosome,$pnstart,$pnstop,$xf1,$xf2,$flipped); | ||
| 81 | |||
| 82 | my $poly_pkg = $self->polygon_package; | ||
| 83 | |||
| 84 | my @orderedsubsets= @{$subsets}; | ||
| 85 | my $nsets= $#orderedsubsets+1; | ||
| 86 | my($xstep,$ystep)= (2,int(100.0/$nsets)); | ||
| 87 | $ystep= 7 unless $ystep>=7; # empiricaly found - to read lines of tiny fonts | ||
| 88 | $ystep= 12 if $ystep>12; # empirically found - to preserve topo feel when number of subsets is small | ||
| 89 | $ystep= 7 if $ystep>7; # tmp unification | ||
| 90 | my($xw,$yw)= ( $nsets*$xstep, ($nsets-1)*$ystep ); | ||
| 91 | |||
| 92 | my $polybg= $poly_pkg->new(); | ||
| 93 | $polybg->addPt($xf1,$yf2-$yw); | ||
| 94 | $polybg->addPt($xf2,$yf2-$yw); | ||
| 95 | $polybg->addPt($xf2-$xw, $yf2); | ||
| 96 | $polybg->addPt($xf1-$xw, $yf2); | ||
| 97 | $gd->filledPolygon($polybg,$lightgrey); # background | ||
| 98 | for( my $xx= $xf1+2; $xx<$xf2; $xx+=6 ) { $gd->line($xx,$yf2-$yw,$xx-$xw,$yf2,$grey); } # grid-helper | ||
| 99 | |||
| 100 | my $xshift= 0; | ||
| 101 | my $yshift= $nsets * $ystep; | ||
| 102 | ($r,$g,$b)= (10,150,80); | ||
| 103 | my $colcycler= 0; | ||
| 104 | my @screencoords= @{$signals->{screencoords}}; | ||
| 105 | my $max_signal= 30; | ||
| 106 | my $koeff= 4; | ||
| 107 | if( exists $signals->{max_signal} ) { | ||
| 108 | $max_signal= $signals->{max_signal}; | ||
| 109 | $koeff= 80.0/$max_signal; | ||
| 110 | } | ||
| 111 | my $predictor_cutoff= int($max_signal*0.95); # empirically found | ||
| 112 | my @prevx= (); | ||
| 113 | my @prevy= (); | ||
| 114 | my @prevvals= (); | ||
| 115 | my $profilen= 0; | ||
| 116 | my %SPEEDUP= (); | ||
| 117 | foreach my $subset ( @orderedsubsets ) { | ||
| 118 | my $edgecolor= ($xshift==0) ? $black : $yellow; | ||
| 119 | #my $color= ($xshift==0) ? $darkgrey : $gd->colorClosest(oct($r),oct($g),oct($b)); | ||
| 120 | my $color= ($profilen==0) ? $darkgrey : $colors[$colcycler]; | ||
| 121 | $xshift -= $xstep; | ||
| 122 | $yshift -= $ystep; | ||
| 123 | my @values= @{$signals->{$subset}}; | ||
| 124 | my($xold,$yold)= ($xf1+$xshift,$yf2-$yshift+1); | ||
| 125 | my $xpos= 0; | ||
| 126 | my $poly= $poly_pkg->new(); | ||
| 127 | $poly->addPt($xold,$yold+1); | ||
| 128 | my @allx= ($xold); | ||
| 129 | my @ally= ($yold); | ||
| 130 | my @allvals= (0); | ||
| 131 | my $runx= $xf1 + $xshift; | ||
| 132 | foreach my $val ( @values ) { | ||
| 133 | $scrx += $leftpad; | ||
| 134 | my $x= $screencoords[$xpos] + $xshift; | ||
| 135 | my $visval; | ||
| 136 | if( exists $SPEEDUP{$val} ) { $visval= $SPEEDUP{$val}; } | ||
| 137 | else { $visval= int($val*$koeff); $SPEEDUP{$val}= $visval; } | ||
| 138 | my $y= $yf2 - $yshift - $visval; | ||
| 139 | push(@allx,$x); | ||
| 140 | push(@ally,$y); | ||
| 141 | push(@allvals,$visval); | ||
| 142 | if( $xpos>0 ) { | ||
| 143 | $poly->addPt($x,$y+1); | ||
| 144 | } | ||
| 145 | ($xold,$yold)= ($x,$y); | ||
| 146 | $xpos++; | ||
| 147 | } | ||
| 148 | $poly->addPt($xf2+$xshift, $yf2-$yshift+1); | ||
| 149 | $gd->filledPolygon($poly,$color) unless $profilen==0; # not on MAX predictor | ||
| 150 | ($xold,$yold)= ($allx[0],$ally[0]); | ||
| 151 | for( my $en=1; $en<=$#allx; $en++ ) { | ||
| 152 | my $x= $allx[$en]; | ||
| 153 | my $y= $ally[$en]; | ||
| 154 | $gd->line($xold,$yold,$x,$y,$edgecolor); | ||
| 155 | ($xold,$yold)= ($x,$y); | ||
| 156 | } | ||
| 157 | if( $profilen==0 ) { # drawing mRNA (cutoff-based) predictor on MAX subset | ||
| 158 | my($xxx,$yyy)= ($allx[1]-1,$yf2-$yw); | ||
| 159 | $gd->line($xxx-4,$yyy,$xxx-2,$yyy,$black); | ||
| 160 | $gd->string(GD::Font->Tiny,$xxx-12, $yyy-3,'0',$black); | ||
| 161 | $gd->line($xxx-2,$yyy,$xxx-2,$yyy-50,$black); | ||
| 162 | $gd->line($xxx-4,$yyy-47,$xxx-2,$yyy-50,$black); | ||
| 163 | $gd->line($xxx,$yyy-47,$xxx-2,$yyy-50,$black); | ||
| 164 | $gd->line($xxx-4,$yyy-44,$xxx-2,$yyy-44,$black); | ||
| 165 | $gd->string(GD::Font->Tiny,$xxx-18, $yyy-47,$max_signal,$black); | ||
| 166 | my($inexon,$exstart,$exend,$ymax)= (0,0,0,999); | ||
| 167 | for( my $en=1; $en<=$#allx; $en++ ) { | ||
| 168 | my $y= $ally[$en]; | ||
| 169 | $ymax= $y if $y < $ymax; | ||
| 170 | if( $allvals[$en]>=$predictor_cutoff ) { | ||
| 171 | my $x= $allx[$en]; | ||
| 172 | unless( $inexon ) { $inexon= 1; $exstart= $x; } # start exon | ||
| 173 | $exend= $x; | ||
| 174 | } | ||
| 175 | elsif( $inexon ) { # end exon and draw it | ||
| 176 | $inexon= 0; | ||
| 177 | $ymax -= 6; | ||
| 178 | my $allowedymax= $yf2-$yshift-45; | ||
| 179 | $ymax= $allowedymax if $ymax < $allowedymax; # set limit for huge peaks | ||
| 180 | $gd->line($exstart,$ymax,$exstart,$ymax+2,$red); | ||
| 181 | $gd->line($exstart,$ymax,$exend,$ymax,$red); | ||
| 182 | $gd->line($exend,$ymax,$exend,$ymax+2,$red); | ||
| 183 | ($inexon,$exstart,$exend,$ymax)= (0,0,0,999); | ||
| 184 | } | ||
| 185 | } | ||
| 186 | if( $inexon ) { # exon which ends beyond this screen | ||
| 187 | $ymax -= 6; | ||
| 188 | my $allowedymax= $yf2-$yshift-45; | ||
| 189 | $ymax= $allowedymax if $ymax < $allowedymax; # set limit for huge peaks | ||
| 190 | $gd->line($exstart,$ymax,$exstart,$ymax+2,$red); | ||
| 191 | $gd->line($exstart,$ymax,$exend,$ymax,$red); | ||
| 192 | } | ||
| 193 | } | ||
| 194 | if( 0 && $profilen>1 ) { # blocked - drawing roof lines doesn't work well with this view.. | ||
| 195 | for( my $en=3; $en<=$#allx; $en+=6 ) { | ||
| 196 | next if $allvals[$en]==0 || $prevvals[$en]==0; | ||
| 197 | my $y= $ally[$en]; | ||
| 198 | $yold= $prevy[$en]; | ||
| 199 | if( $yold<$y ) { | ||
| 200 | my $x= $allx[$en]; | ||
| 201 | $xold= $prevx[$en]; | ||
| 202 | $gd->line($xold,$yold,$x,$y,$darkgrey); | ||
| 203 | } | ||
| 204 | } | ||
| 205 | } | ||
| 206 | $gd->string(GD::Font->Tiny,$xf2+$xshift+3, $yf2-$yshift-5,$subsetsnames->{$subset},$color); | ||
| 207 | $colcycler++; | ||
| 208 | $colcycler= 0 if $colcycler>$#colors; | ||
| 209 | unless( $profilen==0 ) { @prevx= @allx; @prevy= @ally; @prevvals= @allvals; } | ||
| 210 | $profilen++; | ||
| 211 | } | ||
| 212 | |||
| 213 | return; | ||
| 214 | } | ||
| 215 | |||
| 216 | #-------------------------- | ||
| 217 | sub getData { | ||
| 218 | my $self = shift; | ||
| 219 | my($ft,$datadir,$chromosome,$start,$stop,$scrstart,$scrstop,$flipped) = @_; | ||
| 220 | my %Signals= (); | ||
| 221 | $self->openDataFiles($datadir); | ||
| 222 | my @subsets= (exists $ft->{'subsetsorder'}) ? @{$ft->{'subsetsorder'}} : sort split(/\t+/,$Indices{'subsets'}); | ||
| 223 | shift(@subsets) if $subsets[0] eq 'MAX'; | ||
| 224 | warn("subsets: @subsets\n") if DEBUG; | ||
| 225 | my %SubsetsNames= (exists $ft->{'subsetsnames'}) ? %{$ft->{'subsetsnames'}} : map { $_, $_ } @subsets; | ||
| 226 | $SubsetsNames{MAX}= 'MAX'; | ||
| 227 | my $screenstep= ($scrstop-$scrstart+1) * 1.0 / ($stop-$start+1); | ||
| 228 | my $donecoords= 0; | ||
| 229 | foreach my $subset ( @subsets ) { | ||
| 230 | my $nstrings= 0; | ||
| 231 | # scan seq ranges offsets to see where to start reading | ||
| 232 | my $key= $subset.':'.$chromosome; | ||
| 233 | my $poskey= $key.':offsets'; | ||
| 234 | my $ranges_pos= (exists $Indices{$poskey}) ? int($Indices{$poskey}) : -1; | ||
| 235 | if( $ranges_pos == -1 ) { next; } # no such signal.. | ||
| 236 | warn(" positioning for $poskey starts at $ranges_pos\n") if DEBUG; | ||
| 237 | if( $start>=1000000 ) { | ||
| 238 | my $bigstep= int($start/1000000.0); | ||
| 239 | if( exists $Indices{$key.':offsets:'.$bigstep} ) { | ||
| 240 | my $jumpval= $Indices{$key.':offsets:'.$bigstep}; | ||
| 241 | warn(" jump in offset search to $jumpval\n") if DEBUG; | ||
| 242 | $ranges_pos= int($jumpval); } | ||
| 243 | } | ||
| 244 | seek(DATF,$ranges_pos,0); | ||
| 245 | my($offset,$offset1)= (0,0); | ||
| 246 | my $lastseqloc= -999999999; | ||
| 247 | my $useoffset= 0; | ||
| 248 | while( (my $strs=<DATF>) ) { | ||
| 249 | $nstrings++ if DEBUG; | ||
| 250 | if( DEBUG ) { | ||
| 251 | chop($strs); warn(" positioning read for coord $start ($strs)\n"); } | ||
| 252 | last unless $strs=~m/^(-?\d+)[ \t]+(\d+)/; | ||
| 253 | my($seqloc,$fileoffset)= ($1,$2); | ||
| 254 | if( DEBUG ) { | ||
| 255 | chop($strs); warn(" positioning read for $poskey => $seqloc, $fileoffset ($strs)\n"); } | ||
| 256 | $offset1= $offset; | ||
| 257 | $offset= $fileoffset; | ||
| 258 | $lastseqloc= $seqloc; | ||
| 259 | if( $seqloc > $start ) { $useoffset= int($offset1); last; } | ||
| 260 | } | ||
| 261 | warn(" will use offset $useoffset\n") if DEBUG; | ||
| 262 | warn(" (scanned $nstrings offset strings)\n") if DEBUG; | ||
| 263 | if( $useoffset==0 ) { # data offset cannot be 0 - means didn't find where to read required data.. | ||
| 264 | next; | ||
| 265 | my @emptyvals= (); | ||
| 266 | for( my $ii= $scrstart; $ii++ <= $scrstop; ) { push(@emptyvals,0); } | ||
| 267 | $Signals{$subset}= \@emptyvals; | ||
| 268 | } | ||
| 269 | $nstrings= 0; | ||
| 270 | # read signal profile | ||
| 271 | seek(DATF,$useoffset,0); | ||
| 272 | $lastseqloc= -999999999; | ||
| 273 | my $lastsignal= 0; | ||
| 274 | my($scrx,$scrxold)= ($scrstart,$scrstart-1); | ||
| 275 | my $runmax= 0; | ||
| 276 | my @values= (); | ||
| 277 | my @xscreencoords= (); | ||
| 278 | while( (my $str=<DATF>) ) { | ||
| 279 | $nstrings++ if DEBUG; | ||
| 280 | unless( $str=~m/^(-?\d+)[ \t]+(\d+)/ ) { | ||
| 281 | warn(" header read: $str") if DEBUG; | ||
| 282 | last; # because no headers were indexed at the beginning of data packs | ||
| 283 | } | ||
| 284 | my($seqloc,$signal)= ($1,$2); | ||
| 285 | warn(" signal read: $seqloc, $signal line: $str") if DEBUG; | ||
| 286 | last if $lastseqloc > $seqloc; # just in case, as all sits merged in one file.. | ||
| 287 | if( $seqloc>=$start ) { # current is the next one after the one we need to start from.. | ||
| 288 | unless( $lastseqloc== -999999999 ) { # expand previous | ||
| 289 | $lastseqloc= $start-2 if $lastseqloc<$start; # limit empty steps (they may start from -200000) | ||
| 290 | while( $lastseqloc < $seqloc ) { # until another (one we just retrieved) wiggle reading | ||
| 291 | last if $lastseqloc > $stop; # end of subset data | ||
| 292 | next if $lastseqloc++ < $start; | ||
| 293 | # we have actual new seq position in our required range | ||
| 294 | my $scrpos= int($scrx); | ||
| 295 | $runmax= $lastsignal if $runmax < $lastsignal; | ||
| 296 | if( $scrpos != $scrxold ) { # we have actual new seq _and_ screen position | ||
| 297 | push(@values,$runmax); | ||
| 298 | push(@xscreencoords,$scrpos) unless $donecoords; | ||
| 299 | $scrxold= $scrpos; | ||
| 300 | $runmax= 0; | ||
| 301 | } | ||
| 302 | $scrx += $screenstep; # remember - it is not integer | ||
| 303 | } | ||
| 304 | } | ||
| 305 | } | ||
| 306 | ($lastseqloc,$lastsignal)= ($seqloc,$signal); | ||
| 307 | last if $seqloc > $stop; # end of subset data | ||
| 308 | } | ||
| 309 | if( $lastseqloc < $stop ) { # if on the end of signal profile, but still in screen range | ||
| 310 | # just assume that we are getting one more reading with signal == 0 | ||
| 311 | my $signal= 0; | ||
| 312 | while( $lastseqloc++ < $stop ) { | ||
| 313 | my $scrpos= int($scrx); | ||
| 314 | if( $scrpos != $scrxold ) { # we have actual new seq _and_ screen position | ||
| 315 | push(@values,$signal); | ||
| 316 | push(@xscreencoords,$scrpos) unless $donecoords; | ||
| 317 | $scrxold= $scrpos; | ||
| 318 | } | ||
| 319 | $scrx += $screenstep; | ||
| 320 | } | ||
| 321 | } | ||
| 322 | warn(" (scanned $nstrings signal strings)\n") if DEBUG; | ||
| 323 | $nstrings= 0; | ||
| 324 | if( $flipped ) { | ||
| 325 | my @ch= reverse @values; @values= @ch; | ||
| 326 | } | ||
| 327 | warn(" ".$subset."=> ".@values." values @values\n") if DEBUG && $#values<1000; | ||
| 328 | $Signals{$subset}= \@values; | ||
| 329 | $Signals{screencoords}= \@xscreencoords unless $donecoords; | ||
| 330 | $donecoords= 1; | ||
| 331 | } # foreach my $subset ( @subsets ) { | ||
| 332 | if( exists $Indices{max_signal} ) { | ||
| 333 | $Signals{max_signal}= $Indices{max_signal}; | ||
| 334 | warn(" max_signal=> ".$Indices{max_signal}." \n") if DEBUG; | ||
| 335 | } | ||
| 336 | # prepare MAX profile - will be used as a base for exon/UTR prediction | ||
| 337 | my @maxprofile= (); | ||
| 338 | my @ruler= @{$Signals{screencoords}}; | ||
| 339 | for( my $npos= 0; $npos<=$#ruler; $npos++ ) { | ||
| 340 | my $maxval= 0; | ||
| 341 | foreach my $subset ( @subsets ) { | ||
| 342 | my $p= $Signals{$subset}; | ||
| 343 | my $val= $p->[$npos]; | ||
| 344 | $maxval= $val if $maxval < $val; | ||
| 345 | } | ||
| 346 | push(@maxprofile,$maxval); | ||
| 347 | } | ||
| 348 | $Signals{MAX}= \@maxprofile; | ||
| 349 | warn(" MAX=> ".@maxprofile." values @maxprofile\n") if DEBUG && $#maxprofile<1000; | ||
| 350 | unshift(@subsets,'MAX'); | ||
| 351 | |||
| 352 | return(\@subsets,\%SubsetsNames, \%Signals); | ||
| 353 | } | ||
| 354 | |||
| 355 | #-------------------------- | ||
| 356 | sub openDataFiles { | ||
| 357 | my $self = shift; | ||
| 358 | my $datadir= shift; | ||
| 359 | $datadir.= '/' unless $datadir=~m|/$|; | ||
| 360 | my $datafile= $datadir.'data.cat'; | ||
| 361 | open(DATF,$datafile) || warn("cannot open $datafile\n"); | ||
| 362 | use BerkeleyDB; # caller should already used proper 'use lib' command with path | ||
| 363 | my $bdbfile= $datadir . 'index.bdbhash'; | ||
| 364 | tie %Indices, "BerkeleyDB::Hash", -Filename => $bdbfile, -Flags => DB_RDONLY || warn("can't read BDBHash $bdbfile\n"); | ||
| 365 | if( DEBUG ) { foreach my $kk ( sort keys %Indices ) { warn(" $kk => ".$Indices{$kk}."\n"); } } | ||
| 366 | return; | ||
| 367 | } | ||
| 368 | |||
| 369 | 1; | ||
| 370 | |||
| 371 | |||
| 372 | =pod | ||
| 373 | |||
| 374 | =head1 TopoView Glyph | ||
| 375 | |||
| 376 | =begin html | ||
| 377 | |||
| 378 | <i>Warning:</i> This software is still in the developmental stage and is distributed | ||
| 379 | "as is", without packaging and in the same exact condition as currently used by FlyBase. | ||
| 380 | You are free to use it, modify and develop further, but proper reference | ||
| 381 | to the original author and FlyBase is required. | ||
| 382 | |||
| 383 | <p> | ||
| 384 | |||
| 385 | "fb_shmiggle.pm" TopoView (AKA shmiggle) glyph was developed for fast | ||
| 386 | 3D-like demonstration of RNA-seq data consisting of multiple | ||
| 387 | individual subsets. Main purposes were to compact presentation as | ||
| 388 | much as possible (in one reasonably sized track) and | ||
| 389 | to allow easy visual detection of coordinated behavior | ||
| 390 | of the expression profiles of different subsets. | ||
| 391 | |||
| 392 | <p> | ||
| 393 | |||
| 394 | It was found that log2 conversion dramatically changes | ||
| 395 | perception of expression profiles and kind of illuminates | ||
| 396 | coordinated behavior of different subsets. Glyph and data | ||
| 397 | indexer/formatter were in fact modified with the assumption | ||
| 398 | that final data produced by indexer/formatter will always | ||
| 399 | be a log2 conversion of the original coverage, therefore | ||
| 400 | represented by short integer with values in range of 0-200 | ||
| 401 | or so. | ||
| 402 | |||
| 403 | <p> | ||
| 404 | |||
| 405 | Comparing performance (retrieval of several Kbp of data profiles | ||
| 406 | for several subsets of some RNA-seq experiment) of wiggle binary | ||
| 407 | method and of several possible alternatives, it was discovered that | ||
| 408 | one of the approaches remarkably outperforms wiggle bin method | ||
| 409 | (although it requires several times more space for formatted data | ||
| 410 | storage). Optimal storage/retrieval method stores all experiment | ||
| 411 | data (all subsets of the experiment) in one text file, where | ||
| 412 | structure of the file in fact is one of the most simple wiggle | ||
| 413 | (coverage files) formats with the addition of some positioning | ||
| 414 | data (two-column format, without runlength specification, without | ||
| 415 | omission of zero values). This is the only format which glyph is able | ||
| 416 | to handle (there are many reasons for that) so any modification | ||
| 417 | of indexer/formatter _must_ produce exact equivalent of that | ||
| 418 | format. In my experience, 90% of the debugging with new incoming | ||
| 419 | data was related to | ||
| 420 | the problems of that exact format conversion. Example of the formatted | ||
| 421 | data: | ||
| 422 | |||
| 423 | <br> | ||
| 424 | |||
| 425 | <pre> | ||
| 426 | # subset=BS107_all_unique chromosome=2LHet | ||
| 427 | -200000 0 | ||
| 428 | 0 0 | ||
| 429 | 19955 1 | ||
| 430 | 19959 0 | ||
| 431 | 19967 2 | ||
| 432 | 19972 0 | ||
| 433 | 19977 2 | ||
| 434 | 20027 0 | ||
| 435 | 20031 2 | ||
| 436 | 20035 0 | ||
| 437 | 20043 1 | ||
| 438 | 20045 0 | ||
| 439 | 20049 1 | ||
| 440 | 20055 0 | ||
| 441 | 20062 2 | ||
| 442 | 20069 0 | ||
| 443 | 20073 2 | ||
| 444 | 20082 0 | ||
| 445 | 20097 3 | ||
| 446 | 20115 0 | ||
| 447 | 20125 3 | ||
| 448 | 20127 0 | ||
| 449 | 20134 3 | ||
| 450 | 20139 0 | ||
| 451 | 20140 3 | ||
| 452 | 20144 0 | ||
| 453 | 20145 3 | ||
| 454 | 20150 0 | ||
| 455 | 20157 3 | ||
| 456 | 20162 0 | ||
| 457 | 20172 3 | ||
| 458 | 20183 0 | ||
| 459 | </pre> | ||
| 460 | |||
| 461 | <p> | ||
| 462 | |||
| 463 | Glyph is supplied with a "index_cov_files.pl" data indexer/formatter | ||
| 464 | which is converting original coverage (wiggle) files into data structure which will | ||
| 465 | be used for fast retrieval. You should run this script in some separate directory, | ||
| 466 | containing original coverage files (gzipped form works too). After it finishes, | ||
| 467 | directory will contain two new files: data.cat and index.bdbhash. Both files required | ||
| 468 | for data retrieval by glyph. Files can be moved freely between different directories | ||
| 469 | or even operational systems (Mac and PC included, I think). Content of the dat file | ||
| 470 | is subject of accurate check - this is if you want to avoid long debugging sessions | ||
| 471 | on the level of running GBrowse. Size of files is quite big, but in my experience it | ||
| 472 | is like twice less than gzipped size of all initial coverage files - which is quite | ||
| 473 | acceptable. | ||
| 474 | |||
| 475 | <p> | ||
| 476 | |||
| 477 | Example of GBrowse conf file insert (shows actual FlyBase config sections for | ||
| 478 | Baylor and modENCODE RNA-seq tracks): | ||
| 479 | |||
| 480 | <br> | ||
| 481 | <pre> | ||
| 482 | [baylor_wiggle] | ||
| 483 | feature = RNAseq_profile:Baylor | ||
| 484 | glyph = fb_shmiggle | ||
| 485 | height = 124 | ||
| 486 | bgcolor = sub { my $f= shift; | ||
| 487 | $f->{datadir}= '/.data/genomes/dmel/current/rnaseq-gff/baylor/'; # trick it this way.. | ||
| 488 | my @subsetsorder= qw( | ||
| 489 | E2-4hr | ||
| 490 | E2-16hr | ||
| 491 | E2-16hr100 | ||
| 492 | E14-16hr | ||
| 493 | L | ||
| 494 | L3i | ||
| 495 | L3i100 | ||
| 496 | P | ||
| 497 | P3d | ||
| 498 | MA3d | ||
| 499 | FA3d | ||
| 500 | A17d | ||
| 501 | ); | ||
| 502 | $f->{subsetsorder}= \@subsetsorder; | ||
| 503 | return 'lightgrey'; | ||
| 504 | } | ||
| 505 | key = Baylor group RNA-seq coverage by subsets (devel.stages) [log2 converted] | ||
| 506 | category = RNA-seq data | ||
| 507 | label = "" | ||
| 508 | title = "" | ||
| 509 | link = sub { my $f= shift; | ||
| 510 | my $id= $f->{'id'}; | ||
| 511 | my $lnk="javascript:void(0);"; | ||
| 512 | "$lnk\" id=\"$id\" onmouseover=\"showdata_description('Baylor');return false;\" onmouseout=\"delsumm_overlib();"; | ||
| 513 | } | ||
| 514 | |||
| 515 | [celniker_wiggle] | ||
| 516 | feature = RNAseq_profile:Celniker | ||
| 517 | glyph = fb_shmiggle | ||
| 518 | height = 250 | ||
| 519 | bgcolor = sub { my $f= shift; | ||
| 520 | $f->{datadir}= '/.data/genomes/dmel/current/rnaseq-gff/celniker/'; # trick it this way.. | ||
| 521 | my @subsetsorder= qw( | ||
| 522 | BS40_all_unique | ||
| 523 | BS43_all_unique | ||
| 524 | BS46_all_unique | ||
| 525 | BS49_all_unique | ||
| 526 | BS54_all_unique | ||
| 527 | BS55_all_unique | ||
| 528 | BS58_all_unique | ||
| 529 | BS62_all_unique | ||
| 530 | BS66_all_unique | ||
| 531 | BS67_all_unique | ||
| 532 | BS71_all_unique | ||
| 533 | BS73_all_unique | ||
| 534 | BS107_all_unique | ||
| 535 | BS111_all_unique | ||
| 536 | BS113_all_unique | ||
| 537 | BS196_all_unique | ||
| 538 | BS200_all_unique | ||
| 539 | BS203_all_unique | ||
| 540 | BS129_all_unique | ||
| 541 | BS133_all_unique | ||
| 542 | BS136_all_unique | ||
| 543 | BS137_all_unique | ||
| 544 | BS140_all_unique | ||
| 545 | BS143_all_unique | ||
| 546 | BS150_all_unique | ||
| 547 | BS156_all_unique | ||
| 548 | BS162_all_unique | ||
| 549 | BS153_all_unique | ||
| 550 | BS159_all_unique | ||
| 551 | BS165_all_unique | ||
| 552 | ); | ||
| 553 | $f->{subsetsorder}= \@subsetsorder; | ||
| 554 | my %subsetsnames= qw( | ||
| 555 | BS40_all_unique em0-2hr | ||
| 556 | BS43_all_unique em2-4hr | ||
| 557 | BS46_all_unique em4-6hr | ||
| 558 | BS49_all_unique em6-8hr | ||
| 559 | BS54_all_unique em8-10hr | ||
| 560 | BS55_all_unique em10-12hr | ||
| 561 | BS58_all_unique em12-14hr | ||
| 562 | BS62_all_unique em14-16hr | ||
| 563 | BS66_all_unique em16-18hr | ||
| 564 | BS67_all_unique em18-20hr | ||
| 565 | BS71_all_unique em20-22hr | ||
| 566 | BS73_all_unique em22-24hr | ||
| 567 | BS107_all_unique L1 | ||
| 568 | BS111_all_unique L2 | ||
| 569 | BS113_all_unique L3_12hr | ||
| 570 | BS196_all_unique L3_PS1-2 | ||
| 571 | BS200_all_unique L3_PS3-6 | ||
| 572 | BS203_all_unique L3_PS7-9 | ||
| 573 | BS129_all_unique WPP | ||
| 574 | BS133_all_unique WPP_12hr | ||
| 575 | BS136_all_unique WPP_24hr | ||
| 576 | BS137_all_unique WPP_2days | ||
| 577 | BS140_all_unique WPP_3days | ||
| 578 | BS143_all_unique WPP_4days | ||
| 579 | BS150_all_unique AdM_Ecl_1days | ||
| 580 | BS156_all_unique AdM_Ecl_5days | ||
| 581 | BS162_all_unique AdM_Ecl_30days | ||
| 582 | BS153_all_unique AdF_Ecl_1days | ||
| 583 | BS159_all_unique AdF_Ecl_5days | ||
| 584 | BS165_all_unique AdF_Ecl_30days | ||
| 585 | ); | ||
| 586 | $f->{subsetsnames}= \%subsetsnames; | ||
| 587 | return 'lightgrey'; | ||
| 588 | } | ||
| 589 | key = modENCODE Transcription Group RNA-seq coverage (unique reads only) by subsets (devel. stages) [log2 converted] | ||
| 590 | category = RNA-seq data | ||
| 591 | label = "" | ||
| 592 | title = "" | ||
| 593 | link = sub { my $f= shift; | ||
| 594 | my $id= $f->{'id'}; | ||
| 595 | my $lnk="javascript:void(0);"; | ||
| 596 | "$lnk\" id=\"$id\" onmouseover=\"showdata_description('Celniker');return false;\" onmouseout=\"delsumm_overlib();"; | ||
| 597 | } | ||
| 598 | </pre> | ||
| 599 | <br> | ||
| 600 | |||
| 601 | In configuration, it is very important to set 'datadir' variable (relative | ||
| 602 | to server DOCUMENT_ROOT) so that glyph will know where to take data and index. | ||
| 603 | |||
| 604 | <br> | ||
| 605 | <br> | ||
| 606 | |||
| 607 | Setting 'subsetsorder' allows you to display expression profiles of subsets in | ||
| 608 | some predefined order. If setting omitted, glyph will display sets in alphabetical | ||
| 609 | order of the initial subsets names. | ||
| 610 | |||
| 611 | <br> | ||
| 612 | <br> | ||
| 613 | |||
| 614 | Setting 'subsetsnames' allows to rename subsets (very important as in most cases | ||
| 615 | workflow names of subsets are unsutable for intelligent data display to end users). | ||
| 616 | If setting omitted, initial subsets names will be used for display. | ||
| 617 | |||
| 618 | <p> | ||
| 619 | |||
| 620 | For the glyph to be properly activated, you need to insert in all of your GFF files | ||
| 621 | (ones for which you have RNA-seq data) virtual contig-long features which will activate | ||
| 622 | expression data display. To cover whole range of the contig (chromosome arm), it is | ||
| 623 | better to use coordinates presented in 'sequence-region' definition at the top of GFF file. | ||
| 624 | Example of such feature lines for FlyBase data is shown below: | ||
| 625 | |||
| 626 | <p> | ||
| 627 | <pre> | ||
| 628 | 2LHet Baylor RNAseq_profile 1 368874 . + . Comment=This is a reference feature for RNAseq wiggle tracks | ||
| 629 | 2L Baylor RNAseq_profile 1 23011544 . + . Comment=This is a reference feature for RNAseq wiggle tracks | ||
| 630 | 2RHet Baylor RNAseq_profile 1 3288763 . + . Comment=This is a reference feature for RNAseq wiggle tracks | ||
| 631 | 2R Baylor RNAseq_profile 1 21146708 . + . Comment=This is a reference feature for RNAseq wiggle tracks | ||
| 632 | 3LHet Baylor RNAseq_profile 1 2555493 . + . Comment=This is a reference feature for RNAseq wiggle tracks | ||
| 633 | 3L Baylor RNAseq_profile 1 24543557 . + . Comment=This is a reference feature for RNAseq wiggle tracks | ||
| 634 | 3RHet Baylor RNAseq_profile 1 2517509 . + . Comment=This is a reference feature for RNAseq wiggle tracks | ||
| 635 | 3R Baylor RNAseq_profile 1 27905053 . + . Comment=This is a reference feature for RNAseq wiggle tracks | ||
| 636 | 4 Baylor RNAseq_profile 1 1351857 . + . Comment=This is a reference feature for RNAseq wiggle tracks | ||
| 637 | XHet Baylor RNAseq_profile 1 204113 . + . Comment=This is a reference feature for RNAseq wiggle tracks | ||
| 638 | X Baylor RNAseq_profile 1 22422827 . + . Comment=This is a reference feature for RNAseq wiggle tracks | ||
| 639 | YHet Baylor RNAseq_profile 1 347040 . + . Comment=This is a reference feature for RNAseq wiggle tracks | ||
| 640 | </pre> | ||
| 641 | <p> | ||
| 642 | |||
| 643 | Questions about TopoView glyph should be directed to Victor Strelets (strelets@bio.indiana.edu). | ||
| 644 | |||
| 645 | =end html |