ddn3.tools_export

Tools for extrating information from DDN outputs

Module Contents

Functions

get_diff_comm_net_for_plot(omega1, omega2, gene_names)

Generate common and differential networks from DDN outputs

_get_edge_list(conn_mat, beta_mat, gene_names[, group_idx])

Create a pandas data frame reporting the edges

get_node_type_and_label_two_parts(nodes_show[, ...])

Given a list of features, divide them to to groups, and clean their names.

get_edge_subset_by_name(edge_df[, name_match])

Extract subset of edges in the data frame.

get_node_subset_by_name(nodes[, name_match])

Get a subset of the nodes according to the given pattern

ddn3.tools_export.get_diff_comm_net_for_plot(omega1, omega2, gene_names)

Generate common and differential networks from DDN outputs

Parameters:
  • omega1 (ndarray) – DDN estimated coefficient matrix for condition 1

  • omega2 (ndarray) – DDN estimated coefficient matrix for condition 2

  • gene_names (list of str) – Gene names

Returns:

  • comm_edge (pandas.DataFrame) – Data frame containing information of edges in common networks. The first two columns means the two genes in each edge. The fourth column gives the weights of that edge. The weights is the absolute value of the DDN coefficient.

  • dif1_edge (pandas.DataFrame) – Data frame containing information of differential edges from condition 1. The contents are similart to comm_edge.

  • dif2_edge (pandas.DataFrame) – Data frame containing information of differential edges from condition 2. The contents are similart to comm_edge.

  • diff_edge (pandas.DataFrame) – Data frame containing information of edges in the differential networks. The contents are similart to comm_edge, except that the third column labels whether this edge come from condition 1 or 2.

  • node_non_isolated (list of str) – Node names that are involved in edges in either common network or differential networks.

ddn3.tools_export._get_edge_list(conn_mat, beta_mat, gene_names, group_idx=0)

Create a pandas data frame reporting the edges

Parameters:
  • conn_mat (ndarray) – Adjacency matrix for a graph

  • beta_mat (ndarray) – The coefficient matrix of a graph

  • gene_names (list of str) – Gane names

  • group_idx (int, optional) – The group labeling, by default 0 0 for common edges, 1 for condition 1, 2 for condition 2

Returns:

Data frame containing information of edges. The first two columns give names of genes for each edge. The third column is for the group label. The fourth column is the absolute value of the coefficient.

Return type:

pandas.DataFrame

ddn3.tools_export.get_node_type_and_label_two_parts(nodes_show, part1_id='SP', part2_id='TF', ofst1=2, ofst2=1)

Given a list of features, divide them to to groups, and clean their names.

The first several characters in the name of each feature is related to their group information. For example, for feature “SP_AAAA”, it means a gene in the “SP” group and the gene name is “AAAA”. For feature “TF_BBBB”, it means a gene in “TF” group with name “BBBB”. We want to put thing starting with “TF” and “SP” to two separate groups. We also want to create a simplifed label that do not contain “SP” and “TP” to make plotting easier.

Parameters:
  • nodes_show (list of str) – The list of feature names

  • part1_id (str, optional) – The label for group 1, by default “SP”

  • part2_id (str, optional) – The label for group 2, by default “TF”

  • ofst1 (int, optional) – The number of extra characters to remove the prefix before the gene name, by default 2

  • ofst2 (int, optional) – The number of extra characters to remove the prefix before the gene name, by default 1

Returns:

  • nodes_type (dict) – For each name in the feature, give its group index.

  • labels (dict) – For each name in the feature, give its simplified name.

ddn3.tools_export.get_edge_subset_by_name(edge_df, name_match='TF')

Extract subset of edges in the data frame.

Parameters:
  • edge_df (pandas.DataFrame) – The data frame containing edges.

  • name_match (str, optional) – The pattern of the name to match, by default “TF” Must be at the beginning of the name of each feature.

Returns:

Extracted edges

Return type:

pandas.DataFrame

ddn3.tools_export.get_node_subset_by_name(nodes, name_match='TF')

Get a subset of the nodes according to the given pattern