plot_corr_gene_expr_psi: Plot a gene expression vs an alternatively spliced event PSI...

View source: R/vst_plot.R

plot_corr_gene_expr_psiR Documentation

Plot a gene expression vs an alternatively spliced event PSI ( 1 vs 1)

Description

Plot gene expression on X-axis vs AS event PSI on Y-axis and calculate correlation between samples.

Usage

plot_corr_gene_expr_psi(
  data,
  quality_thrshld = "N",
  external_gene_name,
  vst_id,
  unit,
  log_expr = FALSE,
  text = FALSE,
  text_size = 10,
  label_size = 3,
  beautify = FALSE,
  xzero = TRUE,
  colour = c("score", "PSI"),
  save_plot = FALSE,
  out_plot_dir,
  verbose = TRUE,
  return_data = FALSE,
  subttl = NULL
)

Arguments

data

A data.frame with these column names: "Quality_Score_Value", "Gene_Expr", "PSI", "GENE", and "Sample". Header is case-sensitive.

quality_thrshld

vast-tools event quantification quality score threshold. Must be one of "N", "VLOW", "LOW", "OK", "SOK". For more info read the official documentation here under "Column 8, score 1".

external_gene_name

An ensembl-gene-name.

vst_id

vast-tools AS event ID.

unit

Was the vast-tools gene expression quantified in cRPKMs or TPMs?

log_expr

Logical. Should gene expression values on the X-axis be log2 transformed before calculating the correlations and plotting the data? Default FALSE. This influences only the Pearson (r) correlation, the other 3 are unaffected.

text

Logical. Do you want to label the point in the plot. Uses ggrepel. Default FALSE.

text_size

Number How big should the text be? Default is 8.

label_size

Number How big should the label text be? Default is 2.5.

beautify

Remove pre-fixed or post-fixes from sample names. Kinda experimental.

xzero

Logical. Should x-axis start from zero?

colour

Either 'score' or 'PSI' to indicate if the points should be coloured by the AS event score (see quality_thrshld) or the PSI level.

save_plot

Logical. Do you wanna save the plot to pdf? Uses Cairo as device.

out_plot_dir

Path specifing location where to save the plot pdf.

verbose

Lofical, print info on correlation.

return_data

Logical. Do not plot the data but just return the data used to plot. Default FALSE.

subttl

Character string in case you wanna add some info to the subtitle. For example one could specify the type of cell line or tissue.

Details

The plot title reports the correlation values of the:

  • Spearman's rho

  • Pearson's r

  • Kendall's tau

  • Chatterjee's xi

Value

A ggplot2 plot or a data.frame.

Examples

# 1. Get PSI values
grep_psi(inclusion_tbl = psi_tbl_path, vst_id = "HsaEX0000001") |>
       tidy_vst_psi() -> psi_tbl
       
# 2. Get gene expression values
grep_gene_expression(vst_expression_tbl = expression_tbl_path,
                     ensembl_gene_id = gene_name ) |>
    tidy_vst_expr() |>
# 3. Join gene expression table to PSI table
left_join(psi_tbl, by = "Sample") |> 
# 4. Calculate correlations and plot
plot_corr_gene_expr_psi(external_gene_name = gene_name, unit = "TPM",
                        vst_id = "HsaEX0000001", text = TRUE,
                        beautify = TRUE, xzero = FALSE, verbose = FALSE,
                        subttl = "A great subtitle", 
                        out_plot_dir = path_out, save_plot = TRUE)  


Ni-Ar/niar documentation built on Feb. 3, 2025, 9:25 a.m.