Skip to content

Commit e1ff8a5

Browse files
authored
Merge pull request #649 from remlapmot/steiger-issue
TwoSampleMR 0.6.21
2 parents 0c9f896 + c019690 commit e1ff8a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+641
-3899
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ cache$
1818
^CITATION\.cff$
1919
^README\.html$
2020
^\.lintr$
21+
^inst/sandpit$

.lintr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ linters: linters_with_defaults(
44
indentation_linter = NULL,
55
infix_spaces_linter = NULL,
66
quotes_linter = NULL,
7-
brace_linter = NULL,
87
commas_linter = NULL,
98
whitespace_linter = NULL,
109
object_name_linter = NULL,

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: TwoSampleMR
22
Title: Two Sample MR Functions and Interface to MRC Integrative
33
Epidemiology Unit OpenGWAS Database
4-
Version: 0.6.20
4+
Version: 0.6.21
55
Authors@R: c(
66
person("Gibran", "Hemani", , "[email protected]", role = c("aut", "cre"),
77
comment = c(ORCID = "0000-0003-0920-1055")),

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# TwoSampleMR v0.6.21
2+
3+
(Release date 2025-08-11)
4+
5+
* Fixed typos in Steiger related documentation (thanks to @eleanorsanderson and Kaitlin Wade for providing the motivating example for this).
6+
* Some code cleanup to make debugging easier.
7+
* Reduced size of installed package by removing some unused files.
8+
19
# TwoSampleMR v0.6.20
210

311
(Release date 2025-08-01)

R/add_metadata.r

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,24 @@
88
#'
99
#' @export
1010
#' @return Data frame
11-
add_metadata <- function(dat, cols = c("sample_size", "ncase", "ncontrol", "unit", "sd"))
12-
{
11+
add_metadata <- function(dat, cols = c("sample_size", "ncase", "ncontrol", "unit", "sd")) {
1312
stopifnot(is.data.frame(dat))
1413
stopifnot("id.exposure" %in% names(dat) | "id.outcome" %in% names(dat))
15-
get_info <- function(id, what="exposure", cols)
16-
{
14+
get_info <- function(id, what="exposure", cols) {
1715
info <- ieugwasr::gwasinfo(id)
18-
if (nrow(info) == 0)
19-
{
16+
if (nrow(info) == 0) {
2017
message(what, ": none of the IDs found in database")
2118
return(NULL)
2219
}
23-
for (col in cols)
24-
{
25-
if (!col %in% names(info))
26-
{
20+
for (col in cols) {
21+
if (!col %in% names(info)) {
2722
info[[col]] <- NA
2823
}
2924
}
3025
info <- subset(info, select=c("id", cols))
3126
names(info) <- paste0(names(info), ".", what)
3227
names(info)[names(info) == paste0("sample_size.", what)] <- paste0("samplesize.", what)
33-
if ("sample_size" %in% cols)
34-
{
28+
if ("sample_size" %in% cols) {
3529
index <- grepl("ukb-d", info$id) & is.na(info[[paste0("samplesize.", what)]])
3630
info[[paste0("samplesize.", what)]][index] <- 300000
3731
}
@@ -40,42 +34,32 @@ add_metadata <- function(dat, cols = c("sample_size", "ncase", "ncontrol", "unit
4034

4135
order_col <- random_string()
4236
dat[[order_col]] <- seq_len(nrow(dat))
43-
if ("id.exposure" %in% names(dat))
44-
{
37+
if ("id.exposure" %in% names(dat)) {
4538
exposure_id <- unique(dat[["id.exposure"]])
4639
info <- get_info(id=exposure_id, what="exposure", cols=cols)
47-
if (!is.null(info))
48-
{
49-
for (x in names(info))
50-
{
51-
if (! x %in% names(dat))
52-
{
40+
if (!is.null(info)) {
41+
for (x in names(info)) {
42+
if (! x %in% names(dat)) {
5343
dat[[x]] <- NA
5444
}
5545

56-
for (id in unique(info[["id.exposure"]]))
57-
{
46+
for (id in unique(info[["id.exposure"]])) {
5847
dat[[x]][is.na(dat[[x]]) & dat[["id.exposure"]] == id] <- info[[x]][info[["id.exposure"]] == id]
5948
}
6049
}
6150
}
6251
}
6352

64-
if ("id.outcome" %in% names(dat))
65-
{
53+
if ("id.outcome" %in% names(dat)) {
6654
outcome_id <- unique(dat[["id.outcome"]])
6755
info <- get_info(id=outcome_id, what="outcome", cols=cols)
68-
if (!is.null(info))
69-
{
70-
for (x in names(info))
71-
{
72-
if (! x %in% names(dat))
73-
{
56+
if (!is.null(info)) {
57+
for (x in names(info)) {
58+
if (! x %in% names(dat)) {
7459
dat[[x]] <- NA
7560
}
7661

77-
for (id in unique(info[["id.outcome"]]))
78-
{
62+
for (id in unique(info[["id.outcome"]])) {
7963
dat[[x]][is.na(dat[[x]]) & dat[["id.outcome"]] == id] <- info[[x]][info[["id.outcome"]] == id]
8064
}
8165
}

0 commit comments

Comments
 (0)