# NOT RUN {
set.seed(100)
df <- data.frame(start = 1:10,
width = 5,
seqnames = "seq1",
strand = sample(c("+", "-", "*"), 10, replace = TRUE),
gc = runif(10))
rng <- as_granges(df)
filter(rng, strand == "+")
filter(rng, gc > 0.5)
# multiple criteria
filter(rng, strand == "+" | start > 5)
filter(rng, strand == "+" & start > 5)
# multiple conditions are the same as and
filter(rng, strand == "+", start > 5)
# grouping acts on each subset of the data
rng %>%
group_by(strand) %>%
filter(gc > 0.5)
# }
Run the code above in your browser using DataLab