ddn3.tools

Utility functions of DDN

Module Contents

Functions

standardize_data(data[, scaler, zero_mean_already])

Standadize each column of the input data

gen_mv(cov_mat, n_sample)

Generate zero mean multivariate data and standardize it.

concatenate_data(controldata, casedata[, method])

Several method to concatenate two arrays

get_net_topo_from_mat(mat_prec[, thr])

Threshold the input matrxi to get adjacency matrix

get_common_diff_net_topo(g_beta[, thr])

Calcualte common and differential network from the output of DDN

ddn_obj_fun(y, X, lambda1, lambda2, n1, n2, beta)

Objective function for DDN, assuming two conditions having the same sample size

ddn3.tools.standardize_data(data, scaler='std', zero_mean_already=False)

Standadize each column of the input data

Parameters:
  • data (ndarray) – Input data. Each column is a feature.

  • scaler (str, optional) – Method to calculate the scale of each feature, by default “std”

  • zero_mean_already (bool, optional) – The data is already with zero mean, by default False

Returns:

standard_data – Standardized data

Return type:

ndarray

ddn3.tools.gen_mv(cov_mat, n_sample)

Generate zero mean multivariate data and standardize it.

Parameters:
  • cov_mat (ndarray) – Covariance matrix

  • n_sample (int) – Sample size

Returns:

Generated samples

Return type:

ndarray

ddn3.tools.concatenate_data(controldata, casedata, method='diag')

Several method to concatenate two arrays

ddn3.tools.get_net_topo_from_mat(mat_prec, thr=0.0001)

Threshold the input matrxi to get adjacency matrix

The input is also made symmetry. As we do not use self loop, the diagonal elements are always 0.

Parameters:
  • mat_prec (ndarray) – Input matrix. It could be a precision matrix, or a coefficient matrix.

  • thr (float, optional) – Threshold to remove too small items in mat_prec, by default 1e-4

Returns:

Adjacency matrix

Return type:

ndarray

ddn3.tools.get_common_diff_net_topo(g_beta, thr=0.0001)

Calcualte common and differential network from the output of DDN

g_beta[0] is the coefficient matrxi for condition 1 g_beta[0] is the coefficient matrxi for condition 2

ddn3.tools.ddn_obj_fun(y, X, lambda1, lambda2, n1, n2, beta)

Objective function for DDN, assuming two conditions having the same sample size