Website: https://www.tidyverse.org/packages/
Comparison of dplyr and base functions: https://cran.r-project.org/web/packages/dplyr/vignettes/base.html
Piping:
library(dplyr)| 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 |
| # 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 |
| 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!) |
| --- | |
| title: Survival bias in sex association with dementia | |
| author: Gibran Hemani | |
| date: `r Sys.time()` | |
| --- | |
| ```{r} | |
| library(dplyr) | |
| library(tidyr) | |
| library(ggplot2) |
| ($1 == 1) && ($4 >= 48227413) && ($4 <= 52227412) {print $2} | |
| ($1 == 2) && ($4 >= 86000000) && ($4 <= 100500000) {print $2} | |
| ($1 == 2) && ($4 >= 183291755) && ($4 <= 190291755) {print $2} | |
| ($1 == 3) && ($4 >= 47524996) && ($4 <= 50024996) {print $2} | |
| ($1 == 3) && ($4 >= 83417310) && ($4 <= 86917310) {print $2} | |
| ($1 == 5) && ($4 >= 128972101) && ($4 <= 131972101) {print $2} | |
| ($1 == 5) && ($4 >= 44500000) && ($4 <= 50500000) {print $2} | |
| ($1 == 6) && ($4 >= 57000000) && ($4 <= 64000000) {print $2} | |
| ($1 == 6) && ($4 >= 25392021) && ($4 <= 33392022) {print $2} | |
| ($1 == 6) && ($4 >= 139958307) && ($4 <= 142458307) {print $2} |
Website: https://www.tidyverse.org/packages/
Comparison of dplyr and base functions: https://cran.r-project.org/web/packages/dplyr/vignettes/base.html
Piping:
library(dplyr)| # sample size | |
| n <- 10000 | |
| # simulate x and y variables - no association | |
| x <- rnorm(n) | |
| y <- rnorm(n) | |
| # selected into the sample is influenced by x and y | |
| sel <- rbinom(n, 1, plogis(x + y)) |
| #!/bin/bash | |
| path=$(readlink -f $*); | |
| cwd=$(pwd); | |
| winpath=$(wslpath -w $path); | |
| echo "Editing ${path}" | |
| echo "Windows path is ${winpath}" | |
| library(dplyr) | |
| library(org.Hs.eg.db) | |
| # get KEGG pathways | |
| xx <- as.list(org.Hs.egPATH2EG) | |
| keggpathways <- lapply(names(xx), function(x) { | |
| tibble( | |
| symbol=select(org.Hs.eg.db, xx[[x]], c("SYMBOL"), "ENTREZID")$SYMBOL, | |
| pathway=x |
| ($1 == 1) && ($4 >= 48227413) && ($4 <= 52227412) {print $2} | |
| ($1 == 2) && ($4 >= 86000000) && ($4 <= 100500000) {print $2} | |
| ($1 == 2) && ($4 >= 183291755) && ($4 <= 190291755) {print $2} | |
| ($1 == 3) && ($4 >= 47524996) && ($4 <= 50024996) {print $2} | |
| ($1 == 3) && ($4 >= 83417310) && ($4 <= 86917310) {print $2} | |
| ($1 == 5) && ($4 >= 128972101) && ($4 <= 131972101) {print $2} | |
| ($1 == 5) && ($4 >= 44500000) && ($4 <= 50500000) {print $2} | |
| ($1 == 6) && ($4 >= 57000000) && ($4 <= 64000000) {print $2} | |
| ($1 == 6) && ($4 >= 25392021) && ($4 <= 33392022) {print $2} | |
| ($1 == 6) && ($4 >= 139958307) && ($4 <= 142458307) {print $2} |