{"id":23100673,"url":"https://github.com/benkeser/sievetrend","last_synced_at":"2025-04-03T20:45:08.409Z","repository":{"id":129606549,"uuid":"105190557","full_name":"benkeser/sievetrend","owner":"benkeser","description":"Tests for trends in vaccine efficacy by genetic distance","archived":false,"fork":false,"pushed_at":"2017-09-28T19:58:41.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T09:11:14.066Z","etag":null,"topics":["competing-risks","hamming-distance","sieve-analysis","tmle","vaccines"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benkeser.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-28T19:26:08.000Z","updated_at":"2017-10-16T05:45:55.000Z","dependencies_parsed_at":"2023-03-23T16:32:39.650Z","dependency_job_id":null,"html_url":"https://github.com/benkeser/sievetrend","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benkeser%2Fsievetrend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benkeser%2Fsievetrend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benkeser%2Fsievetrend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benkeser%2Fsievetrend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benkeser","download_url":"https://codeload.github.com/benkeser/sievetrend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247078801,"owners_count":20879950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["competing-risks","hamming-distance","sieve-analysis","tmle","vaccines"],"created_at":"2024-12-16T23:33:36.947Z","updated_at":"2025-04-03T20:45:08.394Z","avatar_url":"https://github.com/benkeser.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ntitle: \"Assessing trends in vaccine efficacy by pathogen genetic distance\"\nauthor: \"David Benkeser, Michal Juraska, and Peter Gilbert\"\ndate: \"September 28, 2017\"\noutput:\n    md_document:\n        variant: markdown_github\n---\n\n    \n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE)\n```\n\n## Installation of `sievetrend`\n\nThe `sievetrend` repository is available for download as an `R` package and may be\ndownloaded directly from GitHub as follows. \n\n```{r, messages = FALSE, warnings = FALSE}\n# install sievetrend from GitHub\ndevtools::install_github(\"benkeser/sievetrend\")\nlibrary(sievetrend)\n# also will require package survtmle\nif(!(\"survtmle\" %in% row.names(installed.packages()))){\n\tinstall.packages(\"survtmle\")\t\n}\nlibrary(survtmle)\n```\n\nBelow, we include the code that was used to perform the simulation study\nand to analyze the RTS,S data for the manuscript. \n\n## Simulation\n\nHere, we demonstrate how to obtain results for a simulated data set. \n\n```{r}\n# sample size\nn \u003c- 1000\n\n# set random seed\nset.seed(1234)\n\n# simulate data set\ndat \u003c- makeData(n = n)\n\n# get the formula for the empirical estimate of the\n# censoring distribution needed for input to survtmle\nglm.ctime \u003c- get.ctimeForm(trt = dat$trt, site = dat$adjustVars$site, \n                           ftime = dat$ftime, ftype = dat$ftype)\n\n# call survtmle to estimate cumulative incidence\nobject \u003c- survtmle(ftime = dat$ftime,\n                  ftype = dat$ftype,\n                  adjustVars = dat$adjustVars,\n                  trt = dat$trt,\n                  glm.trt = \"1\",\n                  glm.ftime = \"trt*factor(site)\",\n                  glm.ctime = glm.ctime,\n                  method = \"mean\",\n                  t0=6)\n\n# call trend_test to estimate projection\ntrend \u003c- trend_test(object)\ntrend\n```\n\nA numerical approximation of the true value of $\\beta_{0,n}$ may be obtained as follows.\n\n```{r}\n# get covariance matrix estimate\nnabla_g \u003c- sievetrend:::grad_g(object$est)\nUpsilon_n \u003c- nabla_g %*% cov(Reduce(cbind, object$ic)) %*% t(nabla_g) \n# call getTruth function with this estimate several times \n# and average (to increase accuracy)\nbeta_0n \u003c- rowMeans(replicate(20, getTruth(Upsilon = Upsilon_n, n = 1e6)))[2]\n\n# compare estimate to truth\nc(est = trend$beta, truth = beta_0n)\n```\n\nThe full code used to execute the simulation study is included in the simulation subdirectory. This includes the script `cent.R`, which is batched to a slurm via\nthe script `sce.sh`. The function `makeIllustrationPlot` was used to produce Figure 1.\n\n## RTS,S Analysis\n\nDue to existing privacy agreements, it is difficult to obtain access to the real RTS,S data. Nevertheless, a mock data set is distributed with the `survtmle` package that will serve as illustration for the outputation methodology. See `?rtss` for further description of the data set. \n\nThe `rtss` data set is a list of ten data sets each representing an outputed data set. They are formatted for analysis of a binary genetic mark, so we first replace the failure type column with a simulated genetic distance.\n\n```{r}\n# replace the ftype column in each data set\nrtss_mod \u003c- lapply(rtss, function(data){\n\t# which were observed failures\n\tfail_idx \u003c- which(data$ftype \u003e 0)\n\t# number of observed failures\n\tfail_n \u003c- length(fail_idx)\n\t# replace with a simulated version\n\tdata$ftype[fail_idx] \u003c- rbinom(fail_n, 4, plogis(data$vaccine)) + 1\n\t# collapse site variable into a single column\n\tdata$site \u003c- as.numeric(1*(data$site1==1) + 2*(data$site2==1) + \n\t                        3*(data$site3==1) + 4*(data$site4==1) + \n\t                        5*(data$site5==1))\n\treturn(data)\n})\n\n# check out new ftype distribution for first\n# outputed data set\ntable(rtss_mod[[1]]$ftype)\n```\n\nNow we use `survtmle` to estimate the cumulative incidence for each data set.\n\n```{r}\nrslt \u003c- lapply(rtss_mod, function(data){\n\tglm.ctime \u003c- get.ctimeForm(trt = data$trt, site = data$site, \n                           ftime = data$ftime, ftype = data$ftype)\n\n\tobject \u003c- survtmle(ftime = data$ftime,\n                  ftype = data$ftype,\n                  adjustVars = data[,\"site\",drop=FALSE],\n                  trt = data$vaccine,\n                  glm.trt = \"1\",\n                  glm.ftime = \"trt*factor(site)\",\n                  glm.ctime = glm.ctime,\n                  method = \"mean\",\n                  t0=6)\n\treturn(object)\n})\n```\n\nWe can use the `getMO` function to obtain the averaged cumulative incidence \nresults and apply the trend_test on this scale.\n\n```{r}\n# obtain averaged results\nmo_rslt \u003c- getMO(rslt)\n\n# apply trend test\nmo_trend \u003c- trend_test(mo_rslt)\nmo_trend\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenkeser%2Fsievetrend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenkeser%2Fsievetrend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenkeser%2Fsievetrend/lists"}