Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: TwoSampleMR
Title: Two Sample MR Functions and Interface to MRC Integrative
Epidemiology Unit OpenGWAS Database
Version: 0.7.5
Version: 0.7.6
Authors@R: c(
person("Gibran", "Hemani", , "g.hemani@bristol.ac.uk", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-0920-1055")),
Expand Down
10 changes: 8 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# TwoSampleMR v0.7.6

(Release date 2026-05-15)

* Fix some typos

# TwoSampleMR v0.7.5

(Release date 2026-05-04)
Expand Down Expand Up @@ -62,7 +68,7 @@
* Optimized `mr_mode()`
* Replaced `apply(..., any(is.na()))` with `complete.case()`
* Optimized the `mr()` function
* Optimized the `Optimize get_r_from_lor()` function
* Optimized the `get_r_from_lor()` function
* Optimized the `mr_rucker_bootstrap()` and `mr_rucker_jackknife_internal()` functions
* Replaced `sapply()` with `vapply()` in several cases
* Optimized the `simple_cap()` function
Expand Down Expand Up @@ -406,7 +412,7 @@ TwoSampleMR v0.5.4

* All datasets now re-instated
* Added options for different populations in LD operations
* When converting to MRInput format and supplying an LD matrix, it is possible that multi-allelic variants will be represented differently on in the GWAS and the LD reference panel. Ambiguous alignments were not being removed, now fixed. Credit goes to Mona Almramhi for spotting and fixing this issue.
* When converting to MRInput format and supplying an LD matrix, it is possible that multi-allelic variants will be represented differently in the GWAS and the LD reference panel. Ambiguous alignments were not being removed, now fixed. Credit goes to Mona Almramhi for spotting and fixing this issue.

TwoSampleMR v0.5.3
==============
Expand Down
2 changes: 1 addition & 1 deletion R/forest_plot2.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ format_mr_results <- function(
#generate a simple trait column. this contains only the outcome name (ie excludes consortium and year from the outcome column generated by mr()). This step caters to the possibility that a user's results contain a mixture of results obtained via MR-Base and correspondence. The later won't be present in the MR-Base database. However, still need to split the outcome name into trait, year and consortium.
if (!ao_slc) {
dat$trait <- dat$outcome
Pos <- grep("\\|\\|", dat$trait) #this indicates the outcome column was derived from data in MR-Base. Sometimes it wont look like this e.g. if the user has supplied their own outcomes
Pos <- grep("\\|\\|", dat$trait) #this indicates the outcome column was derived from data in MR-Base. Sometimes it won't look like this e.g. if the user has supplied their own outcomes
if (sum(Pos) != 0) {
Outcome <- dat$trait[Pos]
Outcome <- unlist(strsplit(Outcome, split = "\\|\\|"))
Expand Down
2 changes: 1 addition & 1 deletion R/forest_plot_1-to-many.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ format_1_to_many <- function(
#generate a simple trait column. this contains only the outcome name (ie excludes consortium and year from the outcome column generated by mr()). This step caters to the possibility that a user's results contain a mixture of results obtained via MR-Base and correspondence. The later won't be present in the MR-Base database. However, still need to split the outcome name into trait, year and consortium.
if (!ao_slc) {
dat$trait <- as.character(dat[, TraitM])
Pos <- grep("\\|\\|", dat$trait) #this indicates the outcome column was derived from data in MR-Base. Sometimes it wont look like this e.g. if the user has supplied their own outcomes
Pos <- grep("\\|\\|", dat$trait) #this indicates the outcome column was derived from data in MR-Base. Sometimes it won't look like this e.g. if the user has supplied their own outcomes
if (sum(Pos) != 0) {
Outcome <- dat$trait[Pos]
Outcome <- unlist(strsplit(Outcome, split = "\\|\\|"))
Expand Down
4 changes: 2 additions & 2 deletions R/format_mr_results2.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @export
#' @return data frame
split_outcome <- function(mr_res) {
Pos <- grep("\\|\\|", mr_res$outcome) #the "||"" indicates that the outcome column was derived from summary data in MR-Base. Sometimes it wont look like this e.g. if the user has supplied their own outcomes
Pos <- grep("\\|\\|", mr_res$outcome) #the "||"" indicates that the outcome column was derived from summary data in MR-Base. Sometimes it won't look like this e.g. if the user has supplied their own outcomes
if (sum(Pos) != 0) {
Outcome <- as.character(mr_res$outcome[Pos])
Vars <- strsplit(Outcome, split = "\\|\\|")
Expand All @@ -30,7 +30,7 @@ split_outcome <- function(mr_res) {
#' @export
#' @return data frame
split_exposure <- function(mr_res) {
Pos <- grep("\\|\\|", mr_res$exposure) #the "||"" indicates that the outcome column was derived from summary data in MR-Base. Sometimes it wont look like this e.g. if the user has supplied their own outcomes
Pos <- grep("\\|\\|", mr_res$exposure) #the "||"" indicates that the outcome column was derived from summary data in MR-Base. Sometimes it won't look like this e.g. if the user has supplied their own outcomes
# Pos2<-grep("\\|\\|",mr_res$exposure,invert=T)
# mr_res2 <-mr_res[Pos2,]
# mr_res1<-mr_res[Pos,]
Expand Down
2 changes: 1 addition & 1 deletion R/multivariable_mr.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ mv_extract_exposures <- function(
#'
#' @param filenames_exposure Filenames for each exposure dataset. Must have header with at least SNP column present. Following arguments are used for determining how to read the filename and clumping etc.
#' @param sep Specify delimiter in file. The default is space, i.e. `sep=" "`. If length is 1 it will use the same `sep` value for each exposure dataset. You can provide a vector of values, one for each exposure dataset, if the values are different across datasets. The same applies to all dataset-formatting options listed below.
#' @param phenotype_col Optional column name for the column with phenotype name corresponding the the SNP. If not present then will be created with the value `"Outcome"`. Default is `"Phenotype"`.
#' @param phenotype_col Optional column name for the column with phenotype name corresponding to the SNP. If not present then will be created with the value `"Outcome"`. Default is `"Phenotype"`.
#' @param snp_col Required name of column with SNP rs IDs. The default is `"SNP"`.
#' @param beta_col Required for MR. Name of column with effect sizes. The default is `"beta"`.
#' @param se_col Required for MR. Name of column with standard errors. The default is `"se"`.
Expand Down
6 changes: 3 additions & 3 deletions R/read_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @param filename Filename. Must have header with at least SNP column present.
#' @param snps SNPs to extract. If `NULL`, which the default, then doesn't extract any and keeps all.
#' @param sep Specify delimiter in file. The default is space, i.e. `sep=" "`.
#' @param phenotype_col Optional column name for the column with phenotype name corresponding the the SNP. If not present then will be created with the value `"Outcome"`. Default is `"Phenotype"`.
#' @param phenotype_col Optional column name for the column with phenotype name corresponding to the SNP. If not present then will be created with the value `"Outcome"`. Default is `"Phenotype"`.
#' @param snp_col Required name of column with SNP rs IDs. The default is `"SNP"`.
#' @param beta_col Required for MR. Name of column with effect sizes. The default is `"beta"`.
#' @param se_col Required for MR. Name of column with standard errors. The default is `"se"`.
Expand Down Expand Up @@ -86,7 +86,7 @@ read_outcome_data <- function(
#' @param filename Filename. Must have header with at least SNP column present.
#' @param clump Whether to perform LD clumping with [clump_data()] on the exposure data. The default is `FALSE`.
#' @param sep Specify delimiter in file. The default is a space, i.e. `" "`.
#' @param phenotype_col Optional column name for the column with phenotype name corresponding the the SNP. If not present then will be created with the value "Outcome". The default is `"Phenotype"`.
#' @param phenotype_col Optional column name for the column with phenotype name corresponding to the SNP. If not present then will be created with the value "Outcome". The default is `"Phenotype"`.
#' @param snp_col Required name of column with SNP rs IDs. The default is `"SNP"`.
#' @param beta_col Required for MR. Name of column with effect sizes. The default is `"beta"`.
#' @param se_col Required for MR. Name of column with standard errors. The default is `"se"`.
Expand Down Expand Up @@ -184,7 +184,7 @@ read_exposure_data <- function(
#' @param type Is this the exposure or the outcome data that is being read in? The default is `"exposure"`.
#' @param snps SNPs to extract. If NULL then doesn't extract any and keeps all. The default is `NULL`.
#' @param header The default is `TRUE`.
#' @param phenotype_col Optional column name for the column with phenotype name corresponding the the SNP. If not present then will be created with the value `"Outcome"`. The default is `"Phenotype"`.
#' @param phenotype_col Optional column name for the column with phenotype name corresponding to the SNP. If not present then will be created with the value `"Outcome"`. The default is `"Phenotype"`.
#' @param snp_col Required name of column with SNP rs IDs. The default is `"SNP"`.
#' @param beta_col Required for MR. Name of column with effect sizes. The default is `"beta"`.
#' @param se_col Required for MR. Name of column with standard errors. The default is `"se"`.
Expand Down
2 changes: 1 addition & 1 deletion man/format_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mv_extract_exposures_local.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/read_exposure_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/read_outcome_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vignettes/exposure.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ You can also provide the following extra information:
- `ncontrol` - Number of controls
- `pval` - The P-value for the SNP's association with the exposure
- `units` - The units in which the effects are presented
- `gene` - The gene or other annotation for the the SNP
- `gene` - The gene or other annotation for the SNP

## Reading in from a file

Expand Down
2 changes: 1 addition & 1 deletion vignettes/introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The workflow for performing MR is as follows:

1. Select instruments for the exposure (perform LD clumping if necessary)
2. Extract the instruments from the [IEU GWAS database](https://opengwas.io) for the outcomes of interest
3. Harmonise the effect sizes for the instruments on the exposures and the outcomes to be each for the same reference allele
3. Harmonise the effect sizes for the instruments on the exposures and the outcomes to be aligned to the same reference allele
4. Perform MR analysis, sensitivity analyses, create plots, compile reports

A diagrammatic overview is shown here:
Expand Down
Loading