Skip to content

Commit

Permalink
Merge pull request #524 from remlapmot/tsmr-0-6-4
Browse files Browse the repository at this point in the history
TwoSampleMR 0.6.4
  • Loading branch information
remlapmot authored Jun 5, 2024
2 parents 0c96a35 + 6256e3a commit 49fd1cb
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 50 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: TwoSampleMR
Title: Two Sample MR Functions and Interface to MR Base Database
Version: 0.6.3
Version: 0.6.4
Authors@R: c(
person("Gibran", "Hemani", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-0920-1055")),
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# TwoSampleMR v0.6.4

(Release date: 2024-06-05)

* Update installation instructions in README.md

* Fixed a bug in which the wrong indels recoding function was called (thanks @ruochiz)

# TwoSampleMR v0.6.3

(Release date: 2024-05-23)
Expand Down
3 changes: 1 addition & 2 deletions R/harmonise.R
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ harmonise_12 <- function(SNP, A1, B1, B2, betaA, betaB, fA, fB, tolerance, actio
remove <- palindromic

indel_index <- nchar(B1) > 1 | nchar(B2) > 1 | B1 == "D" | B1 == "I"
temp <- recode_indels_21(A1[indel_index], B1[indel_index], B2[indel_index])
temp <- recode_indels_12(A1[indel_index], B1[indel_index], B2[indel_index])

A1[indel_index] <- temp$A1
A2[indel_index] <- temp$A2
Expand Down Expand Up @@ -660,4 +660,3 @@ check_required_columns <- function(dat, type="exposure")
}
return(NULL)
}

24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](h
[![DOI](https://zenodo.org/badge/49515156.svg)](https://zenodo.org/badge/latestdoi/49515156)
[![Codecov test
coverage](https://codecov.io/gh/MRCIEU/TwoSampleMR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/MRCIEU/TwoSampleMR?branch=master)
[![TwoSampleMR status
badge](https://mrcieu.r-universe.dev/badges/TwoSampleMR)](https://mrcieu.r-universe.dev/TwoSampleMR)
<!-- badges: end -->

A package for performing Mendelian randomization using GWAS summary
Expand All @@ -28,26 +30,28 @@ reference panels.** For full details of the changes, please visit

## Installation

To install the latest version of TwoSampleMR, perform as normal:
Users running Windows and macOS, to install the latest version of
TwoSampleMR please install from our MRC IEU r-universe

``` r
install.packages("remotes")
remotes::install_github("MRCIEU/TwoSampleMR")
install.packages("TwoSampleMR", repos = c("https://mrcieu.r-universe.dev", "https://cloud.r-project.org"))
```

To update the package just run the
`remotes::install_github("MRCIEU/TwoSampleMR")` command again.
Users running Linux or WebR please see the [following
instructions](https://github.com/MRCIEU/mrcieu.r-universe.dev#readme).

To update the package run the same command again.

We recommend using this new version going forwards but for a limited
time we are enabling backwards compatibility, in case you are in the
middle of analysis or need to reproduce old analysis. In order to use
the legacy version of the package and the database, install using:
### Installing from source

``` r
install.packages("remotes")
remotes::install_github("MRCIEU/TwoSampleMR@0.4.26")
remotes::install_github("MRCIEU/TwoSampleMR")
```

To update the package just run the
`remotes::install_github("MRCIEU/TwoSampleMR")` command again.

## Docker

A docker image containing R with the TwoSampleMR package pre-installed
Expand Down
18 changes: 11 additions & 7 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![R-CMD-check](https://github.com/MRCIEU/TwoSampleMR/actions/workflows/check-full.yaml/badge.svg)](https://github.com/MRCIEU/TwoSampleMR/actions/workflows/check-full.yaml)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html) [![DOI](https://zenodo.org/badge/49515156.svg)](https://zenodo.org/badge/latestdoi/49515156)
[![Codecov test coverage](https://codecov.io/gh/MRCIEU/TwoSampleMR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/MRCIEU/TwoSampleMR?branch=master)
[![TwoSampleMR status badge](https://mrcieu.r-universe.dev/badges/TwoSampleMR)](https://mrcieu.r-universe.dev/TwoSampleMR)
<!-- badges: end -->

A package for performing Mendelian randomization using GWAS summary data. It uses the [IEU GWAS database](https://gwas.mrcieu.ac.uk/) to obtain data automatically, and a wide range of methods to run the analysis. You can use the [MR-Base web app](https://www.mrbase.org/) to try out a limited range of the functionality in this package, but for any serious work we strongly recommend using this R package.
Expand All @@ -14,22 +15,25 @@ A package for performing Mendelian randomization using GWAS summary data. It use

## Installation

To install the latest version of TwoSampleMR, perform as normal:
Users running Windows and macOS, to install the latest version of TwoSampleMR please install from our MRC IEU r-universe

``` r
install.packages("remotes")
remotes::install_github("MRCIEU/TwoSampleMR")
```r
install.packages("TwoSampleMR", repos = c("https://mrcieu.r-universe.dev", "https://cloud.r-project.org"))
```

To update the package just run the `remotes::install_github("MRCIEU/TwoSampleMR")` command again.
Users running Linux or WebR please see the [following instructions](https://github.com/MRCIEU/mrcieu.r-universe.dev#readme).

We recommend using this new version going forwards but for a limited time we are enabling backwards compatibility, in case you are in the middle of analysis or need to reproduce old analysis. In order to use the legacy version of the package and the database, install using:
To update the package run the same command again.

### Installing from source

``` r
install.packages("remotes")
remotes::install_github("MRCIEU/TwoSampleMR@0.4.26")
remotes::install_github("MRCIEU/TwoSampleMR")
```

To update the package just run the `remotes::install_github("MRCIEU/TwoSampleMR")` command again.

## Docker

A docker image containing R with the TwoSampleMR package pre-installed is available here: https://hub.docker.com/r/mrcieu/twosamplemr
1 change: 0 additions & 1 deletion inst/sandpit/api_alive.r
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,3 @@ toggle_api("release")
pout2 <- extract_outcome_data(snplist[1:5000], 1001, proxies=TRUE)
Sys.time()-t1
# 40sec

2 changes: 1 addition & 1 deletion inst/sandpit/api_comparisons.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ table(out1 == out2)


dat1 <- harmonise_data(exposure_dat, out2)
dat2 <- harmonise_data(inst2, out2)
dat2 <- harmonise_data(inst2, out2)
1 change: 0 additions & 1 deletion inst/sandpit/forest_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ forest_plot(mr_result, in_columns=TRUE, by_category=FALSE, exponentiate=TRUE, tr

forest_plot(mr_result, in_columns=FALSE, by_category=TRUE)
forest_plot(mr_result, in_columns=FALSE, by_category=FALSE)

12 changes: 5 additions & 7 deletions inst/sandpit/harmonise.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


# Assumptions - effect allele is present in exposure and outcome
# Possibilities

Expand Down Expand Up @@ -29,7 +27,7 @@



a <- read.table("inst/data/alleles.txt", he=T, stringsAsFactors=FALSE)
a <- read.table("inst/extdata/alleles.txt", he=T, stringsAsFactors=FALSE)
SNP <- a$SNP
A1 <- a$A1
A2 <- a$A2
Expand Down Expand Up @@ -62,9 +60,9 @@ outcome_dat <- data.frame(
stringsAsFactors=FALSE
)

dat <- harmonise_exposure_outcome(exposure_dat, outcome_dat)
dat <- TwoSampleMR::harmonise_data(exposure_dat, outcome_dat)

a <- read.table("inst/data/alleles.txt", he=T, stringsAsFactors=FALSE)
a <- read.table("inst/extdata/alleles.txt", he=T, stringsAsFactors=FALSE)
SNP <- a$SNP
A1 <- a$A1
A2 <- a$A2
Expand All @@ -76,5 +74,5 @@ fA <- a$fA
fB <- a$fB

fA[4] <- NA
harmonise_21(SNP, A1, A2, B1, betaA, betaB, fA, rep(NA, length(SNP)), 0.08, 2)
harmonise_22(SNP, A1, A2, B1, B2, betaA, betaB, fA, fB, 0.08, 3)
TwoSampleMR:::harmonise_21(SNP, A1, A2, B1, betaA, betaB, fA, rep(NA, length(SNP)), 0.08, 2)
TwoSampleMR:::harmonise_22(SNP, A1, A2, B1, B2, betaA, betaB, fA, fB, 0.08, 3)
2 changes: 0 additions & 2 deletions inst/sandpit/multivariable_mr.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,3 @@ kable(mv_ivw(dat)$result)
```{r}
kable(mv_basic(dat)$result)
```


2 changes: 0 additions & 2 deletions inst/sandpit/multivariable_mr.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,3 @@ kable(mv_ivw(dat)$result)
```{r}
kable(mv_basic(dat)$result)
```


4 changes: 0 additions & 4 deletions inst/sandpit/mysql.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,3 @@ WHERE a.snp=b.id AND a.study=c.id
AND b.name IN ('rs10900000', 'rs10000010', 'rs10000092')
AND c.filename IN ('cardiogramplusc4d_180814_update_data.txt.uniform.af.txt', 'All_ancestries_SNP_gwas_mc_merge_nogc.tbl.uniq.gz.uniform.af.txt', 'MAGIC_INSULIN_SECRETION_DI_for_release_HMrel27.txt.uniform.af.txt')
ORDER BY filename;




1 change: 0 additions & 1 deletion inst/sandpit/plot_tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,3 @@ mr_leaveoneout_plot(mrl)
mr_leaveoneout_plot(mrl1)
mr_leaveoneout_plot(mrl2)
mr_leaveoneout_plot(mrl3)

8 changes: 3 additions & 5 deletions inst/sandpit/test_indels.r
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ al <- matrix(c(
"I", "D", "D", "I"
), nrow=4) %>% t

recode_indels_22(al[,1], al[,2], al[,3], al[,4]) %>% cbind(al, .)
recode_indels_21(al[,1], al[,2], al[,3]) %>% cbind(al, .)
recode_indels_12(al[,1], al[,3], al[,4]) %>% cbind(al, .)
TwoSampleMR:::recode_indels_22(al[,1], al[,2], al[,3], al[,4]) %>% cbind(al, .)
TwoSampleMR:::recode_indels_21(al[,1], al[,2], al[,3]) %>% cbind(al, .)
TwoSampleMR:::recode_indels_12(al[,1], al[,3], al[,4]) %>% cbind(al, .)



Expand Down Expand Up @@ -97,5 +97,3 @@ x <- data.frame(
)

format_data(x)


1 change: 0 additions & 1 deletion inst/sandpit/test_mr_sign.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ mr(dat, method_list=c("mr_ivw", "mr_sign"))
mr_scatter_plot(mr(dat, method_list=c("mr_ivw", "mr_sign")), dat)

# Could consider doing a parametric bootstrap type analysis

3 changes: 0 additions & 3 deletions inst/sandpit/test_mrinput.r
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ o2 <- dat_to_MRInput(dat, get_correlations=TRUE)

MendelianRandomization::mr_ivw(o1[[1]])
MendelianRandomization::mr_ivw(o2[[1]])



1 change: 0 additions & 1 deletion inst/sandpit/test_selection.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,3 @@ mu_g2x <- min(rbeta(1, 1, 300), 0.05) * sample(c(1,-1), 1)


a <- run_sim(nid1 = nid1, nid2 = nid2, nidu = nidu, ninst1 = ninst1, ninst2 = ninst2, ninstu = ninstu, var_xy = var_xy, var_ux = var_ux, var_uy = var_uy, var_g1x = var_g1x, var_g2y = var_g2y, var_guu = var_guu, var_g1y = var_g1y, var_g2x = var_g2x, mu_g1y = mu_g1y, mu_g2x = mu_g2x)

1 change: 0 additions & 1 deletion inst/sandpit/vignette.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,3 @@ mr_leaveoneout_plot(l)[[2]]
### Enrichment

You can also perform a Fisher's combined test to see if there is an enrichment of p-values in the outcome data (e.g. are the SNPs that influence the exposure also likely to influence the outcome, this is not an MR analysis).

0 comments on commit 49fd1cb

Please sign in to comment.