Contents

1 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-Albrecht et al. 2018).

2 Load the necessary packages

suppressPackageStartupMessages({
  library(SingleCellExperiment)
  library(DuoClustering2018)
  library(dplyr)
  library(tidyr)
})
## snapshotDate(): 2021-03-24

3 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()
## snapshotDate(): 2021-03-24
## see ?DuoClustering2018 and browseVignettes('DuoClustering2018') for documentation
## loading from cache

4 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()
## snapshotDate(): 2021-03-24
## see ?DuoClustering2018 and browseVignettes('DuoClustering2018') for documentation
## loading from cache

5 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))
## DataFrame with 6 rows and 54 columns
##           Run LibraryName     phenoid libsize.drop feature.drop total_features
##   <character> <character> <character>    <logical>    <logical>      <integer>
## 1  SRR3952323      H7hESC      H7hESC        FALSE        FALSE           4895
## 2  SRR3952325      H7hESC      H7hESC        FALSE        FALSE           4887
## 3  SRR3952326      H7hESC      H7hESC        FALSE        FALSE           4888
## 4  SRR3952327      H7hESC      H7hESC        FALSE        FALSE           4879
## 5  SRR3952328      H7hESC      H7hESC        FALSE        FALSE           4873
## 6  SRR3952329      H7hESC      H7hESC        FALSE        FALSE           4893
##   log10_total_features total_counts log10_total_counts
##              <numeric>    <numeric>          <numeric>
## 1              3.68984      2248411            6.35188
## 2              3.68913      2271617            6.35634
## 3              3.68922       584682            5.76692
## 4              3.68842      3191810            6.50404
## 5              3.68789      2190385            6.34052
## 6              3.68966      2187289            6.33991
##   pct_counts_top_50_features pct_counts_top_100_features
##                    <numeric>                   <numeric>
## 1                    18.2790                     25.9754
## 2                    24.6725                     32.2228
## 3                    22.7328                     30.2060
## 4                    20.8674                     29.0039
## 5                    21.2879                     29.4237
## 6                    20.5931                     27.7401
##   pct_counts_top_200_features pct_counts_top_500_features is_cell_control
##                     <numeric>                   <numeric>       <logical>
## 1                     35.5376                     52.4109           FALSE
## 2                     41.5474                     57.9692           FALSE
## 3                     39.4313                     55.2858           FALSE
## 4                     38.7856                     56.0209           FALSE
## 5                     39.3077                     56.6410           FALSE
## 6                     36.7819                     52.7547           FALSE
##        CIDR_3      CIDR_5      CIDR_9   FlowSOM_3   FlowSOM_5   FlowSOM_9
##   <character> <character> <character> <character> <character> <character>
## 1           1           1           1           2           2           4
## 2           1           1           1           2           2           4
## 3           1           1           1           2           2           4
## 4           1           1           1           2           2           4
## 5           1           1           1           2           2           4
## 6           1           1           1           2           2           4
##       PCAHC_3     PCAHC_5     PCAHC_9 PCAKmeans_3 PCAKmeans_5 PCAKmeans_9
##   <character> <character> <character> <character> <character> <character>
## 1           1           1           1           3           1           4
## 2           1           1           1           3           1           4
## 3           1           1           1           3           1           4
## 4           1           1           1           3           1           4
## 5           1           1           1           3           1           4
## 6           1           1           1           3           1           4
##     RaceID2_3   RaceID2_5   RaceID2_9 RtsneKmeans_3 RtsneKmeans_5 RtsneKmeans_9
##   <character> <character> <character>   <character>   <character>   <character>
## 1           1           1           1             1             1             9
## 2           2           2           2             1             1             9
## 3           2           2           2             1             1             9
## 4           1           1           1             1             1             9
## 5           1           1           1             1             1             9
## 6           1           2           2             1             1             9
##        SAFE_3      SAFE_5      SAFE_9       SC3_3       SC3_5       SC3_9
##   <character> <character> <character> <character> <character> <character>
## 1           2           1           3           1           3           4
## 2           2           1           5           1           3           4
## 3           2           1           3           1           3           4
## 4           2           1           5           1           3           4
## 5           2           1           5           1           3           4
## 6           2           1           5           1           3           4
##      SC3svm_3    SC3svm_5    SC3svm_9    Seurat_9     TSCAN_3     TSCAN_5
##   <character> <character> <character> <character> <character> <character>
## 1           3           3           3           5           1           1
## 2           3           3           3           5           1           1
## 3           3           3           3           5           3           3
## 4           3           3           3           5           1           1
## 5           3           3           3           5           2           2
## 6           3           3           3           5           1           1
##       TSCAN_9    ascend_3    ascend_5    ascend_9   monocle_3   monocle_5
##   <character> <character> <character> <character> <character> <character>
## 1           1           1          NA          NA           3           3
## 2           2           1          NA          NA           3           3
## 3           2           1          NA          NA           3           3
## 4           1           1          NA          NA           3           3
## 5           2           1          NA          NA           3           3
## 6           1           1          NA          NA           3           3
##     monocle_9 pcaReduce_3 pcaReduce_5 pcaReduce_9
##   <character> <character> <character> <character>
## 1           3           1           5           5
## 2           3           1           5           5
## 3           3           1           5           5
## 4           3           1           5           5
## 5           3           1           5           5
## 6           3           1           5           5

6 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)
}

7 Session info

sessionInfo()
## R Under development (unstable) (2021-02-10 r79979)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.2 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.13-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.13-bioc/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] parallel  stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] tidyr_1.1.3                  dplyr_1.0.5                 
##  [3] DuoClustering2018_1.9.0      SingleCellExperiment_1.13.12
##  [5] SummarizedExperiment_1.21.1  Biobase_2.51.0              
##  [7] GenomicRanges_1.43.3         GenomeInfoDb_1.27.8         
##  [9] IRanges_2.25.6               S4Vectors_0.29.9            
## [11] BiocGenerics_0.37.1          MatrixGenerics_1.3.1        
## [13] matrixStats_0.58.0           BiocStyle_2.19.1            
## 
## loaded via a namespace (and not attached):
##  [1] bitops_1.0-6                  bit64_4.0.5                  
##  [3] filelock_1.0.2                httr_1.4.2                   
##  [5] tools_4.1.0                   bslib_0.2.4                  
##  [7] utf8_1.2.1                    R6_2.5.0                     
##  [9] DBI_1.1.1                     colorspace_2.0-0             
## [11] withr_2.4.1                   tidyselect_1.1.0             
## [13] gridExtra_2.3                 bit_4.0.4                    
## [15] curl_4.3                      compiler_4.1.0               
## [17] DelayedArray_0.17.10          bookdown_0.21                
## [19] sass_0.3.1                    scales_1.1.1                 
## [21] rappdirs_0.3.3                stringr_1.4.0                
## [23] digest_0.6.27                 rmarkdown_2.7                
## [25] XVector_0.31.1                pkgconfig_2.0.3              
## [27] htmltools_0.5.1.1             dbplyr_2.1.0                 
## [29] fastmap_1.1.0                 rlang_0.4.10                 
## [31] ggthemes_4.2.4                RSQLite_2.2.4                
## [33] shiny_1.6.0                   jquerylib_0.1.3              
## [35] generics_0.1.0                jsonlite_1.7.2               
## [37] mclust_5.4.7                  RCurl_1.98-1.3               
## [39] magrittr_2.0.1                GenomeInfoDbData_1.2.4       
## [41] Matrix_1.3-2                  Rcpp_1.0.6                   
## [43] munsell_0.5.0                 fansi_0.4.2                  
## [45] viridis_0.5.1                 lifecycle_1.0.0              
## [47] stringi_1.5.3                 yaml_2.2.1                   
## [49] debugme_1.1.0                 zlibbioc_1.37.0              
## [51] plyr_1.8.6                    BiocFileCache_1.15.1         
## [53] AnnotationHub_2.23.2          grid_4.1.0                   
## [55] blob_1.2.1                    promises_1.2.0.1             
## [57] ExperimentHub_1.17.1          crayon_1.4.1                 
## [59] lattice_0.20-41               Biostrings_2.59.2            
## [61] KEGGREST_1.31.1               knitr_1.31                   
## [63] pillar_1.5.1                  reshape2_1.4.4               
## [65] glue_1.4.2                    BiocVersion_3.13.1           
## [67] evaluate_0.14                 BiocManager_1.30.10          
## [69] png_0.1-7                     vctrs_0.3.6                  
## [71] httpuv_1.5.5                  gtable_0.3.0                 
## [73] purrr_0.3.4                   assertthat_0.2.1             
## [75] cachem_1.0.4                  ggplot2_3.3.3                
## [77] xfun_0.22                     mime_0.10                    
## [79] xtable_1.8-4                  later_1.1.0.1                
## [81] viridisLite_0.3.0             tibble_3.1.0                 
## [83] AnnotationDbi_1.53.1          memoise_2.0.0                
## [85] ellipsis_0.3.1                interactiveDisplayBase_1.29.0

References

Rue-Albrecht, K, F Marini, C Soneson, and ATL Lun. 2018. “iSEE: Interactive SummarizedExperiment Explorer.” F1000Research 7: 741.