22# ' @param gr A GRanges object with exon annotations, including 'tx_id', 'exon',
33# ' and 'coef_col' metadata columns and preprocessed with preprocess_input().
44# ' @param type The type of overlap to consider when identifying skipped exons.
5+ # ' @param inverse If TRUE, identifies included exons instead of skipped exons.
56# ' @return A GRanges object with an additional 'event' metadata column indicating skipped exons.
67# ' @export
7- calc_skipped_exons <- function (gr , type = c(" over " ," in " , " boundary " ) ) {
8+ calc_skipped_exons <- function (gr , type = c(" boundary " ," over " , " in " ), inverse = FALSE ) {
89 type <- match.arg(type )
910 # if preprocessing didn't happen
1011 check_preprocessed(gr )
1112
13+ if (inverse ) {
14+ gr <- gr | > dplyr :: mutate(estimates = - estimates )
15+ event_name <- " included_exon"
16+ } else {
17+ event_name <- " skipped_exon"
18+ }
19+
1220 # separate positive and negative exons
1321 pos_exons <- gr | > dplyr :: filter(sign(estimates ) == 1 )
1422 neg_exons <- gr | > dplyr :: filter(sign(estimates ) == - 1 )
@@ -76,7 +84,7 @@ calc_skipped_exons <- function(gr, type = c("over","in", "boundary")) {
7684 # build result tibble: one row per (candidate, tx_event) pair
7785 hits_tbl <- cand_tbl [pairs $ cand_idx , ] | >
7886 dplyr :: mutate(
79- event = " skipped_exon " ,
87+ event = event_name ,
8088 tx_event = pairs $ tx_id
8189 )
8290
@@ -89,6 +97,16 @@ calc_skipped_exons <- function(gr, type = c("over","in", "boundary")) {
8997 )
9098}
9199
100+ # ' Calculate included exons from a GRanges object
101+ # ' @param gr A GRanges object with exon annotations, including 'tx_id', 'exon',
102+ # ' and 'coef_col' metadata columns and preprocessed with preprocess_input().
103+ # ' @param type The type of overlap to consider when identifying included exons.
104+ # ' @return A GRanges object with an additional 'event' metadata column indicating included exons.
105+ # ' @export
106+ calc_included_exons <- function (gr , type = c(" boundary" ," over" ," in" )) {
107+ calc_skipped_exons(gr , type , inverse = TRUE )
108+ }
109+
92110# ' Calculate mutually exclusive exons from a GRanges object
93111# ' @param gr A GRanges object with exon annotations, including 'tx_id', 'exon',
94112# ' and 'coef_col' metadata columns and preprocessed with preprocess_input().
0 commit comments