NAME
Bio::Phylo::Matrices::Matrix - Character state matrix.
SYNOPSIS
use Bio::Phylo::Matrices::Matrix;
use Bio::Phylo::Taxa;
use Bio::Phylo::Taxa::Taxon;
# instantiate taxa object
my $taxa = Bio::Phylo::Taxa->new();
for ( 'Homo sapiens', 'Pan paniscus', 'Pan troglodytes' ) {
$taxa->insert( Bio::Phylo::Taxa::Taxon->new( '-name' => $_ ) );
}
# instantiate matrix object
my $matrix = Bio::Phylo::Matrices::Matrix->new(
'-taxa' => $taxa,
'-type' => 'STANDARD',
'-lookup' => {
'-' => [],
'0' => [ '0' ],
'1' => [ '1' ],
'?' => [ '0', '1' ],
},
'-labels' => [ 'Opposable big toes', 'Opposable thumbs', 'Not a pygmy' ],
'-matrix' => [
[ 'Homo sapiens' => '0', '1', '1' ],
[ 'Pan paniscus' => '1', '1', '0' ],
[ 'Pan troglodytes' => '1', '1', '1' ],
],
);
DESCRIPTION
This module defines a container object that holds Bio::Phylo::Matrices::Datum objects. The matrix object inherits from Bio::Phylo::Listable, so the methods defined there apply here.
METHODS
CONSTRUCTOR
- new()
-
Type : Constructor Title : new Usage : my $matrix = Bio::Phylo::Matrices::Matrix->new; Function: Instantiates a Bio::Phylo::Matrices::Matrix object. Returns : A Bio::Phylo::Matrices::Matrix object. Args : -type => required, datatype, one of dna|rna|protein| continuous|standard|restriction|mixed => {} -taxa => optional, link to taxa object -lookup => character state lookup hash ref -labels => array ref of character labels -matrix => two-dimensional array, first element of every row is label, subsequent are characters
MUTATORS
- set_charlabels()
-
Type : Mutator Title : set_charlabels Usage : $matrix->set_charlabels( [ 'char1', 'char2', 'char3' ] ); Function: Assigns character labels. Returns : $self Args : ARRAY, or nothing (to reset);
- set_gapmode()
-
Type : Mutator Title : set_gapmode Usage : $matrix->set_gapmode( 1 ); Function: Defines matrix gapmode ( false = missing, true = fifth state ) Returns : $self Args : boolean
- set_matchchar()
-
Type : Mutator Title : set_matchchar Usage : $matrix->set_matchchar( $match ); Function: Assigns match symbol (default is '.'). Returns : $self Args : ARRAY
- set_polymorphism()
-
Type : Mutator Title : set_polymorphism Usage : $matrix->set_polymorphism( 1 ); Function: Defines matrix 'polymorphism' interpretation ( false = uncertainty, true = polymorphism ) Returns : $self Args : boolean
- set_raw()
-
Type : Mutator Title : set_raw Usage : $matrix->set_raw( [ [ 'taxon1' => 'acgt' ], [ 'taxon2' => 'acgt' ] ] ); Function: Syntax sugar to define $matrix data contents. Returns : $self Args : A two-dimensional array; first dimension contains matrix rows, second dimension contains taxon name / character string pair.
- set_respectcase()
-
Type : Mutator Title : set_respectcase Usage : $matrix->set_respectcase( 1 ); Function: Defines matrix case sensitivity interpretation ( false = disregarded, true = "respectcase" ) Returns : $self Args : boolean
ACCESSORS
- get_charlabels()
-
Type : Accessor Title : get_charlabels Usage : my @charlabels = @{ $matrix->get_charlabels }; Function: Retrieves character labels. Returns : ARRAY Args : None.
- get_gapmode()
-
Type : Accessor Title : get_gapmode Usage : do_something() if $matrix->get_gapmode; Function: Returns matrix gapmode ( false = missing, true = fifth state ) Returns : boolean Args : none
- get_matchchar()
-
Type : Accessor Title : get_matchchar Usage : my $char = $matrix->get_matchchar; Function: Returns matrix match character (default is '.') Returns : SCALAR Args : none
- get_nchar()
-
Type : Accessor Title : get_nchar Usage : my $nchar = $matrix->get_nchar; Function: Calculates number of characters (columns) in matrix (if the matrix is non-rectangular, returns the length of the longest row). Returns : INT Args : none
- get_ntax()
-
Type : Accessor Title : get_ntax Usage : my $ntax = $matrix->get_ntax; Function: Calculates number of taxa (rows) in matrix Returns : INT Args : none
- get_polymorphism()
-
Type : Accessor Title : get_polymorphism Usage : do_something() if $matrix->get_polymorphism; Function: Returns matrix 'polymorphism' interpretation ( false = uncertainty, true = polymorphism ) Returns : boolean Args : none
- get_raw()
-
Type : Accessor Title : get_raw Usage : my $rawmatrix = $matrix->get_raw; Function: Retrieves a 'raw' (two-dimensional array) representation of the matrix's contents. Returns : A two-dimensional array; first dimension contains matrix rows, second dimension contains taxon name and characters. Args : NONE
- get_respectcase()
-
Type : Accessor Title : get_respectcase Usage : do_something() if $matrix->get_respectcase; Function: Returns matrix case sensitivity interpretation ( false = disregarded, true = "respectcase" ) Returns : boolean Args : none
METHODS
- to_nexus()
-
Type : Format convertor Title : to_nexus Usage : my $data_block = $matrix->to_nexus; Function: Converts matrix object into a nexus data block. Returns : Nexus data block (SCALAR). Args : none Comments:
- insert()
-
Type : Listable method Title : insert Usage : $matrix->insert($datum); Function: Converts matrix object into a nexus data block. Returns : Modified object Args : A datum object Comments: This method re-implements the method by the same name in Bio::Phylo::Listable
- validate()
-
Type : Method Title : validate Usage : $obj->validate Function: Validates the object's contents Returns : True or throws Bio::Phylo::Util::Exceptions::InvalidData Args : None Comments: This method implements the interface method by the same name in Bio::Phylo::Matrices::TypeSafeData
- check_taxa()
-
Type : Method Title : check_taxa Usage : $obj->check_taxa Function: Validates relation between matrix and taxa block Returns : Modified object Args : None Comments: This method implements the interface method by the same name in Bio::Phylo::Taxa::TaxaLinker
DESTRUCTOR
- DESTROY()
-
Type : Destructor Title : DESTROY Usage : $phylo->DESTROY Function: Destroys Phylo object Alias : Returns : TRUE Args : none Comments: You don't really need this, it is called automatically when the object goes out of scope.
SEE ALSO
- Bio::Phylo::Listable
-
This object inherits from Bio::Phylo::Listable, so the methods defined therein are also applicable to Bio::Phylo::Matrices::Matrix objects.
- Bio::Phylo::Manual
-
Also see the manual: Bio::Phylo::Manual.
FORUM
CPAN hosts a discussion forum for Bio::Phylo. If you have trouble using this module the discussion forum is a good place to start posting questions (NOT bug reports, see below): http://www.cpanforum.com/dist/Bio-Phylo
BUGS
Please report any bugs or feature requests to bug-bio-phylo@rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Bio-Phylo. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. Be sure to include the following in your request or comment, so that I know what version you're using:
$Id: Matrix.pm 3319 2007-03-20 01:39:35Z rvosa $
AUTHOR
Rutger A. Vos,
- email:
rvosa@sfu.ca
- web page: http://www.sfu.ca/~rvosa/
ACKNOWLEDGEMENTS
The author would like to thank Jason Stajich for many ideas borrowed from BioPerl http://www.bioperl.org, and CIPRES http://www.phylo.org and FAB* http://www.sfu.ca/~fabstar for comments and requests.
COPYRIGHT & LICENSE
Copyright 2005 Rutger A. Vos, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.