Skip to content

Instantly share code, notes, and snippets.

Avatar

Yue Zhang yjzhang

  • University of Washington
View GitHub Profile
View sort_submissions.py
import os
import subprocess
filenames = os.listdir('.')
for filename in filenames:
name = filename.split('_')[0]
if not os.path.exists(name):
os.makedirs(name)
os.rename(filename, os.path.join(name, filename))
if filename.endswith('zip'):
View make_bingo_board.py
# makes an svg bingo board
import svgwrite
def text_to_font_size(text):
if isinstance(text, str):
total_text = text
else:
total_text = ''.join(text)
if len(total_text) < 10:
return 18
@yjzhang
yjzhang / cocluster_heatmap.py
Created Jun 13, 2019
spectral coclustering heatmap
View cocluster_heatmap.py
import numpy as np
from sklearn.cluster.bicluster import SpectralCoclustering
spec = SpectralCoclustering(18)
cluster_counts_subset = np.vstack([cluster_counts[:31, :], cluster_counts[32:,:]])
spec.fit(cluster_counts + 0.0001)
row_labels = spec.row_labels_
column_labels = spec.column_labels_
row_order = np.argsort(row_labels)
@yjzhang
yjzhang / run_split_seq.sh
Last active May 25, 2019
script for running split-seq
View run_split_seq.sh
#!/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
download data from aws
View download_aws.sh
#!/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
merges multiple DGEs/gene matrices generated by the split seq pipeline.
View merge_dges.py
#!/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 Feb 16, 2019
kills all gunicorn processes with a certain port number. useful for when there are multiple gunicorns running on different ports.
View kill_gunicorn.sh
#!/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
View pandoc-build-html.sh
#!/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 Feb 1, 2019
Download all medline citations from ncbi
View download-medline-data.sh
#!/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 Nov 18, 2018
flattening a list in python
View flatten.py
def flatten(l):
output = []
for x in l:
try:
output += flatten(x)
except:
output.append(x)
return output
You can’t perform that action at this time.