Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
explodecomputer committed Jun 19, 2020
1 parent a6fe8fb commit 2563f81
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 75 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export(get_population_allele_frequency)
export(get_r_from_lor)
export(get_r_from_pn)
export(harmonise_data)
export(ios)
export(ld_matrix)
export(make_dat)
export(mr)
Expand Down
9 changes: 5 additions & 4 deletions R/add_metadata.r
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ add_metadata <- function(dat, cols = c("sample_size", "ncase", "ncontrol", "unit
message(what, ": none of the IDs found in database")
return(NULL)
}

for(col in cols)
{
if(!col %in% names(info))
{
info[[col]] <- NA
}
}

info <- dplyr::select(info, "id", "sample_size", "ncase", "ncontrol", "unit", "sd")
names(info) <- paste0(names(info), ".", what)
info <- subset(info, select=c("id", cols))
names(info) <- paste0(names(info), ".", what)
index <- grepl("ukb-d", info$id) & is.na(info$sample_size)
info$sample_size[index] <- 300000
return(info)
}

Expand Down Expand Up @@ -61,5 +61,6 @@ add_metadata <- function(dat, cols = c("sample_size", "ncase", "ncontrol", "unit

dat <- dat[dat[[order_col]], ]
dat <- dat[, !names(dat) %in% order_col]
# dat <- fix_ukb_d(dat)
return(dat)
}
43 changes: 0 additions & 43 deletions R/ios.R

This file was deleted.

27 changes: 0 additions & 27 deletions man/ios.Rd

This file was deleted.

6 changes: 6 additions & 0 deletions tests/testthat/test_add_metadata.r
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ test_that("no id2", {
d <- add_metadata(d)
expect_true(!"units.outcome" %in% names(d))
})

test_that("ukb-d", {
d <- extract_outcome_data(exposure$SNP, 'ukb-d-30710_irnt')
d <- add_metadata(d)
expect_true("units.outcome" %in% names(d))
}
5 changes: 5 additions & 0 deletions tests/testthat/test_rsq.r
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ test_that("dat 2", {
expect_true("rsq.outcome" %in% names(d) & "rsq.exposure" %in% names(d))
})

test_that("dat ukb-d", {
d <- make_dat(exposure="ukb-d-30710_irnt", proxies=FALSE) %>% add_rsq()
expect_true("rsq.outcome" %in% names(d) & "rsq.exposure" %in% names(d))
})

0 comments on commit 2563f81

Please sign in to comment.