Skip to content

Instantly share code, notes, and snippets.

@explodecomputer
explodecomputer / parse_signatures.r
Created November 22, 2021 18:56
Parse signatories from excel spreadsheet
library(tidyverse)
library(readxl)
a <- read_xlsx("~/Downloads/Letter to the Vice Chancellor 2021-11-10 (Responses)(1).xlsx")
to_remove <- tolower(c("ana.baezaruiz@bristol.ac.uk", "Valerie.Aspin@bristol.ac.uk"))
dat <- a %>%
filter(! tolower(`Email Address`) %in% to_remove) %>%
arrange(`School or department`, `Surname`) %>%
---
title: "Reverse MR Sims"
output: html_notebook
---
```{r}
library(simulateGP)
library(TwoSampleMR)
```
@explodecomputer
explodecomputer / hd_protector_alleles.r
Created October 15, 2021 08:54
Huntington's disease protector alleles
# Model of control-only Huntington's disease analysis
# If you have some CAG expansion cases who are non-symptomatic then what distinguishes them from non expansion individuals?
# This script shows the analysis is akin to an interaction analysis
library(dplyr)
n <- 1000000
cag <- rpois(n, 2)
mod <- rbinom(n, 2, 0.4) - 1
d <- rep(0, n)
@explodecomputer
explodecomputer / snakefile
Created September 9, 2021 11:53
Snakefile example
CHUNKSIZE=250
NCHUNK=864
CHUNK=range(0,NCHUNK)
rule all:
input:
"instrument_specificity_analysis.html"
rule dl:
@explodecomputer
explodecomputer / proportions.rmd
Created July 23, 2021 14:29
Comparing survfey answers before and after intervention
---
title: Comparing survey answers before and after intervention
author: Gibran Hemani
---
```{r}
suppressMessages(suppressWarnings(suppressPackageStartupMessages({
library(knitr)
library(tidyverse)
})))
---
title: Analysis of rs13107325 heterogeneity in BMI - osteoarthritis MR analysis
author: Gibran Hemani
date: "`r Sys.time()"
---
```{r}
library(tryx)
library(TwoSampleMR)
library(ieugwasr)
@explodecomputer
explodecomputer / mr_inflammation_oa.rmd
Created April 16, 2021 15:58
Quick MR of fibronectin / cytokines / matrix metalloproteinases on osteoarthritis
---
title: Quick MR of fibronectin / cytokines / matrix metalloproteinases on osteoarthritis
date: "`r Sys.time()"
---
This paper presents a mathematical model linking osteoarthritis (OA) to a dynamic inflammation system involving cytokines and fibronectin https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5562782/.
Quick look at whether genetic relationships associate:
@explodecomputer
explodecomputer / dha_ukbb_finemapping.r
Created April 10, 2021 20:11
dha_ukbb_finemapping
library(gwasglue)
library(ieugwasr)
library(tidyverse)
library(susieR)
library(glue)
# DHA fine mapping
temp <- associations("11:61200000-62100000", "met-d-DHA")
ggplot(temp, aes(x=position, y=-log10(p))) +
geom_point()
---
title: Comparison of effect allele frequencies in TwoSampleMR
author: Gibran Hemani
date: "`r Sys.time()`"
---
```{r, echo=FALSE}
library(knitr)
opts_chunk$set(warning=FALSE, message=FALSE)
library(TwoSampleMR)
library(ieugwasr)
library(tidyverse)
# Get harmonised data for exposure and outcome
# e.g. BMI vs CHD
dat <- make_dat(exposures="ieu-a-2", outcomes="ieu-a-7")
# infer the AF for controls only for CHD
# first get case control sizes