make_edge_weights: Create edge weights

Description Usage Arguments Value See Also Examples

View source: R/utils.R

Description

Create edge weights to modify the shortest path search (find_paths). Discourage and/or encourage certain types of paths by supplying _out and _in arguments, respectively. Node semantic types, node names, and edge predicates are the features that can influence the edge weights. Capitalization is ignored.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
make_edge_weights(
    graph,
    e_feat,
    node_semtypes_out = NULL,
    node_names_out = NULL,
    edge_preds_out = NULL,
    node_semtypes_in = NULL,
    node_names_in = NULL,
    edge_preds_in = NULL
)

Arguments

graph

The SemMed graph

e_feat

A data.frame of edge features from get_edge_features.

node_semtypes_out

A character vector of semantic types to exclude from shortest paths.

node_names_out

A character vector of exact node names to exclude.

edge_preds_out

A character vector of edge predicates to exclude.

node_semtypes_in

A character vector of semantic types to include/encourage in shortest paths.

node_names_in

A character vector of exact node names to include.

edge_preds_in

A character vector of edge predicates to include.

Value

A numeric vector of weights

See Also

find_paths, get_middle_nodes for a way to obtain node names to remove

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
data(g_mini)

node_cortisol <- find_nodes(g_mini, names = "Serum cortisol")
node_stress <- find_nodes(g_mini, names = "Chronic Stress")
paths <- find_paths(g_mini, from = node_cortisol, to = node_stress)

e_feat <- get_edge_features(g_mini)

w1 <- make_edge_weights(g_mini, e_feat, edge_preds_in = "COEXISTS_WITH")
paths1 <- find_paths(g_mini,
    from = node_cortisol, to = node_stress, weights = w1)

w2 <- make_edge_weights(g_mini, e_feat, edge_preds_in = "ISA",
                        node_names_out = "Stress")
paths2 <- find_paths(g_mini,
    from = node_cortisol, to = node_stress, weights = w2)

rsemmed documentation built on Nov. 8, 2020, 5:32 p.m.