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

Passing grouping variables to bed_map #20

Closed
jayhesselberth opened this issue Apr 27, 2016 · 2 comments
Closed

Passing grouping variables to bed_map #20

jayhesselberth opened this issue Apr 27, 2016 · 2 comments

Comments

@jayhesselberth
Copy link
Member

Need a way to pass grouping variables to bed_map, e.g., window intervals from makewindows:

tss_intervals %>%
  bed_flank(size = 1000) %>%
  bed_makewindows(win_size = 50, win_id = 'num') %>%
  bed_map(chip_signal, groups = .win_id, sum = sum(value))

bed_map <- function(..., groups, ...) {
  res <- bed_intersect(bed_tbl, signal_tbl, suffix_y = '') %>%
    group_by_(groups) %>%
    summarize_(.dots = lazyeval::lazy_dots(...)) %>%
    rename(start = start.x, end = end.x)
}

Need more flexible way to specific default grouping by chrom, start.x, end.x. Maybe have a unique ID for each intersection and group_by that?

@jayhesselberth
Copy link
Member Author

jayhesselberth commented Apr 27, 2016

This is one approach, need to propagate groupings in bed_map:

bed_makewindows(win_size = 50, win_id = 'num') %>%
group_by(win_id) %>%
bed_map(chip_signal, sum = sum(value))

Alternatively

bed_makewindows(win_size = 50, win_id = 'num') %>%
bed_map(chip_signal, map_value = sum(value)) %>%
group_by(win_id) %>%
summarize(signal_mean = mean(map_value), signal_var = var(map_value)

I favor the second one as it's closer to the original. But this is currently broken as win_id will have a .y suffix from bed_intersect. This seems to be a recurring problem. One solution would be to only suffix the start and end colnames in bed_intersect.

@jayhesselberth
Copy link
Member Author

closed by e809ea2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant