Bio::EnsEMBL
DensityFeatureSet
Toolbar
Summary
Bio::EnsEMBL::DensityFeatureSet -
A feature representing a set of density features
Package variables
No package variables defined.
Included modules
Synopsis
use Bio::EnsEMBL::DensityFeatureSet;
my $densitySet = Bio::EnsEMBL::DensityFeatureSet->new(
-bin_array = \@out,
-stretch = 1,
);
Description
A density feature set is a wrap around a array of density features with
additional information about the collective density feature set, such as
max_min_values and scale factors etc. a given region.
This module is part of the Ensembl project
Methods
Methods description
Title : colour Usage : $obj->colour($newval) Function: Returns : value of colour Args : newvalue (optional) Status : Stable |
Arg [1] : none Example : @binvalues = @{$dfs->get_all_binvalues}; Description: Scales all of the contained DensityFeatures by $scalefactor and returns them. Returntype : reference to a list of DensityFeatures Exceptions : none Caller : general Status : Stable |
Title : label Usage : $obj->label($newval) Function: Returns : value of label Args : newvalue (optional) Status : Stable |
Title : label2 Usage : $obj->label2($newval) Function: Returns : value of label2 Args : newvalue (optional) Status : Stable |
Arg [1] : none Example : my $max = $dfs->max_value(); Description: Returns the maximum density feature value from the density feature set Returntype : int Exceptions : none Caller : general Status : Stable |
Arg [1] : none Example : my $min = $dfs->min_value(); Description: Returns the minimum density feature value from the density feature set. Returntype : int Exceptions : none Caller : general Status : Stable |
Description: Creates a new density feature set. Returntype : Bio::EnsEMBL::DensityFeatureSet Exceptions : throw if invalid density value type is provided Caller : general Status : Stable |
Title : scale_to_fit Usage : $obj->scale_to_fit($newval) Function: gets/sets the number that the BinValues are to be scaled against - i.e. the greatest BinValue->value will be scaled to this number, and the rest scaled in proportion. Returns : scale_to_fit value Args : newvalue (optional) Status : Stable |
Arg [1] : none Example : my $num_features = $dfs->size(); Description: Returns the number of density features in this density feature set. Returntype : int Exceptions : none Caller : general Status : Stable |
Title : stretch Usage : $obj->stretch($newval) Function: gets/sets a boolean for whether we should stretch the data over the range (i.e. from min to max rather than absolute numbers). Returns : value of _stretch Args : newvalue (optional) Status : Stable |
Methods code
sub colour
{ my $self = shift;
$self->{'color'} = shift if(@_);
return $self->{'color'}; } |
sub get_all_binvalues
{ my $self = shift;
my $max_value = $self->max_value();
my $min_value = $self->min_value();
return [] if(!@{$self->{'bin_array'}});
my $width = $self->scale_to_fit();
return [] unless defined($width);
if ($self->stretch && ($max_value-$min_value) ){
foreach my $bv (@{ $self->{'bin_array'}}){
my $scaledval = (($bv->density_value - $min_value) / ($max_value-$min_value) )* $width; $bv->scaledvalue($scaledval);
}
} elsif($max_value) {
foreach my $bv (@{ $self->{'bin_array'}}){
my $scaledval = ($bv->density_value / $max_value) * $width; $bv->scaledvalue($scaledval);
}
} else {
foreach my $bv (@{ $self->{'bin_array'}}){
$bv->scaledvalue(0);
}
}
return $self->{'bin_array'}; } |
sub label
{ my $self = shift;
$self->{'label'} = shift if (@_);
return $self->{'label'}; } |
sub label2
{ my $self = shift;
$self->{'label2'} = shift if (@_);
return $self->{'label2'}; } |
sub max_value
{$_[0]->{'max_value'}; } |
sub min_value
{$_[0]->{'min_value'}; } |
sub new
{ my $class = shift;
my $max_value = undef;
my $min_value = undef;
my($dfeats, $stretch, $scale_to_fit) =
rearrange(['FEATURES', 'STRETCH', 'SCALE_TO_FIT'], @_);
foreach (@$dfeats){
my $value = $_->density_value;
$max_value = $value if (!defined($max_value) || $value > $max_value);
$min_value = $value if (!defined($min_value) || $value < $min_value);
}
return bless {'bin_array' => $dfeats,
'stretch' => $stretch,
'scale_to_fit' => $scale_to_fit,
'min_value' => $min_value,
'max_value' => $max_value}, $class; } |
sub scale_to_fit
{ my $self = shift;
$self->{'scale_to_fit'} = shift if (@_);
return $self->{'scale_to_fit'}; } |
sub size
{ my $self = shift;
return scalar @{$self->{'bin_array'}};
}
1; } |
sub stretch
{ my $self = shift;
$self->{'stretch'} = shift if(@_);
return $self->{'stretch'}; } |
General documentation
Copyright (c) 1999-2009 The European Bioinformatics Institute and
Genome Research Limited. All rights reserved.
This software is distributed under a modified Apache license.
For license details, please see
/info/about/code_licence.html