find_nodes: Search for nodes by name or semantic type

Description Usage Arguments Value Examples

View source: R/find.R

Description

Search for nodes by name (exact match or using regular expressions) or which match supplied semantic types. Perform anti-matching by setting match = FALSE. Capitalization is ignored.

Usage

1
find_nodes(obj, pattern = NULL, names = NULL, semtypes = NULL, match = TRUE)

Arguments

obj

Either the SemMed graph or a node set (igraph.vs)

pattern

Regular expression used to find matches in node names

names

Character vector of exact node names

semtypes

Character vector of semantic types

match

If TRUE, return nodes that DO match pattern (default). If FALSE, return nodes that DO NOT match.

Value

A vertex sequence of matching nodes

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
data(g_mini)
find_nodes(g_mini, pattern = "cortisol")
find_nodes(g_mini, pattern = "cortisol$")
find_nodes(g_mini, pattern = "stress")
find_nodes(g_mini, pattern = "stress") %>%
    find_nodes(pattern = "disorder", match = FALSE)

find_nodes(g_mini, names = "Serum cortisol")
find_nodes(g_mini, names = "Chronic Stress")

find_nodes(g_mini, semtypes = "dsyn")
find_nodes(g_mini, semtypes = c("dsyn", "fndg"))

## pattern and semtypes are combined via OR:
find_nodes(g_mini, pattern = "cortisol", semtypes = "horm")

## To make an AND query, chain find_nodes sequenctially:
find_nodes(g_mini, pattern = "cortisol") %>%
    find_nodes(semtypes = "horm")

lmyint/rsemmed documentation built on July 26, 2021, 1:20 a.m.