Skip to content

Instantly share code, notes, and snippets.

Avatar

Vince Buffalo vsbuffalo

View GitHub Profile
@vsbuffalo
vsbuffalo / lifeweeks.py
Created Feb 22, 2021
your life, visualized in weeks
View lifeweeks.py
from datetime import date, timedelta
import math
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
from matplotlib.collections import PatchCollection
mean_le = math.ceil(78.54) # for men in US
birthday = (1986, 12, 19)
deathday = (mean_le + birthday[0], 12, 19)
View simple.slim
initialize() {
initializeMutationRate(1e-8);
initializeMutationType("m1", 0.5, "f", 0.0);
initializeGenomicElementType("g1", m1, 1);
initializeGenomicElement(g1, 0, 99999);
initializeRecombinationRate(1e-8);
}
1 early() {
View fix_spines.py
def fix_spines(ax, connect=True, x=True):
"""
Beautifies spines by stopping them at the last tick mark. If connect=False,
also stops them at the first tick mark. For y-axis only, set x=False.
"""
ylim = ax.get_ylim()
xlim = ax.get_xlim()
yticks = ax.get_yticks()
xticks = ax.get_xticks()
View Snakefile
import numpy as np
np.random.seed(1)
DATADIR = "sim_results/"
SLIM = "/home/vsb/src/SLiM_build/slim "
## Parameters
nreps = range(50)
# ------- Shared Parameters -------
View Snakefile
import numpy as np
np.random.seed(1)
DATADIR = "sim_results/"
SLIM = "/home/vsb/src/SLiM_build/slim "
## Parameters
nreps = range(50)
# ------- Shared Parameters -------
View Snakefile
import numpy as np
import slper.slimfile as sf
np.random.seed(1)
DATADIR = "../data/sims/"
SLIM = "/home/vsb/src/SLiM_build/slim "
## Parameters
nreps = range(50)
View split.slim
initialize() {
defineConstant('tmu', 1e-8);
defineConstant('nmu', 1e-8);
defineConstant('rbp', 1e-8);
defineConstant('N', 1000);
defineConstant('alpha', 0.01);
defineConstant('nrep', 1);
defineConstant("seed", getSeed());
defineConstant("data_dir", '../data/sims/');
@vsbuffalo
vsbuffalo / pairwise_cov.r
Created Mar 1, 2019
comparing two implementations of covariance with pairwise complete cases
View pairwise_cov.r
library(tidyverse)
library(MASS)
pcov <- function(x) {
xs <- scale(x, scale=FALSE)
dd <- as.integer(!is.na(x))
dim(dd) <- dim(x)
denom <- (t(dd) %*% dd) - 1L
no_obs <- denom == 0L
xs[is.na(xs)] <- 0
View closure.R
library(purrr)
foo <- function(x) {
return(function(y) {
y + x
})
}
args <- list(1, 2)
foos_map <- map(args, foo)
@vsbuffalo
vsbuffalo / foo.R
Created Apr 13, 2016
23andme and bioc blog post
View foo.R
Title: Using Bioconductor to Analyze your 23andme Data
Bioconductor is one of the open source projects of which I am most
fond. The documentation is excellent, the community wonderful, the
development fast-paced, and the software *very* well written.
There's a new package in the development branch (due to be released as
2.10 very soon) called `gwascat`. `gwascat` is a package that serves
as an interface to the [NHGRI's](http://www.genome.gov/) database of
genome-wide association studies.