This vignette assumes that you have a SingleCellExperiment object at
the ready. As an example, we create one from the ginhoux
dataset containing 248 dendritic cell progenitors.
## Warning: replacing previous import 'S4Arrays::read_block' by
## 'DelayedArray::read_block' when loading 'SummarizedExperiment'
data(ginhoux)
sce <- SingleCellExperiment(
assays = list(counts = t(ginhoux$expression)),
colData = ginhoux$sample_info
)
# short hand notation
group_name <- colData(sce)$group_name
sce
## class: SingleCellExperiment
## dim: 2000 245
## metadata(0):
## assays(1): counts
## rownames(2000): Mpo DQ688647 ... Clcf1 Pip5k1c
## rowData names(0):
## colnames(245): SRR1558744 SRR1558745 ... SRR1558993 SRR1558994
## colData names(1): group_name
## reducedDimNames(0):
## mainExpName: NULL
## altExpNames(0):
The new space is a matrix that can be visualised with or without colouring of the different cell types.
The result is a list containing the final trajectory
path
and the inferred timeline for each sample
time
.
gimp <- gene_importances(
t(assay(sce, "counts")),
traj$time,
num_permutations = 0,
num_threads = 8
)
gene_sel <- gimp[1:50,]
expr_sel <- t(assay(sce, "counts"))[,gene_sel$gene]
To visualise the expression of the selected genes, use the
draw_trajectory_heatmap
function.
Finally, these genes can also be grouped into modules as follows:
reducedDims(sce) <- SimpleList(MDS = space)
colData(sce)$trajectory_path <- traj$path
colData(sce)$trajectory_pseudotime <- traj$time
rowData(sce)$trajectory_importance <- gimp[match(rownames(sce), gimp$gene),]$importance
sce
## class: SingleCellExperiment
## dim: 2000 245
## metadata(0):
## assays(1): counts
## rownames(2000): Mpo DQ688647 ... Clcf1 Pip5k1c
## rowData names(1): trajectory_importance
## colnames(245): SRR1558744 SRR1558745 ... SRR1558993 SRR1558994
## colData names(3): group_name trajectory_path trajectory_pseudotime
## reducedDimNames(1): MDS
## mainExpName: NULL
## altExpNames(0):