## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(SpliceImpactR)
BiocParallel::register(BiocParallel::SerialParam())

## ----bundled-inputs-----------------------------------------------------------
ex <- load_example_data(c("sample_frame", "annotation_df", "exon_features", "ppi"))
annotation_df <- ex$annotation_df
protein_feature_total <- ex$protein_feature_total
exon_features <- ex$exon_features
ppi <- ex$ppi
data <- get_rmats_hit(ex$sample_frame)
res <- get_differential_inclusion(
  data, parallel_glm = FALSE,
  BPPARAM = BiocParallel::SerialParam(), verbose = FALSE
)
res_di <- keep_sig_pairs(res)

## ----standalone---------------------------------------------------------------
ranked <- get_ranked_pairs(
  res_di, annotation_df$annotations, annotation_df$sequences,
  source = "multi", verbose = FALSE
)
names(ranked)
# ranked$pairs: selected pairs, ready for downstream functions
# ranked$rankings: every scored pair, all ranking components and ties
# ranked$candidates: every same-locus candidate, including rejection reasons
# ranked$pair_rejections: self-pairs, form-indistinguishable combinations and
#   approximate combinations without an event difference
# ranked$events: every input form, including forms without matches
# ranked$unmatched: form comparisons without a pair in any tier
# ranked$settings: protocol version and scoring parameters

seq_compare <- compare_sequence_frame(ranked$pairs, annotation_df$annotations)
hits_domain <- get_domains(seq_compare, exon_features)

## ----wrapper------------------------------------------------------------------
out <- get_splicing_impact(
  res = res,
  annotation_df = annotation_df,
  protein_feature_total = protein_feature_total,
  ppi = ppi,
  matching = "orf",
  debug_steps = TRUE,
  verbose = FALSE
)
names(out$matching)

## ----session-information------------------------------------------------------
sessionInfo()

