# Chimeric mouse embryo (10X Genomics) ## Introduction This performs an analysis of the @pijuansala2019single dataset on mouse gastrulation. Here, we examine chimeric embryos at the E8.5 stage of development where td-Tomato-positive embryonic stem cells (ESCs) were injected into a wild-type blastocyst. ## Data loading ```r library(MouseGastrulationData) sce.chimera <- WTChimeraData(samples=5:10) counts(sce.chimera) <- as(counts(sce.chimera), "CsparseMatrix") sce.chimera ``` ``` ## class: SingleCellExperiment ## dim: 29453 20935 ## metadata(0): ## assays(1): counts ## rownames(29453): ENSMUSG00000051951 ENSMUSG00000089699 ... ## ENSMUSG00000095742 tomato-td ## rowData names(2): ENSEMBL SYMBOL ## colnames(20935): cell_9769 cell_9770 ... cell_30702 cell_30703 ## colData names(11): cell barcode ... doub.density sizeFactor ## reducedDimNames(2): pca.corrected.E7.5 pca.corrected.E8.5 ## mainExpName: NULL ## altExpNames(0): ``` ```r library(scater) rownames(sce.chimera) <- uniquifyFeatureNames( rowData(sce.chimera)$ENSEMBL, rowData(sce.chimera)$SYMBOL) ``` ## Quality control Quality control on the cells has already been performed by the authors, so we will not repeat it here. We additionally remove cells that are labelled as stripped nuclei or doublets. ```r drop <- sce.chimera$celltype.mapped %in% c("stripped", "Doublet") sce.chimera <- sce.chimera[,!drop] ``` ## Normalization We use the pre-computed size factors in `sce.chimera`. ```r sce.chimera <- logNormCounts(sce.chimera) ``` ## Variance modelling We retain all genes with any positive biological component, to preserve as much signal as possible across a very heterogeneous dataset. ```r library(scran) dec.chimera <- modelGeneVar(sce.chimera, block=sce.chimera$sample) chosen.hvgs <- dec.chimera$bio > 0 ``` ```r par(mfrow=c(1,2)) blocked.stats <- dec.chimera$per.block for (i in colnames(blocked.stats)) { current <- blocked.stats[[i]] plot(current$mean, current$total, main=i, pch=16, cex=0.5, xlab="Mean of log-expression", ylab="Variance of log-expression") curfit <- metadata(current) curve(curfit$trend(x), col='dodgerblue', add=TRUE, lwd=2) } ```
Per-gene variance as a function of the mean for the log-expression values in the Pijuan-Sala chimeric mouse embryo dataset. Each point represents a gene (black) with the mean-variance trend (blue) fitted to the variances.

(\#fig:unref-pijuan-var-1)Per-gene variance as a function of the mean for the log-expression values in the Pijuan-Sala chimeric mouse embryo dataset. Each point represents a gene (black) with the mean-variance trend (blue) fitted to the variances.

Per-gene variance as a function of the mean for the log-expression values in the Pijuan-Sala chimeric mouse embryo dataset. Each point represents a gene (black) with the mean-variance trend (blue) fitted to the variances.

(\#fig:unref-pijuan-var-2)Per-gene variance as a function of the mean for the log-expression values in the Pijuan-Sala chimeric mouse embryo dataset. Each point represents a gene (black) with the mean-variance trend (blue) fitted to the variances.

Per-gene variance as a function of the mean for the log-expression values in the Pijuan-Sala chimeric mouse embryo dataset. Each point represents a gene (black) with the mean-variance trend (blue) fitted to the variances.

(\#fig:unref-pijuan-var-3)Per-gene variance as a function of the mean for the log-expression values in the Pijuan-Sala chimeric mouse embryo dataset. Each point represents a gene (black) with the mean-variance trend (blue) fitted to the variances.

## Merging We use a hierarchical merge to first merge together replicates with the same genotype, and then merge samples across different genotypes. ```r library(batchelor) set.seed(01001001) merged <- correctExperiments(sce.chimera, batch=sce.chimera$sample, subset.row=chosen.hvgs, PARAM=FastMnnParam( merge.order=list( list(1,3,5), # WT (3 replicates) list(2,4,6) # td-Tomato (3 replicates) ) ) ) ``` We use the percentage of variance lost as a diagnostic: ```r metadata(merged)$merge.info$lost.var ``` ``` ## 5 6 7 8 9 10 ## [1,] 0.000e+00 0.0204433 0.000e+00 0.0169567 0.000000 0.000000 ## [2,] 0.000e+00 0.0007389 0.000e+00 0.0004409 0.000000 0.015474 ## [3,] 3.090e-02 0.0000000 2.012e-02 0.0000000 0.000000 0.000000 ## [4,] 9.024e-05 0.0000000 8.272e-05 0.0000000 0.018047 0.000000 ## [5,] 4.321e-03 0.0072518 4.124e-03 0.0078280 0.003831 0.007786 ``` ## Clustering ```r g <- buildSNNGraph(merged, use.dimred="corrected") clusters <- igraph::cluster_louvain(g) colLabels(merged) <- factor(clusters$membership) ``` We examine the distribution of cells across clusters and samples. ```r table(Cluster=colLabels(merged), Sample=merged$sample) ``` ``` ## Sample ## Cluster 5 6 7 8 9 10 ## 1 87 20 62 53 151 74 ## 2 146 37 132 110 231 215 ## 3 98 16 163 125 367 273 ## 4 134 101 188 442 378 465 ## 5 108 42 314 398 185 242 ## 6 206 51 338 205 525 607 ## 7 149 71 85 86 163 380 ## 8 131 95 108 65 161 311 ## 9 82 20 75 33 165 203 ## 10 97 19 36 18 50 35 ## 11 109 40 46 37 41 147 ## 12 125 67 66 52 63 142 ## 13 157 78 131 104 162 438 ## 14 110 69 72 96 127 253 ## 15 84 48 159 357 198 623 ## 16 43 36 82 81 86 357 ## 17 176 47 223 180 210 381 ## 18 77 43 189 117 324 485 ## 19 47 22 84 50 90 130 ## 20 39 41 50 49 130 126 ## 21 1 5 0 84 0 66 ## 22 18 7 13 17 20 38 ## 23 52 25 79 69 76 182 ## 24 9 7 18 13 30 27 ## 25 11 16 20 9 47 58 ## 26 2 1 7 3 77 138 ## 27 0 2 0 51 0 5 ``` ## Dimensionality reduction We use an external algorithm to compute nearest neighbors for greater speed. ```r merged <- runTSNE(merged, dimred="corrected", external_neighbors=TRUE) merged <- runUMAP(merged, dimred="corrected", external_neighbors=TRUE) ``` ```r gridExtra::grid.arrange( plotTSNE(merged, colour_by="label", text_by="label", text_colour="red"), plotTSNE(merged, colour_by="batch") ) ```
Obligatory $t$-SNE plots of the Pijuan-Sala chimeric mouse embryo dataset, where each point represents a cell and is colored according to the assigned cluster (top) or sample of origin (bottom).

(\#fig:unref-pijuan-tsne)Obligatory $t$-SNE plots of the Pijuan-Sala chimeric mouse embryo dataset, where each point represents a cell and is colored according to the assigned cluster (top) or sample of origin (bottom).

## Session Info {-}
``` R version 4.3.2 Patched (2023-11-13 r85521) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 22.04.3 LTS Matrix products: default BLAS: /home/biocbuild/bbs-3.18-bioc/R/lib/libRblas.so LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_GB 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 time zone: America/New_York tzcode source: system (glibc) attached base packages: [1] stats4 stats graphics grDevices utils datasets methods [8] base other attached packages: [1] batchelor_1.18.1 scran_1.30.2 [3] scater_1.30.1 ggplot2_3.4.4 [5] scuttle_1.12.0 MouseGastrulationData_1.16.0 [7] SpatialExperiment_1.12.0 SingleCellExperiment_1.24.0 [9] SummarizedExperiment_1.32.0 Biobase_2.62.0 [11] GenomicRanges_1.54.1 GenomeInfoDb_1.38.6 [13] IRanges_2.36.0 S4Vectors_0.40.2 [15] BiocGenerics_0.48.1 MatrixGenerics_1.14.0 [17] matrixStats_1.2.0 BiocStyle_2.30.0 [19] rebook_1.12.0 loaded via a namespace (and not attached): [1] jsonlite_1.8.8 CodeDepends_0.6.5 [3] magrittr_2.0.3 ggbeeswarm_0.7.2 [5] magick_2.8.2 farver_2.1.1 [7] rmarkdown_2.25 zlibbioc_1.48.0 [9] vctrs_0.6.5 memoise_2.0.1 [11] DelayedMatrixStats_1.24.0 RCurl_1.98-1.14 [13] htmltools_0.5.7 S4Arrays_1.2.0 [15] AnnotationHub_3.10.0 curl_5.2.0 [17] BiocNeighbors_1.20.2 SparseArray_1.2.4 [19] sass_0.4.8 bslib_0.6.1 [21] cachem_1.0.8 ResidualMatrix_1.12.0 [23] igraph_2.0.1.1 mime_0.12 [25] lifecycle_1.0.4 pkgconfig_2.0.3 [27] rsvd_1.0.5 Matrix_1.6-5 [29] R6_2.5.1 fastmap_1.1.1 [31] GenomeInfoDbData_1.2.11 shiny_1.8.0 [33] digest_0.6.34 colorspace_2.1-0 [35] AnnotationDbi_1.64.1 dqrng_0.3.2 [37] irlba_2.3.5.1 ExperimentHub_2.10.0 [39] RSQLite_2.3.5 beachmat_2.18.1 [41] labeling_0.4.3 filelock_1.0.3 [43] fansi_1.0.6 httr_1.4.7 [45] abind_1.4-5 compiler_4.3.2 [47] bit64_4.0.5 withr_3.0.0 [49] BiocParallel_1.36.0 viridis_0.6.5 [51] DBI_1.2.1 highr_0.10 [53] rappdirs_0.3.3 DelayedArray_0.28.0 [55] rjson_0.2.21 bluster_1.12.0 [57] tools_4.3.2 vipor_0.4.7 [59] beeswarm_0.4.0 interactiveDisplayBase_1.40.0 [61] httpuv_1.6.14 glue_1.7.0 [63] promises_1.2.1 grid_4.3.2 [65] Rtsne_0.17 cluster_2.1.6 [67] generics_0.1.3 gtable_0.3.4 [69] metapod_1.10.1 BiocSingular_1.18.0 [71] ScaledMatrix_1.10.0 utf8_1.2.4 [73] XVector_0.42.0 ggrepel_0.9.5 [75] BiocVersion_3.18.1 pillar_1.9.0 [77] limma_3.58.1 BumpyMatrix_1.10.0 [79] later_1.3.2 dplyr_1.1.4 [81] BiocFileCache_2.10.1 lattice_0.22-5 [83] bit_4.0.5 tidyselect_1.2.0 [85] locfit_1.5-9.8 Biostrings_2.70.2 [87] knitr_1.45 gridExtra_2.3 [89] bookdown_0.37 edgeR_4.0.15 [91] xfun_0.42 statmod_1.5.0 [93] yaml_2.3.8 evaluate_0.23 [95] codetools_0.2-19 tibble_3.2.1 [97] BiocManager_1.30.22 graph_1.80.0 [99] cli_3.6.2 uwot_0.1.16 [101] xtable_1.8-4 munsell_0.5.0 [103] jquerylib_0.1.4 Rcpp_1.0.12 [105] dir.expiry_1.10.0 dbplyr_2.4.0 [107] png_0.1-8 XML_3.99-0.16.1 [109] parallel_4.3.2 ellipsis_0.3.2 [111] blob_1.2.4 sparseMatrixStats_1.14.0 [113] bitops_1.0-7 viridisLite_0.4.2 [115] scales_1.3.0 purrr_1.0.2 [117] crayon_1.5.2 rlang_1.1.3 [119] cowplot_1.1.3 KEGGREST_1.42.0 ```