This file contains hidden or 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
# Replace these with the full path to the executables, if necessary | |
BWA=bwa | |
SAMTOOLS=samtools | |
BCFTOOLS=bcftools | |
# Makefile targets | |
all: ref.fa reads.fq aln.bam aln.bam.bai pileup.vcf filtered_calls.bcf consensus.fa | |
.PHONY: all | |
simulation: ref.fa reads.fq |
This file contains hidden or 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
# Standardisation formula | |
z <- function(x) (x - mean(x)) / sd(x) | |
#' Convert regression parameters obtained from standardised variables | |
#' back to the scale of the original data. | |
#' | |
#' For a regression y ~ x*, where x* denotes the standardised form of x: | |
#' Result: y = m(x*) + c | |
#' Transformed: y = (m / sd(x))(x) + (c - (m*mean(x)/sd(x)) | |
#' |
This file contains hidden or 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 revcomp(s): | |
complements = dict( | |
A='T', C='G', G='C', T='A', | |
M='K', R='Y', W='W', S='S', | |
Y='R', K='M', V='B', H='D', | |
D='H', B='V', N='N' | |
) | |
return ''.join(complements[char] for char in s.upper()[::-1]) |
This file contains hidden or 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 sys | |
class Progress(): | |
def __init__(self, capacity, label = '', width=80, fill='#', blank=' '): | |
self.capacity = capacity | |
self.label = label | |
self.width = width | |
self.fill = fill | |
self.blank = blank | |
self.completed = 0 |
This file contains hidden or 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 pysam | |
import math | |
from itertools import islice | |
def filterfn(read): | |
return (read.is_proper_pair and | |
read.is_paired and | |
read.tlen > 0 and | |
not read.is_supplementary and | |
not read.is_duplicate and |
This file contains hidden or 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
""" | |
PYMC3 model code to do signature fitting using NUTS | |
""" | |
import pymc3 | |
from theano import tensor | |
mytest = pymc3.Model() | |
counts = data | |
with mytest: | |
mixing_proportions = pymc3.Dirichlet('mixing_proportions', a = np.ones(30), shape = 30) |
This file contains hidden or 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 scipy | |
import scipy.stats as ss | |
import numpy as np | |
def discretize(alpha, ncat, dist=ss.gamma): | |
if dist == ss.gamma: | |
dist = dist(alpha, scale=1 / alpha) | |
elif dist == ss.lognorm: | |
dist = dist(s=alpha, scale=np.exp(0.5 * alpha**2)) | |
quantiles = dist.ppf(np.arange(0, ncat) / ncat) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 numpy as np | |
def setup_logger(): | |
import logging | |
logger = logging.getLogger() | |
for handler in logger.handlers: | |
logger.removeHandler(handler) | |
ch=logging.StreamHandler() | |
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | |
ch.setFormatter(formatter) |
This file contains hidden or 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 <math.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include "discrete_gamma.h" | |
// PAML code for discrete gamma | |
// Forward decs | |
double QuantileChi2(double prob, double v); | |
double LnGammaFunction(double alpha); | |
double IncompleteGamma(double x, double alpha, double ln_gamma_alpha); |
NewerOlder