Excluding the phylogenetic relationship from a phylogenetic vector

For the discussion of the sciences. Physics problems, chemistry equations, biology weirdness, it all goes here.

Moderators: gmalivuk, Moderators General, Prelates

User avatar
Minerva
Posts: 947
Joined: Sat Nov 11, 2006 2:58 pm UTC
Location: Australia
Contact:

Excluding the phylogenetic relationship from a phylogenetic vector

Postby Minerva » Tue Sep 13, 2016 2:15 am UTC

Paper here.
http://bioinformatics.oxfordjournals.or ... 2.full.pdf

In particular, note the projection operator, section 2.3, and equation (2) and equation (3).

Given a couple of vectors, u and v (well, nu actually, but can't be bothered typesetting it, and LaTeX makes the page too slow) we want to actually implement this projection operator to exclude the phylogenetic relationship, using a bit of basic Python or something.

Suppose we already have these two vectors, they're equal length, real, floating point.

P = I - |u><u|

P |vi> = |vi> - |u> <u|vi>

Now, how to implement this, in terms of code?

Calculate <u|vi> as simply the dot product of the two vectors.

Take vector |u> multiplied by that scalar product, and subtract that from vector |vi>, to generate the result vector.

Is that correct? Is it sort of on the right track, in terms of taking their operation as described and translating it into code in the easiest way?
...suffer from the computer disease that anybody who works with computers now knows about. It's a very serious disease and it interferes completely with the work. The trouble with computers is you play with them. They are so wonderful. - Richard Feynman

User avatar
Robert'); DROP TABLE *;
Posts: 730
Joined: Mon Sep 08, 2008 6:46 pm UTC
Location: in ur fieldz

Re: Excluding the phylogenetic relationship from a phylogenetic vector

Postby Robert'); DROP TABLE *; » Wed Sep 14, 2016 6:40 pm UTC

From my reading of the paper, I'd have understood the operator to mean |vi> - (|u> <u|)vi>, which I don't think produces the same answer. I have no specific experience in this area, though, so that might not make sense for some other reason.

However, here's an example of how you might write your interpretation in Python:

Code: Select all

import operator

def P(u, v): # u and v are bare lists of floats, hence all the inner functions. Your own linalg library is likely more useful
   def subvec(x,y):
      return map(operator.sub, x,y)
   def crossprod(x,y):
      return sum(map(operator.add, x,y))
   def vec_scale(x, c):
      return map(lambda e: e * c, x)

   return subvec(v, vec_scale(u, crossprod(u,v)))

(Having written it, I've realized that might be very dense if you're not already familiar with the language. Let me know if you want a clarification)
Last edited by Robert'); DROP TABLE *; on Fri Sep 23, 2016 5:13 pm UTC, edited 1 time in total.
...And that is how we know the Earth to be banana-shaped.

User avatar
Minerva
Posts: 947
Joined: Sat Nov 11, 2006 2:58 pm UTC
Location: Australia
Contact:

Re: Excluding the phylogenetic relationship from a phylogenetic vector

Postby Minerva » Fri Sep 23, 2016 4:52 pm UTC

Thanks :)

Code: Select all

def crossprod(x,y):
      return sum(map(operator.add, x,y))


That's supposed to be an

Code: Select all

operator.mul
or something like that, right?
...suffer from the computer disease that anybody who works with computers now knows about. It's a very serious disease and it interferes completely with the work. The trouble with computers is you play with them. They are so wonderful. - Richard Feynman

User avatar
Robert'); DROP TABLE *;
Posts: 730
Joined: Mon Sep 08, 2008 6:46 pm UTC
Location: in ur fieldz

Re: Excluding the phylogenetic relationship from a phylogenetic vector

Postby Robert'); DROP TABLE *; » Fri Sep 23, 2016 5:13 pm UTC

Yup, operator.mul is the right name. I hadn't actually done any testing, so I didn't notice that adding all the components of the two vectors together didn't do anything useful.
...And that is how we know the Earth to be banana-shaped.


Return to “Science”

Who is online

Users browsing this forum: No registered users and 17 guests