General:
Tools | Description |
---|---|
flank | Create new intervals from the flanks of existing intervals. |
slop | Adjust the size of intervals. |
shift | Adjust the position of intervals. |
subtract | Remove intervals based on overlaps b/w two files. |
# Adapted from https://stackoverflow.com/a/7267364/1036500 by Andrie de Vries | |
# This is it: theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)) | |
library(ggplot2) | |
td <- expand.grid( | |
hjust=c(0, 0.5, 1), | |
vjust=c(0, 0.5, 1), | |
angle=c(0, 45, 90), |
# https://stackoverflow.com/a/45614547 | |
GeomSplitViolin <- ggproto("GeomSplitViolin", GeomViolin, draw_group = function(self, data, ..., draw_quantiles = NULL){ | |
data <- transform(data, xminv = x - violinwidth * (x - xmin), xmaxv = x + violinwidth * (xmax - x)) | |
grp <- data[1,'group'] | |
newdata <- plyr::arrange(transform(data, x = if(grp%%2==1) xminv else xmaxv), if(grp%%2==1) y else -y) | |
newdata <- rbind(newdata[1, ], newdata, newdata[nrow(newdata), ], newdata[1, ]) | |
newdata[c(1,nrow(newdata)-1,nrow(newdata)), 'x'] <- round(newdata[1, 'x']) | |
if (length(draw_quantiles) > 0 & !scales::zero_range(range(data$y))) { | |
stopifnot(all(draw_quantiles >= 0), all(draw_quantiles <= | |
1)) |
# ============================================= | |
# Modifying a data frame in place | |
# ============================================= | |
library(ggplot2) | |
str(diamonds) | |
# Modify data frame in place, in loop | |
# This is super, super slow | |
system.time({ |
#!/bin/bash | |
# Usage: interleave_fastq.sh f.fastq r.fastq > interleaved.fastq | |
# | |
# Interleaves the reads of two FASTQ files specified on the | |
# command line and outputs a single FASTQ file of STDOUT. | |
# | |
# Can interleave 100 million paired reads (200 million total | |
# reads; a 2 x 22Gbyte files), in memory (/dev/shm), in 6m54s (414s) | |
# | |
# Latest code: https://gist.github.com/4544979 |
#!/usr/bin/env python | |
''' | |
Automatically estimate insert size of the paired-end reads for a given SAM/BAM file. | |
Usage: getinsertsize.py <SAM file> or samtools view <BAM file> | getinsertsize.py - | |
Author: Wei Li | |
Copyright (c) <2015> <Wei Li> | |
cat hg18.fa | awk '{ | |
if (substr($0, 1, 1)==">") {filename=(substr($0,2) ".fa")} | |
print $0 > filename | |
}' |