Re: Abridged summary of bio-phylo@googlegroups.com - 1 Message in 1 Topic

15 views
Skip to first unread message

László Nagy

unread,
Sep 25, 2012, 6:16:56 PM9/25/12
to bio-...@googlegroups.com, Rutger Vos
Hi again,

So in working on this issue, I got to the following point (which might be a completely wrong direction though):

To assign state info to each of the taxa in my matrix I do

my $fac = Bio::Phylo::Factory->new;
my $taxa = $fac->create_taxa;
foreach (@SpecIDs) { #@SpecIDs contains the taxon names for my matrix
    $taxa->insert( $fac->create_taxon( '-name' => $_ ) );
}
my $matrix = $fac->create_matrix(
     '-type'   => 'STANDARD',
     '-taxa'   => $taxa,
     '-lookup' => {
         '0' => [ '0' ],
         '1' => [ '1' ],
     });
 my $new_char = $fac->create_datum(
 -type   => 'STANDARD',
 );
 foreach (keys %SingleChar) { #the %SingleChar hash contains the character states for each taxa in the @SpecIDs array and eventually the $taxa object
     my $taxonobject = $taxa->get_by_name($_); 
     print "singlechar $_ $SingleChar{$_} $taxonobject $new_char\n";
     $new_char->set_taxon($taxonobject);
     $new_char->set_char($SingleChar{$_});
     $matrix->insert($new_char); #this is line 431 in my code
 }

This returns me the following error message:

singlechar Mellp1 0 Bio::Phylo::Taxa::Taxon=SCALAR(0x7fdb83c2ec88) Bio::Phylo::Matrices::Datum=SCALAR(0x7fdb83c940e8)
-------------------------- EXCEPTION ----------------------------
Message: object is of wrong data type

An exception of type Bio::Phylo::Util::Exceptions::ObjectMismatch
was thrown.

This kind of error happens when an invalid object
argument is provided.

Refer to the Bio::Phylo::Util::Exceptions documentation for more
information.
------------------------- STACK TRACE ---------------------------
STACK: Bio::Phylo::Matrices::Matrix::insert('Bio::Phylo::Matrices::Matrix=SCALAR(0x7fdb83c4f0f8)', 'Bio::Phylo::Matrices::Datum=SCALAR(0x7fdb83c940e8)') called at ./scannerfirstscan_new2noref_ancestry_shortpath4.pl line 431
STACK: main::code_it('HASH(0x7fdb83bb2ea0)', 'ARRAY(0x7fdb83bba210)') called at ./scannerfirstscan_new2noref_ancestry_shortpath4.pl line 137   
-----------------------------------------------------------------


Obviously, it is complaining about the type of object I am trying to insert into $matrix. To me it seems I am doing exactly the same as in the example here: http://search.cpan.org/~rvosa/Bio-Phylo-0.29/lib/Bio/Phylo/Matrices/Datum.pm#CONSTRUCTOR. Can anybody give me thint on whats going wrong?

Thanks,
Laszlo Nagy


2012/9/25 <bio-...@googlegroups.com>

Group: http://groups.google.com/group/bio-phylo/topics

    "László Nagy" <cortina...@gmail.com> Sep 24 03:59PM -0400  

    Hi Rutger,
     
    thanks for the hint with the insert() function. I figured I will have to
    use the create_character function to create a new character object, fill it
    up with the states for each taxa ...more

You received this message because you are subscribed to the Google Group bio-phylo.
You can post via email.
To unsubscribe from this group, send an empty message.
For more options, visit this group.

--
You received this message because you are subscribed to the Google Groups "bio-phylo" group.
To post to this group, send email to bio-...@googlegroups.com.
To unsubscribe from this group, send email to bio-phylo+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/bio-phylo?hl=en.

Rutger Vos

unread,
Oct 11, 2012, 11:18:38 AM10/11/12
to bio-...@googlegroups.com, Rutger Vos
Hi Laszlo,

firstly, let me apologize for being so slow to respond - the last few weeks have been overwhelming both on a personal and professional level. I hope my reply is still relevant.

Anyway, so the problem you are having is that Bio::Phylo detects a mismatch between the "data type object" that is associated with the matrix and the one associated with the matrix row.

"Data type objects" are helper objects that validate whether the contents of a matrix or a matrix row are valid (for example, for dna data this object checks to see whether all letters in a sequence string conform to the IUPAC single character codes, or are the current symbol for "missing" or for "gap).

You can modify these data type objects to give them a different lookup table that defines how ambiguous states in a character state sequence map onto fundamental states. Again the easiest example is for dna data, where one such mapping is N => [ A, C, G, T ], i.e. the IUPAC single character symbol N is an ambiguity code that can mean any of the underlying nucleotides.

In your code, when you create the matrix object, you give it a modified lookup table that says that 0 only maps onto 0, and 1 onto 1. Typically this only makes sense for restriction site data (or other presence/absence data).

To get the behavior that you want (or, in any case, to make this particular error go away) there is two things you can do:

1. when you create the matrix, leave out the -lookup argument, and its value.

OR:

2. when you create the datum, pass in the data type object associated with the matrix, e.g.

$fac->create_datum( -type_object => $matrix->get_type_object )

My sense from your previous questions is that you might just go with option 1, unless I have misunderstood what you are working on.

Best wishes,

Rutger
Reply all
Reply to author
Forward
0 new messages