Skip to content

pyNBS.pyNBS_core.network_inf_KNN_glap

Tongqiu (Iris) Jia edited this page Jan 26, 2018 · 14 revisions

This function constructs the k-nearest neighbor regularization network graph laplacian. The graph laplacian of this KNN network knnGlap is used as the regularizer later in the netNMF step. The function constructs the knnGlap with the following steps:

Steps to construct knnGlap:

  1. Construct the network influence matrix as described by Vandin et al. 2011
    1. Construct laplacian matrix of the molecular network.
    2. Adjust diagonal of the laplacian matrix by small gamma factor (default gamma=0.01)
    3. Calculate the inverse of the diagonal-adjusted graph laplacian from (ii) to get the network influence matrix
    • Note: This step is significantly faster and gives similar results as the original method used previously in Hofree's NBS v0.2.0, which calculated the pseudoinverse of each network component.
  2. Construct KNN graph by conneting each node to its k nearest neighbors by influence score (default k=11)
  3. Calculate graph laplacian of this new KNN graph and return it as knnGlap

Function Call:

network_inf_KNN_glap(network, gamma=0.01, kn=11, verbose=True, **save_args)

Parameters:

  • network (required, Networkx.Graph): Networkx object loaded from network file.
  • gamma (optional, float, default=0.01): Constant value to add to the diagonal of molecular network graph laplacian to calculate influence matrix for regularization network construction (Vandin 2011).
  • kn (optional, int, default=11): Number of nearest neighbors to add to the regularization network during construction.
  • verbose (optional, bool, default=False): Verbosity flag for reporting on patient similarity network construction steps.
  • **save_args (optional, dict, default=None): Dictionary of strings for saving results.
    • save_args['outdir']: A string containing the directory path of which to save the resulting graph laplacian of this function. If this parameter is given within **save_args, the function will automatically write the graph laplacian as a .csv to this location.
    • save_args['job_name']: A string containing a file prefix for the graph laplacian saved in save_args['outdir']. Otherwise the file name will default to knnGlap.csv

Returns:

  • knnGlap (pandas.DataFrame): The graph laplacian of the constructed KNN network to be used for regularizing netNMF.

Additional notes about this function:

This step is technically optional. No regularization network laplacian has to be constructed if the user would like to run the NMF step without a network regularizer. The user simply has to pass 0 for the parameter netNMF_gamma into the optional kwargs dictionary NBS_single() function, or directly calling the mixed_netNMF() function, setting the gamma parameter to being 0. This will cause pyNBS to run a network-regularized NMF procedure with 0 network penalty. However, an empty gene-by-gene array of all 0's (or any other numerical value) must be passed to the NBS_single() and mixed_netNMF() functions. Additionally, given the implementation of the multiplicative update steps, the results may not be exactly the same as some other NMF implementations (e.g. from scikit-learn).

Clone this wiki locally