Statistical Diffusion

class pygna.statistical_diffusion.DiffusionTest(test_statistic, nodes: list, diffusion_matrix: numpy.matrix, weights_table: pandas.core.frame.DataFrame, names_col: str = 'name', weights_col: str = 'stat', diz: dict = {})[source]

This class elaborates the diffusion statistics. It elaborates the diffusion tests over the given network. Please refer to the single method documentation for the returning values

empirical_pvalue(geneset: list, alternative: str = 'less', max_iter: int = 100, cores: int = 1) → [<class 'int'>, <class 'float'>, <class 'float'>, <class 'int'>, <class 'int'>][source]

Calculate the empirical pvalue on the genes list

Parameters:
  • geneset – the geneset to elaborate
  • alternative – the pvalue selection of the observed genes
  • max_iter – the number of iterations to be performed
  • cores – the number of cores to be used
Return observed, pvalue, null_distribution, len(mapped_genesetA), len(mapped_genesetB):
 

the list with the data calculated

get_null_distribution(geneset_index: list, n_samples: int, randomize: str = 'index') → list[source]

Calculate the null distribution over the geneset

Parameters:
  • geneset_index – the geneset id that points to the geneset to be used
  • n_samples – the number of samples to be taken
Returns:

the random distribution calculated for each element

get_null_distribution_mp(geneset_index: list, iter: int = 100, n_proc: int = 1) → numpy.ndarray[source]

Calculate the null distribution with multiple cores on the geneset

Parameters:
  • geneset_index – the geneset id that point to the geneset to be used
  • iter – the number of iterations to perform
  • n_proc – the number of cpu to use for the elaboration
Returns:

the array with null distribution

pygna.statistical_diffusion.map_table2matrix(node_list, x)[source]
pygna.statistical_diffusion.weights_diffusion_statistic(matrix: numpy.matrix, weights: numpy.matrix, geneset_index: list, diz: dict = {}, observed_flag: bool = False) → float[source]

Not in use. This statistic reweights the original weights and returns the average reweighted statistic.

pygna.statistical_diffusion.hotnet_diffusion_statistic(matrix: numpy.matrix, weights: numpy.matrix, geneset_index: list, diz: dict = {}, observed_flag: bool = False) → numpy.ndarray[source]

HOTNET2 like diffusion. Applies the diagonal matrix of weights and gets all rows and columns according to the genelist

Parameters:
  • matrix – the matrix corresponding to the graph
  • weights – the matrix of which it will be created the diagonal matrix
  • geneset_index – the gene list index
  • observed_flag – TBD