napistu.ingestion.napistu_edgelist

Module with helper functions to deal with edgelists

Edgelists are assumed to be DataFrames whose first two columns represent an Edge relation, eg From, To

Functions

count_fraction_of_reciprocal_interactions(...)

Count the fraction of A-B edges which also show up as B-A edges

remove_reciprocal_interactions(edgelist[, ...])

Remove reciprocal edges from an edgelist (i.e., if B-A always exists for every A-B then remove B-A)

napistu.ingestion.napistu_edgelist.count_fraction_of_reciprocal_interactions(edgelist: DataFrame, extra_defining_vars: list = []) float

Count the fraction of A-B edges which also show up as B-A edges

Parameters:
  • edgelist (pd.DataFrame) – edgelist (pd.DataFrame): edgelist where the first two columns are assumed to be the edge vertices

  • extra_defining_vars (list) – list (which can be empty) of variables which define a unique interaction beyond the vertices

Returns:

fraction of A-B edges which are also included as B-A edges

Return type:

fraction (float)

napistu.ingestion.napistu_edgelist.remove_reciprocal_interactions(edgelist: DataFrame, extra_defining_vars: list = []) DataFrame

Remove reciprocal edges from an edgelist (i.e., if B-A always exists for every A-B then remove B-A)

Parameters:
  • edgelist (pd.DataFrame) – edgelist (pd.DataFrame): edgelist where the first two columns are assumed to be the edge vertices

  • extra_defining_vars (list) – list (which can be empty) of variables which define a unique interaction beyond the vertices

Returns:

edgelist with B-A edges removed and A-B retained

Return type:

indegenerate_edgelist (pd.DataFrame)