Skip to content

Instantly share code, notes, and snippets.

@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
@explodecomputer
explodecomputer / higbee_uploads.r
Last active March 19, 2021 15:29
higbee_uploads
# on bc3
# wget https://fluff.bris.ac.uk/fluff/u2/mk19726/Al7MuuePNzS7tMWliJGG6QznF/fev1_adjusted_only_for_sex_imputed.txt
# wget https://fluff.bris.ac.uk/fluff/u2/mk19726/0ar7Sekl4I3Xj4JyatEf_wznc/fvc_adjusted_only_for_sex_imputed.txt
# wget https://fluff.bris.ac.uk/fluff/u4/mk19726/pUNC547Sala4I5Y1V_G9Bwzna/obstructive_ratio_spirometry_imputed.txt
# FEV1:
# sample size 353315
@explodecomputer
explodecomputer / mdd_upload.r
Last active February 24, 2021 15:58
MDD OpenGWAS upload
library(GwasDataImport)
library(data.table)
library(ieugwasr)
library(dplyr)
# Download the Howard et al 2019 MDD GWAS from https://datashare.ed.ac.uk/handle/10283/3203
a <- data.table::fread("https://datashare.ed.ac.uk/bitstream/handle/10283/3203/PGC_UKB_depression_genome-wide.txt?sequence=3&isAllowed=y")
# It doesn't have chr/pos, so let's look them up on OpenGWAS (a bit slow!)
@explodecomputer
explodecomputer / dementia_mortality.rmd
Created February 18, 2021 12:57
Sex differences in dementia rates over time
---
title: Survival bias in sex association with dementia
author: Gibran Hemani
date: `r Sys.time()`
---
```{r}
library(dplyr)
library(tidyr)
library(ggplot2)