gtremper / network-motif Goto Github PK
View Code? Open in Web Editor NEWPython wrapper for the Kavosh network motif finder
Python wrapper for the Kavosh network motif finder
This is the documentation for the FinalMotif.py module: FinalMotif.py Functions: Overview: FinalMotif.py is essentially a wrapper for a simple C++ program (Kavosh) for calculating the total number of motifs in a given graph. Kavosh takes in an edge list of the graph and ouputs a txt file with the number of each motif found. We used cPickle to store the raw data as a python dictionary. Since the runtime of this code increases exponentially with motif size, I created a cache directory that stores the motif results in the json format. MotifData: This class contains the motif data for a set of graphs. It is the returned value for the findMotifs() function. It is basically a wrapper for a list of dictionaries. Each element in the list is represents 1 patient and the dictionary maps motif ID to the number of that motif found in the graph. It contains various access functions to iterate through or retrieve various motif data. makeSwapData(degree=10): This crates a pkl file that contains the graphs of the original data after undergoing edge swapping "degree" is the average degree you want to threshold the graph with. buildCache(motifSize, degree): This function builds the cache of both original graphs and edge-swapped ones for faster processing in future runs of findMotifs "motifSize" is the size of the motif you want to calculate. "degree" is the average degree you want to threshold the graph with. findMotifs(data,key,motifSize=3,degree=10,randGraphs=None, useCache=True): This is the main motif finding routine. "data" is a dictionary of all the graph data. "key" is the key into the dictionary for which you want to run findMotifs on. "motifSize" is the size of the motif you want to calculate. "degree" is the average degree you want to threshold the graph with. "randGraphs" is an optional argument that can be set to random set of random graph data to be used instead of the data from the "data" argument. "useCache" if True, looks first in the cache when running this function to see if the result has already been computed. If not, it computes the motifs and saves the results in the cache for late use. This function returns a MotifData object containing all the results convertIDToGraph(mid, motifSize, save=False): This function draws a graph of the given motif ID "mid" is the motif ID you want to draw "motifSize" is the size of the motif for the ID "save" if true saves the picture in png format. If false, just displays a picture of the graph plotMotifGraphs(data,motifSize=3,degree=10,numofmotifs=10,usetotal=False): This function plots a pyplot graph of the data PDFstats(data, filename, edgeSwap=False, motifSize=3, degree=10): Creates a latex document of the T-test data for the motif distribution probabilities "filename" name of outputfile "edgeSwap" is whether to use edge swapped graphs for the RAND group. "motifSize" is the size of the motif you want to calculate. "degree" is the average degree you want to threshold the graph with. PDFdiststats(data, filename, edgeSwap=False, motifSize=3, degree=10): Same as above except it creates a latex document of the T-test data
Hi,
Thanks for sharing your code. Can this code support motif detection in directed weighted networks?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.