Skip to content

Commit

Permalink
doc: include group_by/summarize in vignette/README
Browse files Browse the repository at this point in the history
  • Loading branch information
js2264 committed Sep 6, 2023
1 parent a8a84aa commit 63f07b7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and [`rlang`](https://rlang.r-lib.org/).

The operations currently available for `GInteractions` objects are:

- Group genomic interactions with `group_by`;
- Summarize grouped genomic interactions with `summarize`;
- Modify genomic interactions with `mutate`;
- Subset genomic interactions with `filter` using
[`<data-masking>`](https://rlang.r-lib.org/reference/args_data_masking.html)
Expand Down
35 changes: 35 additions & 0 deletions vignettes/plyinteractions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,41 @@ gi |> mutate(both_chr = paste(seqnames1, seqnames2, sep = "_"))
gi |> mutate(start1 = 1)
```

### Grouping columns

`group_by` supports accessing both core and metadata columns:

```{r}
gi |> group_by(seqnames2)
gi |> group_by(cis = seqnames1 == seqnames2)
gi |> group_by(seqnames2, cis = seqnames1 == seqnames2)
```

### Summarizing columns

Summarizing grouped GInteractions can be extremely powerful.

```{r}
pairs_file <- HiContactsData::HiContactsData('yeast_wt', 'pairs.gz')
pairs_df <- read.delim(pairs_file, sep = "\t", header = FALSE, comment.char = "#")
head(pairs_df)
pairs <- as_ginteractions(pairs_df,
seqnames1 = V2, start1 = V3, strand1 = V6,
seqnames2 = V4, start2 = V5, strand2 = V7,
width1 = 1, width2 = 1,
keep.extra.columns = FALSE
)
pairs
pairs |> group_by(same_strand = strand1 == strand2) |>
summarize(
neg_strand = sum(strand1 == "-"),
pos_strand = sum(strand1 == "+")
)
```

### Filtering columns

`filter` supports logical expressions:
Expand Down

0 comments on commit 63f07b7

Please sign in to comment.