当前位置:   article > 正文

Chapter 10 Trajectory Analysis pseudotime analysis 拟时序分析_拟时序分析英文

拟时序分析英文

Chapter 10 Trajectory Analysis | Advanced Single-Cell Analysis with BioconductorChapter 10 Trajectory Analysis | Advanced Single-Cell Analysis with Bioconductorhttp://bioconductor.org/books/3.14/OSCA.advanced/trajectory-analysis.html

Chapter 10 Trajectory Analysis

10.1 Overview

Many biological processes manifest as a continuum of dynamic changes in the cellular state. The most obvious example is that of differentiation into increasingly specialized cell subtypes, but we might also consider phenomena like the cell cycle or immune cell activation that are accompanied by gradual changes in the cell’s transcriptome. We characterize these processes from single-cell expression data by identifying a “trajectory”, i.e., a path through the high-dimensional expression space that traverses the various cellular states associated with a continuous process like differentiation. In the simplest case, a trajectory will be a simple path from one point to another, but we can also observe more complex trajectories that branch to multiple endpoints.

The “pseudotime” is defined as the positioning of cells along the trajectory that quantifies the relative activity or progression of the underlying biological process. For example, the pseudotime for a differentiation trajectory might represent the degree of differentiation from a pluripotent cell to a terminal state where cells with larger pseudotime values are more differentiated. This metric allows us to tackle questions related to the global population structure in a more quantitative manner. The most common application is to fit models to gene expression against the pseudotime to identify the genes responsible for generating the trajectory in the first place, especially around interesting branch events.

In this section, we will demonstrate several different approaches to trajectory analysis using the haematopoietic stem cell (HSC) dataset from Nestorowa et al. (2016).

View set-up code (Workflow Chapter 10)

sce.nest
  1. ## class: SingleCellExperiment
  2. ## dim: 46078 1656
  3. ## metadata(0):
  4. ## assays(2): counts logcounts
  5. ## rownames(46078): ENSMUSG00000000001 ENSMUSG00000000003 ...
  6. ## ENSMUSG00000107391 ENSMUSG00000107392
  7. ## rowData names(3): GENEID SYMBOL SEQNAME
  8. ## colnames(1656): HSPC_025 HSPC_031 ... Prog_852 Prog_810
  9. ## colData names(4): cell.type FACS sizeFactor label
  10. ## reducedDimNames(3): diffusion PCA TSNE
  11. ## mainExpName: endogenous
  12. ## altExpNames(1): ERCC

10.2 Obtaining pseudotime orderings

10.2.1 Overview

The pseudotime is simply a number describing the relative position of a cell in the trajectory, where cells with larger values are consider to be “after” their counterparts with smaller values. Branched trajectories will typically be associated with multiple pseudotimes, one per path through the trajectory; these values are not usually comparable across paths. It is worth noting that “pseudotime” is a rather unfortunate term as it may not have much to do with real-life time. For example, one can imagine a continuum of stress states where cells move in either direction (or not) over time but the pseudotime simply describes the transition from one end of the continuum to the other. In trajectories describing time-dependent processes like differentiation, a cell’s pseudotime value may be used as a proxy for its relative age, but only if directionality can be inferred (see Section 10.4).

The big question is how to identify the trajectory from high-dimensional expression data and map individual cells onto it. A massive variety of different algorithms are available for doing so (Saelens et al. 2019), and while we will demonstrate only a few specific methods below, many of the concepts apply generally to all trajectory inference strategies. A more philosophical question is whether a trajectory even exists in the dataset. One can interpret a continuum of states as a series of closely related (but distinct) subpopulations, or two well-separated clusters as the endpoints of a trajectory with rare intermediates. The choice between these two perspectives is left to the analyst based on which is more useful, convenient or biologically sensible.

10.2.2 Cluster-based minimum spanning tree

10.2.2.1 Basic steps

The TSCAN algorithm uses a simple yet effective approach to trajectory reconstruction. It uses the clustering to summarize the data into a smaller set of discrete units, computes cluster centroids by averaging the coordinates of its member cells, and then forms the minimum spanning tree (MST) across those centroids. The MST is simply an undirected acyclic graph that passes through each centroid exactly once and is thus the most parsimonious structure that captures the transitions between clusters. We demonstrate below on the Nestorowa et al. (2016) dataset, computing the cluster centroids in the low-dimensional PC space to take advantage of data compaction and denoising (Basic Chapter 4).

  1. library(scater)
  2. by.cluster <- aggregateAcrossCells(sce.nest, ids=colLabels(sce.nest))
  3. centroids <- reducedDim(by.cluster, "PCA")
  4. # Set clusters=NULL as we have already aggregated above.
  5. library(TSCAN)
  6. mst <- createClusterMST(centroids, clusters=NULL)
  7. mst
  1. ## IGRAPH e1bae72 UNW- 9 8 --
  2. ## + attr: name (v/c), coordinates (v/x), weight (e/n), gain (e/n)
  3. ## + edges from e1bae72 (vertex names):
  4. ## [1] 1--3 1--9 2--3 2--6 3--4 5--8 5--9 6--7

For reference, we can draw the same lines between the centroids in a t�-SNE plot (Figure 10.1). This allows us to identify interesting clusters such as those at bifurcations or endpoints. Note that the MST in mst was generated from distances in the PC space and is merely being visualized here in the t�-SNE space, for the same reasons as discussed in Basic Section 4.5.3. This may occasionally result in some visually unappealing plots if the original ordering of clusters in the PC space is not preserved in the t�-SNE space.

  1. line.data <- reportEdges(by.cluster, mst=mst, clusters=NULL, use.dimred="TSNE")
  2. plotTSNE(sce.nest, colour_by="label") +
  3. geom_line(data=line.data, mapping=aes(x=dim1, y=dim2, group=edge))

Figure 10.1: t�-SNE plot of the Nestorowa HSC dataset, where each point is a cell and is colored according to its cluster assignment. The MST obtained using a TSCAN-like algorithm is overlaid on top.

We obtain a pseudotime ordering by projecting the cells onto the MST with mapCellsToEdges(). More specifically, we move each cell onto the closest edge of the MST; the pseudotime is then calculated as the distance along the MST to this new position from a “root node” with orderCells(). For our purposes, we will arbitrarily pick one of the endpoint nodes as the root, though a more careful choice based on the biological annotation of each node may yield more relevant orderings (e.g., picking a node corresponding to a more pluripotent state).

  1. map.tscan <- mapCellsToEdges(sce.nest, mst=mst, use.dimred="PCA")
  2. tscan.pseudo <- orderCells(map.tscan, mst)
  3. head(tscan.pseudo)
  1. ## class: PseudotimeOrdering
  2. ## dim: 6 2
  3. ## metadata(1): start
  4. ## pathStats(1): ''
  5. ## cellnames(6): HSPC_025 HSPC_031 ... HSPC_014 HSPC_020
  6. ## cellData names(4): left.cluster right.cluster left.distance
  7. ## right.distance
  8. ## pathnames(2): 7 8
  9. ## pathData names(0):

Here, multiple sets of pseudotimes are reported for a branched trajectory. Each column contains one pseudotime ordering and corresponds to one path from the root node to one of the terminal nodes - the name of the terminal node that defines this path is recorded in the column names of tscan.pseudo. Some cells may be shared across multiple paths, in which case they will have the same pseudotime in those paths. We can then examine the pseudotime ordering on our desired visualization as shown in Figure 10.2.

  1. common.pseudo <- averagePseudotime(tscan.pseudo)
  2. plotTSNE(sce.nest, colour_by=I(common.pseudo),
  3. text_by="label", text_colour="red") +
  4. geom_line(data=line.data, mapping=aes(x=dim1, y=dim2, group=edge))

Figure 10.2: t�-SNE plot of the Nestorowa HSC dataset, where each point is a cell and is colored according to its pseudotime value. The MST obtained using TSCAN is overlaid on top.

Alternatively, this entire series of calculations can be conveniently performed with the quickPseudotime() wrapper. This executes all steps from aggregateAcrossCells() to orderCells() and returns a list with the output from each step.

  1. pseudo.all <- quickPseudotime(sce.nest, use.dimred="PCA")
  2. head(pseudo.all$ordering)
  1. ## class: PseudotimeOrdering
  2. ## dim: 6 2
  3. ## metadata(1): start
  4. ## pathStats(1): ''
  5. ## cellnames(6): HSPC_025 HSPC_031 ... HSPC_014 HSPC_020
  6. ## cellData names(4): left.cluster right.cluster left.distance
  7. ## right.distance
  8. ## pathnames(2): 7 8
  9. ## pathData names(0):

10.2.2.2 Tweaking the MST

The MST can be constructed with an “outgroup” to avoid connecting unrelated populations in the dataset. Based on the OMEGA cluster concept from Street et al. (2018), the outgroup is an artificial cluster that is equidistant from all real clusters at some threshold value. If the original MST sans the outgroup contains an edge that is longer than twice the threshold, the addition of the outgroup will cause the MST to instead be routed through the outgroup. We can subsequently break up the MST into subcomponents (i.e., a minimum spanning forest) by removing the outgroup. We set outgroup=TRUE to introduce an outgroup with an automatically determined threshold distance, which breaks up our previous MST into two components (Figure 10.3).

  1. pseudo.og <- quickPseudotime(sce.nest, use.dimred="PCA", outgroup=TRUE)
  2. set.seed(10101)
  3. plot(pseudo.og$mst)

Figure 10.3: Minimum spanning tree of the Nestorowa clusters after introducing an outgroup.

Another option is to construct the MST based on distances between mutual nearest neighbor (MNN) pairs between clusters (Multi-sample Section 1.6). This exploits the fact that MNN pairs occur at the boundaries of two clusters, with short distances between paired cells meaning that the clusters are “touching”. In this mode, the MST focuses on the connectivity between clusters, which can be different from the shortest distance between centroids (Figure 10.4). Consider, for example, a pair of elongated clusters that are immediately adjacent to each other. A large distance between their centroids precludes the formation of the obvious edge with the default MST construction; in contrast, the MNN distance is very low and encourages the MST to create a connection between the two clusters.

  1. pseudo.mnn <- quickPseudotime(sce.nest, use.dimred="PCA", with.mnn=TRUE)
  2. mnn.pseudo <- averagePseudotime(pseudo.mnn$ordering)
  3. plotTSNE(sce.nest, colour_by=I(mnn.pseudo), text_by="label", text_colour="red") +
  4. geom_line(data=pseudo.mnn$connected$TSNE, mapping=aes(x=dim1, y=dim2, group=edge))

Figure 10.4: t�-SNE plot of the Nestorowa HSC dataset, where each point is a cell and is colored according to its pseudotime value. The MST obtained using TSCAN with MNN distances is overlaid on top.

10.2.2.3 Further comments

The TSCAN approach derives several advantages from using clusters to form the MST. The most obvious is that of computational speed as calculations are performed over clusters rather than cells. The relative coarseness of clusters protects against the per-cell noise that would otherwise reduce the stability of the MST. The interpretation of the MST is also straightforward as it uses the same clusters as the rest of the analysis, allowing us to recycle previous knowledge about the biological annotations assigned to each cluster.

However, the reliance on clustering is a double-edged sword. If the clusters are not sufficiently granular, it is possible for TSCAN to overlook variation that occurs inside a single cluster. The MST is obliged to pass through each cluster exactly once, which can lead to excessively circuitous paths in overclustered datasets as well as the formation of irrelevant paths between distinct cell subpopulations if the outgroup threshold is too high. The MST also fails to handle more complex events such as “bubbles” (i.e., a bifurcation and then a merging) or cycles.

10.2.3 Principal curves

To identify a trajectory, one might imagine simply “fitting” a one-dimensional curve so that it passes through the cloud of cells in the high-dimensional expression space. This is the idea behind principal curves (Hastie and Stuetzle 1989), effectively a non-linear generalization of PCA where the axes of most variation are allowed to bend. We use the slingshot package (Street et al. 2018) to fit a single principal curve to the Nestorowa dataset, again using the low-dimensional PC coordinates for denoising and speed. This yields a pseudotime ordering of cells based on their relative positions when projected onto the curve.

  1. library(slingshot)
  2. sce.sling <- slingshot(sce.nest, reducedDim='PCA')
  3. head(sce.sling$slingPseudotime_1)
## [1] 59.17 45.31 57.40 46.40 51.89 41.44

We can then visualize the path taken by the fitted curve in any desired space with embedCurves(). For example, Figure 10.5 shows the behavior of the principle curve on the t�-SNE plot. Again, users should note that this may not always yield aesthetically pleasing plots if the t�-SNE algorithm decides to arrange clusters so that they no longer match the ordering of the pseudotimes.

  1. embedded <- embedCurves(sce.sling, "TSNE")
  2. embedded <- slingCurves(embedded)[[1]] # only 1 path.
  3. embedded <- data.frame(embedded$s[embedded$ord,])
  4. plotTSNE(sce.sling, colour_by="slingPseudotime_1") +
  5. geom_path(data=embedded, aes(x=Dim.1, y=Dim.2), size=1.2)

Figure 10.5: t�-SNE plot of the Nestorowa HSC dataset where each point is a cell and is colored by the slingshot pseudotime ordering. The fitted principal curve is shown in black.

The previous call to slingshot() assumed that all cells in the dataset were part of a single curve. To accommodate more complex events like bifurcations, we use our previously computed cluster assignments to build a rough sketch for the global structure in the form of a MST across the cluster centroids. Each path through the MST from a designated root node is treated as a lineage that contains cells from the associated clusters. Principal curves are then simultaneously fitted to all lineages with some averaging across curves to encourage consistency in shared clusters across lineages. This process yields a matrix of pseudotimes where each column corresponds to a lineage and contains the pseudotimes of all cells assigned to that lineage.

  1. sce.sling2 <- slingshot(sce.nest, cluster=colLabels(sce.nest), reducedDim='PCA')
  2. pseudo.paths <- slingPseudotime(sce.sling2)
  3. head(pseudo.paths)
  1. ## Lineage1 Lineage2 Lineage3
  2. ## HSPC_025 107.06 NA NA
  3. ## HSPC_031 95.11 101.5 117.1
  4. ## HSPC_037 103.29 103.8 109.2
  5. ## HSPC_008 99.23 115.5 103.8
  6. ## HSPC_014 103.29 111.0 105.5
  7. ## HSPC_020 NA 123.6 NA

By using the MST as a scaffold for the global structure, slingshot() can accommodate branching events based on divergence in the principal curves (Figure 10.6). However, unlike TSCAN, the MST here is only used as a rough guide and does not define the final pseudotime.

  1. sce.nest <- runUMAP(sce.nest, dimred="PCA")
  2. reducedDim(sce.sling2, "UMAP") <- reducedDim(sce.nest, "UMAP")
  3. # Taking the rowMeans just gives us a single pseudo-time for all cells. Cells
  4. # in segments that are shared across paths have similar pseudo-time values in
  5. # all paths anyway, so taking the rowMeans is not particularly controversial.
  6. shared.pseudo <- rowMeans(pseudo.paths, na.rm=TRUE)
  7. # Need to loop over the paths and add each one separately.
  8. gg <- plotUMAP(sce.sling2, colour_by=I(shared.pseudo))
  9. embedded <- embedCurves(sce.sling2, "UMAP")
  10. embedded <- slingCurves(embedded)
  11. for (path in embedded) {
  12. embedded <- data.frame(path$s[path$ord,])
  13. gg <- gg + geom_path(data=embedded, aes(x=Dim.1, y=Dim.2), size=1.2)
  14. }
  15. gg

Figure 10.6: UMAP plot of the Nestorowa HSC dataset where each point is a cell and is colored by the average slingshot pseudotime across paths. The principal curves fitted to each lineage are shown in black.

We can use slingshotBranchID() to determine whether a particular cell is shared across multiple curves or is unique to a subset of curves (i.e., is located “after” branching). In this case, we can see that most cells jump directly from a global common segment (1,2,3) to one of the curves (123) without any further hierarchy, i.e., no noticeable internal branch points.

  1. curve.assignments <- slingBranchID(sce.sling2)
  2. table(curve.assignments)
  1. ## curve.assignments
  2. ## 1 1,2 1,2,3 1,3 2 2,3 3
  3. ## 435 6 892 2 222 38 61

For larger datasets, we can speed up the algorithm by approximating each principal curve with a fixed number of points. By default, slingshot() uses one point per cell to define the curve, which is unnecessarily precise when the number of cells is large. Applying an approximation with approx_points= reduces computational work without any major loss of precision in the pseudotime estimates.

  1. sce.sling3 <- slingshot(sce.nest, cluster=colLabels(sce.nest),
  2. reducedDim='PCA', approx_points=100)
  3. pseudo.paths3 <- slingPseudotime(sce.sling3)
  4. head(pseudo.paths3)
  1. ## Lineage1 Lineage2 Lineage3
  2. ## HSPC_025 106.85 NA NA
  3. ## HSPC_031 95.38 101.8 117.1
  4. ## HSPC_037 103.08 104.1 109.0
  5. ## HSPC_008 98.72 115.5 103.7
  6. ## HSPC_014 103.08 110.9 105.3
  7. ## HSPC_020 NA 123.5 NA

The MST can also be constructed with an OMEGA cluster to avoid connecting unrelated trajectories. This operates in the same manner as (and was the inspiration for) the outgroup for TSCAN’s MST. Principal curves are fitted through each component individually, manifesting in the pseudotime matrix as paths that do not share any cells.

  1. sce.sling4 <- slingshot(sce.nest, cluster=colLabels(sce.nest),
  2. reducedDim='PCA', approx_points=100, omega=TRUE)
  3. pseudo.paths4 <- slingPseudotime(sce.sling4)
  4. head(pseudo.paths4)
  1. ## Lineage1 Lineage2 Lineage3
  2. ## HSPC_025 111.83 NA NA
  3. ## HSPC_031 96.16 99.78 NA
  4. ## HSPC_037 105.49 105.08 NA
  5. ## HSPC_008 102.00 117.28 NA
  6. ## HSPC_014 105.49 112.70 NA
  7. ## HSPC_020 NA 126.08 NA

  1. shared.pseudo <- rowMeans(pseudo.paths, na.rm=TRUE)
  2. gg <- plotUMAP(sce.sling4, colour_by=I(shared.pseudo))
  3. embedded <- embedCurves(sce.sling4, "UMAP")
  4. embedded <- slingCurves(embedded)
  5. for (path in embedded) {
  6. embedded <- data.frame(path$s[path$ord,])
  7. gg <- gg + geom_path(data=embedded, aes(x=Dim.1, y=Dim.2), size=1.2)
  8. }
  9. gg

Figure 10.7: UMAP plot of the Nestorowa HSC dataset where each point is a cell and is colored by the average slingshot pseudotime across paths. The principal curves (black lines) were constructed with an OMEGA cluster.

The use of principal curves adds an extra layer of sophistication that complements the deficiencies of the cluster-based MST. The principal curve has the opportunity to model variation within clusters that would otherwise be overlooked; for example, slingshot could build a trajectory out of one cluster while TSCAN cannot. Conversely, the principal curves can “smooth out” circuitous paths in the MST for overclustered data, ignoring small differences between fine clusters that are unlikely to be relevant to the overall trajectory.

That said, the structure of the initial MST is still fundamentally dependent on the resolution of the clusters. One can arbitrarily change the number of branches from slingshot by tuning the cluster granularity, making it difficult to use the output as evidence for the presence/absence of subtle branch events. If the variation within clusters is uninteresting, the greater sensitivity of the curve fitting to such variation may yield irrelevant trajectories where the differences between clusters are masked. Moreover, slingshot is no longer obliged to separate clusters in pseudotime, which may complicate intepretation of the trajectory with respect to existing cluster annotations.

10.3 Characterizing trajectories

10.3.1 Overview

Once we have constructed a trajectory, the next step is to characterize the underlying biology based on its DE genes. The aim here is to find the genes that exhibit significant changes in expression across pseudotime, as these are the most likely to have driven the formation of the trajectory in the first place. The overall strategy is to fit a model to the per-gene expression with respect to pseudotime, allowing us to obtain inferences about the significance of any association. We can then prioritize interesting genes as those with low p�-values for further investigation. A wide range of options are available for model fitting but we will focus on the simplest approach of fitting a linear model to the log-expression values with respect to the pseudotime; we will discuss some of the more advanced models later.

10.3.2 Changes along a trajectory

To demonstrate, we will identify genes with significant changes with respect to one of the TSCAN pseudotimes in the Nestorowa data. We use the testPseudotime() utility to fit a natural spline to the expression of each gene, allowing us to model a range of non-linear relationships in the data. We then perform an analysis of variance (ANOVA) to determine if any of the spline coefficients are significantly non-zero, i.e., there is some significant trend with respect to pseudotime.

  1. library(TSCAN)
  2. pseudo <- testPseudotime(sce.nest, pseudotime=tscan.pseudo[,1])[[1]]
  3. pseudo$SYMBOL <- rowData(sce.nest)$SYMBOL
  4. pseudo[order(pseudo$p.value),]
  1. ## DataFrame with 46078 rows and 4 columns
  2. ## logFC p.value FDR SYMBOL
  3. ## <numeric> <numeric> <numeric> <character>
  4. ## ENSMUSG00000029322 -0.0872517 0.00000e+00 0.00000e+00 Plac8
  5. ## ENSMUSG00000105231 0.0158450 0.00000e+00 0.00000e+00 Iglj3
  6. ## ENSMUSG00000076608 0.0118768 2.66618e-310 3.78002e-306 Igkj5
  7. ## ENSMUSG00000106668 0.0153919 2.54019e-300 2.70105e-296 Iglj1
  8. ## ENSMUSG00000022496 0.0229337 4.84822e-297 4.12418e-293 Tnfrsf17
  9. ## ... ... ... ... ...
  10. ## ENSMUSG00000107367 0 NaN NaN Mir192
  11. ## ENSMUSG00000107372 0 NaN NaN NA
  12. ## ENSMUSG00000107381 0 NaN NaN NA
  13. ## ENSMUSG00000107382 0 NaN NaN Gm37714
  14. ## ENSMUSG00000107391 0 NaN NaN Rian

In practice, it is helpful to pair the spline-based ANOVA results with a fit from a much simpler model where we assume that there exists a linear relationship between expression and the pseudotime. This yields an interpretable summary of the overall direction of change in the logFC field above, complementing the more poweful spline-based model used to populate the p.value field. In contrast, the magnitude and sign of the spline coefficients cannot be easily interpreted.

To simplify the results, we will repeat our DE analysis after filtering out cluster 7. This cluster seems to contain a set of B cell precursors that are located at one end of the trajectory, causing immunoglobulins to dominate the set of DE genes and mask other interesting effects. Incidentally, this is the same cluster that was split into a separate component in the outgroup-based MST.

  1. # Making a copy of our SCE and including the pseudotimes in the colData.
  2. sce.nest2 <- sce.nest
  3. sce.nest2$TSCAN.first <- pathStat(tscan.pseudo)[,1]
  4. sce.nest2$TSCAN.second <- pathStat(tscan.pseudo)[,2]
  5. # Discarding the offending cluster.
  6. discard <- "7"
  7. keep <- colLabels(sce.nest)!=discard
  8. sce.nest2 <- sce.nest2[,keep]
  9. # Testing against the first path again.
  10. pseudo <- testPseudotime(sce.nest2, pseudotime=sce.nest2$TSCAN.first)
  11. pseudo$SYMBOL <- rowData(sce.nest2)$SYMBOL
  12. sorted <- pseudo[order(pseudo$p.value),]

Examination of the top downregulated genes suggests that this pseudotime represents a transition away from myeloid identity, based on the decrease in expression of genes such as Mpo and Plac8 (Figure 10.8).

  1. up.left <- sorted[sorted$logFC < 0,]
  2. head(up.left, 10)
  1. ## DataFrame with 10 rows and 4 columns
  2. ## logFC p.value FDR SYMBOL
  3. ## <numeric> <numeric> <numeric> <character>
  4. ## ENSMUSG00000029322 -0.0951619 0.00000e+00 0.00000e+00 Plac8
  5. ## ENSMUSG00000009350 -0.1230460 6.07026e-245 1.28963e-240 Mpo
  6. ## ENSMUSG00000040314 -0.1247572 5.29679e-231 7.50202e-227 Ctsg
  7. ## ENSMUSG00000031722 -0.0772702 3.46925e-217 3.68521e-213 Hp
  8. ## ENSMUSG00000020125 -0.1055643 2.21357e-211 1.88109e-207 Elane
  9. ## ENSMUSG00000015937 -0.0439171 8.35182e-204 5.91448e-200 H2afy
  10. ## ENSMUSG00000035004 -0.0770322 8.34215e-201 5.06369e-197 Igsf6
  11. ## ENSMUSG00000045799 -0.0270218 8.85762e-197 4.70450e-193 Gm9800
  12. ## ENSMUSG00000026238 -0.0255206 1.31491e-194 6.20783e-191 Ptma
  13. ## ENSMUSG00000096544 -0.0264184 3.73314e-177 1.58621e-173 Gm4617

  1. best <- head(up.left$SYMBOL, 10)
  2. plotExpression(sce.nest2, features=best, swap_rownames="SYMBOL",
  3. x="TSCAN.first", colour_by="label")

Figure 10.8: Expression of the top 10 genes that decrease in expression with increasing pseudotime along the first path in the MST of the Nestorowa dataset. Each point represents a cell that is mapped to this path and is colored by the assigned cluster.

Conversely, the later parts of the pseudotime may correspond to a more stem-like state based on upregulation of genes like Hlf. There is also increased expression of genes associated with the lymphoid lineage (e.g., Ltb), consistent with reduced commitment to the myeloid lineage at earlier pseudotime values.

  1. up.right <- sorted[sorted$logFC > 0,]
  2. head(up.right, 10)
  1. ## DataFrame with 10 rows and 4 columns
  2. ## logFC p.value FDR SYMBOL
  3. ## <numeric> <numeric> <numeric> <character>
  4. ## ENSMUSG00000047867 0.0869463 1.06721e-173 4.12235e-170 Gimap6
  5. ## ENSMUSG00000028716 0.1023233 4.76874e-172 1.68853e-168 Pdzk1ip1
  6. ## ENSMUSG00000086567 0.0294706 9.89947e-165 2.62893e-161 Gm2830
  7. ## ENSMUSG00000027562 0.0646994 5.91659e-156 1.04748e-152 Car2
  8. ## ENSMUSG00000006389 0.1096438 4.69440e-151 7.67174e-148 Mpl
  9. ## ENSMUSG00000037820 0.0702660 1.80467e-135 1.78327e-132 Tgm2
  10. ## ENSMUSG00000003949 0.0934931 3.07633e-126 2.37661e-123 Hlf
  11. ## ENSMUSG00000061232 0.0191498 1.24511e-125 9.44725e-123 H2-K1
  12. ## ENSMUSG00000044258 0.0557909 3.49882e-121 2.28715e-118 Ctla2a
  13. ## ENSMUSG00000024399 0.0998322 5.53699e-116 3.17928e-113 Ltb

  1. best <- head(up.right$SYMBOL, 10)
  2. plotExpression(sce.nest2, features=best, swap_rownames="SYMBOL",
  3. x="TSCAN.first", colour_by="label")

Figure 10.9: Expression of the top 10 genes that increase in expression with increasing pseudotime along the first path in the MST of the Nestorowa dataset. Each point represents a cell that is mapped to this path and is colored by the assigned cluster.

Alternatively, a heatmap can be used to provide a more compact visualization (Figure 10.10).

  1. on.first.path <- !is.na(sce.nest2$TSCAN.first)
  2. plotHeatmap(sce.nest2[,on.first.path], order_columns_by="TSCAN.first",
  3. colour_columns_by="label", features=head(up.right$SYMBOL, 50),
  4. center=TRUE, swap_rownames="SYMBOL")

Figure 10.10: Heatmap of the expression of the top 50 genes that increase in expression with increasing pseudotime along the first path in the MST of the Nestorowa HSC dataset. Each column represents a cell that is mapped to this path and is ordered by its pseudotime value.

10.3.3 Changes between paths

A more advanced analysis involves looking for differences in expression between paths of a branched trajectory. This is most interesting for cells close to the branch point between two or more paths where the differential expression analysis may highlight genes is responsible for the branching event. The general strategy here is to fit one trend to the unique part of each path immediately following the branch point, followed by a comparison of the fits between paths.

To this end, a particularly tempting approach is to perform another ANOVA with our spline-based model and test for significant differences in the spline parameters between paths. While this can be done with testPseudotime(), the magnitude of the pseudotime has little comparability across paths. A pseudotime value in one path of the MST does not, in general, have any relation to the same value in another path; the pseudotime can be arbitrarily “stretched” by factors such as the magnitude of DE or the density of cells, depending on the algorithm. This compromises any comparison of trends as we cannot reliably say that they are being fitted to comparable x�-axes.

Rather, we employ the much simpler ad hoc approach of fitting a spline to each trajectory and comparing the sets of DE genes. To demonstrate, we focus on the cluster containing the branch point in the Nestorowa-derived MST (Figure 10.2). We recompute the pseudotimes so that the root lies at the cluster center, allowing us to detect genes that are associated with the divergence of the branches.

  1. starter <- "3"
  2. tscan.pseudo2 <- orderCells(map.tscan, mst, start=starter)

We visualize the reordered pseudotimes using only the cells in our branch point cluster (Figure 10.11), which allows us to see the correspondence between each pseudotime to the projected edges of the MST. A more precise determination of the identity of each pseudotime can be achieved by examining the column names of tscan.pseudo2, which contains the name of the terminal node for the path of the MST corresponding to each column.

  1. # Making a copy and giving the paths more friendly names.
  2. sub.nest <- sce.nest
  3. sub.nest$TSCAN.first <- pathStat(tscan.pseudo2)[,1]
  4. sub.nest$TSCAN.second <- pathStat(tscan.pseudo2)[,2]
  5. sub.nest$TSCAN.third <- pathStat(tscan.pseudo2)[,3]
  6. # Subsetting to the desired cluster containing the branch point.
  7. keep <- colLabels(sce.nest) == starter
  8. sub.nest <- sub.nest[,keep]
  9. # Showing only the lines to/from our cluster of interest.
  10. line.data.sub <- line.data[grepl("^3--", line.data$edge) | grepl("--3$", line.data$edge),]
  11. ggline <- geom_line(data=line.data.sub, mapping=aes(x=dim1, y=dim2, group=edge))
  12. gridExtra::grid.arrange(
  13. plotTSNE(sub.nest, colour_by="TSCAN.first") + ggline,
  14. plotTSNE(sub.nest, colour_by="TSCAN.second") + ggline,
  15. plotTSNE(sub.nest, colour_by="TSCAN.third") + ggline,
  16. ncol=3
  17. )

Figure 10.11: TSCAN-derived pseudotimes around cluster 3 in the Nestorowa HSC dataset. Each point is a cell in this cluster and is colored by its pseudotime value along the path to which it was assigned. The overlaid lines represent the relevant edges of the MST.

We then apply testPseudotime() to each path involving cluster 3. Because we are operating over a relatively short pseudotime interval, we do not expect complex trends and so we set df=1 (i.e., a linear trend) to avoid problems from overfitting.

  1. pseudo1 <- testPseudotime(sub.nest, df=1, pseudotime=sub.nest$TSCAN.first)
  2. pseudo1$SYMBOL <- rowData(sce.nest)$SYMBOL
  3. pseudo1[order(pseudo1$p.value),]
  1. ## DataFrame with 46078 rows and 5 columns
  2. ## logFC logFC.1 p.value FDR SYMBOL
  3. ## <numeric> <numeric> <numeric> <numeric> <character>
  4. ## ENSMUSG00000009350 0.332855 0.332855 2.67471e-18 9.59018e-14 Mpo
  5. ## ENSMUSG00000040314 0.475509 0.475509 5.65148e-16 1.01317e-11 Ctsg
  6. ## ENSMUSG00000064147 0.449444 0.449444 3.76156e-15 4.49569e-11 Rab44
  7. ## ENSMUSG00000026581 0.379946 0.379946 3.86978e-14 3.46877e-10 Sell
  8. ## ENSMUSG00000085611 0.266637 0.266637 7.51248e-12 5.38720e-08 Ap3s1-ps1
  9. ## ... ... ... ... ... ...
  10. ## ENSMUSG00000107380 0 0 NaN NaN Vmn1r-ps6
  11. ## ENSMUSG00000107381 0 0 NaN NaN NA
  12. ## ENSMUSG00000107382 0 0 NaN NaN Gm37714
  13. ## ENSMUSG00000107387 0 0 NaN NaN 5430435K18Rik
  14. ## ENSMUSG00000107391 0 0 NaN NaN Rian

  1. pseudo2 <- testPseudotime(sub.nest, df=1, pseudotime=sub.nest$TSCAN.second)
  2. pseudo2$SYMBOL <- rowData(sce.nest)$SYMBOL
  3. pseudo2[order(pseudo2$p.value),]
  1. ## DataFrame with 46078 rows and 5 columns
  2. ## logFC logFC.1 p.value FDR SYMBOL
  3. ## <numeric> <numeric> <numeric> <numeric> <character>
  4. ## ENSMUSG00000027342 -0.1265815 -0.1265815 1.14035e-11 4.01425e-07 Pcna
  5. ## ENSMUSG00000025747 -0.3693852 -0.3693852 5.06241e-09 6.43725e-05 Tyms
  6. ## ENSMUSG00000020358 -0.1001289 -0.1001289 6.95055e-09 6.43725e-05 Hnrnpab
  7. ## ENSMUSG00000035198 -0.4166721 -0.4166721 7.31465e-09 6.43725e-05 Tubg1
  8. ## ENSMUSG00000045799 -0.0452833 -0.0452833 5.43487e-08 3.19298e-04 Gm9800
  9. ## ... ... ... ... ... ...
  10. ## ENSMUSG00000107380 0 0 NaN NaN Vmn1r-ps6
  11. ## ENSMUSG00000107381 0 0 NaN NaN NA
  12. ## ENSMUSG00000107382 0 0 NaN NaN Gm37714
  13. ## ENSMUSG00000107386 0 0 NaN NaN Gm42800
  14. ## ENSMUSG00000107391 0 0 NaN NaN Rian

  1. pseudo3 <- testPseudotime(sub.nest, df=1, pseudotime=sub.nest$TSCAN.third)
  2. pseudo3$SYMBOL <- rowData(sce.nest)$SYMBOL
  3. pseudo3[order(pseudo3$p.value),]
  1. ## DataFrame with 46078 rows and 5 columns
  2. ## logFC logFC.1 p.value FDR SYMBOL
  3. ## <numeric> <numeric> <numeric> <numeric> <character>
  4. ## ENSMUSG00000042817 -0.411375 -0.411375 7.83960e-14 2.00860e-09 Flt3
  5. ## ENSMUSG00000015937 -0.163091 -0.163091 1.18901e-13 2.00860e-09 H2afy
  6. ## ENSMUSG00000002985 0.351661 0.351661 7.64160e-13 8.60597e-09 Apoe
  7. ## ENSMUSG00000053168 -0.398684 -0.398684 8.17626e-12 6.90608e-08 9030619P08Rik
  8. ## ENSMUSG00000029247 -0.137079 -0.137079 1.78997e-10 1.06448e-06 Paics
  9. ## ... ... ... ... ... ...
  10. ## ENSMUSG00000107381 0 0 NaN NaN NA
  11. ## ENSMUSG00000107382 0 0 NaN NaN Gm37714
  12. ## ENSMUSG00000107384 0 0 NaN NaN Gm42557
  13. ## ENSMUSG00000107387 0 0 NaN NaN 5430435K18Rik
  14. ## ENSMUSG00000107391 0 0 NaN NaN Rian

We want to find genes that are significant in our path of interest (for this demonstration, the third path reported by TSCAN) and are not significant and/or changing in the opposite direction in the other paths. We use the raw p�-values to look for non-significant genes in order to increase the stringency of the definition of unique genes in our path.

  1. only3 <- pseudo3[which(pseudo3$FDR <= 0.05 &
  2. (pseudo2$p.value >= 0.05 | sign(pseudo1$logFC)!=sign(pseudo3$logFC)) &
  3. (pseudo2$p.value >= 0.05 | sign(pseudo2$logFC)!=sign(pseudo3$logFC))),]
  4. only3[order(only3$p.value),]
  1. ## DataFrame with 64 rows and 5 columns
  2. ## logFC logFC.1 p.value FDR SYMBOL
  3. ## <numeric> <numeric> <numeric> <numeric> <character>
  4. ## ENSMUSG00000042817 -0.411375 -0.411375 7.83960e-14 2.00860e-09 Flt3
  5. ## ENSMUSG00000002985 0.351661 0.351661 7.64160e-13 8.60597e-09 Apoe
  6. ## ENSMUSG00000016494 -0.248953 -0.248953 1.89039e-10 1.06448e-06 Cd34
  7. ## ENSMUSG00000000486 -0.217213 -0.217213 1.24423e-09 5.25468e-06 Sept1
  8. ## ENSMUSG00000021728 -0.293032 -0.293032 3.56762e-09 1.20535e-05 Emb
  9. ## ... ... ... ... ... ...
  10. ## ENSMUSG00000004609 -0.205262 -0.205262 0.000118937 0.0422992 Cd33
  11. ## ENSMUSG00000083657 0.100788 0.100788 0.000145710 0.0484448 Gm12245
  12. ## ENSMUSG00000023942 -0.144269 -0.144269 0.000146255 0.0484448 Slc29a1
  13. ## ENSMUSG00000091408 -0.149411 -0.149411 0.000157634 0.0499154 Gm6728
  14. ## ENSMUSG00000053559 0.135833 0.135833 0.000159559 0.0499154 Smagp

We observe upregulation of interesting genes such as Gata2Cd9 and Apoe in this path, along with downregulation of Flt3 (Figure 10.12). One might speculate that this path leads to a less differentiated HSC state compared to the other directions.

  1. gridExtra::grid.arrange(
  2. plotTSNE(sub.nest, colour_by="Flt3", swap_rownames="SYMBOL") + ggline,
  3. plotTSNE(sub.nest, colour_by="Apoe", swap_rownames="SYMBOL") + ggline,
  4. plotTSNE(sub.nest, colour_by="Gata2", swap_rownames="SYMBOL") + ggline,
  5. plotTSNE(sub.nest, colour_by="Cd9", swap_rownames="SYMBOL") + ggline
  6. )

Figure 10.12: t�-SNE plots of cells in the cluster containing the branch point of the MST in the Nestorowa dataset. 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.

While simple and practical, this comparison strategy is even less statistically defensible than usual. The differential testing machinery is not suited to making inferences on the absence of differences, and we should not have used the non-significant genes to draw any conclusions. Another limitation is that this approach cannot detect differences in the magnitude of the gradient of the trend between paths; a gene that is significantly upregulated in each of two paths but with a sharper gradient in one of the paths will not be DE. (Of course, this is only a limitation if the pseudotimes were comparable in the first place.)

10.3.4 Further comments

The magnitudes of the p�-values reported here should be treated with some skepticism. The same fundamental problems discussed in Section 6.4 remain; the p�-values are computed from the same data used to define the trajectory, and there is only a sample size of 1 in this analysis regardless of the number of cells. Nonetheless, the p�-value is still useful for prioritizing interesting genes in the same manner that it is used to identify markers between clusters.

The previous sections have focused on a very simple and efficient - but largely effective - approach to trend fitting. Alternatively, we can use more complex strategies that involve various generalizations to the concept of linear models. For example, generalized additive models (GAMs) are quite popular for pseudotime-based DE analyses as they are able to handle non-normal noise distributions and a greater diversity of non-linear trends. We demonstrate the use of the GAM implementation from the tradeSeq package on the Nestorowa dataset below. Specifically, we will take a leap of faith and assume that our pseudotime values are comparable across paths of the MST, allowing us to use the patternTest() function to test for significant differences in expression between paths.

  1. # Getting rid of the NA's; using the cell weights
  2. # to indicate which cell belongs on which path.
  3. nonna.pseudo <- pathStat(tscan.pseudo)
  4. not.on.path <- is.na(nonna.pseudo)
  5. nonna.pseudo[not.on.path] <- 0
  6. cell.weights <- !not.on.path
  7. storage.mode(cell.weights) <- "numeric"
  8. # Fitting a GAM on the subset of genes for speed.
  9. library(tradeSeq)
  10. fit <- fitGAM(counts(sce.nest)[1:100,],
  11. pseudotime=nonna.pseudo,
  12. cellWeights=cell.weights)
  13. res <- patternTest(fit)
  14. res$Symbol <- rowData(sce.nest)[1:100,"SYMBOL"]
  15. res <- res[order(res$pvalue),]
  16. head(res, 10)
  1. ## waldStat df pvalue fcMedian Symbol
  2. ## ENSMUSG00000000028 274.76 6 0 1.5278 Cdc45
  3. ## ENSMUSG00000000058 117.63 6 0 1.1083 Cav2
  4. ## ENSMUSG00000000078 190.26 6 0 0.9722 Klf6
  5. ## ENSMUSG00000000088 122.35 6 0 0.5412 Cox5a
  6. ## ENSMUSG00000000184 213.83 6 0 0.2063 Ccnd2
  7. ## ENSMUSG00000000247 108.78 6 0 0.2195 Lhx2
  8. ## ENSMUSG00000000248 121.31 6 0 1.1093 Clec2g
  9. ## ENSMUSG00000000278 200.69 6 0 1.9958 Scpep1
  10. ## ENSMUSG00000000290 92.37 6 0 0.7041 Itgb2
  11. ## ENSMUSG00000000303 123.68 6 0 1.0692 Cdh1

From a statistical perspective, the GAM is superior to linear models as the former uses the raw counts. This accounts for the idiosyncrasies of the mean-variance relationship for low counts and avoids some problems with spurious trajectories introduced by the log-transformation (Basic Section 2.5). However, this sophistication comes at the cost of increased complexity and compute time, requiring parallelization via BiocParallel even for relatively small datasets.

When a trajectory consists of a series of clusters (as in the Nestorowa dataset), pseudotime-based DE tests can be considered a continuous generalization of cluster-based marker detection. One would expect to identify similar genes by performing an ANOVA on the per-cluster expression values, and indeed, this may be a more interpretable approach as it avoids imposing the assumption that a trajectory exists at all. The main benefit of pseudotime-based tests is that they encourage expression to be a smooth function of pseudotime, assuming that the degrees of freedom in the trend fit prevents overfitting. This smoothness reflects an expectation that changes in expression along a trajectory should be gradual.

10.4 Finding the root

10.4.1 Overview

The pseudotime calculations rely on some specification of the root of the trajectory to define “position zero”. In some cases, this choice has little effect beyond flipping the sign of the gradients of the DE genes. In other cases, this choice may necessarily arbitrary depending on the questions being asked, e.g., what are the genes driving the transition to or from a particular part of the trajectory? However, in situations where the trajectory is associated with a time-dependent biological process, the position on the trajectory corresponding to the earliest timepoint is clearly the best default choice for the root. This simplifies interpretation by allowing the pseudotime to be treated as a proxy for real time.

10.4.2 Entropy-based methods

Trajectories are commonly used to characterize differentiation where branches are interpreted as multiple lineages. In this setting, the root of the trajectory is best set to the “start” of the differentiation process, i.e., the most undifferentiated state that is observed in the dataset. It is usually possible to identify this state based on the genes that are expressed at each point of the trajectory. However, when such prior biological knowledge is not available, we can fall back to the more general concept that undifferentiated cells have more diverse expression profiles (Gulati et al. 2020). The assumption is that terminally differentiated cells have expression profiles that are highly specialized for their function while multipotent cells have no such constraints - and indeed, may need to have active expression programs for many lineages in preparation for commitment to any of them.

We quantify the diversity of expression by computing the entropy of each cell’s expression profile (Grun et al. 2016; Guo et al. 2017; Teschendorff and Enver 2017), with higher entropies representing greater diversity. We demonstrate on the Nestorowa HSC dataset (Figure 10.13) where clusters 5 and 8 have the highest entropies, suggesting that they represent the least differentiated states within the trajectory. It is also reassuring that these two clusters are adjacent on the MST (Figure 10.1), which is consistent with branched differentiation “away” from a single root.

  1. library(TSCAN)
  2. entropy <- perCellEntropy(sce.nest)
  3. ent.data <- data.frame(cluster=colLabels(sce.nest), entropy=entropy)
  4. ggplot(ent.data, aes(x=cluster, y=entropy)) +
  5. geom_violin() +
  6. coord_cartesian(ylim=c(7, NA)) +
  7. stat_summary(fun=median, geom="point")

Figure 10.13: Distribution of per-cell entropies for each cluster in the Nestorowa dataset. The median entropy for each cluster is shown as a point in the violin plot.

Of course, this interpretation is fully dependent on whether the underlying assumption is reasonable. While the association between diversity and differentiation potential is likely to be generally applicable, it may not be sufficiently precise to enable claims on the relative potency of closely related subpopulations. Indeed, other processes such as stress or metabolic responses may interfere with the entropy comparisons. Furthermore, at low counts, the magnitude of the entropy is dependent on sequencing depth in a manner that cannot be corrected by scaling normalization. Cells with lower coverage will have lower entropy even if the underlying transcriptional diversity is the same, which may confound the interpretation of entropy as a measure of potency.

10.4.3 RNA velocity

Another strategy is to use the concept of “RNA velocity” to identify the root (La Manno et al. 2018). For a given gene, a high ratio of unspliced to spliced transcripts indicates that that gene is being actively upregulated, under the assumption that the increase in transcription exceeds the capability of the splicing machinery to process the pre-mRNA. Conversely, a low ratio indicates that the gene is being downregulated as the rate of production and processing of pre-mRNAs cannot compensate for the degradation of mature transcripts. Thus, we can infer that cells with high and low ratios are moving towards a high- and low-expression state, respectively, allowing us to assign directionality to any trajectory or even individual cells.

To demonstrate, we will use matrices of spliced and unspliced counts from Hermann et al. (2018). The unspliced count matrix is most typically generated by counting reads across intronic regions, thus quantifying the abundance of nascent transcripts for each gene in each cell. The spliced counts are obtained in a more standard manner by counting reads aligned to exonic regions; however, some extra thought is required to deal with reads spanning exon-intron boundaries, as well as reads mapping to regions that can be either intronic or exonic depending on the isoform (Soneson et al. 2020). Conveniently, both matrices have the same shape and thus can be stored as separate assays in our usual SingleCellExperiment.

  1. library(scRNAseq)
  2. sce.sperm <- HermannSpermatogenesisData(strip=TRUE, location=TRUE)
  3. assayNames(sce.sperm)
## [1] "spliced"   "unspliced"

We run through a quick-and-dirty analysis on the spliced counts, which can - by and large - be treated in the same manner as the standard exonic gene counts used in non-velocity-aware analyses. Alternatively, if the standard exonic count matrix was available, we could just use it directly in these steps and restrict the involvement of the spliced/unspliced matrices to the velocity calculations. The latter approach is logistically convenient when adding an RNA velocity section to an existing analysis, such that the prior steps (and the interpretation of their results) do not have to be repeated on the spliced count matrix.

  1. # Quality control:
  2. library(scuttle)
  3. is.mito <- which(seqnames(sce.sperm)=="MT")
  4. sce.sperm <- addPerCellQC(sce.sperm, subsets=list(Mt=is.mito), assay.type="spliced")
  5. qc <- quickPerCellQC(colData(sce.sperm), sub.fields=TRUE)
  6. sce.sperm <- sce.sperm[,!qc$discard]
  7. # Normalization:
  8. set.seed(10000)
  9. library(scran)
  10. sce.sperm <- logNormCounts(sce.sperm, assay.type="spliced")
  11. dec <- modelGeneVarByPoisson(sce.sperm, assay.type="spliced")
  12. hvgs <- getTopHVGs(dec, n=2500)
  13. # Dimensionality reduction:
  14. set.seed(1000101)
  15. library(scater)
  16. sce.sperm <- runPCA(sce.sperm, ncomponents=25, subset_row=hvgs)
  17. sce.sperm <- runTSNE(sce.sperm, dimred="PCA")

We use the velociraptor package to perform the velocity calculations on this dataset via the scvelo Python package (Bergen et al. 2019). scvelo offers some improvements over the original implementation of RNA velocity by La Manno et al. (2018), most notably eliminating the need for observed subpopulations at steady state (i.e., where the rates of transcription, splicing and degradation are equal). velociraptor conveniently wraps this functionality by providing a function that accepts a SingleCellExperiment object such as sce.sperm and returns a similar object decorated with the velocity statistics.

  1. library(velociraptor)
  2. velo.out <- scvelo(sce.sperm, assay.X="spliced",
  3. subset.row=hvgs, use.dimred="PCA")
  4. velo.out
  1. ## class: SingleCellExperiment
  2. ## dim: 2500 2175
  3. ## metadata(4): neighbors velocity_params velocity_graph
  4. ## velocity_graph_neg
  5. ## assays(6): X spliced ... Mu velocity
  6. ## rownames(2500): ENSMUSG00000038015 ENSMUSG00000022501 ...
  7. ## ENSMUSG00000095650 ENSMUSG00000002524
  8. ## rowData names(3): velocity_gamma velocity_r2 velocity_genes
  9. ## colnames(2175): CCCATACTCCGAAGAG AATCCAGTCATCTGCC ... ATCCACCCACCACCAG
  10. ## ATTGGTGGTTACCGAT
  11. ## colData names(7): velocity_self_transition root_cells ...
  12. ## velocity_confidence velocity_confidence_transition
  13. ## reducedDimNames(1): X_pca
  14. ## mainExpName: NULL
  15. ## altExpNames(0):

The primary output is the matrix of velocity vectors that describe the direction and magnitude of transcriptional change for each cell. To construct an ordering, we extrapolate from the vector for each cell to determine its future state. Roughly speaking, if a cell’s future state is close to the observed state of another cell, we place the former behind the latter in the ordering. This yields a “velocity pseudotime” that provides directionality without the need to explicitly define a root in our trajectory. We visualize this procedure in Figure 10.14 by embedding the estimated velocities into any low-dimensional representation of the dataset.

  1. sce.sperm$pseudotime <- velo.out$velocity_pseudotime
  2. # Also embedding the velocity vectors, for some verisimilitude.
  3. embedded <- embedVelocity(reducedDim(sce.sperm, "TSNE"), velo.out)
  4. grid.df <- gridVectors(reducedDim(sce.sperm, "TSNE"), embedded, resolution=30)
  5. library(ggplot2)
  6. plotTSNE(sce.sperm, colour_by="pseudotime", point_alpha=0.3) +
  7. geom_segment(data=grid.df,
  8. mapping=aes(x=start.1, y=start.2, xend=end.1, yend=end.2),
  9. arrow=arrow(length=unit(0.05, "inches"), type="closed"))

Figure 10.14: t�-SNE plot of the Hermann spermatogenesis dataset, where each point is a cell and is colored by its velocity pseudotime. Arrows indicate the direction and magnitude of the velocity vectors, averaged over nearby cells.

While we could use the velocity pseudotimes directly in our downstream analyses, it is often helpful to pair this information with other trajectory analyses. This is because the velocity calculations are done on a per-cell basis but interpretation is typically performed at a lower granularity, e.g., per cluster or lineage. For example, we can overlay the average velocity pseudotime for each cluster onto our TSCAN-derived MST (Figure 10.15) to identify the likely root clusters. More complex analyses can also be performed (e.g., to identify the likely fate of each cell in the intermediate clusters) but will not be discussed here.

  1. library(bluster)
  2. colLabels(sce.sperm) <- clusterRows(reducedDim(sce.sperm, "PCA"), NNGraphParam())
  3. library(TSCAN)
  4. mst <- TSCAN::createClusterMST(sce.sperm, use.dimred="PCA", outgroup=TRUE)
  5. # Could also use velo.out$root_cell here, for a more direct measure of 'rootness'.
  6. by.cluster <- split(sce.sperm$pseudotime, colLabels(sce.sperm))
  7. mean.by.cluster <- vapply(by.cluster, mean, 0)
  8. mean.by.cluster <- mean.by.cluster[names(igraph::V(mst))]
  9. color.by.cluster <- viridis::viridis(21)[cut(mean.by.cluster, 21)]
  10. set.seed(1001)
  11. plot(mst, vertex.color=color.by.cluster)

Figure 10.15: TSCAN-derived MST created from the Hermann spermatogenesis dataset. Each node is a cluster and is colored by the average velocity pseudotime of all cells in that cluster, from lowest (purple) to highest (yellow).

Needless to say, this lunch is not entirely free. The inferences rely on a sophisticated mathematical model that has a few assumptions, the most obvious of which being that the transcriptional dynamics are the same across subpopulations. The use of unspliced counts increases the sensitivity of the analysis to unannotated transcripts (e.g., microRNAs in the gene body), intron retention events, annotation errors or quantification ambiguities (Soneson et al. 2020) that could interfere with the velocity calculations. There is also the question of whether there is enough intronic coverage to reliably estimate the velocity for the relevant genes for the process of interest, and if not, whether this lack of information may bias the resulting velocity estimates. From a purely practical perspective, the main difficulty with RNA velocity is that the unspliced counts are often unavailable.

10.4.4 Real timepoints

There does, however, exist a gold-standard approach to rooting a trajectory: simply collect multiple real-life timepoints over the course of a biological process and use the population(s) at the earliest time point as the root. This approach experimentally defines a link between pseudotime and real time without requiring any further assumptions. To demonstrate, we will use the activated T cell dataset from Richard et al. (2018) where they collected CD8+ T cells at various time points after ovalbumin stimulation.

  1. library(scRNAseq)
  2. sce.richard <- RichardTCellData()
  3. sce.richard <- sce.richard[,sce.richard$`single cell quality`=="OK"]
  4. # Only using cells treated with the highest affinity peptide
  5. # plus the unstimulated cells as time zero.
  6. sub.richard <- sce.richard[,sce.richard$stimulus %in%
  7. c("OT-I high affinity peptide N4 (SIINFEKL)", "unstimulated")]
  8. sub.richard$time[is.na(sub.richard$time)] <- 0
  9. table(sub.richard$time)
  1. ##
  2. ## 0 1 3 6
  3. ## 44 51 64 91

We run through the standard workflow for single-cell data with spike-ins - see Basic Section 2.4 and Basic Section 3.3 for more details.

  1. library(scran)
  2. sub.richard <- computeSpikeFactors(sub.richard, "ERCC")
  3. sub.richard <- logNormCounts(sub.richard)
  4. dec.richard <- modelGeneVarWithSpikes(sub.richard, "ERCC")
  5. top.hvgs <- getTopHVGs(dec.richard, prop=0.2)
  6. sub.richard <- denoisePCA(sub.richard, technical=dec.richard, subset.row=top.hvgs)

We can then run our trajectory inference method of choice. As we expecting a fairly simple trajectory, we will keep matters simple and use slingshot() without any clusters. This yields a pseudotime that is strongly associated with real time (Figure 10.16) and from which it is straightforward to identify the best location of the root. The rooted trajectory can then be used to determine the “real time equivalent” of other activation stimuli, see Richard et al. (2018) for more details.

  1. sub.richard <- slingshot(sub.richard, reducedDim="PCA")
  2. plot(sub.richard$time, sub.richard$slingPseudotime_1,
  3. xlab="Time (hours)", ylab="Pseudotime")

Figure 10.16: Pseudotime as a function of real time in the Richard T cell dataset.

Of course, this strategy relies on careful experimental design to ensure that multiple timepoints are actually collected. This requires more planning and resources (i.e., cost!) and is frequently absent from many scRNA-seq studies that only consider a single “snapshot” of the system. Generation of multiple timepoints also requires an amenable experimental system where the initiation of the process of interest can be tightly controlled. This is often more complex to set up than a strictly observational study, though having causal information arguably makes the data more useful for making inferences.

Session Info

View session info

References

Bergen, Volker, Marius Lange, Stefan Peidli, F. Alexander Wolf, and Fabian J. Theis. 2019. “Generalizing Rna Velocity to Transient Cell States Through Dynamical Modeling.” bioRxivGeneralizing RNA velocity to transient cell states through dynamical modeling | bioRxiv.

Grun, D., M. J. Muraro, J. C. Boisset, K. Wiebrands, A. Lyubimova, G. Dharmadhikari, M. van den Born, et al. 2016. “De Novo Prediction of Stem Cell Identity using Single-Cell Transcriptome Data.” Cell Stem Cell 19 (2): 266–77.

Gulati, G. S., S. S. Sikandar, D. J. Wesche, A. Manjunath, A. Bharadwaj, M. J. Berger, F. Ilagan, et al. 2020. “Single-cell transcriptional diversity is a hallmark of developmental potential.” Science 367 (6476): 405–11.

Guo, M., E. L. Bao, M. Wagner, J. A. Whitsett, and Y. Xu. 2017. “SLICE: determining cell differentiation and lineage based on single cell entropy.” Nucleic Acids Res. 45 (7): e54.

Hastie, T., and W. Stuetzle. 1989. “Principal Curves.” J Am Stat Assoc 84 (406): 502–16.

Hermann, B. P., K. Cheng, A. Singh, L. Roa-De La Cruz, K. N. Mutoji, I. C. Chen, H. Gildersleeve, et al. 2018. “The Mammalian Spermatogenesis Single-Cell Transcriptome, from Spermatogonial Stem Cells to Spermatids.” Cell Rep 25 (6): 1650–67.

La Manno, G., R. Soldatov, A. Zeisel, E. Braun, H. Hochgerner, V. Petukhov, K. Lidschreiber, et al. 2018. “RNA velocity of single cells.” Nature 560 (7719): 494–98.

Nestorowa, S., F. K. Hamey, B. Pijuan Sala, E. Diamanti, M. Shepherd, E. Laurenti, N. K. Wilson, D. G. Kent, and B. Gottgens. 2016. “A single-cell resolution map of mouse hematopoietic stem and progenitor cell differentiation.” Blood 128 (8): 20–31.

Richard, A. C., A. T. L. Lun, W. W. Y. Lau, B. Gottgens, J. C. Marioni, and G. M. Griffiths. 2018. “T cell cytolytic capacity is independent of initial stimulation strength.” Nat. Immunol. 19 (8): 849–58.

Saelens, W., R. Cannoodt, H. Todorov, and Y. Saeys. 2019. “A comparison of single-cell trajectory inference methods.” Nat. Biotechnol. 37 (5): 547–54.

Soneson, C., A. Srivastava, R. Patro, and M. B. Stadler. 2020. “Preprocessing Choices Affect Rna Velocity Results for Droplet scRNA-Seq Data.” bioRxivPreprocessing choices affect RNA velocity results for droplet scRNA-seq data | bioRxiv.

Street, K., D. Risso, R. B. Fletcher, D. Das, J. Ngai, N. Yosef, E. Purdom, and S. Dudoit. 2018. “Slingshot: cell lineage and pseudotime inference for single-cell transcriptomics.” BMC Genomics 19 (1): 477.

Teschendorff, A. E., and T. Enver. 2017. “Single-cell entropy for accurate estimation of differentiation potency from a cell’s transcriptome.” Nat Commun 8 (June): 15599.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/511863
推荐阅读
相关标签
  

闽ICP备14008679号