Archives for October 2007

Drug resistance in malaria

My PhD thesis is around the spread of drug resistant malaria. The idea, from my supervisor, is that between sensitiveness (i.e. a parasite strain that is killed by a drug) and resistance (i.e. a parasite strain that that survives treatment) there are intermediate forms, tolerant forms, that are able to resist sub-terapheutic levels of treatment. The more I read, the more I like the idea. In fact, I think there is no thing like resistance or sensitiveness, there are only various degrees of tolerance. Let me explain:

Imagine a parasite (a single one, one in an infection of 10000000000 parasites), this guy is resistant to chloroquine and is exposed, by chance, to a MASSIVE amount of chloroquine. He will die (”he”, by the way, is a “it”, as we are talking about asexual forms. Although P. falciparum also has sexual forms). This interpretation is supported for instance, in the fact that chloroquine “resistant” infections can still be treated with chloroquine as long as the host has accumulated immunity (as in adults in malaria endemic areas). There is an “add-up” effect of the drug plus the immunity. Put it another way, a “resistant” strain is still partially affected by the drug.

The converse is also true, a sensitive (I should be saying highly intolerant) parasite might survive chloroquine treatment if either the drug level is sub-therapeutic or, shear luck of not crossing in the way of the drug.

There are good reasons for the existence of resistant and sensitive words though, I can think of at least two: First, from the outcome perspective - either the infection is cleared or not. Second from a cognitive and linguistic perspective: it is easy to talk and think about “black and white” sensitive and resistant than “gray toned” level of tolerance.

But I think that “resistant” and “sensitive” create a cognitive bias that undermines the ability to understand the underlying biological processes.

I prefer the notion of “tolerance” that, for me, is tightly associated to the notion of drop in parasite load per unit of time. A resistant infection, exposed to a drug, still has some drop in parasite load, but that is not enough to offset multiplication of surviving parasites (at least to bring the parasite count to 0). A tolerant infection, exposed to the same quantity of drug, has a big drop in parasite load, enough to offset the multiplication of surviving parasites that most probably will be eliminated soon.

The idea of tolerance and drop in parasite load also goes well with the importance of drug concentration.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • connotea
  • DZone
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Filed in: malaria

by: tiago

4 Comments

Scala types again

It turns out that my previous Scala idea to model environments for arithmetic expressions doesn’t fly. Solution? Go to the Scala mailing list and ask for opinions, there is always a lot of helpful, highly skilled people willing to help. What follows is my account of things based on the help that I have got.

My initial solution was to create a type like this:

type Env = String => Double

Doesn’t work as types have to be defined inside objects or classes. This will, by the way, work on the interpreter as the interpreter is really running inside an anonymous class (so type definitions will be attached to that anonymous class).

I then tried 2 traits as alternatives:

trait Env {
 def apply(name : String) : Double
}

and

trait Env extends Fuction1[String, Double]

When I used any of those like in:

val env : Env = (x : String) => x match {case "S" => 1.0}

I had a typing error complaining that String => Double is different from Env. But is it really? Aren’t the two traits above the same as String => Double? Well, they are, but Scala uses nominative typing, not structural typing. So after you give that type a name it will be different from equal structural types that have different names.

I ended up with with a type inside a companion object. The companion object pattern seems to be widely used in Scala. I still don’t have a opinion if that is generally good or bad.

In any case, I don’t like the idea that types cannot be defined top level. I don’t see any advantage in disallowing this.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • connotea
  • DZone
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Filed in: Scala

by: tiago

No Comments

Learning Scala: Types

I will document my effort in learning Scala. The main objective is to help in building up as much content as possible on the Web about Scala. Caveat though: I am learning, therefore what I document here might be rubbish.

The problem: I need an arithmetic expression parser to be able to deal with drug isobolograms like these 2 taken from Wang et al.:

Isobologram

Very roughly speaking, the concentration “curve” that you see is when the drug combination becomes active against the parasite. In this case the compounds are Sulfadoxine (SDX) and Pyrimethamine (PYR) used to combat P. falciparum malaria.

I want to be able to build expressions for those curves. These expressions run in contexts, that is, if one “curve” (here approximated by a line) is 133*SDX + 2000 - PYR then there is a need for having a variable SDX and another PYR.

[People with a functional programming background might immediately recognize the typical newbie exercise of doing an expression evaluator… In fact you can find it in various Scala documentation… and Caml]

So I need, what is called an environment, a store of mappings from symbols to values. Something like

{case "PYR" => 1800.0 case "SDX" => 5.0}.

First problem: Doubles and Ints. There seems to be no way to specify that the return is a Number. I would like, sometime, to use Numbers irrespective of the specific subclass. I would like to do something like:

type Exp : String => Number

The problem is that one cannot have type at all, unless inside a class. But, but, but the type is not visible outside the class as a type (i.e. just for the type info, without the need to instantiate to access). Maybe putting it into an object? Did not try it, but it would be clumsy.

I ended up with this solution for now:

trait Env {
  def apply(name : String) : Double
}

Can live with it. The Double instead of Number hurts more.

Again, I am beginning. Please don’t be too harsh on me ;)

By the way: It would be nice to have Scala support on GeSHi so that Wordpress blogs could render Scala code beautifully. No, I am suggesting only, I don’t have the time to actually do it myself.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • connotea
  • DZone
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Filed in: Scala, bioinformatics

by: tiago

No Comments

Scala for bioinformatics

I am seriously considering doing the core of my work (at least when I have the freedom to decide) in Scala. The reasons? Well, I can give them in the form of requirements:

  1. Domain Specific Language support, that is:
    1. Making life easy on declarative programming
    2. Ability to show the code to non-programmers in a form that is readable and understandable (I will talk about this topic a lot in the future).
  2. DSLs should be embedded and not stand-alone. A DSL (say, one to model the spread of malaria drug resistance) can be made in any programming language, really. But embedded languages (i.e., where the DSL resides inside the host language) cannot really be done in most languages. This allows for “unlimited” extensibility (Turing completeness some would say). Prolog is still my favorite here.
  3. Availability of a wide range of libraries (think math libraries, chart libraries, bio libraries). All JVM based languages can use Java libraries. This more or less kills Prolog, Caml and Haskell.
  4. Easy multi platform support. Think Linux, Mac OS X and Windows. With not much pain. Kills most non-VM languages and “system” languages (C, C++, Fortran).
  5. By the way, I refuse to malloc. I was born in the 70s, not retired in the 70s.
  6. Lively, clever and helpful community.
  7. Strong-typing, better yet, strong typing with type inference. I don’t think typing in traditional “scripting” languages scale when the code base grows, it is overrated (think Ruby, Python, Perl and friends), debugging becomes a mess. Caml wins here. Scala type inference seems to sometime fail (i.e. requiring the programmer to explicitly specify the type). Java type of languages force you to always be verbose, that kills productivity.
  8. The language should be seem by the creators mainly as a production vehicle and not as a research vehicle. A big no-no to Prolog here. Haskell goes the same way. Scala seems to strike a reasonable balance. I need to produce reliable code, I require a reliable compiler/interpreter.
  9. I have a strong bias towards the JVM: Open source and open development process (Java Community Process), robust, widely supported, massive user base. .NET, being in practice vendor locked (I don’t think Mono is really a viable alternative as MS really controls whatever they want to control) is out. At the end of the day I also have a soft spot for Java. There are many things that I don’t mind doing in Java.
  10. Introspection. Caml fails here. I actually don’t know how Scala fares here, but at least JVM mechanisms are enough for me.
  11. Striking a good balance between cognitive freedom and damage control on bad code design. As an example, Java gives little freedom in regards on how to express your ideas. Perl, on the other hand allows you to do a big mess (without really giving you expressive power, actually). Functional and logic programming languages shine here.
  12. Over engineering might be good support all possible use cases, but it is a productivity disaster to code in. I am thinking Java here. All libraries are difficult to use by design. Even 3rd party libraries seem to be designed mostly with a complexity culture in mind.

Scala seems to be the option that tackles most issues. To be honest I was always frustrated with all languages because they missed a crucial point in a big way. Prolog is too “researchy”, Haskell also, C too low level, Java too verbose and too freedom-curtaining. Perl and C++ are a complete mess (although in different ways).

Python is almost there (Major: Jython lags. Minor: weak DSL and functional-paradigm support). JRuby is probably there. Scala is probably there. My gut feeling points to try out Scala.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • connotea
  • DZone
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Filed in: Scala, bioinformatics

by: tiago

5 Comments

Financial crisis explained

Via Portfolio.com

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • connotea
  • DZone
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Filed in: money

by: tiago

No Comments

Sebastião Salgado

Sebastião Salgado is a Brazilian photographer mostly known for in photographs depicting works and the people of developing nations. His work really strikes a chord with me. Its strong, poetic, real, … I don’t know… Check it out and decide for yourself…

The best “gallery” seems be available by
Googling for images using Sebastiao Salgado as a keyword.

There is also an official homepage. The navigation is not very intuitive, but if you dig down the site, you can find some gems.

Scaffolding by Sebastiao Salgado

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • connotea
  • DZone
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Filed in: timeout

by: tiago

No Comments

Software engineering radio

I am currently strongly considering Scala as my main development language.

In the process of getting acquainted with the language I came across this interview with Martin Odersky, one of the creators of Scala (he was also involved in the design of Java generics - although that doesn’t count as a cookie point in favor - I will return to Java generics soon, and give a simple example why I think they suck).

Anyway, this post is not about Scala (I will surely come back to it, as I think it is a language worthwhile considering) but about Software Engineering Radio. I have only listened to a few interviews, but the general level of the guests is high. Furthermore the interviewer seems to be highly prepared and really does insightful questions and raises interesting points. This is certainly not mass media journalism. This is first class work.

If you are interested in software engineering content, check Software Engineering Radio and try to listen to podcasts of topics that might interest you.

As another outstanding example of an high quality interview is this one with Laurence Tratt on Compile-time metaprogramming. A treat for anyone interested in metaprogramming and DSLs.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • connotea
  • DZone
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Filed in: software engineering

by: tiago

1 Comment

Pissed with Connotea

I am (was?) a Connotea user (my Connotea bib reference still sits on the right column of this blog). Today, as of writing a report, I tried to import my references from Connotea… The authors of many papers are simply not there. I tried RIS and bibtex (what I use) export, nothing. The authors are not there (I inspected the bibtex export). Yes, maybe I should have checked the quality of the citation, but the point of selecting a DOI (which I always did when clicking my “Add to Connotea” bookmarlet) is not to take away the burden of specifying all important details?

I don’t really like to write on the negative, but, in fact, I had a few more problems with services from the Nature Publishing Group:
1. Performance and downtime: Sometimes to submit a citation takes ages, or the service is down (although, regarding downtime, it seems to be getting better).
2. Postgenomic: When I tried to use it, it was mostly down. Want anedoctical evidence? If you search now (as of the posting date of this entry) for postgenomic on google, the cached page says: “Unable to select database”, nothing more.
3. Postgenomic again: A few months I submitted my blog. I got no answer at all.

Well, let me go back to my report and to manually correct entries downloaded from Connotea into JabRef (JabRef, by the way, can download PubMed entries automatically and correctly).

Updated with screenshot of Google cache (click the thumbnail for full sized screenshot):

Google cache of postgenomic

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • connotea
  • DZone
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Filed in: science

by: tiago

3 Comments

Cheap philosophy

I would like to say a few words on Paulo’s comment, there is one phrase I disagree with and that I would like to discuss:

You can only fight the environment with the tools the genome has given you.

In a very indirect way, yes, but well… no. I don’t want to take this to those interesting discussions on nature versus nurture: I think it would be easy to make the case for social interactions (both for us and other species), drugs (which might suppress some genome changes - think cancer), etc tweaking our genome… A stronger case could be put forward by reminding that we will be able to change our genome in even more radical ways than getting rid of cancer cells. In the future we will be able to create genomes (or am I seeing too much sci-fi?). Of course it could be counter-argued that at the end this is the product of our genome (in the sense that this is all products of our “genomic-based” intelligence) to start with, but I think that would be an argument of a more rhetorical than practical form.

This reminds me of that idea (and getting to the point that concerns me the most) that “You can only do what physics allows you to do” (the comparison is not perfect as the “physics case” is easier to defend). Yes, you can only do what is physically possible, but does that matter in practice? When you want to describe, say genetic based problems, you could resort only to reductionist physics arguments, but that would make the whole description and study of genetics’ problems cumbersome and very very verbose. To put it a CS way of expressing things: The level of abstraction is not enough. The same goes (in fact the whole idea that we can only use the tools that the genome gave us is more debatable, while the idea that we are all physics is much less so) to the “genome”. Yes, we might be all genome definable and maybe we cannot escape that but I think it would be a fallacy to try to see all things from the “eye of the genome”.

Paulo might complain that I am misinterpreting his words (I doubt we wants to see the world only through the “eye of the genome”), for that I apologize. But I was feeling the need to complain against “reductionist” approaches and so I used him as a scapegoat ;) .

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • connotea
  • DZone
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Filed in: biology

by: tiago

2 Comments

Evolution is a route to genetic stability

I am starting to hold this belief that evolution is a route to genetic stability:

If you look at simpler living beings (I am currently looking myself at p. falciparum, the cause of the most mortal form of malaria) they tend to genetically evolve very rapidly as genetics is their fundamental way to adapt to new environments. Not only their numbers are so big that mutations can appear in the population more frequently, but also, it is one of the few ways they have to adapt. And of course, their environment might change rather rapidly in very stressful ways (in my study case, with Man bringing in drugs to which p. falciparum seems to adapt very fast… too fast).

More complex beings have other ways to adapt, the most extreme example that I can think of is ourselves (we adapt culturally, linguistically, …) but other “intermediate” forms also have more “degrees of freedom” than just genetics (like a body that can bend, a muscle that can grow larger, …).

Also, in complex beings different parts of the genome are subjected to very different adaptive stresses (think MHC against brain related genes).

We are at an evolutive step (not only biological, but also scientifically and culturally) that genetic evolution (through mutation) is normally a dreadful thing (think cancer).

Therefore I would speculate that evolution tends to breed genetic stability.

As a side note, from this philosophical point I think it is quite easy to guess what I think about things like “molecular clocks” or, in fact, the current underlying assumptions on which phylogenetics is based.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • connotea
  • DZone
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Filed in: biology

by: tiago

3 Comments