Skip to content

Instantly share code, notes, and snippets.

View dwinter's full-sized avatar
🐢
I may be slow to respond.

David Winter dwinter

🐢
I may be slow to respond.
View GitHub Profile
library(lubridate)
library(dplyr)
#fake data as an example, just 4 ranodm dates in the last month
set.seed(123)
fake_data_a <- data.frame(date = today() - sample(30,4), value_a=rnorm(4))
fake_data_b <- data.frame(date = today() - sample(30,4), value_b=rnorm(4))
#find all the dates in the window dfeine by fake_data_a
all_dates <- data.frame(date = seq(min(fake_data_a$date), max(fake_data_a$date), by=1))
@dwinter
dwinter / .block
Last active November 2, 2022 10:27
voc_map
license: cc-by-4.0
height: 1800
scrolling: no
border: yes
def base_consensus(alignment, base_index):
""" """
# get the bases at this position, store in case we want to come back
# and assign the first one as th winner
#n_seqs = len(alignment)
bases = [r[base_index].upper() for r in alignment]
base_c = Counter(bases)
max_count = max(base_c.values())
most_common_base = [b for b in base_c.items() if b[1] == max_count]
if len(most_common_base) == 1:
$include /etc/inputrc
"\e[A":history-search-backward
"\e[B":history-search-forward
export HISTSIZE=1000000
export HISTFILESIZE=1000000000
export HISTIGNORE='pwd:ls:history:'
@dwinter
dwinter / ortho.py
Last active November 21, 2019 00:51
from collections import defaultdict
from Bio import SeqIO
class Orthologs:
def __init__(self, ortho_file, seq_map_file):
"""Store information on orthologs from another of strains """
self.ortholog_map = defaultdict(lambda: defaultdict(list))
with open(ortho_file) as infile:
@dwinter
dwinter / coverage.sh
Last active July 31, 2019 01:39
three column cov to windows
tail cov.tsv -n1 | cut -f1,2 > spp.genome
bedtools makewindows -g spp.genome -w 1000 > spp_1kw.bed
awk -v OFS='\t' '{print $1,($2 -1),$2,$3 }' cov.tsv > cov.bed
bedtools map -a spp_1kw.bed -b cov.bed -c 4 -o mean
@dwinter
dwinter / sample_disk.r
Last active January 9, 2019 21:34
uniform sampling on a (half) disk
sample_half_disk <- function(n,radius) {
prop_radius <- runif(n)
angles <- runif(n,0,360)
data.frame( x= sqrt(prop_radius) * cos(angles) * radius,
y = -abs(sqrt(prop_radius) * sin(angles) * radius))
}
plot(sample_half_disk(1e4,300))
@dwinter
dwinter / ideograms.r
Last active September 8, 2022 11:35
.one_chrom_outline <- function(chrom_name, len, offset, width, centro_s, centro_e, notch_prop=0.6){
one_side <- c(0, centro_s-offset, (centro_s + centro_e)/2, centro_e+offset, len)
wd = width/2
data.frame(
chrom = chrom_name,
x = c(one_side, rev(one_side), 0),
y = c(wd, wd, notch_prop * wd, wd, wd, -wd, -wd, -notch_prop * wd, -wd, -wd, wd)
)
obs unit magnitude
1 1 -0.61
2 1 -1.43
3 1 -1.09
4 1 -1.13
5 1 -0.66
6 1 -0.36
7 1 -0.73
8 1 -0.89
9 1 -0.69
```
---
name: rotl-paper-published
layout: post
title: "rotl paper published"
date: 2016-18-02
authors:
- name: Francois Michonneau
url: http://francoismichonneau.net/
- name: Joseph Brown