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)
($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} |
# simulation | |
n <- 10000 | |
a <- rbinom(n, 2, 0.5) | |
b <- rbinom(n, 2, 0.49) | |
# perform fisher's exact test to obtain odds ratio for two allele frequencies being different | |
cont <- matrix( | |
c(sum(a==0) * 2 + sum(a==1), sum(a==2) * 2 + sum(a==1), sum(b==0) * 2 + sum(b==1), sum(b==2) * 2 + sum(b==1)), 2, 2) | |
fisher.test(cont) |
# Number of individuals in the population | |
npop <- 100000 | |
# Distribution of variable in the population | |
x <- rnorm(npop) | |
# Individuals selected into sample with high x value | |
s <- rbinom(npop, 1, plogis(x * 0.4)) | |
# Population mean of x |
library(dplyr) | |
library(data.table) | |
library(TwoSampleMR) | |
bmi_id <- "ukb-b-19953" | |
chd_id <- "ukb-b-3983" | |
datadir <- "/mnt/storage/private/mrcieu/research/mr-eve/UKBB_replication/replication/results" |