Skip to content

Instantly share code, notes, and snippets.

View crazyhottommy's full-sized avatar
🎯
Focusing

Ming Tang crazyhottommy

🎯
Focusing
View GitHub Profile
@crazyhottommy
crazyhottommy / merge_then_call_consensus.sh
Created July 17, 2020 20:09 — forked from taoliu/merge_then_call_consensus.sh
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
@crazyhottommy
crazyhottommy / iterm2-solarized.md
Created March 26, 2020 04:16 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@crazyhottommy
crazyhottommy / Pkgdown deploy from Travis.md
Created February 13, 2020 18:38 — forked from gaborcsardi/Pkgdown deploy from Travis.md
Walkthrough: deploy a pkgdown site from Travis

Run usethis::use_pkgdown_travis()

usethis::use_pkgdown_travis()
✔ Setting active project to '/Users/gaborcsardi/works/ps'Adding 'docs/' to '.gitignore'Set up deploy keys by running `travis::use_travis_deploy()`Insert the following code in '.travis.yml'
  before_cache: Rscript -e 'remotes::install_cran("pkgdown")'
@crazyhottommy
crazyhottommy / BSdownload.md
Created August 23, 2019 03:51 — forked from lh3/BSdownload.md
Download files from Illumina's BaseSpace

References:

Steps:

  1. Follow steps 1-5 in the first link above to acquire access_token. This will take a while, but you only need to do this once. Never share this token!!
  2. Find the file you want to download. Copy the link, which looks something like: https://basespace.illumina.com/sample/9804795/files/tree/NA12878-L1_S1_L001_R1_001.fastq.gz?id=515013503. The "id" is the unique file identifier.
  3. Download the file with: wget -O filename 'https://api.basespace.illumina.com/v1pre3/files/{id}/content?access_token={token}', where {token} is from step 1 and {id} from step 2.

download data

cd data
mkdir pbmc5k
cd pbmc5k

wget http://cf.10xgenomics.com/samples/cell-exp/3.0.2/5k_pbmc_v3/5k_pbmc_v3_filtered_feature_bc_matrix.tar.gz

tar xvzf 5k_pbmc_v3_filtered_feature_bc_matrix.tar.gz
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",
@crazyhottommy
crazyhottommy / check_phred.sh
Created May 18, 2019 02:09 — forked from mdozmorov/check_phred.sh
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";}'
@crazyhottommy
crazyhottommy / plot_aligned_series.R
Created February 4, 2019 19:40 — forked from tomhopper/plot_aligned_series.R
Align multiple ggplot2 graphs with a common x axis and different y axes, each with different y-axis labels.
#' When plotting multiple data series that share a common x axis but different y axes,
#' we can just plot each graph separately. This suffers from the drawback that the shared axis will typically
#' not align across graphs due to different plot margins.
#' One easy solution is to reshape2::melt() the data and use ggplot2's facet_grid() mapping. However, there is
#' no way to label individual y axes.
#' facet_grid() and facet_wrap() were designed to plot small multiples, where both x- and y-axis ranges are
#' shared acros all plots in the facetting. While the facet_ calls allow us to use different scales with
#' the \code{scales = "free"} argument, they should not be used this way.
#' A more robust approach is to the grid package grid.draw(), rbind() and ggplotGrob() to create a grid of
#' individual plots where the plot axes are properly aligned within the grid.
library(splatter)
library(scater)
library(scran)
library(Seurat)
library(dplyr)

# Load the PBMC dataset https://s3-us-west-2.amazonaws.com/10x.files/samples/cell/pbmc3k/pbmc3k_filtered_gene_bc_matrices.tar.gz
pbmc.data <- Read10X(data.dir = "~/Downloads/filtered_gene_bc_matrices/hg19/")
@crazyhottommy
crazyhottommy / simplified_dendrogram_to_circlepack.R
Created January 2, 2019 03:19 — forked from clairemcwhite/simplified_dendrogram_to_circlepack.R
Demo of going from an igraph dendrogram to a simplified view as a ggraph circlepack as in https://twitter.com/clairemcwhite/status/1079895521446293505
library(tidyverse)
library(ggraph)
library(dendextend)
library(igraph)
cut_df <- function(dendrogram, height, c){
#Function to cut a dendrogram
cd <- cutree(dendrogram, h = height) %>% as.data.frame()
cd$ID <- row.names(cd)
cd <- cd %>% as_tibble()