Skip to content

Instantly share code, notes, and snippets.

View ericminikel's full-sized avatar

Eric Minikel ericminikel

View GitHub Profile
@ericminikel
ericminikel / nthprime.py
Created January 8, 2014 22:05
Finds the nth prime number.
primes = []
x = 2
nthprime = 1000 # set to 1000 to get the 1000th prime number
while len(primes) < nthprime:
isPrime = True
for item in primes:
if item > x**.5:
break
if x % item == 0:
isPrime = False
@ericminikel
ericminikel / inoculum-incubationtime.r
Created January 13, 2014 02:26
Model the relationship between prion inoculum titer and incubation time
# Eric Minikel
# 2014-01-12
# explore relationship between inoculated dose and incubation time
# this is all the code from this post:
# http://www.cureffi.org/2014/01/12/prion-kinetic-models-relationship-inoculum-titer-incubation-time/
logdose = runif(n=100,min=0,max=10) # simulate 100 different experiments with diff titers
days = 10^( (logdose-26.66)/(-12.99) ) + 40 + rnorm(n=100,m=0,s=2) # apply Prusiner's model
plot(logdose,days,xlab="log10(LD50 units)",ylab="days to illness",pch=19,
main="incubation time interval bioassay\nPrusiner 1982b - Sc237 in hamsters",
@ericminikel
ericminikel / exampleRScript1.r
Created January 14, 2014 23:53
An example of how to use Rscript and optparse to run R in batch mode with command line args.
#!/broad/software/free/Linux/redhat_5_x86_64/pkgs/r_3.0.2/bin/Rscript
# Eric Vallabh Minikel
# CureFFI.org
# 2014-01-14
# example of how to use optparse in R scripts
# usage: ./exampleRScript1.r -a thisisa -b hiagain
# ./exampleRScript1.r --avar thisisa --bvar hiagain