Skip to content

Instantly share code, notes, and snippets.

@jwaage
jwaage / string.R
Created October 12, 2016 14:06
StringDB PPI grabber
# Libraries
# ------------------------------------------------------------------------------
library("RCurl")
library("bitops")
# Define functions
# ------------------------------------------------------------------------------
getInteractions = function(id,score,limit,species=9606,print=FALSE){
@jwaage
jwaage / adonis_table.R
Created August 18, 2017 14:14
Adonis Table
adonis_table <- function(phy, d, ...){
subs <- function(dist, index) as.dist(as.matrix(dist)[index,index])
contcheck <- function(var){
suppressWarnings(
if(all(is.na(as.numeric(var))) | length(unique(var))<10){
return(var)
} else {
return(as.numeric(var))
}
)
@jwaage
jwaage / sinecurve.R
Created September 15, 2017 08:10
Sine curve function and plot
# Season test
# Do a sine function with arbitrary phase shift and plot the results with confidence band.
library(tidyverse)
library(broom)
set.seed(1)
x <- runif(200, 1, 365) %>% round(0)
y <- sin(2*pi*x/365) + rnorm(200, 0, 0.5)
yshift <- sin(2*pi*x/365 - 0.3*pi) + rnorm(200, 0, 0.5)