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") | |
} |
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
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
#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 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
#!/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
#!/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
""" | |
Author: YOUR NAME HERE | |
JHED: YOUR JHED HERE | |
Name: triangle_count.py | |
Get the list of cycle triangles in the graph | |
""" | |
from pyspark import SparkContext | |
from time import time |
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
# This script was wholly obtained from: https://spark-summit.org/2013/exercises/machine-learning-with-spark.html. | |
# I take no credit/blame for the implementation. | |
import os | |
import sys | |
import numpy as np | |
from pyspark import SparkContext | |
def setClassPath(): | |
oldClassPath = os.environ.get('SPARK_CLASSPATH', '') |
OlderNewer