[Segtools-users] Using Segtools work as an R package
Michael Hoffman
mmh1 at uw.edu
Fri Nov 4 12:52:23 PDT 2011
Recent versions of Segtools have a feature where it produces an R
transcript that can be used to reproduce the results easily. This is
designed such that it's easy to customize these scripts and the output
options in various ways.
The scripts load Segtools using source() and hard-coded paths to the
current Segtools installation, such as this:
source('/net/noble/vol1/software/modules-sw/segtools/1.1.8/Linux/RHEL5/x86_64/lib/python2.7/segtools/R/common.R')
source('/net/noble/vol1/software/modules-sw/segtools/1.1.8/Linux/RHEL5/x86_64/lib/python2.7/segtools/R/overlap.R')
This can be problematic if you want to use the script on some other
system, or if you install a new version of Segtools in a different
directory.
Ideally, one would be able to load Segtools from R using simply
library(segtools)
Expecting this to happen during installation will add an additional
thing that can break if you change versions of R, or you can't install
into the right location, etc.
Another easier alternative is to easier to change the directory in the
scripts in a way that would allow easy overriding via environment variables:
segtools.r.dir <-
if (!is.na(Sys.getenv("SEGTOOLS_R_DIR", unset = NA)))
Sys.getenv("SEGTOOLS_R_DIR")
else
'/net/noble/vol1/software/modules-sw/segtools/1.1.8/Linux/RHEL5/x86_64/lib/python2.7/segtools/R/'
source(file.path(segtools.r.dir, 'common.R'))
source(file.path(segtools.r.dir, 'overlap.R'))
Still another would be to allow installation as an R package but make
the user do it explicitly from R (with install.packages()) before
being able to use library(segtools). Slightly clunky but seems more
likely to give predictable results than the others.
Any thoughts? This might be a good question to ask on Stack Overflow
too.
--
Michael Hoffman, PhD
Senior Fellow
Department of Genome Sciences
University of Washington
PO Box 355065
Seattle, WA 98195-5065
mmh1 at uw.edu
More information about the Segtools-users
mailing list