Skip to content

Instantly share code, notes, and snippets.

View adrisede's full-sized avatar
🎯
Focusing

adrisede adrisede

🎯
Focusing
  • Seattle, WA
View GitHub Profile
@adrisede
adrisede / bash_strict_mode.md
Created July 8, 2022 17:52 — forked from vncsna/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@adrisede
adrisede / app.R
Created June 22, 2022 21:00 — forked from wch/app.R
Example Shiny app that automatically installs a source package when deployed to shinyapps.io
# By default, the directories in .libPaths() aren't writable on shinyapps.io, so
# create a subdir where we'll install our package.
if (!file.exists("R-lib")) {
dir.create("R-lib")
}
# Unfortunately, there's no way to get deployapp() to ignore this directory, so
# make sure to remove it locally before you call deployapp(). This can be done
# with:
# unlink("pkgInst/R-lib", recursive = TRUE)
@adrisede
adrisede / get-srr.sh
Created April 6, 2022 17:16 — forked from mfansler/get-srr.sh
bash commands for downloading SRRs from NCBI's SRA
#!/bin/bash
# download SRR from NCBI SRA via Aspera Connect
#
# > get-srr SRR304976
get-srr () {
SRR=${1}
SRR_6=$(echo $SRR | cut -c1-6)
ascp -i ~/.aspera/connect/etc/asperaweb_id_dsa.openssh \
@adrisede
adrisede / index-gtf.sh
Created April 4, 2022 16:01 — forked from mfansler/index-gtf.sh
GTF file compressed indexing for IGV compatibility
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo -e "Incorrect number of parameters! Usage:\n index-gtf.sh <file.gtf(.gz)>" >&2
exit 1
fi
gtf="$1"
if [[ $gtf =~ \.gz$ ]]; then
@adrisede
adrisede / BCFtools cheat sheet
Created March 30, 2022 18:35 — forked from elowy01/BCFtools cheat sheet
BCFtools cheat sheet
*bcftools filter
*Filter variants per region (in this example, print out only variants mapped to chr1 and chr2)
qbcftools filter -r1,2 ALL.chip.omni_broad_sanger_combined.20140818.snps.genotypes.hg38.vcf.gz
*printing out info for only 2 samples:
bcftools view -s NA20818,NA20819 filename.vcf.gz
*printing stats only for variants passing the filter:
bcftools view -f PASS filename.vcf.gz
@adrisede
adrisede / depth2bedgraph.awk
Created June 3, 2020 21:53 — forked from nathanhaigh/depth2bedgraph.awk
Converts the output of samtools depth into bedgraph format
#!/usr/bin/awk
# Takes output of "samtools depth" and reformats into grouped bedgraph format:
# samtools depth -r ${loc} -Q 1 --reference $fasta $bam | mawk -f scripts/depth2bedgraph.awk > /tmp/my.bedgraph
# Example input:
#chr1 26 2
#chr1 27 2
#chr1 28 2
#chr1 29 5
#chr1 30 5
#chr1 31 5
@adrisede
adrisede / install-rstudio-server.sh
Created January 8, 2020 19:09 — forked from cosmincatalin/install-rstudio-server.sh
AWS EMR bootstrap to install RStudio Server along with sparklyr
#!/bin/bash
# These variables can be overwritten using the arguments below
VERSION="1.1.463"
# drwho is listed as user in YARN's Resource Manager UI.
USER="drwho"
# Depending on where the EMR cluster lives, you might have to change this to avoid security issues.
# To change the default password (and user), use the arguments bellow.
# If the cluster is not visible on the Internet, you can just leave the defaults for convenience.
PASS="tardis"
@adrisede
adrisede / bash-cheat-sheet
Created February 18, 2019 18:04 — forked from ssledz/bash-cheat-sheet
BASH Cheat Sheet
B A S H C H E A T S H E E T
to page output forward (only): command filename | more
to page output forward & back: command filename | less
to print a dataset: lp datasetname (-d printerid) (-o landscape)
USE OF QUOTATION MARKS
echo "$varname" = echo The value of \$varname is \"$varname\"
= echo "The value of \$varname is \"$varname\"."
$fred='Four spaces between these words.'