Pages

Wednesday, August 10, 2011

Plotting molecular properties for (sub)sets

For a toxicology paper we are writing up, I need to create a few plots showing how the toxic and non-toxic molecules differ (or not) with respect to a few molecular properties, such as logP or the molecular weight. The rcdk package provides all, of course, except for a nice convenience method (or does it?) to make a plot. That is, I just want to do something like:
plot.propdist(
  mols,
  selections=list(all, actives, inactives),
  descriptor=
    "org.openscience.cdk.qsar.descriptors.molecular.WeightDescriptor",
  main="", xlab="Weight"
)
And now I can. The result looks something like:


Not much difference in this plot. The colors can be changed, if you like, overwriting the rainbow defaults.

The source code of my method (licensed MIT):

1 comment:

  1. Nice. You could simplify the code by slightly changing how you do the grouping. Basically take a grouping factor as input argument and then simply call lattices' densityplot function. See git://gist.github.com/1139433.git

    Then using it simply requires that you generate a factor indicating the grouping. For example,

    cl <- sample(c('active', 'inactive'), 100, replace=TRUE)
    plot.propdist(mols, selections=cl)

    ReplyDelete