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
#!/usr/bin/Rscript | |
frobenius.norm <- function(V, W, H) { | |
sqrt(sum((V - (W%*%H))^2)/prod(dim(V))) | |
} | |
nmf <- function (V, r, H=abs(replicate(dim(V)[2], rnorm(r))), | |
W=abs(replicate(r, rnorm(dim(V)[1]))), max.iters=1000) { | |
set.seed(12345) | |
converged <- FALSE |
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
#!/usr/bin/python | |
# Disa Mhembere | |
# Make me a new file with a nice comment block and optinal | |
# things like a main, and argparser | |
# This is free software and comes with not guarantee of correct | |
# functionality. Use at your own peril | |
import argparse | |
import os |
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 mrcap.utils.igraph_io as igraph_io | |
import igraph | |
from glob import glob | |
import cPickle as pickle | |
import os | |
def get_dist(directory): | |
deg_map = {} | |
for fn in glob(os.path.join(directory, "*.zip")): | |
g = igraph_io.read_arbitrary(fn, informat="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
#include <igraph.h> | |
#include <stdio.h> | |
void custom_warning_handler (const char *reason, const char *file, | |
int line, int igraph_errno) { | |
printf("Warning: %s\n", reason); | |
} | |
int main(int argc, char* argv[]) | |
{ |
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 subprocess | |
import os | |
for _file_ in os.listdir("."): | |
if not _file_.startswith(".") and not _file_.endswith("py"): | |
subprocess.call(["zip", "-v", _file_+".zip", _file_]) | |
print "Deleting,", _file_ | |
os.remove(_file_) |
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 os | |
import sys | |
value = sys.argv[1] | |
for _file_ in os.listdir("."): | |
if not _file_.startswith(".") and not _file_.endswith("py"): | |
print "Attempting to read and split %s ..." % _file_ | |
f = open(_file_, "r") | |
print "Renaming uncompressed" |
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") | |
} |
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(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
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) |