Load the Pathway Commons SIF file into a pandas data frame, naming the three columns
In [1]:
import pandas
df = pandas.read_csv("shared/pathway_commons.sif",
sep="\t",
names=["species1","interaction_type","species2"])
Make a set of specific interaction-type names, for three general types of networks: PPI, metabolic network, and PPD
In [2]:
interaction_types_ppi = set(["interacts-with",
"in-complex-with",
"neighbor-of"])
interaction_types_metab = set(["controls-production-of",
"consumption-controlled-by",
"controls-production-of",
"controls-transport-of-chemical"])
interaction_types_ppd = set(["catalysis-precedes",
"controls-phosphorylation-of",
"controls-state-change-of",
"controls-transport-of",
"controls-expression-of"])
For each of the three sets, make a new data frame by subsetting your pandas dataframe to only the rows where the "interaction_type" column contains a value that is in the set of specific interaction types.
In [8]:
ppirows = df.interaction_type.isin(interaction_types_ppi)
metabrows = df.interaction_type.isin(interaction_types_metab)
ppdrows = df.interaction_type.isin(interaction_types_ppd)
df_ppi = df[ppirows]
df_metab = df[metabrows]
df_ppd = df[ppdrows]
df_ppi_el = df_ppi[["species1","species2"]].values.tolist()
df_metab_el = df_metab[["species1","species2"]].values.tolist()
df_ppd_el = df_ppd[["species1","species2"]].values.tolist()
Make an igraph Graph object from each of your three data frames, using Graph.TupleList; call the summary function on each graph object to print the summary information for the graph.
In [9]:
from igraph import Graph
from igraph import summary
In [10]:
In [11]:
In [7]:
type(df_ppi_el)
Out[7]: