Permalink
Browse files

Some changes to bring back to like hybrid_plot and vista_plot

  • Loading branch information...
1 parent c1eb90c commit 806f7188a0508ac7864e24c9885837e4ab557b4f @pruzanov pruzanov committed with lstein Feb 25, 2012
@@ -5,7 +5,6 @@ use base qw(Bio::Graphics::Glyph::wiggle_xyplot);
use constant DEBUG=>0;
use constant NEGCOL=>"orange";
use constant POSCOL=>"blue";
-
our $VERSION = '1.0';
sub my_options {
@@ -1,12 +1,13 @@
package Bio::Graphics::Glyph::vista_plot;
use strict;
-use base qw(Bio::Graphics::Glyph::wiggle_data
+use base qw(Bio::Graphics::Glyph::wiggle_minmax
Bio::Graphics::Glyph::wiggle_xyplot
Bio::Graphics::Glyph::wiggle_density
Bio::Graphics::Glyph::wiggle_whiskers
Bio::Graphics::Glyph::heat_map
- Bio::Graphics::Glyph::smoothing);
+ Bio::Graphics::Glyph::smoothing);
+
our $VERSION = '1.0';
@@ -46,8 +47,8 @@ sub my_options {
'vista',
"What to show, peaks or signal, both (vista plot) or density graph."],
graph_type => [
- ['whiskers','histogram','line','points','linepoints'],
- 'histogram',
+ ['whiskers','histogram','boxes','line','points','linepoints'],
+ 'boxes',
"Type of signal graph to show."],
alpha => [
'integer',
@@ -160,9 +161,9 @@ sub draw {
peak => (eval{$feature->get_tag_values('peak_type')})[0],
fasta=> (eval{$feature->get_tag_values('fasta')})[0]);
$self->panel->startGroup($gd);
- $self->configure(opacity => 0.5) if $only_show eq 'vista';
+
$self->draw_signal($only_show,\%features,@_) if $only_show =~ /signal|density|vista/;
- $self->draw_peaks(\%features,@_) if $features{peak} && $only_show =~ /peaks|vista/;
+ $self->draw_peaks(\%features,@_) if $features{peak} && $only_show =~ /peaks|vista|both/;
$self->Bio::Graphics::Glyph::xyplot::draw_label(@_) if $self->option('label');
$self->draw_description(@_) if $self->option('description');
$self->panel->endGroup($gd);
@@ -206,7 +207,6 @@ sub draw_signal {
my @vals = map {$_->{validCount} ? Bio::DB::BigWig::binMean($_) : 0} @$stats;
$self->bigwig_summary($summary);
if ($signal_type eq 'density') {
-# $self->Bio::Graphics::Glyph::wiggle_density::draw_coverage($summary,\@vals,@_);
$self->Bio::Graphics::Glyph::wiggle_density::_draw_coverage($summary,\@vals,@_);
} else {
$self->Bio::Graphics::Glyph::wiggle_data::_draw_coverage($summary,\@vals,@_);
@@ -3,7 +3,6 @@ package Bio::Graphics::Glyph::wiggle_data;
use strict;
use base qw(Bio::Graphics::Glyph::minmax);
use File::Spec;
-
sub minmax {
my $self = shift;
my $parts = shift;
@@ -157,7 +156,6 @@ sub datatype {
my $self = shift;
my $feature = $self->feature;
my ($tag,$value);
-
for my $t ('wigfile','wigdata','densefile','coverage') {
if (my ($v) = eval{$feature->get_tag_values($t)}) {
$value = $v;
@@ -178,7 +176,6 @@ sub get_parts {
my $feature = $self->feature;
my ($start,$end) = $self->effective_bounds($feature);
my ($datatype,$data) = $self->datatype;
-
return $self->subsample($data,$start,$end) if $datatype eq 'wigdata';
return $self->create_parts_from_wigfile($data,$start,$end) if $datatype eq 'wigfile';
return $self->create_parts_for_dense_feature($data,$start,$end) if $datatype eq 'densefile';
@@ -251,6 +248,9 @@ sub create_parts_from_summary {
sub create_parts_from_wigfile {
my $self = shift;
my ($path,$start,$end) = @_;
+ if (ref $path && $path->isa('Bio::Graphics::Wiggle')) {
+ return $self->create_parts_for_dense_feature($path,$start,$end);
+ }
$path = $self->rel2abs($path);
if ($path =~ /\.wi\w{1,3}$/) {
eval "require Bio::Graphics::Wiggle" unless Bio::Graphics::Wiggle->can('new');
@@ -313,8 +313,8 @@ sub draw {
sub draw_wigfile {
my $self = shift;
my $feature = shift;
-
- my ($wigfile) = eval{$feature->get_tag_values('wigfile')};
+ my $wigfile = shift;
+ $wigfile ||= eval{$feature->get_tag_values('wigfile')};
$wigfile = $self->rel2abs($wigfile);
eval "require Bio::Graphics::Wiggle" unless Bio::Graphics::Wiggle->can('new');
@@ -325,7 +325,7 @@ sub draw_wigfile {
warn $@;
return $self->SUPER::draw(@_);
}
- $self->_draw_wigfile($feature,$wig,@_);
+ $self->_draw_wigfile($feature,$wigfile,@_);
}
sub draw_wigdata {
@@ -424,7 +424,15 @@ sub _draw_coverage {
sub _draw_wigfile {
my $self = shift;
my $feature = shift;
- my $wig = shift;
+ my $wigfile = shift;
+
+ $self->feature->remove_tag('wigfile') if $self->feature->has_tag('wigfile');
+ $self->feature->add_tag_value('wigfile',$wigfile);
+
+ eval "require Bio::Graphics::Wiggle" unless Bio::Graphics::Wiggle->can('new');
+ my $wig = ref $wigfile && $wigfile->isa('Bio::Graphics::Wiggle')
+ ? $wigfile
+ : eval { Bio::Graphics::Wiggle->new($wigfile) };
$wig->smoothing($self->get_smoothing);
$wig->window($self->smooth_window);

0 comments on commit 806f718

Please sign in to comment.