knitr::opts_chunk$set(warning = FALSE, message = FALSE, eval = TRUE, results = "hide", fig.align="center")

````{=html}

## Introduction

Trajectory analysis is a technique to determine pattern of dynamic process experienced by cells and then arrange cells as per their progression. Trajectory is a path through high dimensional expression space that traverses various cellular states associated with a process like differentiation.

There are multiple algorithms to implement trajectory analysis, however currently Single Cell Toolkit (SCTK) only provides methods from TSCAN [@Ji2016]. SCTK basically wraps three types of analysis from TSCAN:

1. Calculate MST and determine the trajectory as the longest connected path of the MST. The TSCAN MST calculation is cluster based, thus cluster assignment of cells is required. See [Clustering Documentation](clustering.html). For the computation efficiency, a low-dimensional representation of the dataset is also required for the trajectory and pseudotime calculation. See [Dimensionality Reduction Documentation](dimensionality_reduction.html). For the visualization of trajectory paths projected on cells, we recommend generating UMAP embedding, as it gives a better presentation of the global structure than TSNE. See [2D Embedding Documentation](2d_embedding.html).
2. Identify features with significant changes along one pseudotime path. TSCAN fits a natural spline to the expression of each feature, and performs an ANOVA test to determine if there is some significant trend with respect to the pseudotime. Step 1 is required to provide the pseudotime path. 
3. Identify features with significant changes between paths. TSCAN sets the branch point of interest as a root, recomputes pseudotime for paths rooting from here, finds significant features changing on each path, and finally identifies path specific features. This is most interesting for cells close to the branch point and identified features might be responsible for the branching event. The general strategy here is to fit a trend to each path, followed by a comparison of the fits between paths. Step 1 is required to provide the pseudotime paths. 

More detailed instructions on how to use TSCAN approach either through the Shiny UI application (select "Interactive Analysis") or through the R console (select "Console Analysis") are described below:

## Workflow Guide

````{=html}
<div class="tab">
  <button class="tablinks" onclick="openTab(event, 'interactive')" id="ia-button">Interactive Analysis</button>
  <button class="tablinks" onclick="openTab(event, 'console')" id="console-button">Console Analysis</button>
</div>

<div id="interactive" class="tabcontent">

Entry of the Panel

From anywhere of the UI, the panel for TSCAN trajectory analysis can be accessed from the top navigation panel at "Trajectory Analysis" and then select "TSCAN".

Entry\

Calculate Pseudotime Values

The UI is constructed in a sidebar style, where the left-sided sidebar works for setting the parameters and running the TSCAN, and the right part main panel is for visualization.

For finding the MST trajectory and estimating pseudotime, there are always two essential inputs that users should make selection:

After the parameters are set, press button "Run" to start the calculation. When the process is successfully done, a scatter plot of cells colored with pseudotime, with the trajectory projected to the coordinates, will be shown on the right. By default SCTK UI use the input dimension reduction for visualization. Users can change it to a UMAP embedding with the option "Select 2D embedding for visualization" in the dropdown box.

step1\

Identify Genes Differentially Expressed For Path

For identifying DE genes for path, users must have run the trajectory construction in the first step. There are two essential inputs that users should be aware of:

During the analysis, users might found some cell population with features dominating the set of DE features and mask other interesting effects. To exclude the cluster(s) of them in the test, users can make selection in "Select cluster(s) to discard (OPTIONAL)".

After these parameters are set, press button "Run" to start the test. Visualization will be shown on the right after running. To present the features the UI has 3 visualization tabs:

````{=html}

Visualization setting

With options in the dropdown box, Users can: 

- Choose to show results for a different path (must run the test first) at **"Select path terminal node"**
- Change the number of top features in each regulation direction to be shown in the heatmap at **"Number of top features for heatmap"**
- Change the number of top features to be shown in the scatter plot at **"Number of top features for regulation plots"**
- Change the displayed feature ID type at **"Display ID Type"**. This can also be set globally at [Import Single Cell Data](import_data.html) tab. 

````{=html}
</details>

step2\

Identify Genes Differentially Expressed For Branched Cluster

For identifying DE features on branches rooting from a cluster, users must have run the trajectory construction in the first step. there are always two essential inputs that users should make selection:

  • "Select branched cluster of interest" - The cluster of interest, where branches exist. Only clusters that are connected to at least 2 other clusters (degree >= 2) are listed as options. Users can go back to step 1 to determine the branch point of interest.
  • "Select assay" - The expression matrix to use for testing the expression change. Here a log-normalized matrix is recommended.

Optionally, users can also tweak the filter on output result by setting FDR cutoff at the numeric input "FDR less than". This will rule out DE features with FDR (false discovery rate) value greater than the cutoff.

After these parameters are set, press button "Run" to start the test. Visualization will be shown on the right after the test is successfully done. To present the results, the UI has three tabs:

  • Top Feature Plot - The UI will select the top features on one of the branch derived from the cluster of interest, and create embedding plots of cells in the cluster to show the exprssion of these features.
  • "Top Feature Table" - A data table of the stats of the top features on one of the branch derived from the cluster of interest will be shown here.
  • "Pseudotime" - The recomputed pseudotime for each branch rooting from the cluster of interest will be shown on the embedding plots with only cells in the cluster.

````{=html}

Visualization setting

With options in the dropdown box, Users can: 

- Choose to show results for a different branch point/cluster (must run the test first) at **"Select branched cluster of interest"**.
- Choose to show results on a specific branch derived from the cluster selected at **"Select Path Index"**. Branches are listed in the format of `{terminal node of the path}|{all nodes on the path from the cluster to the terminal}`.
- Choose to plot feature expression/pseudotime on a different dimension reduction/2D embedding at **"Select 2D embedding for visualization"**.
- Change the number of top features to be shown in **Top Feature Plot** tab, at **"Number of top features to plot"**
- Change the displayed feature ID type at **"Display ID Type"**. This can also be set globally at [Import Single Cell Data](import_data.html) tab. 

````{=html}
</details>

step3\

Plot expression of individual genes

This section allows users to visualize the expression of any features of interest. Each point is a cell colored by the expression of a gene of interest and the relevant edges of the MST are overlaid on top. As for the inputs:

  • "Select assay" - The expression matrix to use for finding the features' expression value.
  • "Selec features" - Users can select as many features of interest as possible. Too many might squeeze the plot in the limited area of the UI.
  • "Select 2D embedding for visualization" - The low-dimensional representation to use.
  • "Show cluster(s) of interest" - By default, SCTK plots the feature expression in all cells. When there's only a subset of cells that should be highlighted, users can choose the cluster(s) containing the here. The MST edges connected to selected clusters will also be subsetted.
  • "Display ID Type" - Change the displayed feature ID type. This can also be set globally at Import Single Cell Data tab.

Entry\

````{=html}

wzxhzdk:4 To demonstrate simple and clear examples, here we use the PBMC 3K dataset from 10X, which is available with `importExampleData()` function. Necessary steps for getting a PCA, a UMAP and the cluster assignment are presented, while QC and filtering steps are skipped. ```{R tscan_prep, eval = FALSE} library(singleCellTK) sce <- importExampleData("pbmc3k") sce <- runPerCellQC(sce, mitoRef = "human", mitoIDType = "symbol", mitoGeneLocation = "rownames") sce <- subsetSCECols(sce, colData = c('total > 600', 'detected > 300', 'mito_percent < 5')) sce <- scaterlogNormCounts(sce, useAssay = "counts", assayName = "logcounts") sce <- runModelGeneVar(sce, useAssay = "logcounts") sce <- setTopHVG(sce, method = "modelGeneVar") # Values required as input sce <- scaterPCA(inSCE = sce, useAssay = "logcounts", useFeatureSubset = "HVG_modelGeneVar2000", reducedDimName = "PCA", seed = 12345) sce <- runScranSNN(sce, useReducedDim = "PCA", nComp = 10, k = 14, weightType = "jaccard", clusterName = "cluster", seed = 12345) # Values needed for visualization sce <- runUMAP(sce, useReducedDim = "PCA", initialDims = 10, reducedDimName = "UMAP", seed = 12345) wzxhzdk:5 And we can visualize the cell populations on the UMAP with cluster labeled. ```{R tscan_prep_plot, results = "hide"} plotSCEDimReduceColData(sce, colorBy = "cluster", reducedDimName = "UMAP") wzxhzdk:6 To see how the trajectory paths span across the cell population, SCTK provides `plotTSCANResults()` function which project the MST on to the embedding. ```{R plotTSCANResults} plotTSCANResults(sce, useReducedDim = "UMAP") wzxhzdk:7 Two visualization methods are provided. One is a heatmap of the expression of features significantly changed on the path of interest, in the cells involved in this path. Another groups scatter plots of cells with top feature expression change along the path. ```{R plotTSCANDEG} plotTSCANPseudotimeHeatmap(sce, pathIndex = 7) plotTSCANPseudotimeGenes(sce, pathIndex = 7, direction = "increasing") wzxhzdk:8 We can explore the features significantly changes on a specific branch in the approaches below. For visualization method in this step, argument `useCluster` is used to specify the cluster used in the calculation above, and argument `pathIndex` is used for specifying the branch of interest. Valid path indices can be listed with `names(getTSCANResults(sce, "ClusterDEAnalysis", "3")$DEgenes)`, where `"3"` corresponds to `useCluster` in the calculation above. ```{R plotTSCANClusterDE} plotTSCANClusterDEG(sce, useCluster = 3, pathIndex = 6, useReducedDim = "UMAP", topN = 4) wzxhzdk:9 The table from the branch, of which we just visualized the top feature expression, looks like: ```{R tscanClusterDETable2, results = "markup"} tableList$`6` wzxhzdk:10 ````{=html} wzxhzdk:11 ## References

compbiomed/singleCellTK documentation built on May 8, 2024, 6:58 p.m.