One solution to the issue of managing packages in your R
namespace/environment is Hadley Wickham's devtools
package<https://github.com/hadley/devtools#readme>.
 I am surprised more people don't use it for this


On Tue, Jun 7, 2011 at 9:04 AM, Steve Lianoglou <
mailinglist.honeypot@gmail.com> wrote:

> Hi,
>
> On Tue, Jun 7, 2011 at 11:40 AM,  <J.delasHeras@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)
> > [1] "ACACACACCTGGAGAGCCCCA"
> >
> > # 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)
> > [1] "ACACACACCTGGAGAGCCCCA"
> >
> > # 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)
> seq: ACACACACCTGGAGAGCCCCA
>
> R> subseq(hg19$chr1, 11401198, 11401198+20)
>  21-letter "MaskedDNAString" instance (# for masking)
> seq: ACACACACCTGGAGAGCCCCA
>
> 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
>
> --
> 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
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor@r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>



-- 
If people do not believe that mathematics is simple, it is only because they
do not realize how complicated life is.
John von Neumann<http://www-groups.dcs.st-and.ac.uk/~history/Biographies/Von_Neumann.html>

	[[alternative HTML version deleted]]

