Skip to content

Instantly share code, notes, and snippets.

View taoliu's full-sized avatar
🌎
Working from the earth

Tao Liu (τν) taoliu

🌎
Working from the earth
View GitHub Profile
@taoliu
taoliu / wrapToSlurm
Last active December 30, 2021 19:10
Wrapper for submitting jobs to SLURM
#!/usr/bin/env python
# This script is a wrapper in Python to help submit jobs, that need to use CONDA environment, to SLURM.
import subprocess
import sys
import os
import time
import argparse as ap
@taoliu
taoliu / KNNsmoothing.R
Created November 11, 2020 21:57
kNN smoothing on a given feature x barcode matrix, based on a given sNN graph barcode x barcode matrix
# K-nearest neighbor smoothing based on sNN from clustering
# Inspired by knn-smooth.R: https://github.com/yanailab/knn-smoothing/blob/master/knn_smooth.R
# by Tao Liu <[email protected]>
#' kNN-smoothing on a given matrix based on a pre-calculated sNN matrix
#'
#' Note: sparse matrix will be converted to regular matrix, so memory
#' usage will be high.
#'
#' @param M A numeric matrix that will be smoothed. It should have
@taoliu
taoliu / merge_then_call_consensus.sh
Last active October 25, 2024 13:07
Merge multiple peak files (BED format) then call the consensus regions
#!/bin/bash
#
# This script will find the consensus peak regions from peak files (in
# BED format) of multiple samples by:
#
# 1. Converting the peak file of each sample into non-overlapping 3
# cols BED file and concatenating them;
#
# 2. Sorting the concatenated file and Building a genome coverage
# track in BedGraph, of which the value (the 3rd col) indicates the
#!/usr/bin/env perl -w
# Time-stamp: <2008-03-03 11:24:07 Tao Liu>
#
# By: Tao Liu <[email protected]>
#
use strict;
die "need x paras: $0 <options> [y=blah]\n" if @ARGV < x;
#!/bin/bash
if [ $# -lt 1 ]; then
echo "need 1 para!"
exit
fi
#!/usr/bin/env python3
# Time-stamp: <2008-04-07 17:51:27 Tao Liu>
"""Module Description
Copyright (c) 2020 Tao Liu <[email protected]>
This code is free software; you can redistribute it and/or modify it
under the terms of the BSD License (see the file COPYING included with
the distribution).
#!/usr/bin/env python
# Time-stamp: <2008-01-18 13:42:57 Tao Liu>
import os
import sys
# ------------------------------------
# Main function
# ------------------------------------
def main():
if len(sys.argv) < x+1:
@taoliu
taoliu / samcovToBedGraph.pl
Last active October 25, 2024 14:13
Convert samtools depth output to bedGraph
#!/usr/bin/env perl
# A script to convert samtools (>v1.3) depth (with -aa option) output
# to bedGraph by merging continous positions with the same value.
if ( $#ARGV < 0 ) {
print "Need 1 parameter! $0 <samtools depth output (with -aa)>\n";
exit ();
}
@taoliu
taoliu / narrowPeak2bb.sh
Created July 26, 2015 14:39
UCSC narrowPeak to bigBed
#!/bin/bash
# set the path to as file for narrowPeak. Locate it in your UCSC source code directory or google...
asfile=/data/db/UCSC_sqls/encode/narrowPeak.as
which bedToBigBed &>/dev/null || { echo "bedToBigBed not found! Download: <http://hgdownload.cse.ucsc.edu/admin/exe/>"; exit 1; }
if [ $# -lt 2 ];then
echo "Need 2 parameters! <narrowPeak> <chrom info>"
exit
@taoliu
taoliu / gist:9799831
Created March 27, 2014 03:55
DNA Codon Dictionary
codon_dictionary = {
'TCA' : 'S', # Serine
'TCC' : 'S', # Serine
'TCG' : 'S', # Serine
'TCT' : 'S', # Serine
'TTC' : 'F', # Phenylalanine
'TTT' : 'F', # Phenylalanine
'TTA' : 'L', # Leucine
'TTG' : 'L', # Leucine
'TAC' : 'Y', # Tyrosine