[BioC] how to build a R package with the inclusion of inst/extdata
Steve Lianoglou
mailinglist.honeypot at gmail.com
Fri Sep 7 01:50:00 CEST 2012
Hi,
On Thu, Sep 6, 2012 at 7:21 PM, Yue Li <gorillayue at gmail.com> wrote:
> Hi Steven,
>
> Thanks for the quick response. I think I probably didn't articulate my intend clearly.
I actually understood your intent -- I thought you were confused on
why you were getting some error when you ran the `R CMD build ...`
command you posted previously.
The problem was that you were trying to build something that wasn't
really a package -- it seemed as if you were trying to build the
*parent* directory your package directory was living in.
> Basically, I'm trying to develop a R package rather than using someone else's package. In order to run some examples I have for the functions I wrote, I need to have BAM data saved in the "inst/extdata" (or anywhere for that matters). So when I call:
>
> R CMD check mypackage
>
> The example that says something like
>
> testfiles <- system.file("inst/extdata/*bam$", package = "mypackage", )
>
> can give me the BAM files saved in that inst/extdata/ that come with the tar ball package. But I'm too ignorant to figure out how to do that.
If you want to do this pattern matching on *.bam, I'm pretty sure you
can't do it in a call to system.file, so you'd first get a handle on
your `extdata` directory, then call `dir` on it. For example (and to
be extra explicit), assuming you install your package succesfully, you
would then do in R:
R> extdata.dir <- system.file("extdata", package="myPackage")
R> bamfiles <- dir(extdata.dir, pattern="\\.bam$", full.names=TRUE)
The directory structure of your package would look something like this:
myPackage
`- inst
`- extdata
`- data1.bam
`- data2.bam
`- R
`- ...
`- NAMESPACE
`- DESCRIPTION
And note that when you actually install the package, the contents
inside the `inst` directory get "hoisted" out of it and dropped into
the directory of your package, eg. after installation, on your
filesystem the `extdata` directory would be something like:
/path/to/your/R/library/myPackage/extdata/
Download the source code of, say, the ShortRead package to see the
structure you want to follow:
http://www.bioconductor.org/packages/2.10/bioc/src/contrib/ShortRead_1.14.4.tar.gz
HTH,
-steve
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the Bioconductor
mailing list