[BioC] Recommend some R packages source code to read.
James W. MacDonald
jmacdon at uw.edu
Wed May 16 16:18:17 CEST 2012
Hi Fabrice,
Rather than writing a single long script, may I suggest you try to
modularize your code? In other words, it is easier to write, test, and
maintain multiple functions, each of which does a single thing, rather
than one monolithic piece of code. When writing my own code I try to
follow two principles; keep each function under a page in length, and if
I am doing the same (relative) thing twice or more, strip that code out
and put it in its own function. Of course these aren't hard rules, and I
do have some really long spaghetti code in my code base, so there you are.
There are many BioC packages that follow this paradigm, including pretty
much all the packages that are supplied by the core authors. The biggest
drawback to this type of coding is that it is difficult for those not
familiar with the code base to figure out what is going on. Compare for
example the code for heatmap.2 in gplots, which is one great hunk of
spaghetti code to something like the table creation functions in table.R
of annaffy
(https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/annaffy/R/table.R).
Those two examples are extremes. There are almost 400 lines in
heatmap.2() whereas each of the table functions in annaffy are maybe 50
lines, max.
Best,
Jim
On 5/15/2012 10:09 PM, Fabrice Tourre wrote:
> Dear list,
>
> I am try to write some long R script. Does anyone can recommend some
> good examples on Bioconductor to read its source code?
>
> So I can learn how to write long R script more quickly in R's way.
>
> Thank you very much in advance.
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
--
James W. MacDonald, M.S.
Biostatistician
University of Washington
Environmental and Occupational Health Sciences
4225 Roosevelt Way NE, # 100
Seattle WA 98105-6099
More information about the Bioconductor
mailing list