Data Import and Export (Python API)
1. Importing a network from a Table
- If you have an interaction matrix stored in a
tsvorcsvformat, you can load it into aNetworkobject. Additionally we require: obsmeta_file- Acsvfile containing the taxonomy information for the microbes that are a part of the matrixmeta_file- Ajsonfile containing the experimental metadata for the networkcmeta_file- Ajsonfile containing the details about the computational processing done on the data
from micone import Network, NetworkGroup
network = Network.load_data(
interaction_file,
meta_file,
cmeta_file,
obsmeta_file,
)
network_group = NetworkGroup([network])
Additionally, you can specify the matrix of pvalues and thesholds if any to be applied to the data
Note
The indices of the
interaction_fileandobsmeta_filemust matchThe order of indicies of
interaction_fileandpvalue_filemust match
2. Importing a network from an edge list
If you have interaction data stored in the form of an edge list
from micone import Network. NetworkGroup
network = Network.load_elist(
elist_file,
meta_file,
cmeta_file,
obsmeta_file,
)
network_group = NetworkGroup([network])
Note
The headers of the
elist_filemust contain “source”, “target”, “weight”
3. Exporting your Network object into JSON file
network_group.write("network.json", pvalue_filter=True, interaction_filter=False)
This JSON file is compatible with the MIND database and can be uploaded and visualized directly on the website.