Skip to content

Instantly share code, notes, and snippets.

View hypercompetent's full-sized avatar

Lucas Graybuck hypercompetent

View GitHub Profile
@hypercompetent
hypercompetent / matlab_mann_kendall.R
Created April 19, 2019 16:42
R implementation of the Matlab Mann-Kendall test function
matlab_mann_kendall <- function(V,
alpha = 0.05) {
alpha <- alpha/2
n <- length(V)
S <- 0
for (i in 1:(n-1)) {
for(j in (i+1):n) {
S <- S + sign(V[j] - V[i])
@hypercompetent
hypercompetent / nmToRGB.js
Created April 17, 2019 20:36
JavaScript nm to RGB color function
nmToRGB: function(wavelength){
var Gamma = 0.80,
IntensityMax = 255,
factor, red, green, blue;
if((wavelength >= 380) && (wavelength<440)){
red = -(wavelength - 440) / (440 - 380);
green = 0.0;
blue = 1.0;
}else if((wavelength >= 440) && (wavelength<490)){
red = 0.0;
@hypercompetent
hypercompetent / immune.R
Last active April 17, 2019 22:16
immune heritability replotting
# adding on to Mike Love's analysis of data here:
# https://twitter.com/mikelove/status/1118595655608483843
# Data source is:
# https://www.cell.com/cms/10.1016/j.cell.2014.12.020/attachment/fb539453-989f-49e5-b880-34cf88151add/mmc5.xlsx
library(readxl)
x <- read_excel("mmc5.xlsx", skip = 1)
names(x)[12:13] <- c("ci_95_low","ci_95_high")