Skip to content

Instantly share code, notes, and snippets.

@yjzhang
yjzhang / run_split_seq.sh
Last active May 25, 2019 04:19
script for running split-seq
#!/bin/bash
# run using 'nohup sh run_split_seq.sh &'
nohup split-seq all --fq1 Matthew_77_S1_R1_001.fastq.gz --fq2 Matthew_77_S1_R2_001.fastq.gz --output_dir output --chemistry v2 --genome_dir /data/reference_genomes/mm10/ --nthreads 16
@yjzhang
yjzhang / download_aws.sh
Created May 25, 2019 04:08
download data from aws
#!/bin/bash
for i in $(seq 1 18); do
aws s3 cp --recursive s3://sdfas/S${i}_L1_outputDGE_filtered S${i}_L1_outputDGE_filtered
aws s3 cp --recursive s3://sdfas/S${i}_L2_outputDGE_filtered S${i}_L2_outputDGE_filtered
done
@yjzhang
yjzhang / merge_dges.py
Last active May 28, 2019 18:12
merges multiple DGEs/gene matrices generated by the split seq pipeline.
#!/usr/bin/env python
# merge DGE matrices from multiple runs of split-seq
# joins on genes...
import os
import sys
import numpy as np
import pandas as pd
@yjzhang
yjzhang / kill_gunicorn.sh
Created February 16, 2019 01:29
kills all gunicorn processes with a certain port number. useful for when there are multiple gunicorns running on different ports.
#!/bin/bash
# kills all gunicorn processes with 8889
pids=`ps ax | grep gunicorn | grep "8889" | awk '{split($0,a," "); print a[1]}'`
# TODO
for pid in $pids; do
killall -9 $pid
echo "killed gunicorn process $pid"
done
#!/bin/bash
for var in "$@"; do
filename=${var%.*}
#echo $filename
#echo $@
echo writing to $filename.html
pandoc $var --self-contained --toc -c /home/yjzhang/Dropbox/Notes/buttondown.css -s --mathml -o $filename.html
done
@yjzhang
yjzhang / download-medline-data.sh
Created February 1, 2019 23:01
Download all medline citations from ncbi
#!/bin/bash
# downloads all MEDLINE/Pubmed citations in the annual baseline.
for i in $(seq 1 972); do
fname="1"
if ((i < 10)); then
fname="ftp://ftp.ncbi.nlm.nih.gov/pubmed/baseline/pubmed19n000$i.xml.gz"
elif ((i < 100)); then
fname="ftp://ftp.ncbi.nlm.nih.gov/pubmed/baseline/pubmed19n00$i.xml.gz"
@yjzhang
yjzhang / flatten.py
Created November 18, 2018 07:14
flattening a list in python
def flatten(l):
output = []
for x in l:
try:
output += flatten(x)
except:
output.append(x)
return output
class TrieNode(object):
def __init__(self, char = '', children = {}, parent = None, wordEnd = False, value = True):
self.char = char
self.children = children
self.parent = parent
self.wordEnd = wordEnd
self.value = value
# simple implementation of quantile normalization?
import numpy as np
def quantile_norm(data):
"""
Source: https://en.wikipedia.org/wiki/Quantile_normalization
Note: this doesn't deal with ties very well.
Args:
@yjzhang
yjzhang / particle_filter.py
Created March 10, 2018 23:37
particle filter implementation for localization in a rectangular room with 1 gaussian observation.
import numpy as np
from scipy.stats import norm
# particle filter for localization using echolocation
# given: measurements, accelerometer readings, heading
# user's state: [x, y, theta]
# control: d(theta), d(position)