Contents
SingleCellExperiment
object
library(SingleCellExperiment)
d <- read.table("~/Downloads/primedMed.txt", header = TRUE, stringsAsFactors = FALSE)
# annotate feature names
ann <- data.frame(feature_symbol = d[,1])
sce <- SingleCellExperiment(assays = list(counts = as.matrix(d[,-1])), rowData = ann)
# define ERCCs
isSpike(sce, "ERCC") <- grepl("ERCC", ann$feature_symbol)
# remove features with duplicated names
sce <- sce[!duplicated(rowData(sce)$feature_symbol), ]
Quality Control (QC)
library(scater)
sce <- calculateQCMetrics(
sce,
feature_controls = list(
ERCC = isSpike(sce, "ERCC")
)
)
# distribution of total counts
hist(log10(sce$total_counts + 1), breaks = 100)

# filter very lowly expressed cells
sce_filtered <- sce[,sce$total_counts > 10]
logcounts(sce_filtered) <- log2(calculateCPM(sce_filtered, use.size.factors = FALSE) + 1)
Run SC3
# run SC3
library(SC3)
sce_filtered <- sc3_prepare(sce_filtered, ks = 2:4)
sce_filtered <- sc3_estimate_k(sce_filtered)
metadata(sce_filtered)$sc3$k_estimation
## [1] 40
sessionInfo()
## R version 3.4.2 (2017-09-28)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS Sierra 10.12.6
##
## Matrix products: default
## BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
##
## attached base packages:
## [1] parallel stats4 stats graphics grDevices utils datasets
## [8] methods base
##
## other attached packages:
## [1] SC3_1.6.0 scater_1.7.1
## [3] ggplot2_2.2.1 SingleCellExperiment_1.0.0
## [5] SummarizedExperiment_1.8.0 DelayedArray_0.4.1
## [7] matrixStats_0.52.2 Biobase_2.38.0
## [9] GenomicRanges_1.30.0 GenomeInfoDb_1.14.0
## [11] IRanges_2.12.0 S4Vectors_0.16.0
## [13] BiocGenerics_0.24.0 BiocStyle_2.6.1
##
## loaded via a namespace (and not attached):
## [1] bitops_1.0-6 bit64_0.9-7 RColorBrewer_1.1-2
## [4] doParallel_1.0.11 progress_1.1.2 rprojroot_1.2
## [7] tools_3.4.2 backports_1.1.1 doRNG_1.6.6
## [10] R6_2.2.2 KernSmooth_2.23-15 vipor_0.4.5
## [13] DBI_0.7 lazyeval_0.2.1 colorspace_1.3-2
## [16] gridExtra_2.3 prettyunits_1.0.2 bit_1.1-12
## [19] compiler_3.4.2 pkgmaker_0.22 bookdown_0.5
## [22] caTools_1.17.1 scales_0.5.0 mvtnorm_1.0-6
## [25] DEoptimR_1.0-8 robustbase_0.92-8 stringr_1.2.0
## [28] digest_0.6.12 rmarkdown_1.8.3 XVector_0.18.0
## [31] rrcov_1.4-3 pkgconfig_2.0.1 htmltools_0.3.6
## [34] WriteXLS_4.0.0 limma_3.34.3 rlang_0.1.4
## [37] RSQLite_2.0 shiny_1.0.5 bindr_0.1
## [40] gtools_3.5.0 dplyr_0.7.4 RCurl_1.95-4.8
## [43] magrittr_1.5 GenomeInfoDbData_0.99.1 Matrix_1.2-11
## [46] Rcpp_0.12.14 ggbeeswarm_0.6.0 munsell_0.4.3
## [49] viridis_0.4.0 stringi_1.1.6 yaml_2.1.15
## [52] edgeR_3.20.1 zlibbioc_1.24.0 rhdf5_2.22.0
## [55] gplots_3.0.1 plyr_1.8.4 grid_3.4.2
## [58] blob_1.1.0 gdata_2.18.0 shinydashboard_0.6.1
## [61] lattice_0.20-35 locfit_1.5-9.1 knitr_1.17
## [64] rjson_0.2.15 rngtools_1.2.4 reshape2_1.4.2
## [67] codetools_0.2-15 biomaRt_2.34.0 XML_3.98-1.9
## [70] glue_1.2.0 evaluate_0.10.1 data.table_1.10.4-3
## [73] httpuv_1.3.5 foreach_1.4.3 gtable_0.2.0
## [76] assertthat_0.2.0 mime_0.5 xtable_1.8-2
## [79] e1071_1.6-8 pcaPP_1.9-72 class_7.3-14
## [82] viridisLite_0.2.0 pheatmap_1.0.8 tibble_1.3.4
## [85] iterators_1.0.8 registry_0.5 AnnotationDbi_1.40.0
## [88] beeswarm_0.2.3 memoise_1.1.0 tximport_1.6.0
## [91] bindrcpp_0.2 cluster_2.0.6 ROCR_1.0-7