Skip to content

Instantly share code, notes, and snippets.

View nickp60's full-sized avatar

Nick Waters nickp60

View GitHub Profile
@nickp60
nickp60 / cumulative_domination_example.R
Last active May 2, 2023 13:51
Cumulative Microbiome Domination
library(tidyverse)
if (!"speedyseq" %in% installed.packages()) remotes::install_github("mikemc/speedyseq")
library(speedyseq)
download.file("https://figshare.com/ndownloader/files/33076496", "samples.tsv")
#this file has duplicate rows, and has multiple rows per pool
samples <- read.csv("samples.tsv") %>% distinct() %>%
select(-Pool, -Run, -ShotgunBatchID) %>% distinct()
#download.file("https://figshare.com/ndownloader/files/26770931", "metadata.tsv")
#metadata <- read.csv("metadata.tsv")
# Source this for a handy discrete color palette and various helper functions for microbiome analyses.
# not complex enough for an actual package. For now... #featurecreep
mycolors=c(
"#511087", "#4ecdc4", "#ffd447", "#13c01f", "#b78900", "#e66d17",
"#8e3400", "#729b79", "#bf0000", "#907ad6", "#3f6356", "#ffbfb7",
"#92bccc", "#c0e8ab", "#890466", "#382438", "#dad2bc", "#0048ff",
"#f5f749", "#146d25", "#c08552", "#fc60a8", "#89fc00", "#3df8ff",
"#ef2917", "#101f75", "#bfcccc"
)
searchres <- "~/Downloads/SearchResults.csv"
outdir <- "~/Downloads/springercovid/"
dir.create(outdir)
resdf <- read.csv(searchres, stringsAsFactors = FALSE)
resdf$dloadurl <- paste0("http://link.springer.com/content/pdf/",
gsub("\\/", "%2F", fixed=TRUE, resdf$Item.DOI), ".pdf")
resdf$local_file <- paste0(gsub(" +", "_", gsub("[^[:alnum:][:space:]]", "", resdf$Item.Title)), ".pdf")
@nickp60
nickp60 / Priz
Created April 7, 2019 22:25
A M4L 4-voice harmonizer
----------begin_max5_patcher---------- 8209.3oc68r1iiabjed8uBBgb.w41YR+lj2GBNm3CFFw9BfMt6vAGiEZj3LC8pgbhD0tdufje6W+hRjyPotjX0TxAw.ViVIpppt5pptppqt5+5m8lY2U+yEalk7uk7CIu4M+0O6Muw9QlO3M9+8al8z7edwp4arO1rphOVe2OM6stupo3mare7u4u29Q0aaVUzz7omKbfc1lxGpluZVxO5efmWWronpYdSYc06VWrnw8brb4sj2ljSxL+gkeqT+J4VxteW01mJqzf1RGL+Gto4SqrHZVK9eddyhGKqd3DAsirsvl5+zxkV.qGt2PE7YlO7u8Yel4k2NNl07kaVGje81tuy9+g3fblxL9xRsCSE0NXOHGTdJbPHftCGTL.GjmeNbvmJ1rY9CEuhERNH6KrfFM0JMPsCII43roSSPC.nCHnQnmCaZQ8SOoGpuhM0TroIon5CyNNKglyrSubKcScDNM6P7D5ovS.A6NLEx.LEI6bXJqJVdPojRMyJjfRpJ0Qx1oQQ6q6+YyWO+ohlh0uqnZ9cNNAY.P1kkc97QllNz1sxjpCPN.Lhkior02EPnRJ32xzTbpkTcZF8l2wmGIU14pr7yWTSnvjG88g3Q5kjlZdDm3LkOBdj.SdzWFfGIT42R6vjxsbrHykDN9SNYDbIFlbouHDWhmN0RRBdtyx94yi3oH5VEB9fJsikLJAeePA.5PluoHxr1L+iimcQsB.obq+fbIpdREFzgXWjyxogxOTb6lUkKKV2RdeX95J8B8u7q+A9OdXmP09qe+p54gcxPj6Vk7FqWRNMpTV.uLnmiN8.bYkjZjCuI+.3tOSlMjBrpkGrY9GJV9t4MMqKuaaSw92swys8raC+b01h56a+31Ou6PsrprozHAZ8fjrih58PadrdcytYl1kZ68HsSIjA9tsZbrSVjNvCrpt5g8fe6ll4kUCgDOw1c9w8PVQu1+fqb32UrpX9lBDD.k7Ko.XtXrB
@nickp60
nickp60 / dates.R
Created July 31, 2018 14:48
Vectorized date selection in R
# I made some slighlty bigger test data to make sure we had some we weren't interested in
# here are all the dates in the two years between dec 2011 and 2013
all_dates <- seq(as.Date("2011-12-15"), as.Date("2013-12-15"), "day")
# like you did, randomly fill in value, and randomly sample for the available nodes
bigtest <- data.frame(
time = all_dates,
node = sample(c(206,211,301,108), size = length(all_dates), replace=T),
value = rnorm(length(all_dates), 21, 2)
)
@nickp60
nickp60 / Microbiology_Society_Annual_Meeting_Program.md
Last active April 10, 2018 06:48
For those tired of clicking and scrolling...

Session View

Monday 09 April, Morning

Pre-Conference session: Teaching microbiology in higher education

This half-day symposium will present several interactive sessions which aim to bring delegates together to discuss and share innovative ways of teaching.

@nickp60
nickp60 / plotMSA.py
Created August 31, 2017 13:13
plotMSA.py: making entropy plots for msa's (with rDNA annotations)
#!/usr/bin/env python
"""
Gist of how to make similar plots to the entropy plots in riboSeed from an MSA.
This assumes you want to annotate rDNAs, but you probably don't
care about those. Adjust as needed.
"""
import os
import datetime
import time
@nickp60
nickp60 / kptrk.sh
Last active June 14, 2018 14:35
kptrk: KeeP TRacK of your shell comamnds
# The purpose of this script it to make working from the terminal a bit more reprodicible.
# It is very simple
# A boolean value (KPTRK_ON) is set to true when kptrk is invoked, and the current directory is recorded.
# when kptrk is invoked again, logging is turned off.
# it is built on top of https://github.com/rcaloras/bash-preexec
# Installation
# - install bash-pre-exec, see instructions here https://github.com/rcaloras/bash-preexec, or, in short:
# -- Pull down our file from GitHub and write it to our home directory as a hidden file.
@nickp60
nickp60 / quickplot.py
Last active June 5, 2017 14:44
Sometimes you just wanna plot something and not deal with matplotlib. I use this in logging messages sometimes.
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import math
import random
import sys
from bisect import bisect
def printPlot(data, line=None, y=30, x=60, tick=.2, title="test", logger=None):
yax = "|"
xax = "_"
<?
/////////////////////
// slack2html
// by @levelsio
/////////////////////
//
/////////////////////
// WHAT DOES THIS DO?
/////////////////////
//