ddn3.simulation

Utility function for simple simulation

These simulations are designed to illustrate the usage DDN, and not for formal evaluation of performance. Only the pair graph is supported.

It also contains some helper functions for other simulation functions.

Module Contents

Functions

create_pair_graph([n_node, corr, n_shuf])

Generate precision matrix for pair graph.

prep_sim_from_two_omega(omega1, omega2)

Get covariance matrices and adjacency matrices from two precisions matrices

gen_sample_two_conditions(g1_cov, g2_cov, n1, n2)

Generate multivariante normal samples for two conditions

create_cov_prec_mat(prec_mat_in)

Create covariance from temporary precision matrix

simple_data()

Generate example data for the tutorial

ddn3.simulation.create_pair_graph(n_node=40, corr=0.75, n_shuf=3)

Generate precision matrix for pair graph.

For graph with N nodes, there are N/2 edges, and each node has degree one.

Parameters:
  • n_node (int, optional) – The number of nodes, by default 40

  • corr (float, optional) – The value of precision matrix between two neighboring nodes, by default 0.75

  • n_shuf (int, optional) – The number of edges to shuffle, by default 3

Returns:

  • g1_prec (ndarray) – Precision matrix for condition 1, shape (N, N)

  • g2_prec (ndarray) – Precision matrix for condition 2, shape (N, N)

ddn3.simulation.prep_sim_from_two_omega(omega1, omega2)

Get covariance matrices and adjacency matrices from two precisions matrices

Parameters:
  • omega1 (array_like) – The precision matrix for condition 1

  • omega2 (array_like) – The precision matrix for condition 2

Returns:

  • g1_cov (ndarray) – Covariance matrix for condition 1

  • g2_cov (ndarray) – Covariance matrix for condition 2

  • comm_gt (ndarray) – Adjacency matrix of common network

  • diff_gt (ndarray) – Adjacency matrix of differential network

ddn3.simulation.gen_sample_two_conditions(g1_cov, g2_cov, n1, n2)

Generate multivariante normal samples for two conditions

Let P be the number of features.

Parameters:
  • g1_cov (array_like) – Covariance matrix for condition 1

  • g2_cov (array_like) – Covariance matrix for condition 2

  • n1 (int) – Number of samples for condition 1

  • n2 (int) – Number of samples for condition 2

Returns:

  • dat1 (ndarray) – Generated samples for condition 1. Shape (n1, P)

  • dat2 (ndarray) – Generated samples for condition 2. Shape (n2, P)

ddn3.simulation.create_cov_prec_mat(prec_mat_in)

Create covariance from temporary precision matrix

Each variable now have unit variance. We also provide the corresponding precision matrix.

We follow [Peng 2009] and do not use the d_ij term as the JGL paper.

Parameters:

prec_mat_in (ndarray) – Input precision matrix

Returns:

  • cov_mat (ndarray) – Modified covariance matrix

  • prec_mat (ndarray) – Corresponding precision matrix

ddn3.simulation.simple_data()

Generate example data for the tutorial