Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for dplyr 1.0.0 #363

Closed
wants to merge 7 commits into from
Closed
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
6 changes: 3 additions & 3 deletions R/bed_absdist.r
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ bed_absdist <- function(x, y, genome) {
genome <- inner_join(genome, get_labels(y), by = c("chrom"))

ref_points <- summarize(y, .ref_points = n())
genome <- inner_join(genome, ref_points, by = c("chrom", groups_xy))
genome <- inner_join(genome, ref_points, by = c("chrom", setdiff("chrom", groups_xy)))

genome <- mutate(genome, .ref_gap = .ref_points / size)
genome <- select(genome, -size, -.ref_points)

# calculate scaled reference sizes
res <- full_join(res, genome, by = c("chrom", groups_xy))
res <- full_join(res, genome, by = c("chrom", setdiff("chrom", groups_xy)))
res <- mutate(res, .absdist_scaled = .absdist * .ref_gap)
res <- select(res, -.ref_gap)

# report back original x intervals not found
x_missing <- anti_join(x, res, by = c("chrom", groups_xy))
x_missing <- anti_join(x, res, by = c("chrom", setdiff("chrom", groups_xy)))
x_missing <- ungroup(x_missing)
x_missing <- mutate(x_missing, .absdist = NA, .absdist_scaled = NA)
res <- bind_rows(res, x_missing)
Expand Down
2 changes: 1 addition & 1 deletion R/bed_complement.r
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bed_complement <- function(x, genome) {

res <- complement_impl(res, genome)

res <- bind_rows(res, chroms_no_overlaps)
res <- bind_rows(res, as_tibble(chroms_no_overlaps))
res <- bed_sort(res)

res
Expand Down
2 changes: 1 addition & 1 deletion R/bed_glyph.r
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bed_glyph <- function(expr, label = NULL) {
for (i in 1:nargs) {
env_i <- get(expr_vars[i], env)
rows <- mutate(env_i, .facet = expr_vars[i])
res <- bind_rows(res, rows)
res <- bind_rows(res, as_tibble(rows))
}

# assign `.y` values in the result based on clustering
Expand Down
2 changes: 1 addition & 1 deletion R/bed_partition.r
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ bed_partition <- function(x, ...) {
res <- partition_impl(x)
}

res <- tbl_df(res)
res <- as_tibble(res)

# drop non-grouped cols as values no longer match ivls
res <- select(res, chrom, start, end, one_of(groups_df))
Expand Down
2 changes: 1 addition & 1 deletion R/bed_shuffle.r
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ bed_shuffle <- function(x, genome, incl = NULL, excl = NULL,
}

# bind original x column data to result (#81)
res <- bind_cols(res, x[, !colnames(x) %in% colnames(res)])
res <- bind_cols(res, as_tibble(x[, !colnames(x) %in% colnames(res)]))

res <- as.tbl_interval(res)

Expand Down
4 changes: 2 additions & 2 deletions src/dist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ DataFrame dist_impl(ValrGroupedDataFrame x, ValrGroupedDataFrame y,

/***R
library(dplyr)
x <- tibble::frame_data(
x <- tibble::tribble(
~chrom, ~start, ~end,
"chr1", 5, 15,
"chr1", 50, 150,
"chr2", 1000, 2000,
"chr3", 3000, 4000
) %>% group_by(chrom)
y <- tibble::frame_data(
y <- tibble::tribble(
~chrom, ~start, ~end,
"chr1", 25, 125,
"chr1", 150, 250,
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test_absdist.r
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
context("bed_absdist")

genome <- tibble::frame_data(
genome <- tibble::tribble(
~ chrom, ~ size,
"chr1", 10000,
"chr2", 10000,
"chr3", 10000
)

x <- tibble::frame_data(
x <- tibble::tribble(
~ chrom, ~ start, ~ end,
"chr1", 75, 125
)

y <- tibble::frame_data(
y <- tibble::tribble(
~ chrom, ~ start, ~ end,
"chr1", 50, 100,
"chr1", 100, 150
Expand All @@ -24,7 +24,7 @@ test_that("absdist calculation is correct", {
})

test_that("self absdist is 0", {
x <- tibble::frame_data(
x <- tibble::tribble(
~ chrom, ~ start, ~ end,
"chr1", 5, 15,
"chr1", 50, 150,
Expand All @@ -37,15 +37,15 @@ test_that("self absdist is 0", {
})

test_that("x ivls without matching y-ivls chroms are reported with absdist = NA", {
x <- tibble::frame_data(
x <- tibble::tribble(
~ chrom, ~ start, ~ end,
"chr1", 5, 15,
"chr1", 50, 150,
"chr2", 1000, 2000,
"chr3", 3000, 4000
)

y <- tibble::frame_data(
y <- tibble::tribble(
~ chrom, ~ start, ~ end,
"chr1", 25, 125,
"chr1", 150, 250,
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_glyph.r
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test_that("glyphs are rendered", {
})

test_that("glyph labels are applied", {
res <- bed_glyph(bed_merge(x, id = n()), label = "id")
res <- bed_glyph(bed_merge(x, id = dplyr::n()), label = "id")
expect_equal(res$labels$label, "id")
})

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_groups.r
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ df_new <- structure(
)

test_that("old dataframe groupings (dplyr v. < 0.7.9.900) are tolerated", {

skip("no longer tolerated from dplyr 1.0.0")
if (packageVersion("dplyr") >= "0.7.9.9000"){
expect_warning(bed_intersect(df_old, df_old))
res <- suppressWarnings(bed_intersect(df_old, df_old))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_intersect.r
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ test_that("unmatched groups are included when invert = TRUE", {
)

res <- bed_intersect(x, y, invert = TRUE)
expect_equal(res, pred)
expect_equivalent(res, pred)
})

# from https://github.com/arq5x/bedtools2/blob/master/test/intersect/test-intersect.sh
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_map.r
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ test_that("book-ended intervals are not reported", {
"chr1", 100, 200, 10
)
res <- bed_map(x, y, value = sum(value))
expect_equal(res, expected)
expect_equivalent(res, expected)
})

test_that("ensure that mapping is calculated with respect to input tbls issue#108", {
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test_partition.r
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test_that("basic partition works (bedops partition1 test)", {
)

res <- bed_partition(x)
expect_equal(res, pred)
expect_equivalent(res, pred)
})


Expand Down Expand Up @@ -116,7 +116,7 @@ pred <- trbl_interval(
)

res <- bed_partition(x)
expect_equal(res, pred)
expect_equivalent(res, pred)
})


Expand Down Expand Up @@ -146,7 +146,7 @@ test_that("partition drops non-grouped cols (bedops partition3 test)", {
)

res <- bed_partition(x)
expect_equal(res, pred)
expect_equivalent(res, pred)
})


Expand Down Expand Up @@ -179,7 +179,7 @@ test_that("partition drops non-grouped cols (bedops partition4 test)", {
)

res <- bed_partition(x)
expect_equal(res, pred)
expect_equivalent(res, pred)
})


Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_sort.r
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ test_that("ties in start are sorted by end", {
)

res <- bed_sort(x)
expect_equal(res, pred)
expect_equivalent(res, pred)
})

# from https://github.com/arq5x/bedtools2/blob/master/test/sort/test-sort.sh
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_subtract.r
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ test_that("test baseline subtraction", {
"chr1", 50, 70, "a2", 2, "-"
)
res <- bed_subtract(a, b)
expect_equal(res, c)
expect_equivalent(res, c)
})

test_that("test any = TRUE subtraction", {
Expand All @@ -201,5 +201,5 @@ test_that("test with 2 DBs", {
"chr1", 65, 70, "a2", 2, "-"
)
res <- bed_subtract(bed_subtract(a, b), b2)
expect_equal(res, c)
expect_equivalent(res, c)
})