KEGG/General Relation Construction (Post-KEGG Parsing)
pdb.construct_kegg_relations
Constructs Gene-Gene and Compound-Compound relationships from an initial Gene-Compound bipartite DataFrame. Relations are based on shared partners, and the shared partners (evidence) are aggregated and counted.
| Parameter | Type | Default | Description |
|---|---|---|---|
gene_compound_df |
pd.DataFrame | DataFrame with gene and compound columns. | |
gene_col |
str | "symbol" | Column name for genes in the input DataFrame. |
compound_col |
str | "compound" | Column name for compounds in the input DataFrame. |
output_gene_col |
str | "gene" | Base name for gene columns in the output DataFrames (gene1,gene2). |
output_compound_col |
str | "compound" | Base name for compound columns in the output DataFrames (compound1,compound2). |
Returns
Tuple[pd.DataFrame,pd.DataFrame]: A tuple containing:
-
gene_relation_df: Gene-Gene relations (columns: ’gene1’, ’gene2’, ’shared_compounds’, ’shared_compound_count’).
-
compound_relation_df: Compound-Compound relations (columns: ’compound1’, ’compound2’, ’shared_genes’, ’shared_gene_count’).
Usage
# Assuming kegg_gc_df has 'kegg_gene_id' and 'kegg_compound_id'
kegg_gg_df, kegg_cc_df = pdb.construct_kegg_relations(
gene_compound_df=kegg_gc_df,
gene_col="kegg_gene_id",
compound_col="kegg_compound_id",
output_gene_col="kegg_gene",
output_compound_col="kegg_compound",
)