Skip to main content

5  Post DTU Analysis

In this chapter, we show how to explore the results from the DTU analysis performed using satuRn (see Statistical testing chapter).

Load needed objects computed in Statistical testing chapter

library(here)
library(SummarizedExperiment)
# Load SummarizeExperiment with DTU results
se <- readRDS(here::here("data", "glinos_saturn_dtu.rds"))
# Load exons 
exons <- readRDS(here::here("data", "glinos_exons.rds")) 

Extract test results

sig_res <- rowData(se)[["fitDTUResult_WT_vs_KD"]] |>
  tibble::as_tibble() |>
  dplyr::bind_cols(as.data.frame(rowData(se)[,1:4])) |>
  dplyr::filter(empirical_FDR < .1) |>
  dplyr::select(gene_id, isoform_id, symbol, estimates, empirical_pval, empirical_FDR) |>
  dplyr::arrange(empirical_pval)

sig_res

Obtain a GRanges of all the exons present in significant DTU. First, we flatten-out the GRangesList of all the transcripts and include a column to identify if an exon is internal (i.e. is not the first or last in the isoform) or not.

library(plyranges)

flat_exons <- unlist(exons) #GRanges

#include 'isoform_id' column 
flat_exons$isoform_id <- names(flat_exons)

#include 'internal' column
tab <- table(flat_exons$isoform_id)
flat_exons <- flat_exons |> 
                      mutate(
                        nexons = tab[isoform_id], 
                        internal = exon_rank > 1 & exon_rank < nexons
                      )
flat_exons 

To perform exon-level detection events, we include a metadata column that will tell us if a given exon has a - or + coefficient (from satuRn analysis).

#filter to keep only significant DTU transcripts 
flat_sig_exons <- flat_exons |>
                       filter( isoform_id %in% sig_res$isoform_id)

#include coef +/- column from the DTU analysis saturn 
flat_sig_exons$coef <- sig_res$estimates[match(names(flat_sig_exons), sig_res$isoform_id)]
flat_sig_exons$sign <- sign(flat_sig_exons$coef)

#include gene symbol for each transcript name 
flat_sig_exons$symbol <- sig_res$symbol[match(names(flat_sig_exons), sig_res$isoform_id)]

flat_sig_exons

5.1 Detect skipped-exon events

We are looking to detect exons that were skipped-out due to PTBP1 (down-regulated exons). A transcript with a positive coefficient will be more likely to be expressed when the protein is abundant, and a transcript with a negative coefficient will be less likely to be expressed when the protein is abundant.

Exons that appear in transcripts with negative coefficients and that do not appear in transcripts with positive coefficients may be down-regulated by the protein.

We want to get exons that are present in the KD condition (sign -1) that are not present in the WD condition (sign -1)

library(dplyr)
flat_sig_exons <- flat_sig_exons |>
    dplyr::mutate(key = paste0(isoform_id, "-", exon_rank))

# 1) split + vs – coef sign
pos_exons  <- flat_sig_exons |> filter(sign ==  1)
neg_exons <- flat_sig_exons |> filter(sign ==  -1)

# 2) filter non overlaps 
downreg_candidates <- neg_exons |>
  filter_by_non_overlaps_directed(pos_exons) |>
  mutate(SE = TRUE) |>
  filter(internal == TRUE)

# 3) detect left and right exons from candidates
left_keys <- paste0(downreg_candidates$isoform_id, "-", 
                    downreg_candidates$exon_rank-1)
left_exons <- flat_sig_exons |>
  filter(key %in% left_keys)

right_keys <- paste0(downreg_candidates$isoform_id, "-", 
                     downreg_candidates$exon_rank+1)
right_exons <- flat_sig_exons |>
  filter(key %in% right_keys)

# 4) filter in candidates with left and right present in pos_exons
downreg_candidates <-  downreg_candidates |>
  mutate(left_and_right =
                 left_exons %in% pos_exons &
                 right_exons %in% pos_exons
  )
downreg_exons  <- downreg_candidates |> filter(left_and_right == TRUE)

# summary
length(downreg_exons) # n of spliced exons 
length(unique(downreg_exons$symbol)) # n of dif genes

List of genes that had skipped-exon events

downreg_exons$symbol |> unique()

5.2 Analyse upstream regions of the down-regulated exons

We know that PTPB1 binds to intronic regions upstream to the skipped exons, regions 15-20 rich in U and C.
With the selected down-regulated exon candidates, we can analyze their upstream region and study their bp composition to look for PTPB1 signals.

Get upstream sequences.

library(Biostrings)
library(BSgenome.Hsapiens.UCSC.hg38)

#get ranges of 100bp upstream region
width_upstream <- 100
upstr_downreg_exons <- downreg_exons |>  #GRanges
        flank_upstream(width = width_upstream) 

# get sequence from GRanges 
seq_downreg_exons <-  Hsapiens |>  ## RNAStringSet object
                       getSeq(upstr_downreg_exons) |>
                       RNAStringSet() 

seq_downreg_exons

Create ranges using sliding window of with 10 with 5 bp overlap

window_width <- 10
overlap <- 5
step <-  window_width - overlap 
n_windows <- ceiling((width_upstream - window_width) / step) + 1

# create GRanges with the defined window ranges
windows <- upstr_downreg_exons |> slide_ranges( width = window_width,  # GRanges
                                         step = step) # divide into windows
windows |> as_tibble()

Get the sequence for each window

seq_windows <-  Hsapiens |>
  getSeq(windows) |>
  RNAStringSet()  # RNAStringSet
# The RNAStringSet result has n_windows * (# of exons) rows.
head(seq_windows)

Calculate the oligonucleotide frequency (A/C/G/U) per window

bp_counts <- oligonucleotideFrequency(seq_windows, 
                                      width = 1) #1-mer
windows_bp <- bp_counts / rowSums(bp_counts)
windows_bp |> as_tibble()

5.3 Run SPLain app

SPLain is a Shiny app that allows the exploration and visualization of DTU results. You can find the repository at https://github.com/beamimc/SPLain, and follow the installation instructions. Basically, we need to clone the repo and call the app providing the path of the cloned repo.

splain_path <- "your_path/SPLain" # path to dir with the cloned SPLain repo
app_dir <- file.path(splain_path, "app")

# load the SPLain app 
source(file.path(app_dir, "app.R"))

# Run the Shiny app with your data and app directory
shiny::runApp(
  app(
    se = se,
    exons = exons,
    app_dir = app_dir
  )
)