Skip to content

Instantly share code, notes, and snippets.

View chrissyhroberts's full-sized avatar

Chrissy h Roberts (He/Him) chrissyhroberts

View GitHub Profile
@chrissyhroberts
chrissyhroberts / Diagnostic_evaluation_Power_Calculations.R
Created October 26, 2017 14:07
A power calculator for determining how many specimens you need to include in a population based diagnostic evaluation
#For the findings of the proposed study of diagnostic accuracy to be robust, we require a minimum number of infected and uninfected cases. The total number of samples required to accurately evaluate the diagnostic devices can be calculated4 using the formula
#p the expected sensitivity of the novel diagnostic
p<-0.99
# po is the minimum acceptable level of sensitivity
#pick one of these or use your own value(s)
po<-0.98
require(season)
# use glm model in the first part, date can be full date or month (1-12),
res = cosinor(response~exposures+exposures2+exposures3, date=month, data=df,family=binomial(link='cloglog'),type = "monthly",cycles = 1)
summary(res)
plot(res)
@chrissyhroberts
chrissyhroberts / Platemap_96
Created October 12, 2017 15:44
#draws a 96 cell grid and adds some data to the cells : useful for drawing plate maps for 96 well laboratory plates
#draws a 96 cell grid in R and adds some data to the cells : useful for drawing plate maps for 96 well laboratory plates
title="PLATE X"
values<-paste(c("A","B","C"),1:3,sep="\n")
verticals<-c(rep(7.5,12),rep(6.5,12),rep(5.5,12),rep(4.5,12),rep(3.5,12),rep(2.5,12),rep(1.5,12),rep(0.5,12))
h2<-rep(seq(0.5,11.5,1),8)
#draw the grid
plot(c(0,12),c(0,8),pch=0,col="white",axes=FALSE,xlab="",ylab="")
abline(v=c(0:12))
@chrissyhroberts
chrissyhroberts / polynomial_fits.R
Created October 11, 2017 15:08
Polynomial fits : Run a set of polynomial mode (order 1-4) on some x vs y data.
#Run a set of polynomial models on some x vs y data.
#create a data set x and y
x<-1:1100
y<-sqrt(x^6+x/x^4)+x/x^x
#Define function to run models
polyfit<-function(x,order,raw=TRUE)
{
fit<-lm(y~poly(x,order,raw=raw))