Skip to content

Instantly share code, notes, and snippets.

View crazyhottommy's full-sized avatar
🎯
Focusing

Ming Tang crazyhottommy

🎯
Focusing
View GitHub Profile
@sbamin
sbamin / reset_path_variable_bash.sh
Last active November 5, 2021 21:31
Reset PATH in ~/.bash_profile such that PATH variable follows user-defined order of paths.
## add following to the end of ~/.bash_profile assuming ~/.bash_profile takes the precedence over ~/.profile (if present), ~/.bash_profile, or other bash configs.
## for zsh or other shells, you may need to tweak following code.
## Be careful "resetting" PATH variable and know the implications of PATH variable being either empty or missing critical system paths!
################################### SET PATH ###################################
## User specific environment and startup programs
## Rewriting PATH ##
## We want user and anaconda paths to precede system paths, esp. this string:
## /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin which contains
## most of system default libs,
@taoliu
taoliu / merge_then_call_consensus.sh
Last active November 21, 2023 08:14
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
@vasantm
vasantm / reprod-plot-example.R
Created May 29, 2020 21:24
How to embed script name or a hash of it on a plot to allow to track plots and the scripts thar produced it in R, based on this question : https://twitter.com/tangming2005/status/1266404192744243202?s=20
# code source for plotting
# https://www.datanovia.com/en/blog/ggplot-title-subtitle-and-caption/
# get source filename SO quest: http://stackoverflow.com/q/1815606/946850
# get source fielname answer: https://stackoverflow.com/a/20282846
# if you do use a hash, you will have to save these to a csv or write
# a DB, perhaps an sqlite file that has the entry
# for the source file and corresponding hash to keep track of the
# hashes or just use filename and proj_dir,
# and display that if you want to keep it simple,
# open and reproducible
@sbamin
sbamin / example_modulefile.lua
Created May 3, 2020 16:26
Advanced Modulefile using lua syntax
--[[
## Modulefile in lua syntax
## Author: Samir Amin
## Read about Lmod
## https://lmod.readthedocs.io/en/latest/015_writing_modules.html
## https://lmod.readthedocs.io/en/latest/050_lua_modulefiles.html
## https://lmod.readthedocs.io/en/latest/020_advanced.html
--]]
@michaelmhoffman
michaelmhoffman / auto-insert-python.el
Last active August 25, 2020 14:47
Template for Python scripts
(defun new-copyright ()
"Generate new copyright string."
(format-time-string "Copyright %Y Michael M. Hoffman <michael.hoffman@utoronto.ca>"))
(define-auto-insert 'python-mode
`(
"Description: "
"#!/usr/bin/env python3.6" \n
"\"\"\"" (setq basename (buffer-file-basename)) ": " str \n
"\"\"\"" \n \n
DATASETS = ["PBMC_8K", "PBMC_4k"]
SALMON = "$BINS/salmon-0.14.0_linux_x86_64/bin/salmon"
rule all:
input: expand("quants/{dataset}/alevin/quants_mat.gz", dataset=DATASETS)
rule salmon_quant:
input:
r1 = "reads/{sample}_1.fastq",
@mdozmorov
mdozmorov / check_phred.sh
Created May 18, 2019 01:55
Check Phred offset
# https://www.biostars.org/p/63225/
FILE=VLI9_AA_S60_L008_R1_001.fastq.gz
zcat $FILE | head -n 40 | awk '{if(NR%4==0) printf("%s",$0);}' | od -A n -t u1 | awk 'BEGIN{min=100;max=0;}{for(i=1;i<=NF;i++) {if($i>max) max=$i; if($i<min) min=$i;}}END{if(max<=74 && min<59) print "Phred+33"; else if(max>73 && min>=64) print "Phred+64"; else if(min>=59 && min<64 && max>73) print "Solexa+64"; else print "Unknown score encoding";}'