Skip to content

Instantly share code, notes, and snippets.

View tpoisot's full-sized avatar

Timothée Poisot tpoisot

View GitHub Profile
@tpoisot
tpoisot / layout.foodweb.r
Created June 24, 2012 17:29
layout.foodweb function for igraph, with layout.foodweb.radial
layout.foodweb = function(w, tlfunc = min, ...)
{
# Who is a primary producer ?
PrimProd = (degree(w,mode='out') == 0)
# Get trophic level
fullSP = shortest.paths(w)
SP = shortest.paths(w,V(w)[ names(PrimProd[!PrimProd]) ],V(w)[ names(PrimProd[PrimProd]) ])
V(w)[ names(PrimProd[PrimProd]) ]$y = 0
LE = apply(SP,1, tlfunc, ...)
for(i in c(1:length(LE))){
@tpoisot
tpoisot / pylogis.py
Created September 10, 2012 20:14
Fit logistic growth with Python / probably poorly written, but the job is done
## PyLogis
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
# Param orders: r, K
def logis(x, y, p):
est = []
@tpoisot
tpoisot / minted.tex
Created November 18, 2012 22:21
minted package in beamer
\documentclass{beamer}
\usepackage{bera,berasans,beramono}
\usepackage{minted}
\usemintedstyle{colorful}
\begin{document}
\begin{frame}[fragile]{Code}{Test in Python}
@tpoisot
tpoisot / gist:4195796
Created December 3, 2012 15:40
Sort lines and remove duplicates
sort garbage.txt | uniq -u
@tpoisot
tpoisot / pgf-gl.tex
Last active December 10, 2015 22:08 — forked from anonymous/pgf-gl.tex
Added open-sans, which I use on my website
\documentclass{minimal}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[default,scale=0.95]{opensans}
\usepackage{mathastext}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
@tpoisot
tpoisot / eebtools-interview.md
Created January 23, 2013 20:38
Template for the EEBTools interviews pages -- fill it out, and send the file to [email protected] with a picture of you! Please try to make sure that your picture does not exceed 500 pixels in width (otherwise we may have to resize it for you).
layout title shortbio blob isinterview photo
interview
Your Name goes here
What do you do for a living (in 5-6 words!)
Two to three sentences about what you do, and the tools you use
true

#Who are you and what do you do?

@tpoisot
tpoisot / nodecontrib.py
Created February 13, 2013 04:02
Node contribution to network modularity
import networkx as nx
import scipy as sp
import numpy as np
import matplotlib.pyplot as plt
import community
def removeNode(web,node):
tempWeb = nx.DiGraph()
tempWeb.add_nodes_from(web.nodes())
@tpoisot
tpoisot / qr.py
Created February 13, 2013 18:41
An a posteriori measure of network modularity -- code associated to the F1000R paper
import networkx as nx
import numpy as np
import scipy as sp
from scipy import stats
import matplotlib.pyplot as plt
import progressbar as pb # Get it from http://code.google.com/p/python-progressbar/
import community # Get it from http://perso.crans.org/aynaud/communities/
def nullModel(graph):
"""
@tpoisot
tpoisot / nichemodel.py
Created February 20, 2013 03:16
Niche model of food webs in python
def niche_foodweb(S, C):
G = nx.DiGraph()
G.add_nodes_from([n for n in xrange(S)])
## Step 1 - create random species
for n in G:
G.node[n]['n'] = np.round(np.random.uniform(),2)
G.node[n]['r'] = np.random.beta(1, 1/float(2*C)-1) * G.node[n]['n']
G.node[n]['c'] = np.random.uniform(G.node[n]['r']/float(2),G.node[n]['n'])
## Step 2 - smallest species are basal
Smallest = np.min([G.node[n]['n'] for n in G])
@tpoisot
tpoisot / nichemodel.c
Created February 20, 2013 21:17
Niche model in c
// gcc niche.c -o nm -lgsl -lgslcblas -O3 -DHAVE_INLINE
// clang niche.c -o nm -lgsl -lgslcblas -O3 -DHAVE_INLINE
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>