oxfordrse / ntdmc_tech_meeting_2021 Goto Github PK
View Code? Open in Web Editor NEWMaterial and references for a talk/workshop on simple approaches to write maintainable research code
Material and references for a talk/workshop on simple approaches to write maintainable research code
Dear Thibault and Ben,
Thank you so much for the excellent talk on Monday and for developing this repo! I am currently a first-year PhD student at Oxford and previously I was trained in medicine and public health. I am quite new to programming and I learned quite a lot from your materials. However, I wonder, could you please recommend more good codes examples? Programming is a language and I feel most of my day when I was coding by myself I was just checking R/Python libraries--- this feels I was more like learning how to use vocabularies. However, usually when we learn a new language, we also want to learn from good articles so that to learn how other people organize their articles and use different vocabularies. so I wonder, have you noticed any good open-source code project in health data science field? I know nowadays more infectious disease modellers shared their codes, but sometimes I found some of them are so hard to read/understand!
In addition, do you by any chance know any research coding community within Oxford? It would be nice to learn from and help with each other!
Many thanks,
model <- function(start, stop, stoc,
spec, dens,
b,
i_mat, i_dur,
ntype, ncov) {
# do stuff
}
simulate <- function(time_start, time_stop,
is_stochastic, mosquito_species,
mosquito_density,
mosquito_to_human_prob,
immunity_maternal, immunity_duration,
net_type, net_coverage) {
# do stuff
}
SimulationParameters <- setClass("SimulationParameters",
slots=list(time_start="numeric",
time_stop="numeric",
is_stochastic="logical"))
# doesn't work
simulation_parameters <- SimulationParameters(
time_start=1990,
time_stop=2018,
is_stochastic=2)
# works
simulation_parameters <- SimulationParameters(
time_start=1990,
time_stop=2018,
is_stochastic=FALSE)
check <-function(object) {
if(!object@net_type %in% c("net 1", "net 2"))
return("A net must of type `net 1` or `net 2`.")
coverage <- object@net_coverage
if(coverage < 0 | coverage > 1)
return("Net coverage must not be outside [0, 1].")
}
BednetParameters <- setClass("BednetParameters",
slots=list(net_type="character",
net_coverage="numeric"),
validity = check)
# fails
bednet_parameters <- BednetParameters(net_type = "net 3",
net_coverage = 0.3)
# fails
bednet_parameters <- BednetParameters(net_type = "net 2",
net_coverage = 100)
Simulation <- setClass("Simulation",
slots=list(simulation_parameters="SimulationParameters",
bednet_parameters="BednetParameters",
immunity_parameters="ImmunityParameters",
mosquito_parameters="MosquitoParameters"))
# ...don't show how to do but could create a "run" method
simulation <- Simulation(simulation_parameters=....)
result <- run(simulation)
# what parameters did I use to run my simulation?
simulation@simulation_parameters
I've been going through the various links (thanks @tlestang!) and, to my mind, the following is an ordering representing the prevalence of various code smells in epidemiological code. Note, this partly reflects that most epidemiological people code in R (there are people that also code in C++ but I don't know the language as well) and don't tend to use classes.
What are your thoughts @tlestang ? Any clangers I've missed off? I don't think we'll want to go into the detail of too many.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.