Skip to content

Instantly share code, notes, and snippets.

View arundurvasula's full-sized avatar

Arun Durvasula arundurvasula

View GitHub Profile
import gzip
import csv
import argparse
import sys
parser = argparse.ArgumentParser(description="A script that makes a haploid vcf diploid. Expects a whole genome VCF.")
parser.add_argument("-v", "--vcf", action="store", required=True, help="Input VCF file. Should be a multisample, whole genome VCF from Shore with haploid calls.")
parser.add_argument("-o", "--out", action="store", required=True, help="Output filename")
parser.add_argument("-g", "--gzip", action="store_true", required=False, help="Set if the VCF is gzipped.")
#python
# a script that makes a haploid vcf diploid. Expects a whole genome VCF
import gzip
import csv
import argparse
import sys
parser = argparse.ArgumentParser(description="A script that makes a haploid vcf diploid. Expects a whole genome VCF.")
parser.add_argument("-v", "--vcf", action="store", required=True, help="Input VCF file. Should be a multisample, whole genome VCF from Shore with haploid calls.")
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/inotify.h>
#define EVENT_SIZE ( sizeof (struct inotify_event ) )
#define BUF_LEN ( 1024 * (EVENT_SIZE + 16 ) )
int main( int argc, char **argv)
@arundurvasula
arundurvasula / vcf2FASTA.py
Created February 24, 2016 22:29
A script to extract a chromosome from a multisample VCF and create a fasta file
import gzip
import csv
import argparse
import sys
parser = argparse.ArgumentParser(description="script to convert an all sites vcf to FASTA format. FASTA description will be the sample name in the VCF header.Only does one chromosome/region at a time.")
parser.add_argument("-v", "--vcf", action="store", required=True, help="Input VCF file. Should be a multisample vcf, though it should theoretically work with a single sample.")
parser.add_argument("-o", "--out", action="store", required=True, help="Output filename")
parser.add_argument("-c", "--chromosome", action="store", required=True, help="Chromosome to output. Should be something in the first column of the vcf.")
parser.add_argument("-g", "--gzip", action="store_true", required=False, help="Set if the VCF is gzipped.")
import gzip
import csv
import argparse
import sys
parser = argparse.ArgumentParser(description="script to convert an all sites vcf to sweepfinder format. FASTA description will be the sample name in the VCF header.Only does one chromosome/region at a time.")
parser.add_argument("-v", "--vcf", action="store", required=True, help="Input VCF file. Should be a multisample vcf, though it should theoretically work with a single sample.")
parser.add_argument("-o", "--out", action="store", required=True, help="Output filename")
parser.add_argument("-c", "--chromosome", action="store", required=True, help="Chromosome to output. Should be something in the first column of the vcf.")
parser.add_argument("-g", "--gzip", action="store_true", required=False, help="Set if the VCF is gzipped.")
@arundurvasula
arundurvasula / aw-tutorial-data-md5.log
Created October 8, 2015 09:37
Making sure the data I'm using for the tutorial and paper are the same as the example data.
adurvasu@farm:~/rilab/aw-tutorial/data$ md5sum ?.sub.bam
b78c7735c1325782553e6b59b52cfc84 0.sub.bam
1759a99e93a08fff73bf47f5ef6ba576 1.sub.bam
dbae3c832c94618a8281f7ec18154237 2.sub.bam
c29c78c8a073498b59d54180d833697b 3.sub.bam
eefa22f9dfb92f9d44aeb9acfb016e54 4.sub.bam
87b364a444edc5fa837fc337d661c537 5.sub.bam
6567145497fda85bea95b9da0fa301a0 6.sub.bam
393e90693dc84d45316651afd03d9026 7.sub.bam
6a662054b4ee9bd7314a8ceeb490fbe8 8.sub.bam
@arundurvasula
arundurvasula / XKCD_sfs_plots.py
Last active November 8, 2015 20:09
Make an SFS from an MS output file
#!/bin/python
#xkcd SFS plots
# usage: ms 20 10000 -t 50 -r 10 1000 > neutral_ms.txt; python XKCD_sfs_plots.py neutral_ms.txt
from matplotlib import pyplot as plt
import numpy as np
from itertools import groupby
from sys import argv
ms_file = open(argv[1])
@arundurvasula
arundurvasula / add_regions.sh
Created May 3, 2015 23:22
add regions to config files
#!/bin/bash
# this script will add "REGIONS="${REGION}:" to a base regions file and save it as [basename].conf.${REGION}
set -u
INCONF=$1
START=1
END=12
for ((i=START; i<=END; i++))

In order to get the right code, you need to clone the correct repository and branch

git clone -b ecl298 https://github.com/arundurvasula/angsd-wrapper.git

SFS

First things first, we need to create a directory in the cloned folder called results:

mkdir results

tl;dr: data management software that logs access to files.

##1. The problem:

Modern data analysis relies on many sophisticated tools that perform a wide range of calculations on data. While software continues to evolve along with methods, data management still remains a complicated problem.

First, data analysis involves a lot of trail and error. One method may work well on one dataset, but it may not work as well on another. In its nature, data analysis must be done many times to arrive upon the best solution (if there is one). This process of trial and error, however is costly in time and organization. While solutions exist to mitigate these problems (for example, software that runs other software for you), these solutions are not complete.

Specifically, organization is difficult because there is no obvious and systematic way to keep track of what has been done to data. For example, when assembling sequence data many assemblers must be used with different options to find the optimal assembly method