rwr_find_closest_type: RWR Find closest nodes

View source: R/RWR.R

rwr_find_closest_typeR Documentation

RWR Find closest nodes

Description

From a rwr results, this function returns the closest nodes from a seed with a given attribute and value. In biological context, it might be useful to get the closest Gene Ontology annotation nodes from unannotated seeds.

Usage

rwr_find_closest_type(X, seed = NULL, attribute = NULL, value = NULL, top = 1)

Arguments

X

a random walk result from random_walk_restart

seed

a character vector or NULL. If NULL, all the seeds from X are considered.

attribute

a character value or NULL. If NULL, the closest node is returned.

value

a character value or NULL. If NULL, the closest node for a given attribute is returned.

top

a numeric value, the top closest nodes to extract

Value

A list of data.frame for each seed containing the closest nodes per seed and their vertex attributes. If X is list.rwr, the returned value is a list of list.

Examples

graph1 <- igraph::graph_from_data_frame(
    list(from = c("A", "B", "A", "D", "C", "A", "C"), 
         to = c("B", "C", "D", "E", "D", "F", "G")), 
    directed = FALSE)
graph1 <- igraph::set_vertex_attr(graph = graph1, 
                                  name = 'type', 
                                  index = c("A","B","C"),
                                  value = "1")
graph1 <- igraph::set_vertex_attr(graph = graph1, 
                                  name = 'type', 
                                  index = c("D","E"),
                                  value = "2")
graph1 <- igraph::set_vertex_attr(graph = graph1, 
                                  name = 'type', 
                                  index = c("F", "G"),
                                  value = "3")

rwr_res <- random_walk_restart(X = graph1,
                               seed = c("A", "B", "C", "D", "E"))
rwr_find_closest_type(X=rwr_res, attribute = "type", 
                      seed = "A")

abodein/netOmics documentation built on April 16, 2024, 2:59 p.m.