Skip to content

Instantly share code, notes, and snippets.

View brevans's full-sized avatar

Ben Evans brevans

View GitHub Profile
@brevans
brevans / gen_bowtie2_coms.py
Last active December 23, 2015 15:09
bowtie 2 -> sorted bams
#!/usr/bin/env python
'''
example:
./gen_bowtie2_coms.py fastq_dir bin_dir out_dir
-all sample fastq files must be in on directory
-the bin directory should have samtools and bowtie2
-the outdir must already exist
This script prints the commands to screen. You can save them to a file with
#!/usr/bin/env python
from os import path
from glob import iglob
import re
trans = {'AGO':'DAR', 'CAZ':'GUN', 'CF':'CF', 'F':'CF',
'CRU':'POR', 'ESP':'HOO', 'LG':'ABI', 'LP':'VIC',
'LT':'VIC', 'PBL':'PBL', 'PBR':'PBR', 'PZ':'EPH',
'SCR':'CHA', 'VA':'VAN', 'VD':'MIC'}
for fi in iglob('consensus/*.fa'):
@brevans
brevans / SNPolish.R
Last active August 29, 2015 14:00
Used in analyzing snp calls for Axiom_aegypti1 chip
library("SNPolisher")
cwd <- getwd()
summ <- file.path(cwd,"AxiomGT1.summary.txt")
conf <- file.path(cwd,"AxiomGT1.confidences.txt")
post <- file.path(cwd,"AxiomGT1.snp-posteriors.txt")
call <- file.path(cwd,"AxiomGT1.calls.txt")
# Ps_Metrics
ps.metrics <- Ps_Metrics(posteriorFile=post,
@brevans
brevans / genlight_PCA.R
Created April 22, 2014 16:24
doing some pca on snps from Axiom_aegypti1 chip
library("adegenet")
library("rgl")
library("phangorn")
library("ape")
setwd("C:/Users/ben/Desktop/temp/pca")
#Read in the data
X <- read.PLINK("pca6.raw", parallel=FALSE)
col <- rainbow(length(levels(pop(X))), start=.3, end=.1)
#!/usr/bin/env python
from os import path, makedirs, remove, stat
import argparse
import re
from glob import iglob
from collections import defaultdict as dd
from Bio import SeqIO
import vcf
AMB = {'AC': 'M', 'AG': 'R', 'AT': 'W', 'CG': 'S', 'CT': 'Y', 'GT': 'K',
@brevans
brevans / keybase.md
Created September 22, 2014 15:03
my keybase verification

Keybase proof

I hereby claim:

  • I am brevans on github.
  • I am benevans (https://keybase.io/benevans) on keybase.
  • I have a public key whose fingerprint is 9247 52CE 3718 C27F A5FC 2BAE 102B C92B 8CBF 0EF1

To claim this, I am signing this object:

@brevans
brevans / cat_pairs.py
Last active August 29, 2015 14:08
dumbly concatenate paired end illumina sequences
#!/usr/bin/env python
import gzip
import sys
from glob import glob
from os.path import basename
import re
from Bio import SeqIO
def gopen(fi, *args, **kwargs):
if fi.endswith('.gz'):
@brevans
brevans / Prof_Dan_random_sample.py
Created February 2, 2015 18:45
sub-sampler for Dan, specific to her naming scheme
#!/usr/bin/env python
import sys
import re
import random
import argparse
from os import makedirs
from glob import glob
import os.path as path
from collections import defaultdict as dd
from Bio import SeqIO
@brevans
brevans / export2plink.py
Last active August 29, 2015 14:21
export2plink.py prefix pop_file snp_list AxiomGT1.calls.txt
#!/usr/bin/env python
from datetime import datetime
import os
from glob import glob
#set up columns
interaction_columns = ['Time_of_Day', 'Time_Stamp', 'Initiator_ID',
'Interaction_Number', 'Data_Type', 'Partner_ID',
'Initiator_Stake', 'Initiator_X', 'Initiator_Y',
'Partner_Stake', 'Partner_X', 'Partner_Y', 'Females_Present',