-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathR-batchJob_NAc-n8_optimalPCselxn_MNT2021.R
49 lines (37 loc) · 1.71 KB
/
R-batchJob_NAc-n8_optimalPCselxn_MNT2021.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
################################################################################
### LIBD pilot 10x snRNA-seq: Nucleus accumbens samples - 8 samples (as of revision)
### **Region-specific analyses**
### - R-batch job for detxn of optimal PC space with 'sce.nac' object
### -> see '10x_NAc-n8_step02_clust-annot_MNT.R'
### for setup of the SCE
### MNT 23Jun2021
################################################################################
library(SingleCellExperiment)
library(scRNAseq)
library(batchelor)
library(EnsDb.Hsapiens.v86)
library(scater)
library(scran)
library(uwot)
library(DropletUtils)
library(jaffelab)
# ===
load("/dcs04/lieber/marmaypag/Tran_LIBD001/Matt/MNT_thesis/snRNAseq/10x_pilot_FINAL/rdas/revision/regionSpecific_NAc-n8_cleaned-combined_MNT2021.rda",
verbose=TRUE)
# sce.nac, chosen.hvgs.nac, ref.sampleInfo
## ** [corrected] PCA already done (interactively, using `fastMNN`) - took top 100 PCs **
# getClusteredPCs() to identify working PC space
pc.choice.nac <- getClusteredPCs(reducedDim(sce.nac, "PCA_corrected"))
# How many PCs should use in this space?
metadata(pc.choice.nac)$chosen
## Plot n Clusters vs. d PCs
pdf("/dcs04/lieber/marmaypag/Tran_LIBD001/Matt/MNT_thesis/snRNAseq/10x_pilot_FINAL/pdfs/revision/regionSpecific_NAc-n8_getClusteredPCs_MNT2021.pdf")
plot(pc.choice.nac$n.pcs, pc.choice.nac$n.clusters,
main=paste0("Combined NAc (n=8) samples (d PCs choice = ", metadata(pc.choice.nac)$chosen, ")"))
abline(v=metadata(pc.choice.nac)$chosen, col="red", lty="dashed", lwd=0.8)
dev.off()
# Save
save(sce.nac, chosen.hvgs.nac, ref.sampleInfo, pc.choice.nac,
file="rdas/revision/regionSpecific_NAc-n8_cleaned-combined_MNT2021.rda")
rm(list=ls())
sessionInfo()