Skip to content

Commit

Permalink
Add: NetworkGroup.combine_pvalues allows for a cids parameter
Browse files Browse the repository at this point in the history
This is needed because only some of the `networks` in the `NetworkGroup`
object are correlation methods and we only apply the p-value merging
algorithm to those `cids`.
  • Loading branch information
dileep-kishore committed Mar 10, 2021
1 parent df1e375 commit 3b0c7d8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions micone/main/network_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,14 @@ def load_json(cls, fpath: str) -> "NetworkGroup":
networks.append(Network.load_json(raw_data=network_raw_data))
return cls(networks)

def combine_pvalues(self) -> pd.Series:
def combine_pvalues(self, cids: List[str]) -> pd.Series:
"""
Combine pvalues of links in the network group using the Brown's Method
Combine pvalues of links in the `cids` using Brown's p-value merging method
Parameters:
-----------
cids : List[str]
The list of context ids that are to be used in the merger
Returns
-------
Expand All @@ -352,8 +357,12 @@ def combine_pvalues(self) -> pd.Series:
"""
pvalue_vectors = self.get_adjacency_vectors("pvalue")
weight_vectors = self.get_adjacency_vectors("weight")
pvalue_df: pd.DataFrame = pd.concat(pvalue_vectors, join="outer")
weight_df: pd.DataFrame = pd.concat(weight_vectors, join="outer")
pvalue_df: pd.DataFrame = pd.concat(
[pvalue_vectors[i] for i in cids], join="outer"
)
weight_df: pd.DataFrame = pd.concat(
[weight_vectors[i] for i in cids], join="outer"
)
# E[psi] = 2 * k
k = pvalue_df.shape[1]
expected_value = 2 * k
Expand Down

0 comments on commit 3b0c7d8

Please sign in to comment.