Skip to content

Commit

Permalink
oma_pairwise_genesymbols: convenient wrapper to get pairwase orthol…
Browse files Browse the repository at this point in the history
…ogous gene table with gene symbols (related to saezlab/liana#137)
  • Loading branch information
deeenes committed Feb 16, 2024
1 parent 4644659 commit ece62ad
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export(obo_parser)
export(oma_code)
export(oma_organisms)
export(oma_pairwise)
export(oma_pairwise_genesymbols)
export(omnipath)
export(omnipath_cache_autoclean)
export(omnipath_cache_clean)
Expand Down
1 change: 1 addition & 0 deletions R/id_mapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ translate_ids <- function(
.nse_ensure_str(!!enquo(organism)) %>%
{`if`(. == 'organism', organism, .)} %>%
ncbi_taxid

id_cols <- names(ids)
id_types <- unlist(ids)
from_col <- id_cols[1]
Expand Down
61 changes: 61 additions & 0 deletions R/oma.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,67 @@ oma_pairwise <- function(
}


#' Orthologous pairs of gene symbols between two organisms
#'
#' The Orthologous Matrix (OMA), a resource of orthologous relationships
#' between genes, doesn't provide gene symbols, the identifier preferred in
#' many bioinformatics pipelines. Hence this function wraps
#' \code{\link{oma_pairwise}} by translating the identifiers used in OMA to
#' gene symbols. Items that can not be translated to `id_type` (but present
#' in the data with their internal OMA IDs) will be removed. This part is done by . Then,
#' in this function we translate the identifiers to gene symbols.
#'
#' @param organism_a Name or identifier of an organism.
#' @param organism_b Name or identifier of another organism.
#' @param id_type The gene or protein identifier to use in the table. For a
#' list of supported ID types see `omnipath.env$id_types$oma`. These are
#' the identifiers that will be translated to gene symbols.
#' @param mappings Character vector: control ambiguous mappings: \itemize{
#' \item{1:1 - unambiguous}
#' \item{1:m - one-to-many}
#' \item{n:1 - many-to-one}
#' \item{n:m - many-to-many}
#' }
#' @param only_ids Logical: include only the two identifier columns, not the
#' mapping type and the orthology group columns.
#'
#' @return A data frame with orthologous gene pairs.
#'
#' @examples
#' oma_pairwise_genesmybols("human", "mouse")
#'
#' @importFrom magrittr %>%
#' @importFrom rlang exec !!! !! := sym
#' @importFrom dplyr filter
#' @export
oma_pairwise_genesymbols <- function(
organism_a = 'human',
organism_b = 'mouse',
id_type = 'uniprot',
mappings = c('1:1', '1:m', 'n:1', 'n:m'),
only_ids = TRUE
) {

.slow_doctest()

environment() %>%
as.list %>%
exec(oma_pairwise, !!!.) %>%
translate_ids(
id_organism_a := !!sym(id_type),
id_organism_a := genesymbol,
organism = !!sym(organism_a)
) %>%
translate_ids(
id_organism_b := !!sym(id_type),
id_organism_b := genesymbol,
organism = !!sym(organism_b)
) %>%
filter(!is.na(id_organism_a) & !is.na(id_organism_b))

}


#' OMA identifier type from synonyms and lower case version
#'
#' @param id_type Character: a synonym or a lower case version of an OMA
Expand Down
49 changes: 49 additions & 0 deletions man/oma_pairwise_genesymbols.Rd

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

0 comments on commit ece62ad

Please sign in to comment.