Skip to content

Commit

Permalink
Make same changes as in fuzzyjoin
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Aug 6, 2019
1 parent d6774c6 commit 655c44d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions R/intersect.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ genome_intersect <- function(x, y, by=NULL, mode= "both"){
# nest around the chromosome column
x$..index <- seq_len(nrow(x))
y$..index <- seq_len(nrow(y))
nested_x <- tidyr::nest_(x, "x_data", colnames(x)[-1])
nested_y <- tidyr::nest_(y, "y_data", colnames(y)[-1])
nested_x <- dplyr::group_by_at(x, 1) %>% tidyr::nest()
nested_y <- dplyr::group_by_at(y, 1) %>% tidyr::nest()
by <- c(colnames(nested_y)[1])
names(by) <- colnames(nested_x)[1]

Expand All @@ -82,7 +82,7 @@ genome_intersect <- function(x, y, by=NULL, mode= "both"){
..start=IRanges::start(intersection), ..end=IRanges::end(intersection))
}

ret <- purrr::map2_df(joined$x_data, joined$y_data, find_overlaps)
ret <- purrr::map2_df(joined$data.x, joined$data.y, find_overlaps)
ret
}

Expand Down
7 changes: 4 additions & 3 deletions R/join_closest.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ genome_join_closest <- function(x, y, by=NULL, mode = "inner",
# nest around the chromosome column
x$..index <- seq_len(nrow(x))
y$..index <- seq_len(nrow(y))
nested_x <- tidyr::nest_(x, "x_data", colnames(x)[-1])
nested_y <- tidyr::nest_(y, "y_data", colnames(y)[-1])

nested_x <- dplyr::group_by_at(x, 1) %>% tidyr::nest()
nested_y <- dplyr::group_by_at(y, 1) %>% tidyr::nest()
by <- c(colnames(nested_y)[1])
names(by) <- colnames(nested_x)[1]

Expand All @@ -69,7 +70,7 @@ genome_join_closest <- function(x, y, by=NULL, mode = "inner",
dplyr::filter(`..distance` < max_distance)
}

ret <- purrr::map2_df(joined$x_data, joined$y_data, find_closest)
ret <- purrr::map2_df(joined$data.x, joined$data.y, find_closest)

if(! is.null(distance_column_name)){
ret[[distance_column_name]] <- ret$..distance
Expand Down
6 changes: 3 additions & 3 deletions R/subtract.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ genome_subtract <- function(x, y, by=NULL){
# nest around the chromosome column
x$..index <- seq_len(nrow(x))
y$..index <- seq_len(nrow(y))
nested_x <- tidyr::nest_(x, "x_data", colnames(x)[-1])
nested_y <- tidyr::nest_(y, "y_data", colnames(y)[-1])
nested_x <- dplyr::group_by_at(x, 1) %>% tidyr::nest()
nested_y <- dplyr::group_by_at(y, 1) %>% tidyr::nest()
by <- c(colnames(nested_y)[1])
names(by) <- colnames(nested_x)[1]

Expand All @@ -74,7 +74,7 @@ genome_subtract <- function(x, y, by=NULL){
..end=pmin(IRanges::end(subtraction)[o$queryHits], IRanges::end(r1)[o$subjectHits]))
}

ret <- purrr::map2_df(joined$x_data, joined$y_data, find_subtractions)
ret <- purrr::map2_df(joined$data.x, joined$data.y, find_subtractions)
ret
}

Expand Down

0 comments on commit 655c44d

Please sign in to comment.