GOSemSim redesign in terms of S4 classes

November 30, 2010
By

(This article was first published on YGC » R, and kindly contributed to R-bloggers)

I started to develop GOSemSim package two years ago when I was not quite familiar with R. I am very happy to see that someone use it and found it helpful.

I try to learn S4 and redesign GOSemSim with S4 classes and methods in the pass two weeks, and the very first version was implemented. As I’m not very familiar with S4, the package may need improve in many aspect.

The newest version of GOSemSim can be installed by:

install.packages("GOSemSim",repos="http://www.bioconductor.org/packages/devel/bioc",type="source")

Here are some examples:

> library(GOSemSim)
Loading required package: AnnotationDbi
Loading required package: Biobase

Welcome to Bioconductor

  Vignettes contain introductory material. To view, type
  'openVignette()'. To cite Bioconductor, see
  'citation("Biobase")' and for packages 'citation(pkgname)'.

Loading required package: GO.db
Loading required package: DBI
Loading required package: org.Hs.eg.db
> params <- new("Params", ontology="MF", method="Wang")
>
>
> go1 <- c("GO:0004022", "GO:0004024", "GO:0004023")
> go2 <- c("GO:0009055", "GO:0020037")
> gos <- new("GOSet", GOSet1=go1, GOSet2=go2)
>
> sim(gos,params)
           GO:0009055 GO:0020037
GO:0004022      0.318      0.151
GO:0004024      0.290      0.136
GO:0004023      0.290      0.136

> setCombineMethod(params)<-"rcmax.avg"
> sim(gos,params)
[1] 0.273

> gs1 <- c("835", "5261","241", "994", "514", "533")
> gs2 <- c("578","582", "400", "409", "411")
> gs <- new("GeneSet", GeneSet1=gs1, GeneSet2=gs2)
> setOrganism(params) <- "human"
[1] "loading GOMap..."
[1] "Done..."
>
> x <- org.Hs.egGO
> hsEG <- mappedkeys(x)
> clusters <- list(a=sample(hsEG, 20), b=sample(hsEG, 20), c=sample(hsEG, 20))
> geneClusters <- new("GeneClusterSet", GeneClusters=clusters)
>
> sim(gs, params)
[1] "loading GOMap..."
[1] "Done..."
       578   582   400   409   411
835  0.743 1.000 0.624 0.741 0.543
5261 0.551 0.842 0.580 0.582 0.438
241  0.729 1.000 0.666 0.702 0.360
994  0.610 1.000 0.542 0.642 0.673
514  0.285 0.390 0.420 0.282 0.550
533  0.378 0.481 0.373 0.369 0.357
> sim(geneClusters, params)
      a     b     c
a 1.000 0.782 0.770
b 0.782 1.000 0.745
c 0.770 0.745 1.000
>
> setOrganism(params) <- "yeast"
Loading required package: org.Sc.sgd.db
[1] "loading GOMap..."
[1] "Done..."
> ygs <- new("GeneSet", GeneSet1="snR18", GeneSet2="YPR062W")
> sim(ygs,params)
[1] 0.199
> setOntology(params) <- "BP"
> sim(ygs,params)
[1] 0.295
> setMethod(params) <- "Resnik"
> sim(ygs,params)
[1] 0.234

Related Posts

To leave a comment for the author, please follow the link and comment on his blog: YGC » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , , ,

Comments are closed.