Skip to content

Instantly share code, notes, and snippets.

View danielecook's full-sized avatar
😀
Things are going good

Daniel E Cook danielecook

😀
Things are going good
View GitHub Profile
test_df %>%
dplyr::arrange(chromosome, isotype, start, stop) %>%
dplyr::filter(
(!(lead(start) == stop & lead(haplotype) == haplotype & lead(isotype) == isotype & lead(chromosome) == chromosome) | is.na(lag(start)) | is.na(lead(stop)))
) %>%
dplyr::mutate(stop = ifelse(lead(isotype) == isotype &
lead(haplotype) == haplotype &
@danielecook
danielecook / gist:d2bb89371403073ae9e6b024dca88c05
Created December 6, 2017 22:26
Plot png in ggplot/cowplot #ggplot #cowplot
library(imager)
library(cowplot)
im <- imager::load.image("https://storage.googleapis.com/elegansvariation.org/photos/hawaii2017/C-3273.jpg")
plot <- ggplot() + annotation_raster(im, xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)
cowplot::plot_grid(plot, plot)
@danielecook
danielecook / is_overlapping.R
Last active December 7, 2017 19:50
R is overlapping #R
is_overlapping <- function(start_1, end_1, start_2, end_2) {
if (
(dplyr::between(start_1, start_2, end_2)) |
(dplyr::between(end_1, start_2, end_2)) |
(dplyr::between(start_2, start_1, end_1)) |
(dplyr::between(end_2, start_1, end_1))
) {
return(TRUE)
}
FALSE
@danielecook
danielecook / bash_profile.sh
Last active July 5, 2018 01:25
Setup quest
# VERSION 1
export HOMEBREW_EDITOR=nano
export PS1='\[\e[0;35m\][\h::\w] 😱 \[\e[m\] '
export PATH="$HOME/.linuxbrew/bin:~/google-cloud-sdk/bin:$PATH"
export MANPATH="$(brew --prefix)/share/man:$MANPATH"
export INFOPATH="$(brew --prefix)/share/info:$INFOPATH"
# Load modules
# module load bamtools/2.4.1
# module load bcftools/1.4-6 - messes with qstat
@danielecook
danielecook / awk_ceiling.sh
Created November 28, 2017 17:25
Bash ceiling #bash_snippets
awk '{printf("%d\n",$0+=$0<0?0:0.9)}'
@danielecook
danielecook / curl.md
Created November 21, 2017 05:41 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@danielecook
danielecook / rsid_annotation.sh
Last active October 10, 2017 02:39
Download rsids for annotation
#!/usr/bin/bash
# @author = Daniel E. Cook
# @date = 2017-10-09
# This script downloads rs identifiers
# The function 'annotate_rsid' can be used to annotate a strat file with rsid.
# Usage:
# zcat chr1.strat.frq.gz | annotate_rside - | bgzip > out.bed.gz
curl -s http://hgdownload.cse.ucsc.edu/goldenPath/hg19/database/snp150.txt.gz | \
gunzip -c | \

Keybase proof

I hereby claim:

  • I am danielecook on github.
  • I am danielecook (https://keybase.io/danielecook) on keybase.
  • I have a public key ASCbBKJnoEdxZ_P-Ch2FzRbEIKg0iSyZgjZRsU4lDZvhsgo

To claim this, I am signing this object:

@danielecook
danielecook / download_blast_db.sh
Last active September 13, 2017 20:20
Download blast databases
# cd /usr/local/share/blast
lftp ftp://ftp.ncbi.nlm.nih.gov -e 'mget /blast/db/nt*.tar.gz'
lftp ftp://ftp.ncbi.nlm.nih.gov -e 'mget /blast/db/nr*.tar.gz'
lftp ftp://ftp.ncbi.nlm.nih.gov -e 'mget /blast/db/refseq_genomic*.tar.gz'
other_genomic.*tar.gz
@danielecook
danielecook / generate_blast_genome.sh
Last active September 12, 2017 21:29
Generate a blast genome from wormbase genomic sequences
# Download ref genomes/contigs
lftp ftp.wormbase.org -e 'mget /pub/wormbase/species/**/sequence/genomic/*.current.genomic.fa.gz'
function get_genomes() {
for i in `ls -1 *canonical*fa.gz`; do
IFS='.' read -r -a genome <<< "$i";
zcat ${i} | sed "s/>/> ${genome[0]} :: /g"
done;
}