Skip to content

Commit

Permalink
change buildGOmap() parameter, #47
Browse files Browse the repository at this point in the history
  • Loading branch information
GuangchuangYu committed Feb 5, 2024
1 parent 1800f40 commit 72c8b70
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 96 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: GOSemSim
Type: Package
Title: GO-terms Semantic Similarity Measures
Version: 2.29.1
Version: 2.29.1.001
Authors@R: c( person(given = "Guangchuang", family = "Yu", email = "[email protected]", role = c("aut", "cre")),
person(given = "Alexey", family = "Stukalov", email = "[email protected]", role = "ctb"),
person(given= "Pingfan", family = "Guo", email = "[email protected]", role = "ctb"),
Expand Down Expand Up @@ -48,4 +48,4 @@ URL: https://yulab-smu.top/biomedical-knowledge-mining-book/
BugReports: https://github.com/YuLab-SMU/GOSemSim/issues
Packaged: 2012-08-29 06:44:50 UTC; root
biocViews: Annotation, GO, Clustering, Pathways, Network, Software
RoxygenNote: 7.2.3
RoxygenNote: 7.3.0
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# GOSemSim 2.29.1.001

+ update `buildGOmap()` parameter to consistent with `enricher()` and `GSEA()` (2024-02-06, Tue, #47)

# GOSemSim 2.29.1

+ extend `godata()` to support passing a data.frame (can be output of `read.gaf()` or `read.blast2go()`) to 'annoDb' (2023-01-16, Tue)
Expand Down
44 changes: 2 additions & 42 deletions R/GOSemSim-package.R
Original file line number Diff line number Diff line change
@@ -1,45 +1,5 @@
##'Gene Ontology-based Sematic Similarity Measures
##'
##'Implementation of semantic similarity measures to estimate the functional
##'similarities among Gene Ontology terms and gene products
##'
##'Quantitative measure of functional similarities among gene products is
##'important for post-genomics study. and widely used in gene function
##'prediction, cluster analysis and pathway modeling. This package is designed
##'to estimate the GO terms' and genes' semantic similarities. Implemented five
##'methods proposed by Resnik, Schlicker, Jiang, Lin and Wang respectively.
##'Support many species, including Anopheles, Arabidopsis, Bovine, Canine,
##'Chicken, Chimp, E coli strain K12 and strain Sakai, Fly, Human, Malaria,
##'Mouse, Pig, Rhesus, Rat, Worm, Xenopus, Yeast, Zebrafish.
##'
##'\tabular{ll}{ Package: \tab GOSemSim\cr Type: \tab Package\cr Version: \tab
##'2.0.0\cr Date: \tab 09-11-2012\cr biocViews:\tab GO, Clustering, Pathways,
##'Anopheles_gambiae, Arabidopsis_thaliana, Bos_taurus, Caenorhabditis_elegans,
##'Canis_familiaris, Danio_rerio, Drosophila_melanogaster, Escherichia_coli,
##'Gallus_gallus, Homo_sapiens, Mus_musculus, Pan_troglodytes,
##'Plasmodium_falciparum, Rattus_norvegicus, Saccharomyces_cerevisiae,
##'Streptomyces_coelicolor, Sus_scrofa, Xenopus_laevis\cr Depends:\tab \cr
##'Imports: \tab methods, AnnotationDbi, GO.db\cr
##'Suggests:\tab clusterProfiler, DOSE\cr
##'License: \tab Artistic-2.0\cr }
##'
##'@name GOSemSim-package
##'@aliases GOSemSim-package GOSemSim
##'@docType package
##'@author Guangchuang Yu
##'
##'Maintainer: Guangchuang Yu <guangchuangyu@@gmail.com>
##'@seealso \code{\link{goSim}} \code{\link{mgoSim}} \code{\link{geneSim}}
##'\code{\link{mgeneSim}} \code{\link{clusterSim}} \code{\link{mclusterSim}}
##'@references Yu et al. (2010) GOSemSim: an R package for measuring semantic
##'similarity among GO terms and gene products \emph{Bioinformatics} (Oxford,
##'England), 26:7 976--978, April 2010. ISSN 1367-4803
##'\url{http://bioinformatics.oxfordjournals.org/cgi/content/abstract/26/7/976}
##'PMID: 20179076
##'@keywords package
NULL


#' @keywords internal
"_PACKAGE"



Expand Down
23 changes: 11 additions & 12 deletions R/buildGOmap.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
##' Addding indirect GO annotation
##'
##' provided by a data.frame of GENE (column 1), GO (column 2) and ONTOLOGY (optional) that
##' provided by a data.frame of GO TERM (column 1), GENE (column 2) and ONTOLOGY (optional) that
##' describes GO direct annotation,
##' this function will add indirect GO annotation of genes.
##' @title buildGOmap
##' @param x data.frame with two or three columns of GENE, GO and ONTOLOGY (optional)
##' @param TERM2GENE data.frame with two or three columns of GO TERM, GENE and ONTOLOGY (optional)
##' @return data.frame, GO annotation with direct and indirect annotation
##' @importMethodsFrom AnnotationDbi as.list
##' @importFrom GO.db GOMFANCESTOR
##' @importFrom GO.db GOBPANCESTOR
##' @importFrom GO.db GOCCANCESTOR
##' @export
##' @author Yu Guangchuang
buildGOmap <- function(x) {
buildGOmap <- function(TERM2GENE) {
mfanc <- as.list(GOMFANCESTOR)
ccanc <- as.list(GOCCANCESTOR)
bpanc <- as.list(GOBPANCESTOR)

if (!'ONTOLOGY' %in% names(x)) {
if (!'ONTOLOGY' %in% names(TERM2GENE)) {
anc <- c(mfanc, ccanc, bpanc)
res <- buildGOmap_internal(x, anc)
res <- buildGOmap_internal(TERM2GENE, anc)
return(res)
}

anc <- list(MF=mfanc, CC=ccanc, BP=bpanc)
y <- split(x, x$ONTOLOGY)
y <- split(TERM2GENE, TERM2GENE$ONTOLOGY)

res <- lapply(names(y), function(i) {
d <- buildGOmap_internal(y[[i]], anc[[i]])
Expand All @@ -37,15 +37,14 @@ buildGOmap <- function(x) {

##' @importFrom stats setNames
##' @importFrom yulab.utils ls2df
buildGOmap_internal <- function(y, anc) {
res <- setNames(anc[y$GO], y[,1]) |>
buildGOmap_internal <- function(TERM2GENE, anc) {
res <- setNames(anc[TERM2GENE[,1]], TERM2GENE[,2]) |>
ls2df() |>
unique()

names(res) <- c(names(y)[1], "GO")
res <- res[res$GO != "all", ]

res <- rbind(y[, names(res)], res)
res <- setNames(res[, c(2,1)], names(TERM2GENE)[1:2])
res <- res[res[,1] != "all", ]
res <- rbind(TERM2GENE[,1:2], res)
return(res)
}

Expand Down
56 changes: 19 additions & 37 deletions man/GOSemSim-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/buildGOmap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 72c8b70

Please sign in to comment.