Skip to content

Instantly share code, notes, and snippets.

@merckey
merckey / metaphlanToPhyloseq.R
Created August 25, 2021 20:31 — forked from lwaldron/metaphlanToPhyloseq.R
Import a table of MetaPhlAn taxonomic abundances into phyloseq
metaphlanToPhyloseq <- function(
metaphlandir,
metadat=NULL,
simplify=TRUE){
## tax is a matrix or data.frame with the table of taxonomic abundances, rows are taxa, columns are samples
## metadat is an optional data.frame of specimen metadata, rows are samples, columns are variables
## if simplify=TRUE, use only the most detailed level of taxa names in the final object
## metaphlanToPhyloseq("~/Downloads/metaphlan_bugs_list")
.getMetaphlanTree <- function(removeGCF=TRUE, simplify=TRUE){
if (!requireNamespace("ape")) {
@merckey
merckey / readBismarkFiles.R
Created November 15, 2020 17:10 — forked from al2na/readBismarkFiles.R
read Bismark coverage and cytosine report files as methylKit objects
#' Read bismark coverage file as a methylKit object
#'
#' Bismark aligner can output methylation information per base in
#' multiple different formats. This function reads coverage files,
#' which have chr,start,end, number of cytosines (methylated bases)
#' and number of thymines (unmethylated bases).
#'
#' @param location a list or vector of file paths to coverage files
#'
#' @param sample.id a list or vector of sample ids
@merckey
merckey / deseq2-analysis-template.R
Created October 5, 2020 01:58 — forked from stephenturner/deseq2-analysis-template.R
Template for analysis with DESeq2
## RNA-seq analysis with DESeq2
## Stephen Turner, @genetics_blog
# RNA-seq data from GSE52202
# http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=gse52202. All patients with
# ALS, 4 with C9 expansion ("exp"), 4 controls without expansion ("ctl")
# Import & pre-process ----------------------------------------------------
# Import data from featureCounts
@merckey
merckey / twoscales.R
Created September 24, 2020 10:17 — forked from sebastianrothbucher/twoscales.R
Two scales in ggplot2
# two scales in one diag (not always recommended, but I WANT that now)
# some reading up: https://stackoverflow.com/questions/3099219/plot-with-2-y-axes-one-y-axis-on-the-left-and-another-y-axis-on-the-right/3101876#
library(ggplot2)
library(lubridate)
dt <- data.frame(when=ymd(c(20180320,20180321, 20180323, 20180324, 20180325)), numinter=c(1, 5, 4, 3, 4), prod=c(0.95, 0.5, 0.7, 0.75, 0.6)) # pure fiction
ggplot() +
geom_bar(mapping = aes(x = dt$when, y = dt$numinter), stat = "identity", fill = "grey") +
geom_line(mapping = aes(x = dt$when, y = dt$prod*5), size = 2, color = "blue") +
scale_x_date(name = "Day", labels = NULL) +
scale_y_continuous(name = "Interruptions/day", sec.axis = sec_axis(~./5, name = "Productivity % of best", labels = function(b) { paste0(round(b * 100, 0), "%")})) +
@merckey
merckey / README.md
Created July 31, 2018 13:29 — forked from jdblischak/README.md
rnaseq-de-tutorial

Differential expression analysis with edgeR

This is a tutorial I have presented for the class Genomics and Systems Biology at the University of Chicago. In this course the students learn about study design, normalization, and statistical testing for genomic studies. This is meant to introduce them to how these ideas are implemented in practice. The specific example is a differential expression analysis with edgeR starting with a table of counts and ending with a list of differentially expressed genes.

Past versions:

@merckey
merckey / UploadDirS3.py
Created November 29, 2017 16:40 — forked from feelinc/UploadDirS3.py
Upload folder contents to AWS S3
#!/usr/bin/python
import os
import sys
import boto3
# get an access token, local (from) directory, and S3 (to) directory
# from the command-line
local_directory, bucket, destination = sys.argv[1:4]
@merckey
merckey / sed cheatsheet
Created September 6, 2017 15:16 — forked from un33k/sed cheatsheet
magic of sed -- find and replace "text" in a string or a file
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
@merckey
merckey / memusg
Created March 16, 2017 17:47 — forked from netj/memusg
memusg -- Measure memory usage of processes
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2010-08-16
############################################################################
# Copyright 2010 Jaeho Shin. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #

Modifying an Existing Docker Image

To install a custom package or modify an existing docker image we need to

  1. run a docker a container from the image we wish to modify
  2. modify the docker container
  3. commit the changes to the container as a docker image
  4. test changes made to image

1.) Running a docker container from an image