makeNhoods: Define neighbourhoods on a graph (fast)

View source: R/makeNhoods.R

makeNhoodsR Documentation

Define neighbourhoods on a graph (fast)


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.


  prop = 0.1,
  k = 21,
  d = 30,
  refined = TRUE,
  reduced_dims = "PCA",
  refinement_scheme = "reduced_dim"



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


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


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


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


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


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.


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


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.


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.


Emma Dann, Mike Morgan


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

milo <- makeNhoods(milo, prop=0.1)

MikeDMorgan/miloR documentation built on Aug. 7, 2022, 8:21 a.m.