Skip to content

Instantly share code, notes, and snippets.

View meren's full-sized avatar

A. Murat Eren (Meren) meren

View GitHub Profile
@meren
meren / add_gaps.py
Last active October 13, 2015 06:08
Adds gaps to an unaligned Illumina collection.
import sys
sys.path.append('/bioware/pythonmodules/fastalib/')
import fastalib as u
fasta = u.SequenceSource(sys.argv[1])
output = u.FastaOutput(sys.argv[1] + '-with-gaps')
longest_read = 0
@meren
meren / qiimize.py
Last active December 10, 2015 02:18
Convert oligotyping ready fasta files into QIIME ready ones.
import sys
import Oligotyping.lib.fastalib as u
fasta = u.SequenceSource(sys.argv[1])
output = u.FastaOutput(sys.argv[1] + '-QIIME-READY')
# H12DL4_12 B022DACXX4110133892403 orig_bc=GATCAG new_bc=GATCAG bc_diffs=0
sample_read_counter = {}
@meren
meren / qiime_otus.txt_to_matrices.py
Last active December 10, 2015 02:18
Generate ENVIRONMENT file and matrices for OTU/sample distribution from *_otus.txt file (result of qiime's pick_otus.py).
# coding: utf-8
import sys
from Oligotyping.utils.utils import generate_ENVIRONMENT_file
from Oligotyping.utils.utils import get_oligos_sorted_by_abundance
from Oligotyping.utils.utils import get_unit_counts_and_percents
from Oligotyping.utils.utils import generate_MATRIX_files
from Oligotyping.utils.utils import get_filtered_samples_dict
from Oligotyping.utils.utils import get_samples_dict_from_environment_file
@meren
meren / qqplot.R
Created January 8, 2013 16:18
a substitute for qqplot and qqline.
#####################################################################################
# Q-Q plot in ggplot2
# taken from http://stackoverflow.com/questions/4357031/qqnorm-and-qqline-in-ggplot2
#####################################################################################
require(ggplot2)
vec <- Hg$AMT # whateer
y <- quantile(vec[!is.na(vec)], c(0.25, 0.75))
# sorry about the terrible code. example use:
#
# python expand_regex_pattern.py A.T[C,T]AAA.[A,G]AAT[A,T]GACGG
#
import sys
rp = sys.argv[1]
expant = ['']
valid_bases = ['A', 'T', 'C', 'G']
# example fasta defline:
#>147406386-BM_GFKBOSR02F10DX|Bacteria;Actinobacteria;Actinobacteria;Actinomycetales;Micrococcaceae;Rothia
import sys
import Oligotyping.lib.fastalib as u
from Oligotyping.utils.utils import generate_ENVIRONMENT_file
from Oligotyping.utils.utils import get_sample_name_from_defline
from Oligotyping.utils.utils import get_oligos_sorted_by_abundance
from Oligotyping.utils.utils import get_unit_counts_and_percents
from Oligotyping.utils.utils import generate_MATRIX_files
@meren
meren / gist:6090106
Last active December 20, 2015 06:59
Output files generated by the oligotyping pipeline w/o the --quick directive.
meren ~/tmp/sample-run $ ls mock-env-aligned-c2-s1-a1.0-A0-M0/
COLORS MATRIX-PERCENT.txt OLIGOS.nexus
ENVIRONMENT.txt NETWORK.gexf READ-DISTRIBUTION.txt
FIGURES/ OLIGO-REPRESENTATIVES/ RUNINFO
FIGURES.cPickle OLIGO-REPRESENTATIVES.fasta RUNINFO.cPickle
MATRIX-COUNT.txt OLIGOS.fasta RUNINFO.log
@meren
meren / for_tom.R
Created August 24, 2013 00:12
This should create an iTOL compatible newick tree under your home directory..
library('ape')
library('vegan')
library('ade4')
raw_data <- t(data.matrix(read.table('YOUR TAB DELIMITED TRANSCRIPTOMIC DATA MATRIX', header = TRUE, row.names = 1, sep="\t")))
drows<-vegdist(t(raw_data), method='euclidean', na.rm=TRUE)
hc <- hclust(drows, method='ward')
phy <- hclust2phylog(hc, add.tools = TRUE)
import sys
import IlluminaUtils.lib.fastqlib as u
import IlluminaUtils.lib.fastalib as f
from IlluminaUtils.utils.helperfunctions import reverse_complement
# call this script like this:
#
# python demultiplex.py barcode_to_sample_name_file index_fastq_file quality_filtered_fasta_file
#
# expected file formats are shown below.
library(ggplot2)
library(maps)
require(ggmap)
library(vegan)
require(mapproj)
library(maptools)
#######################################################################################################################
#######################################################################################################################
#