[BioC] removing packages from the workspace - is this ok?

Steve Lianoglou mailinglist.honeypot at gmail.com
Tue Jun 7 18:04:43 CEST 2011


On Tue, Jun 7, 2011 at 11:40 AM,  <J.delasHeras at ed.ac.uk> wrote:
> This is more of a general R question, but it concerns in this case genomic
> annotation packages (BSgenome) and I would like to be sure I'm using this
> correctly and not mudling things up inadvertently.
> As part of certain checks I'm running, using various IDs and coordinates
> from different genomic builds, I want to extract sequences from two
> different human genomic builds. Sometimes HG18, sometimes HG19.
> This sometimes requires removing the annotation package from one build and
> loading the other.

I'm not sure what the best way of doing what you want is, but I'd just
reassign the BSgenome objects to their own variables and not try to
juggle packages into/out-of the workspace, eg:

R> library(BSgenome.Hsapiens.UCSC.hg19)
R> hg19 <- Hsapiens
R> library(BSgenome.Hsapiens.UCSC.hg18)
R> hg18 <- Hsapiens

You'll get the same results as you do now:

> library(BSgenome.Hsapiens.UCSC.hg18)
> seq1<-subseq(Hsapiens$chr1, 11323785, 11323785+20)
> as.character(seq1)
> # ok, I got those 20 nucleotides.
> # now I want to check a sequence in the HG19 build
> # to remove HG18, I use
> detach("package:BSgenome.Hsapiens.UCSC.hg18", unload=T)
> # then I load HG19, and do whatever I want to do with it:
> library(BSgenome.Hsapiens.UCSC.hg19)
> seq2<-subseq(Hsapiens$chr1, 11401198, 11401198+20)
> as.character(seq2)
> # the same sequence, good, I verified the coordinates match.
> # and now I remove it like I did for HG18:
> detach("package:BSgenome.Hsapiens.UCSC.hg19", unload=T)

R> subseq(hg18$chr1, 11323785, 11323785+20)
  21-letter "MaskedDNAString" instance (# for masking)

R> subseq(hg19$chr1, 11401198, 11401198+20)
  21-letter "MaskedDNAString" instance (# for masking)

It seems your way works fine, but maybe it could be a bit easier to
name the genome objects explicitly so you don't have to wonder which
build your Hsapiens object points to at any given time ...

My 2 cents ...


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