This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#power calculations for genetic case control study | |
#using gap package and pbsize2 command | |
#citation Jing Hua Zhao (2013). gap: Genetic Analysis Package. R package version 1.1-10. | |
#define study characteristics | |
require(gap) | |
prevalence=0.1 | |
alpha=0.05 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#find overlap between some SNP locations and a list of gene locations | |
#test SNPs | |
#df = snps | |
#chr start stop | |
#1 1232 1232 | |
#2 12444 12444 | |
#gene positions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(reshape2) | |
library(ggplot2) | |
#make csv file as below | |
#name,start.date,end.date,WP | |
#Task 1,1,10,1 | |
#Task 2,2,8,1 | |
#Task 3,12,16,2 | |
#Task 4,22,32,2 | |
#Task 5,18,22,3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rworldmap) | |
theCountries<-read.table("Countries.txt",header=T,sep="\t") | |
# These are the ISO3 names of the countries you'd like to plot in red | |
malMap <- joinCountryData2Map(theCountries, joinCode = "ISO3", | |
nameJoinColumn = "ISO.ALPHA.3.Code") | |
# This will join your malDF data.frame to the country map data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Setting up ODK collect for use with offline maps | |
https://export.hotosm.org/ | |
Sign up for an account | |
Describe the data set in tab 1. | |
In tab 2 select only “MBTiles” | |
In tab 3 choose the source “OpenStreetMap” and set zoom range to 1-14 | |
In the map viewer, navigate to your region of interest. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#R script to make a KML file of GPS data points collected in ODK | |
library(sp) | |
library(rgdal) | |
#make some dummy data | |
lon<-c(-123.736597,6.263428,147.263399,83.263430,169.263481,7.736540,0.0) | |
lat<-c(21.04847,-66.04859,42.04850,66.04854,44.04862,50.04865,52.00000) | |
status<-c(1,1,1,1,2,2,2) | |
names<-c("Mid_Pacific_Off_Mexico","North_Of_Antarctica","East_Of_Hokkaido","North_Central_Russia","Suiko_Seamount","Bacharach_Germany","Barkaway_UK") | |
df<-data.frame(lon,lat,status,names) |
OlderNewer