Introduction

In this vignette we describe how to generate a SingleCellExperiment object combining observed values and clustering results for a data set from the DuoClustering2018 package, and how the resulting object can be explored and visualized with the iSEE package [@Rue-Albrecht2018-wz].

Load the necessary packages

suppressPackageStartupMessages({
  library(SingleCellExperiment)
  library(DuoClustering2018)
  library(dplyr)
  library(tidyr)
})

Retrieve a data set

The different ways of retrieving a data set from the package are described in the plot_performance vignette. Here, we will load a data set using the shortcut function provided in the package.

dat <- sce_filteredExpr10_Koh()

Read a set of clustering results

For this data set, we also load a set of clustering results obtained using different clustering methods.

res <- clustering_summary_filteredExpr10_Koh_v2()

Merge data and clustering results

We add the cluster labels for one run and for a set of different imposed number of clusters to the data set.

res <- res %>% dplyr::filter(run == 1 & k %in% c(3, 5, 9)) %>%
  dplyr::group_by(method, k) %>% 
  dplyr::filter(is.na(resolution) | resolution == resolution[1]) %>%
  dplyr::ungroup() %>% 
  tidyr::unite(col = method_k, method, k, sep = "_", remove = TRUE) %>% 
  dplyr::select(cell, method_k, cluster) %>%
  tidyr::spread(key = method_k, value = cluster)

colData(dat) <- DataFrame(
  as.data.frame(colData(dat)) %>%
    dplyr::left_join(res, by = c("Run" = "cell"))
)
head(colData(dat))

Visualize with iSEE

The resulting SingleCellExperiment can be interactively explored using, e.g., the iSEE package. This can be useful to gain additional understanding of the partitions inferred by the different clustering methods, to visualize these in low-dimensional representations (PCA or t-SNE), and to investigate how well they agree with known or inferred groupings of the cells.

if (require(iSEE)) {
  iSEE(dat)
}

Session info

sessionInfo()

References



csoneson/DuoClustering2018 documentation built on May 18, 2024, 7:13 a.m.