Load packages
library( "DropletUtils" )
Warning message:
In if (charToRaw(x) < 20) paste("\\u", toupper(format(as.hexmode(as.integer(charToRaw(x))), :
the condition has length > 1 and only the first element will be used
library( "scater" )
library( "scran" )
Prepare data
Load counts
sce <- read10xCounts( "/home/idies/workspace/practical_genomics/day1/pbmc3k/filtered_gene_bc_matrices/hg19/", col.names=TRUE )
rownames( sce ) <- rowData( sce )$Symbol
sce
class: SingleCellExperiment
dim: 32738 2700
metadata(1): Samples
assays(1): counts
rownames(32738): MIR1302-10 FAM138A ... AC002321.2
AC002321.1
rowData names(2): ID Symbol
colnames(2700): AAACATACAACCAC-1 AAACATTGAGCTAC-1 ...
TTTGCATGAGAGGC-1 TTTGCATGCCTCAC-1
colData names(2): Sample Barcode
reducedDimNames(0):
altExpNames(0):
Normalize
sce <- logNormCounts( sce )
sce
class: SingleCellExperiment
dim: 32738 2700
metadata(1): Samples
assays(2): counts logcounts
rownames(32738): MIR1302-10 FAM138A ... AC002321.2
AC002321.1
rowData names(2): ID Symbol
colnames(2700): AAACATACAACCAC-1 AAACATTGAGCTAC-1 ...
TTTGCATGAGAGGC-1 TTTGCATGCCTCAC-1
colData names(3): Sample Barcode sizeFactor
reducedDimNames(0):
altExpNames(0):
Find variable genes
dec <- modelGeneVar( sce )
hvg <- getTopHVGs( dec, prop=0.1 )
Reduce dimensions
sce <- runPCA( sce, ncomponents=25, subset_row=hvg )
sce <- runUMAP( sce, dimred="PCA", external_neighbors=TRUE )
Cluster
g <- buildSNNGraph( sce, use.dimred="PCA" )
colLabels( sce ) <- factor( igraph::cluster_louvain(g)$membership )
Find makers
markers <- findMarkers( sce )
data.frame( markers[[1]] )
Visualize cells
plotUMAP( sce, colour_by="label", text_by="label" )
plotUMAP( sce, colour_by="MS4A1" )
Visalize expression
goi <- c( "MS4A1", "GNLY", "CD3E", "CD14", "FCER1A", "FCGR3A", "LYZ", "PPBP", "CD8A" )
plotExpression( sce, x="label", features=goi )
plotGroupedHeatmap( sce, group="label", features=goi, scale="row" )
Save object
saveRDS( sce, "/home/idies/workspace/practical_genomics/day1/pbmc3k.rds" )
Document software
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 8
Matrix products: default
BLAS: /home/idies/R/lib64/R/lib/libRblas.so
LAPACK: /home/idies/R/lib64/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[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
[7] datasets methods base
other attached packages:
[1] scran_1.18.7 scater_1.18.6
[3] ggplot2_3.3.3 DropletUtils_1.10.3
[5] SingleCellExperiment_1.12.0 SummarizedExperiment_1.20.0
[7] Biobase_2.50.0 GenomicRanges_1.42.0
[9] GenomeInfoDb_1.26.7 IRanges_2.24.1
[11] S4Vectors_0.28.1 BiocGenerics_0.36.1
[13] MatrixGenerics_1.2.1 matrixStats_0.58.0
loaded via a namespace (and not attached):
[1] viridis_0.6.1 edgeR_3.32.1
[3] BiocSingular_1.6.0 jsonlite_1.7.2
[5] viridisLite_0.4.0 DelayedMatrixStats_1.12.3
[7] scuttle_1.0.4 R.utils_2.10.1
[9] assertthat_0.2.1 statmod_1.4.35
[11] dqrng_0.2.1 GenomeInfoDbData_1.2.4
[13] vipor_0.4.5 yaml_2.2.1
[15] pillar_1.6.0 lattice_0.20-41
[17] glue_1.4.2 limma_3.46.0
[19] beachmat_2.6.4 digest_0.6.27
[21] RColorBrewer_1.1-2 XVector_0.30.0
[23] colorspace_2.0-0 cowplot_1.1.1
[25] htmltools_0.5.1.1 Matrix_1.2-18
[27] R.oo_1.24.0 pkgconfig_2.0.3
[29] pheatmap_1.0.12 zlibbioc_1.36.0
[31] purrr_0.3.4 scales_1.1.1
[33] RSpectra_0.16-0 HDF5Array_1.18.1
[35] BiocParallel_1.24.1 tibble_3.1.1
[37] farver_2.1.0 generics_0.1.0
[39] ellipsis_0.3.2 withr_2.4.2
[41] cli_2.5.0 magrittr_2.0.1
[43] crayon_1.4.1 evaluate_0.14
[45] R.methodsS3_1.8.1 fansi_0.4.2
[47] bluster_1.0.0 beeswarm_0.3.1
[49] tools_4.0.3 lifecycle_1.0.0
[51] Rhdf5lib_1.12.1 munsell_0.5.0
[53] locfit_1.5-9.4 DelayedArray_0.16.3
[55] irlba_2.3.3 compiler_4.0.3
[57] rsvd_1.0.5 rlang_0.4.10
[59] rhdf5_2.34.0 grid_4.0.3
[61] RCurl_1.98-1.3 rstudioapi_0.13
[63] rhdf5filters_1.2.0 BiocNeighbors_1.8.2
[65] igraph_1.2.6 labeling_0.4.2
[67] bitops_1.0-7 rmarkdown_2.7
[69] gtable_0.3.0 DBI_1.1.1
[71] R6_2.5.0 gridExtra_2.3
[73] knitr_1.33 dplyr_1.0.7
[75] uwot_0.1.10 utf8_1.2.1
[77] ggbeeswarm_0.6.0 Rcpp_1.0.6
[79] vctrs_0.3.8 tidyselect_1.1.1
[81] xfun_0.22 sparseMatrixStats_1.2.1
LS0tCnRpdGxlIDogIlBHMjAyMSBEYXkgMSAtLSBQcm9jZXNzIHBibWMzayB1c2luZyBCaW9jb25kdWN0b3IgT1NDQSIKYXV0aG9yOiAiRnJlZGVyaWNrIEogVGFuIgpkYXRlICA6ICIyOCBTZXB0ZW1iZXIgMjAyMSIKb3V0cHV0OiAKICBodG1sX25vdGVib29rOgogICAgdG9jOiB0cnVlCiAgICB0b2NfZmxvYXQ6IHRydWUKLS0tCgojIFN1bW1hcnkKCi0gQmFzZWQgb24gaHR0cHM6Ly9iaW9jb25kdWN0b3Iub3JnL2Jvb2tzL3JlbGVhc2UvT1NDQS91bmZpbHRlcmVkLWh1bWFu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