This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See http://docs.python.org/tutorial/modules.html#packages | |
import os | |
import pyximport; | |
pyximport.install() | |
os.sys.path.extend([os.path.abspath('./PyGraphStat/code/'), | |
os.path.abspath('./MR-connectome/mrcap/')]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def embed_graph(ccfn, roiRootName, fgfn, embedfn, dim=10): | |
""" | |
ccfn - connected components file with numpy arrray | |
roiRootName - roi files root name | |
fgfn - mat file with the fibergraph | |
embedfn - full file name of output file to be saved | |
dim - desired dimension for the embedding | |
""" | |
vcc = lcc.ConnectedComponent(fn =ccfn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dependencies cython | |
# zindex.pyx - https://github.com/openconnectome/MR-connectome/blob/master/mrcap/zindex.pyx | |
# setup.py - https://github.com/openconnectome/MR-connectome/blob/master/mrcap/setup.py | |
# Build zindex & install it first - from terminal: sudo python setup.py install | |
import zindex | |
def xyzToz(xyz): # xyz is a tuple [x,y,z] | |
return XYZMorton() # returns z-index as int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
from math import factorial as fact | |
import sys | |
def test_tri_count(num_nodes): | |
g = nx.complete_graph(num_nodes) | |
tri = nx.triangles(g) | |
num_tri = sum(tri.values())/3 # Div by 3 because of triple counting | |
comb = int(fact(num_nodes)/(fact(3)*fact(num_nodes-3))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(Matrix) | |
require(igraph) | |
require(gtools) | |
args <- commandArgs(trailingOnly = TRUE) | |
n <- 10^6 | |
m <- 10^2 | |
(KA <- n/m) | |
rho <- c(0.02,0.5,0.15,0.08,0.25) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(Matrix) | |
require(igraph) | |
createc3 <- function() | |
{ | |
set.seed(12345) | |
n <- 10^6 | |
m <- 10^2 | |
(KA <- n/m) | |
rho <- c(0.02,0.5,0.15,0.08,0.25) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
import numpy as np | |
p = 0.3 # Alter as necessary | |
n = 1000 # Alter as necessary | |
fn = "graph%d"%n # Alter as necessary | |
g = nx.erdos_renyi_graph(n, p,False) | |
gsp = nx.to_scipy_sparse_matrix(g) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(Matrix) | |
require(igraph) | |
require(argparse) | |
parser <- ArgumentParser(description="Process some integers") | |
parser$add_argument("gfn", help="The graph file name") | |
parser$add_argument("nev", type="integer", help="Number of eigenvectors to compute") | |
parser$add_argument("ncv", type="integer",help="Number of Lanczos vectors to compute") | |
parser$add_argument("maxiter", type="integer",help="Max number of iterations to compute eigenvectors") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(igraph) | |
dat <- read.table("./fly.csv", header=TRUE, sep=",") | |
dat <- dat[c("presynaptic", "postsynaptic" , "pre.x", "post.x", "pre.y", "post.y", "pre.z", "post.z","proofreading.details")] | |
g <- graph.data.frame(dat, directed=TRUE) | |
g <- set.graph.attribute(g, "source", value="http://www.nature.com/nature/journal/v500/n7461/full/nature12450.html") | |
g <- set.graph.attribute(g, "info", value="source=presynaptic, targe=postsynaptic") | |
write.graph(g, "drosophila_retina.graphml", format="graphml") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(igraph) | |
g <- read.graph("./web-Google.txt") # Change fn | |
cl <- clusters(g, "strong") # "weak" | |
unique.clusters <- unique(cl$csize) | |
for (i in 1: length(unique.clusters) ) { | |
cat(unique.clusters[i], length(which(cl$csize == unique.clusters[i])),"\n") | |
} |
OlderNewer