Commit 22a6becb authored by Anne  BITON's avatar Anne BITON
Browse files

Replace YS_02.merge_withoutMitoGenes.Rmd

parent afc977a3
......@@ -50,12 +50,9 @@ We load the data obtained after a first filtering step was applied: cells for w
```{r load sce ys}
Look at the distribution of the fraction of UMI counts taken up by mitochondrial genes, the cells with more than 5% have already been filtered out.
Note: Some proportion are larger than 5% below because the fraction of UMI counts is recomputed on the filtered data and so the set of genes is smaller hence the total UMI counts per cell too.
......@@ -143,8 +140,8 @@ bio <- combined.decs[order(combined.decs$bio, decreasing = TRUE),'bio']
# use the top 3000 positive "biological" variance as variable genes
chosen <- names(bio[1:3000])
sceall <- lapply(sce_merge, function(x) x[chosen,])
sceall <-,sceall)
sceall <-,sce_merge)
......@@ -160,6 +157,17 @@ Batch effects were removed by hierarchically merging the samples using the `redu
We first merged plates by run within condition and then merged the three runs together. This is done on the `r length(chosen)` genes selected above.
```{r multiBatchPCA}
sceall$condition_run <- paste(sceall$condition, sceall$run, sep='_')
sceall$condition_run_plate <- paste(sceall$condition, sceall$run, sceall$plate, sep='_')
#We use the multiBatchPCA() function to perform a PCA across all batches to be merged. This ensures that all cells are placed onto the same coordinate space, which would obviously not be possible if a PCA was performed for each batch separately. Specifically, multiBatchPCA() performs a modified PCA to ensure that each supplied matrix contributes equally to the definition of the PC space. This avoids problems with imbalances in the number of cells across batches, meaning that smaller batches (possibly with unique cell types) are not ignored.
pcs <- batchelor::multiBatchPCA(sceall[chosen,], batch=sceall$condition_run_plate, BPPARAM= BiocParallel::MulticoreParam(3))
reducedDim(sceall, "multiBatchPCA") <-,pcs)[colnames(sceall),]
```{r merge by condition and run then by condition across runs then across conditions}
......@@ -182,12 +190,13 @@ mnn.e9.5yolksac <-batchelor::reducedMNN(mnn.run3.e9.5yolksac$corrected, <- batchelor::reducedMNN(mnn.e10.5yolksac$corrected,
sceall_seurat[['fastMNN']] <- CreateDimReducObject(embeddings =$corrected, key = 'fastMNN')
sceall_seurat[['multiBatchPCA']] <- CreateDimReducObject(embeddings =,pcs), key = 'multiBatchPCA')
sceall_seurat <- as.Seurat(sceall)
sceall_seurat[['fastMNN']] <- CreateDimReducObject(embeddings =$corrected[colnames(sceall_seurat),], key = 'fastMNN')
VariableFeatures(sceall_seurat) <- chosen
save(sceall_seurat, file = paste0(dirdata,'derived/YS_library123/YS_sceall_seurat_fastMNN_bycondbyrun_withoutMitoGenes.rda'))
save(sceall_seurat, file = paste0(dirdata,'derived/YS/YS_sceall_seurat_fastMNN_bycondbyrun_withoutMitoGenes.rda'))
......@@ -196,7 +205,7 @@ save(sceall_seurat, file = paste0(dirdata,'derived/YS_library123/YS_sceall_seura
```{r plot merge by condition then runs}
sceall_seurat <- RunUMAP(object = sceall_seurat, dims = 1:50, reduction = 'fastMNN', verbose=FALSE)
sceall_seurat <- RunUMAP(object = sceall_seurat, dims = 1:50, reduction = 'fastMNN', verbose=FALSE, n.neighbors = 16, min.dist = 0.32)
DimPlot(object = sceall_seurat , reduction = "umap", = 'run', pt.size = .9, dims = c(1,2), label = FALSE)
DimPlot(object = sceall_seurat , reduction = "umap", = 'condition', pt.size = .9, dims = c(1,2), label = FALSE)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment