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".
\
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:
"Select input dimension reduction" - Used for specifying which low-dimensional representation to be used for MST construction.
"Select clustering result:" - Used for specifying which cluster assignment variable in cell metadata should be used for MST construction. When selecting "Auto generate cluster", the UI will automatically run scran-SNN based Louvain clustering on the specified dimension reduction, and use this cluster assignment as the guide for MST construction.
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.
\
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:
{terminal node of the path}|{all nodes on the path}
(a node is a cluster). Users can go back to the first collapse box and easily see where each path is.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>
\
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:
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:
````{=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>
\
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:
\
````{=html}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.