Borrowing heavily from
cydar which corrects for multiple-testing
using a weighting scheme based on the volumetric overlap over hyperspheres.
In the instance of graph neighbourhoods this weighting scheme can use graph
connectivity or incorpate different within-neighbourhood distances for the
weighted FDR calculation.
A list of vertices and the constituent vertices of their neighbourhood
The kNN graph used to define the neighbourhoods
A vector of p-values calculated from a GLM or other appropriate statistical test for differential neighbourhood abundance
A string scalar defining which weighting scheme to use. Choices are: vertex, edge, k-distance, neighbour-distance.
(optional) A list of neighbourhood index vertices in the same order as the input neighbourhoods. Only used for the k-distance weighting.
A vector of adjusted p-values
Each neighbourhood is weighted according to the weighting scheme
defined. Vertex and edge use the respective graph connectivity measures
of the neighbourhoods, k-distance uses the distance to the kth nearest neighbour
of the index vertex, while neighbour-distance uses the average within-neighbourhood
Euclidean distance in reduced dimensional space. The frequency-weighted version of the
BH method is then applied to the p-values, as in