This article demonstrates the visualization tools in seuratTools. We'll introduce included functions, their usage, and resulting plots

knitr::opts_chunk$set(
    collapse = TRUE,
    comment = "#>",
    # dev.args = list(png = list(type = "cairo")),
    dpi = 900,
    out.width = "100%",
    fig.width = 10,
    fig.height = 6,
    message = FALSE,
    warning = FALSE
)

library(xfun)

format_table <- function(mydf) {
    mydf %>%
        kableExtra::kbl() %>%
        kable_paper() %>%
        scroll_box(width = "700px", height = "200px")
}

First step is to load seuratTools package and all other packages required

library(seuratTools)
library(Seurat)
library(tidyverse)
library(ggraph)
library(patchwork)
human_gene_transcript_seu <- RunUMAP(human_gene_transcript_seu, dims = 1:30)

seuratTools contains many plotting functions that allows for visualization, these plots can be customized for interactive or non-interactive display.

Plot expression

Expression of one or more features (genes or transcripts) can be plotted on a given embedding, resulting in an interactive, single or multi-feature plot.

When plotting only one feature, output is identical to Seurat::FeaturePlot

plot_feature(human_gene_transcript_seu,
    embedding = "umap",
    features = "NRL", return_plotly = FALSE
)

An interactive output plot can be generated by specifying return_plotly = TRUE which uses ggplotly allowing identification of individual cells for further investigation.

Plot read count or other QC measurements

The plot_readcount function displays a histogram of cell read counts colored according to a categorical variable using the argument color.by. Here we can see that read counts for this dataset are not distinctly different depending on the method of organoid preparation used (Kuwahara or Zhong)

plot_readcount(human_gene_transcript_seu,
    metavar = "nCount_RNA",
    color.by = "Prep.Method"
)

Plot

seuratTools contains a function that produces an interactive scatter plot of a metadata variable, where each point in the plot represents a cell whose position on the plot is given by the cell embedding determined by the dimensional reduction technique. The default dimension reduction used is "UMAP". The group argument in plot_var() function allows the user to enter the metadata variable by which to group the cells by, its default value is set to "batch".

plot_var(human_gene_transcript_seu, group = "type", embedding = "umap")

This function utilizes a Seurat function, DimPlot(), as sub function which produces the dimensional reduction plot.The interactive parameter, return_plotly, in plot_var when set to TRUE will convert the plot into an interactive plot using ggplotly function from R's plotly package

Plot cluster marker genes

Marker genes of louvain clusters or additional experimental metadata can be plotted using plot_markers. This allows visualization of n marker features grouped by the metadata of interest. Marker genes are identified using wilcoxon rank-sum test as implemented in presto. In the resulting dot plot the size of the dot corresponds to the percentage of cells expressing the feature in each cluster and the color represents the average expression level of the feature.

plot_markers(human_gene_transcript_seu,
    metavar = "gene_snn_res.0.2",
    marker_method = "presto"
)

Violin plot

To visualize the distribution of expression level of a feature in different groups of cells seuratTools draws a violin plot. This function uses Seurat's VInPlot() function as a sub-function to create the violin plot, where the metadata variable, provided to the function through the variable plot_var, is used to group the cells and based on the level of feature expression a violin plot is produced.

plot_violin(human_gene_transcript_seu, plot_var = "type", features = "NRL")

Ploting all transcripts

This function plots the expression level of all the transcripts present in a given Seurat object, coding for a feature/gene of interest. The gene of interest is specified by the argument 'features' and by default the data is superimposed on UMAP embedding.

plot_all_transcripts(human_gene_transcript_seu, features = "NRL")

Ploting transcrpit composition

This seuratTools function produces a visual representation of the expression levels of each transcript in a gene map. The function plot_transcript_composition() plots the proportion of reads of a given gene map to each transcript. The gene of interest is specified by the argument 'gene_symbol'.

plot_transcript_composition(human_gene_transcript_seu, "NRL",
    group.by = "gene_snn_res.0.2", standardize = TRUE
)

Ploting ridge plots for cell cycle scoring

The plot_ridge() function in seuratTools plots a ridge plot for cell cycle scoring of a feature, providing a visual representation of expression level of the feature in each cell cycle. This function uses two embedded Seurat functions. The function CellCycleScoring() assigns each cell a score based on its expression of G2/M and S phase markers. This data is then used by the function, RidgePlot(), which uses user provided 'features' argument to plot the ridge plot of the features.

plot_cell_cycle_distribution(human_gene_transcript_seu, "NRL")

plot_cell_cycle_distribution(human_gene_transcript_seu, "nFeature_RNA")

Plot Complex heatmap from Seurat object

The seuratTools function plots an annotated complex heat map from the Seurat object with a dendogram added to the left side and the top.

top_10_features <- VariableFeatures(human_gene_transcript_seu)[1:10]

seu_complex_heatmap(human_gene_transcript_seu,
    features = top_10_features,
    group.by = "gene_snn_res.0.2"
)
seu_complex_heatmap(human_gene_transcript_seu,
    features = top_10_features,
    group.by = "gene_snn_res.0.2", col_arrangement = "average"
)
seu_complex_heatmap(human_gene_transcript_seu,
    features = top_10_features,
    group.by = c("Prep.Method", "gene_snn_res.0.2"),
    col_arrangement = "gene_snn_res.0.2"
)
seu_complex_heatmap(human_gene_transcript_seu,
    features = top_10_features,
    group.by = c("Prep.Method", "gene_snn_res.0.2"),
    col_arrangement = "Prep.Method"
)


whtns/seuratTools documentation built on June 28, 2024, 8:30 p.m.