NAME
Bio::Matrix::Generic - A generic matrix implementation
SYNOPSIS
# A matrix has columns and rowsmy $matrix = Bio::Matrix::Generic->new;$matrix->add_column(1,$column1);$matrix->add_column(2,$column2);my $element = $matrix->entry_by_num(1,2);$matrix->entry_by_num(1,2,$newval);my $entry = $matrix->entry('human', 'mouse');$matrix->entry('human','mouse', $newval);
DESCRIPTION
This is a general purpose matrix object for dealing with row+column data which is typical when enumerating all the pairwise combinations and desiring to get slices of the data.
Data can be accessed by column and row names or indexes. Matrix indexes start at 0.
FEEDBACK
Mailing Lists
User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated.
[email protected] - General discussionhttp://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support
Please direct usage questions or support issues to the mailing list:
rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.
Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web:
https://github.com/bioperl/bioperl-live/issues
AUTHOR - Jason Stajich
Email jason-at-bioperl-dot-org
APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
new
Title : newUsage : my $obj = Bio::Matrix::Generic->new();Function: Builds a new Bio::Matrix::Generic objectReturns : an instance of Bio::Matrix::GenericArgs : -values => arrayref of arrayrefs of data initialization-rownames => arrayref of row names-colnames => arrayref of col names-matrix_id => id of the matrix-matrix_name=> name of the matrix-matrix_init_value => default value to initialize empty cells
matrix_id
Title : matrix_idUsage : my $id = $matrix->matrix_idFunction: Get/Set the matrix IDReturns : scalar valueArgs : [optional] new id value to store
matrix_name
Title : matrix_nameUsage : my $name = $matrix->matrix_name();Function: Get/Set the matrix nameReturns : scalar valueArgs : [optional] new matrix name value
entry
Title : entryUsage : my $entry = $matrix->entry($row,$col,$value)Function: Get the value for a specific cell as specifiedby the row and column namesReturns : scalar value or undef if row or col does notexistArgs : $rowname - name of the row$colname - column name$value - [optional] New value for the entry
get_entry
Title : get_entryUsage : my $entry = $matrix->get_entry($rowname,$columname,$value)Function: Get the entry for a given row,column pairReturns : scalarArgs : $row name$column name$value
entry_by_num
Title : entry_by_numUsage : my $entry = $matrix->entry_by_num($rownum,$colnum)Function: Get an entry by row and column numbers instead of by name(rows and columns start at 0)Returns : scalar value or undef if row or column name does notexistArgs : $row - row number$col - column number[optional] $newvalue to store at this cell
column
Title : columnUsage : my @col = $matrix->column('ALPHA');OR$matrix->column('ALPHA', \@col);Function: Get/Set a particular columnReturns : Array (in array context) or arrayref (in scalar context)of values.For setting will warn if the new column is of a differentlength from the rest of the columns.Args : name of the column[optional] new column to store here
get_column
Title : get_columnUsage : my @row = $matrix->get_column('ALPHA');Function: Get a particular columnReturns : Array (in array context) or arrayref (in scalar context)of valuesArgs : name of the column
column_by_num
Title : column_by_numUsage : my @col = $matrix->column_by_num(1);OR$matrix->column_by_num(1,\@newcol);Function: Get/Set a column by its number instead of name(cols/rows start at 0)Returns : Array (in array context) or arrayref (in scalar context)of valuesArgs : name of the column[optional] new value to store for a particular column
row
Title : rowUsage : my @row = $matrix->row($rowname);OR$matrix->row($rowname,\@rowvalues);Function: Get/Set the row of the matrixReturns : Array (in array context) or arrayref (in scalar context)Args : rowname[optional] new value of row to store
get_row
Title : get_rowUsage : my @row = $matrix->get_row('ALPHA');Function: Get a particular rowReturns : Array (in array context) or arrayref (in scalar context)of valuesArgs : name of the row
row_by_num
Title : row_by_numUsage : my @row = $matrix->row_by_num($rownum);OR$matrix->row($rownum,\@rowvalues);Function: Get/Set the row of the matrixReturns : Array (in array context) or arrayref (in scalar context)Args : rowname[optional] new value of row to store
diagonal
Title : diagonalUsage : my @diagonal = $matrix->get_diagonal()Function: Get the diagonal of a matrixReturns : Array (in array context) or arrayref (in scalar context)of values which lie along the diagonalArgs : none
add_row
Title : add_rowUsage : $matrix->add_row($index,\@newrow);Function: Adds a row at particular location in the matrix.If $index < the rowcount will shift all the rows downby the number of new rows.To add a single empty row, simply call$matrix->add_row($index,undef);Returns : the updated number of total rows in the matrixArgs : index to storename of the row (header)newrow to add, if this is undef will add a singlerow with all values set to undef
remove_row
Title : remove_rowUsage : $matrix->remove_row($colnum)Function: remove a row from the matrix shifting all the rowsup by oneReturns : Updated number of rows in the matrixArgs : row index
add_column
Title : add_columnUsage : $matrix->add_column($index,$colname,\@newcol);Function: Adds a column at particular location in the matrix.If $index < the colcount will shift all the columns rightby the number of new columns.To add a single empty column, simply call$matrix->add_column($index,undef);Returns : the updated number of total columns in the matrixArgs : index to storename of the column (header)newcolumn to add, if this is undef will add a singlecolumn with all values set to undef
remove_column
Title : remove_columnUsage : $matrix->remove_column($colnum)Function: remove a column from the matrix shifting all the columnsto the left by oneReturns : Updated number of columns in the matrixArgs : column index
column_num_for_name
Title : column_num_for_nameUsage : my $num = $matrix->column_num_for_name($name)Function: Gets the column number for a particular column nameReturns : integerArgs : string
row_num_for_name
Title : row_num_for_nameUsage : my $num = $matrix->row_num_for_nameFunction: Gets the row number for a particular row nameReturns : integerArgs : string
column_header
Title : column_headerUsage : my $name = $matrix->column_header(0)Function: Gets the column header for a particular column numberReturns : stringArgs : integer
row_header
Title : row_headerUsage : my $name = $matrix->row_header(0)Function: Gets the row header for a particular row numberReturns : stringArgs : integer
num_rows
Title : num_rowsUsage : my $rowcount = $matrix->num_rows;Function: Get the number of rowsReturns : integerArgs : none
num_columns
Title : num_columnsUsage : my $colcount = $matrix->num_columnsFunction: Get the number of columnsReturns : integerArgs : none
row_names
Title : row_namesUsage : my @rows = $matrix->row_namesFunction: The names of all the rowsReturns : array in array context, arrayref in scalar contextArgs : none
column_names
Title : column_namesUsage : my @columns = $matrix->column_namesFunction: The names of all the columnsReturns : array in array context, arrayref in scalar contextArgs : none
private methods
Private methods for a Generic Matrix
_values
Title : _valuesUsage : $matrix->_values();Function: get/set for array ref of the matrix containingdistance valuesReturns : an array referenceArgs : an array reference