GOSemSim redesign in terms of S4 classes

[This article was first published on YGC » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 come some example:

> 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", organism="human", method="Wang")
>
>
> go1 <- c("GO:0004022", "GO:0004024", "GO:0004023")
> go2 <- c("GO:0009055", "GO:0020037")
> gos <- new("GOIdentifiers", GOSet1=go1, GOSet2=go2)
>
> gs1 <- c("835", "5261","241", "994", "514", "533")
> gs2 <- c("578","582", "400", "409", "411")
> gs <- new("GeneIdentifiers", GeneSet1=gs1, GeneSet2=gs2)
>
> 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(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
> 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("GeneIdentifiers", 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 their blog: YGC » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)