CASi is a comprehensive framework for analyzing longitudinal scRNA-seq data, which provides users with: (1) cross-time points cell annotation, (2) detection of potentially novel cell types emerged over time, (3) visualization of cell population evolution, and (4) identification of temporal differentially expressed genes (tDEGs). This vignette introduces the functions of the CASi package and shows how it analyzes longitudinal scRNA-seq data. CASi was created by Yizhuo Wang, Ziyi Li and Xuelin Huang, and is now maintained by Yizhuo Wang.
Install CASi using the code below.
# install.packages("CASi")
library(CASi)Make sure that Python is installed to load all required dependencies.
CASi has four functions in total. A simulated longitudinal scRNA-seq dataset is used here to demonstrate the usages of these two functions. We obtain a publicly available dataset of peripheral blood mononuclear cells (PBMC)[1], containing more than 60,000 sorted cells from eight immune cell types. We randomly extract cells from five cell types to build the simulation data. The demo pbmc data, “pbmc_demo”, has been lazy-loaded with the package. It is a list of four items: * 1. train_count: used as The initial time point’s gene expression. * 2. train_label: used as The initial time point’s cell label. * 3. test_count: used as following time points’ gene expression. * 4. test_label: the following time points’ cell labels, which is not known in reality. * 5. Meta data: contains Group and Time information.
data(pbmc_demo)
names(pbmc_demo)
#> [1] "train_count" "train_label" "test_count" "test_label"The first step is to create a CASi object using the data. The longitudinal scRNA-seq should be seperated to two subsets regardless of how many time points you have, one includes the initial time point’s data (\(t_{0}\)) and one includes all the following time points’ data (\(t_{1}\)). This is because we always want to use only the initial time point’s data as the training data to prevent any potential bias during the training process.
The labels/cell types of \(t_{0}\) data is optional. If you do not provide CASi with the cell labels, CASi will first perform an unsupervised clustering for unlabeled data and use the clustering number (e.g., C1, C2, C3…) as the cell type labels. Note that CASi will automatically select a smaller set of informative features/genes for computational efficiency. Below are the input parameters of the CreatCASiList function:
l1 <- CreateCASiList(t0_count = as.matrix(pbmc_demo[[1]]), t1_count = as.matrix(pbmc_demo[[3]]), t0_label = pbmc_demo[[2]])The CASi list should contain three elements:
names(l1)
#> [1] "Data: t0 cells gene expression" "Data: t0 cell types"
#> [3] "Data: t1 cell gene expression"CASi uses an artificial neural network built on Keras to annotate cells of \(t_{1}\) data. The Keras R interface uses the TensorFlow backend engine by default. So please make sure you have installed the Tensorflow package properly. Below are the input parameters of the CrossTimeAnnotation function:
l1 <- CrossTimeAnnotation(l1)The CASi list after this function should contain six elements:
names(l1)
#> [1] "Data: t0 cells gene expression" "Data: t0 cell types"
#> [3] "Data: t1 cell gene expression" "Neural network: setting"
#> [5] "Neural network: training history" "Data: t1 cell types"The next step of CASi is to identify any novel cell types that have emerged over time. When data of interest is collected from multiple time points’ samples, it is highly possible that the some cells such as tumor cells will differentiate and new cell types (e.g., a distinct subclone of tumor cells) might appear. This step helps to distinguish those new cell types from existing cell types. For the DetectNovelCells function, we have the following parameters:
l1 <- DetectNovelCells(l1)
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 362
#> Number of edges: 18353
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9990
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 362
#> Number of edges: 18353
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9913
#> Number of communities: 2
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9990
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9890
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9790
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9690
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9590
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9490
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9390
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9290
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9190
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9090
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8990
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8890
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8790
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8690
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8590
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8490
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8390
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8290
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8190
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8090
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7990
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7890
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7790
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7690
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7590
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7490
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7390
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7290
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7190
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7090
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6990
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6890
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6790
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6690
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6590
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6490
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6390
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6290
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6190
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6090
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.5990
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.5890
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.5790
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 307
#> Number of edges: 17256
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.5700
#> Number of communities: 2
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9990
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9890
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9790
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9690
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9590
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9490
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9390
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9290
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9190
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9090
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8990
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8890
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8790
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8690
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8590
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8490
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8390
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8290
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8190
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.8090
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7990
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7890
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7790
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7690
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7590
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7490
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7390
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7290
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7190
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.7090
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6990
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6890
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6790
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6690
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6590
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6490
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 433
#> Number of edges: 23692
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.6416
#> Number of communities: 2
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 396
#> Number of edges: 23383
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9990
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 396
#> Number of edges: 23383
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9890
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 396
#> Number of edges: 23383
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9790
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 396
#> Number of edges: 23383
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9690
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 396
#> Number of edges: 23383
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9590
#> Number of communities: 1
#> Elapsed time: 0 seconds
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#>
#> Number of nodes: 396
#> Number of edges: 23383
#>
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9495
#> Number of communities: 2
#> Elapsed time: 0 seconds The CASi
list after this function should contain seven elements:
names(l1)
#> [1] "Data: t0 cells gene expression"
#> [2] "Data: t0 cell types"
#> [3] "Data: t1 cell gene expression"
#> [4] "Neural network: setting"
#> [5] "Neural network: training history"
#> [6] "Data: t1 cell types"
#> [7] "Data: t1 cell types (potential novel cells)"This step performs differential analysis tailored to longitudinal scRNA-seq data. We combine a generalized linear model with iterative feature selection to select genes that have apparent increasing/decreasing behavior over time and genes that behave differently along time in different groups. Users of this function must provide the metadata of two variables: ‘Group’, which should be a binary factor variable, and ‘Time’, which can be either numerical or categorical variable. Below are the input parameters of the FindTemporalDEGs function:
To demonstrate this function, we manually adjusted the previous simulation dataset by adding cell-type-specific time/group effect. The demonstration list, “CASiList_tDEG_demo” and its corresponding metadata, “metadata_tDEG_demo” have been been lazy-loaded with the package. As shown below, the metadata should contain a Group variable and a Time variable, and the row number should match the total cell number of your data.
data("CASiList_tDEG_demo")
data("metadata_tDEG_demo")
summary(metadata_tDEG_demo)
#> Group Time
#> Length:3097 Length:3097
#> Class :character Class :character
#> Mode :character Mode :character
nCell_t0 <- length(CASiList_tDEG_demo[[2]])
nCell_t1 <- length(CASiList_tDEG_demo[[6]])
nCell_t0 + nCell_t1
#> [1] 3097l2 <- FindTemporalDEGs(CASiList_tDEG_demo, metadata_tDEG_demo)The CASi list after this function should contain eight elements:
names(l2)
#> [1] "Data: t0 cells gene expression"
#> [2] "Data: t0 cell types"
#> [3] "Data: t1 cell gene expression"
#> [4] "Neural network: setting"
#> [5] "Neural network: training history"
#> [6] "Data: t1 cell types"
#> [7] "Data: t1 cell types (potential novel cells)"
#> [8] "Cell-type-specific p-value of temporal DEGs"