makeNhoods: Define neighbourhoods on a graph (fast)

View source: R/makeNhoods.R

makeNhoodsR Documentation

Define neighbourhoods on a graph (fast)

Description

This function randomly samples vertices on a graph to define neighbourhoods. These are then refined by either computing the median profile for the neighbourhood in reduced dimensional space and selecting the nearest vertex to this position (refinement_scheme = "reduced_dim"), or by computing the vertex with the highest number of triangles within the neighborhood (refinement_scheme = "graph"). Thus, multiple neighbourhoods may be collapsed down together to prevent over-sampling the graph space.

Usage

makeNhoods(
  x,
  prop = 0.1,
  k = 21,
  d = 30,
  refined = TRUE,
  reduced_dims = "PCA",
  refinement_scheme = "reduced_dim"
)

Arguments

x

A Milo object with a non-empty graph slot. Alternatively an igraph object on which neighbourhoods will be defined.

prop

A double scalar that defines what proportion of graph vertices to randomly sample. Must be 0 < prop < 1.

k

An integer scalar - the same k used to construct the input graph.

d

The number of dimensions to use if the input is a matrix of cells X reduced dimensions.

refined

A logical scalar that determines the sampling behavior, default=TRUE implements a refined sampling scheme, specified by the refinement_scheme argument.

reduced_dims

If x is an Milo object, a character indicating the name of the reducedDim slot in the Milo object to use as (default: 'PCA'). If x is an igraph object, a matrix of vertices X reduced dimensions with rownames() set to correspond to the cellIDs.

refinement_scheme

A character scalar that defines the sampling scheme, either "reduced_dim" or "graph". Default is "reduced_dim".

Details

This function randomly samples graph vertices, then refines them to collapse down the number of neighbourhoods to be tested. The refinement behaviour can be turned off by setting refine=FALSE, however, we do not recommend this as neighbourhoods will contain a lot of redundancy and lead to an unnecessarily larger multiple-testing burden.

Value

A Milo object containing a list of vertices and the indices of vertices that constitute the neighbourhoods in the nhoods slot. If the input is a igraph object then the output is a matrix containing a list of vertices and the indices of vertices that constitute the neighbourhoods.

Author(s)

Emma Dann, Mike Morgan

Examples


require(igraph)
m <- matrix(rnorm(100000), ncol=100)
milo <- buildGraph(m, d=10)

milo <- makeNhoods(milo, prop=0.1)
milo


MarioniLab/miloR documentation built on Oct. 18, 2024, 6:04 p.m.