swhite_20 <- ReadH5AD(file ="additional_files/adata/white_20.h5ad")
swhite_20@meta.data$nCount_RNA=colSums(swhite_20@assays$RNA@counts)
swhite_20@meta.data$nFeatures_RNA=colSums(swhite_20@assays$RNA@counts>0)
# Add latent space inferred using scVI to Seurat object.
lwhite_20 <- read.csv("additional_files/latent_space/white_20.csv", row.names=1)
lwhite_20=as.matrix(lwhite_20)
rownames(lwhite_20)=rownames(swhite_20@meta.data)
swhite_20[["scVI"]] <- CreateDimReducObject(embeddings =lwhite_20,key = "scVI_")
swhite_20=RunUMAP(swhite_20,reduction="scVI",dims = 1:20)
UMAPPlot(swhite_20)
# Normalize Data
swhite_20=NormalizeData(swhite_20)
# Clustering
swhite_20=FindNeighbors(swhite_20,reduction="scVI",graph.name="RNA_snn_scVI",dims=1:20)
swhite_20=FindClusters(swhite_20,resolution = .45,graph.name = "RNA_snn_scVI", verbose = FALSE)
UMAPPlot(swhite_20,label=TRUE)+theme_bw(base_size = 20)+theme(legend.position = "none")
# We removed empty droplets using CellBender package. To remove barcodes that could be empty, we only worked with barcodes that were called as "cell-containing" by both CellRanger and CellBender.
# Reading barcodes called as "cells" by CellBender below
cells.cellbender=read.table("additional_files/cellbender/white_20.csv", quote="\"", comment.char="")
cells.cellbender=cells.cellbender$V1
cells=colnames(swhite_20@assays$RNA@data)
cells.common=intersect(cells.cellbender,cells)
cells.cellranger=setdiff(cells,cells.common)
# Visualizing barcodes called as "cells" only by cellranger, which are potentially empty droplets (as they were called empty by CellBender)
# Cluster 3 predominantly consisted of empty barcodes
UMAPPlot(swhite_20,cells.highlight = cells.cellranger,label = TRUE,label.size = 6) + theme_bw(base_size = 20)+theme(legend.position = "none")
# Cluster 5 had high MT content
# Visualize percent mt content
swhite_20[["percent.mt"]] <- PercentageFeatureSet(swhite_20, pattern = "^MT-")
FeaturePlot(swhite_20,"percent.mt")
# Cluster 4 was enriched for genes suggesting cellular debris based on GO analysis.
# Enrichemnt for terms associated with trnaslation, protein localization to ER was observed
# Cluster 4 also had ~ 11% mitochondrial content
i_2=FindMarkers(object = swhite_20,ident.1 = 4,ident.2=c(0,1),assay = "RNA",slot = "data",logfc.threshold = .5,verbose = FALSE,only.pos = TRUE)
i_2=subset.data.frame(i_2,subset = p_val_adj<.05)
# GO analysis on cluster 4
# Showing results from go.db
entrez.ids <- mapIds(org.Hs.eg.db, keys=rownames(i_2), column="ENTREZID", keytype="SYMBOL")
entrez.ids.universe=mapIds(org.Hs.eg.db, keys=rownames(swhite_20), column="ENTREZID", keytype="SYMBOL")
go.out <- goana(unique(entrez.ids), species="Hs",universe=unique(entrez.ids.universe))
go.out <- go.out[order(go.out$P.DE),]
go.useful <- go.out[go.out$Ont=="BP" & go.out$N <= 600,]
head(go.useful, 20)
# Doublets were detected using doublet_detection
# Cluster 2 mostly consisted of doublets
# Visualize doublets from doublet detection. Output can be found in additional_files
dwhite_20 <- read.table("additional_files/doublet_white_20.txt", quote="\"", comment.char="")
swhite_20@meta.data$doublet=dwhite_20$V1
dwhite_20=rownames(swhite_20@meta.data)[swhite_20@meta.data$doublet==1]
dwhite_20=dwhite_20[!is.na(dwhite_20)]
dwhite_20=union(dwhite_20,rownames(swhite_20@meta.data)[swhite_20@meta.data$RNA_snn_scVI_res.0.45==2])
UMAPPlot(swhite_20,cells.highlight = dwhite_20,label = TRUE,label.size = 6) + theme_bw(base_size = 20)+theme(legend.position = "none")
# Filter for cells from cluster 2,3,4 and 5
bwhite_20=rownames(swhite_20@meta.data)[swhite_20@meta.data$RNA_snn_scVI_res.0.45!=2 & swhite_20@meta.data$RNA_snn_scVI_res.0.45!=3 & swhite_20@meta.data$RNA_snn_scVI_res.0.45!=4 & swhite_20@meta.data$RNA_snn_scVI_res.0.45!=5]
# Remove remaining doublets and low-quality barcodes
bwhite_20=intersect(bwhite_20,cells.common)
bwhite_20=setdiff(bwhite_20,dwhite_20)
UMAPPlot(swhite_20,cells.highlight=bwhite_20)
swhite20=subset(swhite_20,cells=bwhite_20)
save(swhite_20,file = "rdata/seurat.white20.postQC.RData")
load(file = "rdata/seurat.white20.postQC.RData")
# Load libraries
library(Seurat)
library(Matrix)
library(ggplot2)
library(RColorBrewer)
library(viridis)
library(tibble)
library(clusterCrit)
library(dplyr)
library(ComplexHeatmap)
library("circlize")
library(DropletUtils)
size=10
# Read scRNA-seq and snRNA-seq adipocyte data
# See pre_processing folder for QC notebooks
load(file = "rdata/seurat.cellenone.postQC.RData")
load(file = "rdata/seurat.white20.postQC.RData")
# Clustering of scRNA-seq dataset
scellenone=RunUMAP(scellenone,dims = 1:20)
scellenone=FindNeighbors(object = scellenone,dims = 1:20)
scellenone=FindClusters(scellenone,resolution = .6)
# panel (A) in Fig. 5
UMAPPlot(scellenone,group.by="seurat_clusters",pt.size=1,cols=brewer.pal(n = 2,name = "Set1"),label=TRUE,label.size=5)+theme_void()+theme(legend.position = "top")+theme(axis.text.x=element_blank(),axis.ticks.x=element_blank(),axis.text.y=element_blank(),axis.ticks.y=element_blank())
FeaturePlot(scellenone,"THY1",pt.size=1)+scale_color_viridis(option = "B")+theme_void(base_size = size)
FeaturePlot(scellenone,"ADIPOQ",pt.size=1)+scale_color_viridis(option = "B")+theme_void(base_size = size)
# Visualizing clusters in snRNA-seq data
# See QC notebook to see details about clustering
# Panel (A) in Fig. 5
UMAPPlot(swhite_20,group.by="seurat_clusters",pt.size=.5,cols=brewer.pal(n = 3,name = "Set1"),label=TRUE,label.size=5)+theme_void()+theme(legend.position = "top")+theme(axis.text.x=element_blank(),axis.ticks.x=element_blank(),axis.text.y=element_blank(),axis.ticks.y=element_blank())
UMAPPlot(swhite20)
UMAPPlot(swhite_20)
swhite_20=subset(swhite_20,cells=bwhite_20)
save(swhite_20,file = "rdata/seurat.white20.postQC.RData")
save(swhite_20,file = "rdata/seurat.white20.postQC.RData")
save(swhite_20,file = "rdata/seurat.white20.postQC.RData")
knitr::opts_knit$set(root.dir = '~/Desktop/scRNA-seq_snRNA-seq_adipocyte_lineages/')
save(swhite_20,file = "rdata/seurat.white20.postQC.RData")
save(swhite_20,file = "rdata/seurat.white20.postQC.RData")
# Load libraries
library(Seurat)
library(Matrix)
library(ggplot2)
library(RColorBrewer)
library(viridis)
library(tibble)
library(clusterCrit)
library(dplyr)
library(ComplexHeatmap)
library("circlize")
library(DropletUtils)
size=10
# Read scRNA-seq and snRNA-seq adipocyte data
# See pre_processing folder for QC notebooks
load(file = "rdata/seurat.cellenone.postQC.RData")
load(file = "rdata/seurat.white20.postQC.RData")
# Clustering of scRNA-seq dataset
scellenone=RunUMAP(scellenone,dims = 1:20)
scellenone=FindNeighbors(object = scellenone,dims = 1:20)
scellenone=FindClusters(scellenone,resolution = .6)
# panel (A) in Fig. 5
UMAPPlot(scellenone,group.by="seurat_clusters",pt.size=1,cols=brewer.pal(n = 2,name = "Set1"),label=TRUE,label.size=5)+theme_void()+theme(legend.position = "top")+theme(axis.text.x=element_blank(),axis.ticks.x=element_blank(),axis.text.y=element_blank(),axis.ticks.y=element_blank())
FeaturePlot(scellenone,"THY1",pt.size=1)+scale_color_viridis(option = "B")+theme_void(base_size = size)
FeaturePlot(scellenone,"ADIPOQ",pt.size=1)+scale_color_viridis(option = "B")+theme_void(base_size = size)
# Visualizing clusters in snRNA-seq data
# See QC notebook to see details about clustering
# Panel (A) in Fig. 5
UMAPPlot(swhite_20,group.by="seurat_clusters",pt.size=.5,cols=brewer.pal(n = 3,name = "Set1"),label=TRUE,label.size=5)+theme_void()+theme(legend.position = "top")+theme(axis.text.x=element_blank(),axis.ticks.x=element_blank(),axis.text.y=element_blank(),axis.ticks.y=element_blank())
FeaturePlot(swhite_20,"THY1",pt.size=.5)+scale_color_viridis(option = "B")+theme_void(base_size = size)
FeaturePlot(swhite_20,"ADIPOQ",pt.size=.5)+scale_color_viridis(option = "B")+theme_void(base_size = size)
knitr::opts_knit$set(root.dir = '~/Desktop/scRNA-seq_snRNA-seq_adipocyte_lineages/')
knitr::opts_knit$set(root.dir = '~/Desktop/scRNA-seq_snRNA-seq_adipocyte_lineages/')
# Load libraries
library(Seurat)
library(Matrix)
library(ggplot2)
library(RColorBrewer)
library(viridis)
library(tibble)
library(clusterCrit)
library(dplyr)
library(ComplexHeatmap)
library("circlize")
library(DropletUtils)
library(VISION)
size=10
# Load libraries
library(Seurat)
library(Matrix)
library(ggplot2)
library(RColorBrewer)
library(viridis)
library(tibble)
library(clusterCrit)
library(dplyr)
library(ComplexHeatmap)
library("circlize")
library(DropletUtils)
library(VISION)
size=10
# Four datasets were integrated using scVI
#1. scRNA-seq white preadipocyte
#2. snRNA-seq white preadipocyte
#3. scRNA-seq white adipocyte
#4. snRNA-seq white adipocyte
# Read seurat objects for each of these 4 datasets
load(file = "rdata/seurat.preadipocytes.post.demultiplexingAndQC.RData")
# Load libraries
library(Seurat)
library(Matrix)
library(ggplot2)
library(RColorBrewer)
library(viridis)
library(tibble)
library(clusterCrit)
library(dplyr)
library(ComplexHeatmap)
library("circlize")
library(DropletUtils)
library(VISION)
size=10
# Four datasets were integrated using scVI
#1. scRNA-seq white preadipocyte
#2. snRNA-seq white preadipocyte
#3. scRNA-seq white adipocyte
#4. snRNA-seq white adipocyte
# Read seurat objects for each of these 4 datasets
load(file = "rdata/seurat.preadipocytes.post.demultiplexingAndQC.RData")
white_cell_singlets=read.delim("additional_files/barcodes/singlets.high.quality.white.cells.txt",header = FALSE)
white_cells=subset(preadipocytes,cells = white_cell_singlets$V1)
white_cells=subset(dataset.subset,cells = white_cell_singlets$V1)
white_nuclei_0=ReadH5AD('additional_files/adata/white_00.h5ad')
white_nuclei_singlets = read.delim("additional_files/barcodes/singlets.high.quality.white.nuclei.txt",header=FALSE)
white_nuclei_0=subset(white_nuclei_0,cells = white_nuclei_singlets$V1)
load(file = "rdata/seurat.cellenone.postQC.RData")
load(file = "rdata/seurat.white20.postQC.RData")
# Merge all 4 seurat objects
swhite_0_20=merge(white_cells, y = c(scellenone, white_nuclei_0,white_nuclei_20), add.cell.ids = c("0", "1", "2","3"))
swhite_0_20=merge(white_cells, y = c(scellenone, white_nuclei_0,swhite_20), add.cell.ids = c("0", "1", "2","3"))
# Add batch level information
swhite_0_20$batch=substr(colnames(swhite_0_20),start = 1,stop = 1)
lwhite_0_20 <- read.csv("additional_files/latent_space/no_integration.csv", row.names=1)
lwhite_0_20=as.matrix(lwhite_0_20)
rownames(lwhite_0_20)=rownames(swhite_0_20@meta.data)
swhite_0_20[["scVI"]] <- CreateDimReducObject(embeddings =lwhite_0_20,key = "scVI_")
swhite_0_20=RunUMAP(swhite_0_20,reduction="scVI",dims = 1:10)
UMAPPlot(swhite_0_20)
Idents(swhite_0_20)="batch"
lwhite_0_20 <- read.csv("additional_files/latent_space/no_integration.csv", row.names=1)
lwhite_0_20=as.matrix(lwhite_0_20)
rownames(lwhite_0_20)=rownames(swhite_0_20@meta.data)
swhite_0_20[["scVI"]] <- CreateDimReducObject(embeddings =lwhite_0_20,key = "scVI_")
swhite_0_20=RunUMAP(swhite_0_20,reduction="scVI",dims = 1:10)
UMAPPlot(swhite_0_20)
white_cell_singlets=white_cell_singlets$V1
white_nuclei_singlets=white_nuclei_singlets$V1
white_cell_singlets=paste("0",white_cell_singlets,sep = "_")
white_nuclei_singlets=paste("2",white_nuclei_singlets,sep = "_")
white.cells.20.0=paste("1",rownames(scellenone@meta.data)[scellenone@meta.data$seurat_clusters==0],sep = "_")
white.cells.20.1=paste("1",rownames(scellenone@meta.data)[scellenone@meta.data$seurat_clusters==1],sep = "_")
white.nuclei.20.0=paste("3",rownames(swhite_20@meta.data)[swhite_20@meta.data$seurat_clusters==0],sep = "_") #0
white.nuclei.20.1=paste("3",rownames(swhite_20@meta.data)[swhite_20@meta.data$seurat_clusters==1],sep = "_") #1
white.nuclei.20.6=paste("3",rownames(swhite_20@meta.data)[swhite_20@meta.data$seurat_clusters==6],sep = "_") #2
swhite_0_20@meta.data$type=factor("day.0.cells.pread",levels = c("day.0.cells.pread","day.0.nuclei.pread","day.20.cells.pread","day.20.cells.adipo","day.20.nuclei.pread","day.20.nuclei.adipo","day.20.nuclei.mitotic"))
swhite_0_20@meta.data[white_nuclei_singlets,"type"]="day.0.nuclei.pread"
swhite_0_20@meta.data[white.cells.20.0,"type"]="day.20.cells.pread"
swhite_0_20@meta.data[white.cells.20.1,"type"]="day.20.cells.adipo"
swhite_0_20@meta.data[white.nuclei.20.0,"type"]="day.20.nuclei.pread"
swhite_0_20@meta.data[white.nuclei.20.1,"type"]="day.20.nuclei.adipo"
swhite_0_20@meta.data[white.nuclei.20.6,"type"]="day.20.nuclei.mitotic"
Idents(swhite_0_20)="type"
UMAPPlot(swhite_0_20,label=TRUE,label.size=6,pt.size=1)+theme_classic(base_size = 20)+theme(legend.position = "top")
UMAPPlot(swhite_0_20,label=TRUE,label.size=6,pt.size=1)+theme_classic(base_size = 20)+theme(legend.position = "top")
white.cells.20.0
rownames(scellenone@meta.data)[scellenone@meta.data$seurat_clusters==0]
scellenone@meta.data$seurat_clusters
View(scellenone)
knitr::opts_knit$set(root.dir = '~/Desktop/scRNA-seq_snRNA-seq_adipocyte_lineages/')
# load libraries
library(Seurat)
# Read cellenone seurat data
load(file = "rdata/seurat.cellenone.RData")
scellenone=seurat_singlet_object
rm(seurat_singlet_object)
# We initially ran the experiment for both white and brown adipocytes
# This Seurat object has brown adipocytes as well. However, doublets and negatives were removed based on the images of cells acquired during spotting.
# Therefore, sub-sample to white cells and extract the count and metadata for white cells
# Then, initiate a new Seurat object
scellenone=subset(scellenone,Type=="Sub")
count=scellenone@assays$RNA@counts
meta=scellenone@meta.data
scellenone=CreateSeuratObject(counts = count,meta.data = meta)
scellenone=NormalizeData(scellenone)
scellenone=FindVariableFeatures(scellenone)
scellenone=ScaleData(scellenone)
scellenone=RunPCA(scellenone)
ElbowPlot(scellenone)
# Clustering
scellenone=RunUMAP(scellenone,dims = 1:20)
scellenone=FindNeighbors(object = scellenone,dims = 1:20)
scellenone=FindClusters(scellenone,resolution = .6)
save(scellenone,file = "rdata/seurat.cellenone.postQC.RData")
# Load libraries
library(Seurat)
library(Matrix)
library(ggplot2)
library(RColorBrewer)
library(viridis)
library(tibble)
library(clusterCrit)
library(dplyr)
library(ComplexHeatmap)
library("circlize")
library(DropletUtils)
library(VISION)
size=10
# Four datasets were integrated using scVI
#1. scRNA-seq white preadipocyte
#2. snRNA-seq white preadipocyte
#3. scRNA-seq white adipocyte
#4. snRNA-seq white adipocyte
# Read seurat objects for each of these 4 datasets
load(file = "rdata/seurat.preadipocytes.post.demultiplexingAndQC.RData")
white_cell_singlets=read.delim("additional_files/barcodes/singlets.high.quality.white.cells.txt",header = FALSE)
white_cells=subset(dataset.subset,cells = white_cell_singlets$V1)
white_nuclei_0=ReadH5AD('additional_files/adata/white_00.h5ad')
white_nuclei_singlets = read.delim("additional_files/barcodes/singlets.high.quality.white.nuclei.txt",header=FALSE)
white_nuclei_0=subset(white_nuclei_0,cells = white_nuclei_singlets$V1)
load(file = "rdata/seurat.cellenone.postQC.RData")
load(file = "rdata/seurat.white20.postQC.RData")
# Merge all 4 seurat objects
swhite_0_20=merge(white_cells, y = c(scellenone, white_nuclei_0,swhite_20), add.cell.ids = c("0", "1", "2","3"))
# Add batch level information
swhite_0_20$batch=substr(colnames(swhite_0_20),start = 1,stop = 1)
Idents(swhite_0_20)="batch"
# Add latent space inferred from scVI with NO batch correction and generate UMAP
lwhite_0_20 <- read.csv("additional_files/latent_space/no_integration.csv", row.names=1)
lwhite_0_20=as.matrix(lwhite_0_20)
rownames(lwhite_0_20)=rownames(swhite_0_20@meta.data)
swhite_0_20[["scVI"]] <- CreateDimReducObject(embeddings =lwhite_0_20,key = "scVI_")
swhite_0_20=RunUMAP(swhite_0_20,reduction="scVI",dims = 1:10)
UMAPPlot(swhite_0_20)
# Add cell-type information
white_cell_singlets=white_cell_singlets$V1
white_nuclei_singlets=white_nuclei_singlets$V1
white_cell_singlets=paste("0",white_cell_singlets,sep = "_")
white_nuclei_singlets=paste("2",white_nuclei_singlets,sep = "_")
white.cells.20.0=paste("1",rownames(scellenone@meta.data)[scellenone@meta.data$seurat_clusters==0],sep = "_")
white.cells.20.1=paste("1",rownames(scellenone@meta.data)[scellenone@meta.data$seurat_clusters==1],sep = "_")
white.nuclei.20.0=paste("3",rownames(swhite_20@meta.data)[swhite_20@meta.data$seurat_clusters==0],sep = "_") #0
white.nuclei.20.1=paste("3",rownames(swhite_20@meta.data)[swhite_20@meta.data$seurat_clusters==1],sep = "_") #1
white.nuclei.20.6=paste("3",rownames(swhite_20@meta.data)[swhite_20@meta.data$seurat_clusters==6],sep = "_") #2
swhite_0_20@meta.data$type=factor("day.0.cells.pread",levels = c("day.0.cells.pread","day.0.nuclei.pread","day.20.cells.pread","day.20.cells.adipo","day.20.nuclei.pread","day.20.nuclei.adipo","day.20.nuclei.mitotic"))
swhite_0_20@meta.data[white_nuclei_singlets,"type"]="day.0.nuclei.pread"
swhite_0_20@meta.data[white.cells.20.0,"type"]="day.20.cells.pread"
swhite_0_20@meta.data[white.cells.20.1,"type"]="day.20.cells.adipo"
swhite_0_20@meta.data[white.nuclei.20.0,"type"]="day.20.nuclei.pread"
swhite_0_20@meta.data[white.nuclei.20.1,"type"]="day.20.nuclei.adipo"
swhite_0_20@meta.data[white.nuclei.20.6,"type"]="day.20.nuclei.mitotic"
Idents(swhite_0_20)="type"
UMAPPlot(swhite_0_20,label=TRUE,label.size=6,pt.size=1)+theme_classic(base_size = 20)+theme(legend.position = "top")
# Plot cluster tree without integration
swhite_0_20@reductions$pca=swhite_0_20@reductions$scVI
swhite_0_20=BuildClusterTree(object = swhite_0_20,reorder = TRUE,dims = 1:10)
PlotClusterTree(swhite_0_20)
# Performing same analysis but WITH integration
# Add latent space inferred from scVI with batch correction and generate UMAP
lwhite_0_20 <- read.csv("additional_files/latent_space/with_integration.csv", row.names=1)
lwhite_0_20=as.matrix(lwhite_0_20)
rownames(lwhite_0_20)=rownames(swhite_0_20@meta.data)
swhite_0_20[["scVI"]] <- CreateDimReducObject(embeddings =lwhite_0_20,key = "scVI_")
swhite_0_20=RunUMAP(swhite_0_20,reduction="scVI",dims = 1:10)
UMAPPlot(swhite_0_20)
# Plot cluster tree
swhite_0_20@reductions$pca=swhite_0_20@reductions$scVI
swhite_0_20=BuildClusterTree(object = swhite_0_20,reorder = TRUE,dims = 1:10)
PlotClusterTree(swhite_0_20)
# Investigating localization of preadipocytes from both day-0-snRNA-seq and day-0-scRNA-seq datasets into two distinct groups
top=intersect(rownames(swhite_0_20@reductions$umap@cell.embeddings)[swhite_0_20@reductions$umap@cell.embeddings[,2]>1.25],c(white_cell_singlets,white_nuclei_singlets))
UMAPPlot(swhite_0_20,cells.highlight=top)
bottom=setdiff(c(white_cell_singlets,white_nuclei_singlets),top)
UMAPPlot(swhite_0_20,cells.highlight=bottom)
swhite_0_20@meta.data$manual_cluster=factor(0,levels = c(0,1,2,3,4))
swhite_0_20@meta.data[WhichCells(object = swhite_0_20,idents = c("day.20.nuclei.adipo","day.20.cells.adipo")),"manual_cluster"]=1
swhite_0_20@meta.data[top,"manual_cluster"]=2
swhite_0_20@meta.data[bottom,"manual_cluster"]=3
swhite_0_20@meta.data[WhichCells(object = swhite_0_20,idents = "day.20.nuclei.mitotic"),"manual_cluster"]=4
Idents(swhite_0_20)="manual_cluster"
UMAPPlot(swhite_0_20)
s.genes <- cc.genes$s.genes
g2m.genes <- cc.genes$g2m.genes
swhite_0_20 <- CellCycleScoring(swhite_0_20, s.features = s.genes, g2m.features = g2m.genes, set.ident = TRUE)
UMAPPlot(swhite_0_20,label=TRUE,label.size=6,pt.size=1.25,cols=brewer.pal(n = 3,name = "Set3"),group.by="Phase")+theme_classic(base_size = 20)
UMAPPlot(swhite_0_20,label=TRUE,label.size=6,pt.size=1.25,cols=brewer.pal(n = 4,name = "Set3"),group.by="Phase")+theme_classic(base_size = 20)
UMAPPlot(swhite_0_20)
Idents(swhite_0_20)="manual_cluster"
UMAPPlot(swhite_0_20)
swhite_0_20 <- CellCycleScoring(swhite_0_20, s.features = s.genes, g2m.features = g2m.genes, set.ident = F)
UMAPPlot(swhite_0_20,label=TRUE,label.size=6,pt.size=1.25,cols=brewer.pal(n = 4,name = "Set3"),group.by="Phase")+theme_classic(base_size = 20)
UMAPPlot(swhite_0_20,label=TRUE,label.size=5,pt.size=.5,cols=brewer.pal(n = 5,name = "Dark2"))+theme_void()+theme(legend.position = "none")+theme(axis.text.x=element_blank(),axis.ticks.x=element_blank(),axis.text.y=element_blank(),axis.ticks.y=element_blank(),legend.text = element_text(size=size))
VlnPlot(swhite_0_20,"PLK1",pt.size=0,cols = brewer.pal(n = 5,name = "Dark2"))+theme_classic(base_size =size)
FeaturePlot(swhite_0_20,features = "PLK1")
VlnPlot(swhite_0_20,"MYBL2",pt.size=0,cols = brewer.pal(n = 5,name = "Dark2"))+theme_classic(base_size =size)+theme(legend.position = "none")
VlnPlot(swhite_0_20,"MYBL2",pt.size=0,cols = brewer.pal(n = 5,name = "Dark2"))+theme_classic(base_size =size)+theme(legend.position = "none")
swhite_0_20=NormalizeData(swhite_0_20)
VlnPlot(swhite_0_20,"MYBL2",pt.size=0,cols = brewer.pal(n = 5,name = "Dark2"))+theme_classic(base_size =size)+theme(legend.position = "none")
load("/Users/anushka/Desktop/Analysis/RData/seurat_integration_supplemet.scvi.tools.RData")
load("/Users/anushka/Desktop/scRNA-seq_snRNA-seq_adipocyte_lineages/rdata/figures/supplement/s7/swhite_0_20.RData")
VlnPlot(swhite_0_20,"MYBL2",pt.size=0,cols = brewer.pal(n = 5,name = "Dark2"))+theme_classic(base_size =size)+theme(legend.position = "none")
FeaturePlot(swhite_0_20,features = "PLK1")
FeaturePlot(swhite_0_20,features = "MYBL2")
load("/Users/anushka/Desktop/scRNA-seq_snRNA-seq_adipocyte_lineages/rdata/figures/supplement/s7/swhite_0_20.RData")
test=swhite_0_20
knitr::opts_knit$set(root.dir = '~/Desktop/scRNA-seq_snRNA-seq_adipocyte_lineages/')
# Load libraries
library(Seurat)
library(Matrix)
library(ggplot2)
library(RColorBrewer)
library(viridis)
library(tibble)
library(clusterCrit)
library(dplyr)
library(ComplexHeatmap)
library("circlize")
library(DropletUtils)
library(VISION)
size=10
# Four datasets were integrated using scVI
#1. scRNA-seq white preadipocyte
#2. snRNA-seq white preadipocyte
#3. scRNA-seq white adipocyte
#4. snRNA-seq white adipocyte
# Read seurat objects for each of these 4 datasets
load(file = "rdata/seurat.preadipocytes.post.demultiplexingAndQC.RData")
white_cell_singlets=read.delim("additional_files/barcodes/singlets.high.quality.white.cells.txt",header = FALSE)
white_cells=subset(dataset.subset,cells = white_cell_singlets$V1)
white_nuclei_0=ReadH5AD('additional_files/adata/white_00.h5ad')
white_nuclei_singlets = read.delim("additional_files/barcodes/singlets.high.quality.white.nuclei.txt",header=FALSE)
white_nuclei_0=subset(white_nuclei_0,cells = white_nuclei_singlets$V1)
load(file = "rdata/seurat.cellenone.postQC.RData")
load(file = "rdata/seurat.white20.postQC.RData")
# Merge all 4 seurat objects
swhite_0_20=merge(white_cells, y = c(scellenone, white_nuclei_0,swhite_20), add.cell.ids = c("0", "1", "2","3"))
# Add batch level information
swhite_0_20$batch=substr(colnames(swhite_0_20),start = 1,stop = 1)
Idents(swhite_0_20)="batch"
# Add latent space inferred from scVI with NO batch correction and generate UMAP
lwhite_0_20 <- read.csv("additional_files/latent_space/no_integration.csv", row.names=1)
lwhite_0_20=as.matrix(lwhite_0_20)
rownames(lwhite_0_20)=rownames(swhite_0_20@meta.data)
swhite_0_20[["scVI"]] <- CreateDimReducObject(embeddings =lwhite_0_20,key = "scVI_")
swhite_0_20=RunUMAP(swhite_0_20,reduction="scVI",dims = 1:10)
UMAPPlot(swhite_0_20)
# Add cell-type information
white_cell_singlets=white_cell_singlets$V1
white_nuclei_singlets=white_nuclei_singlets$V1
white_cell_singlets=paste("0",white_cell_singlets,sep = "_")
white_nuclei_singlets=paste("2",white_nuclei_singlets,sep = "_")
white.cells.20.0=paste("1",rownames(scellenone@meta.data)[scellenone@meta.data$seurat_clusters==0],sep = "_")
white.cells.20.1=paste("1",rownames(scellenone@meta.data)[scellenone@meta.data$seurat_clusters==1],sep = "_")
white.nuclei.20.0=paste("3",rownames(swhite_20@meta.data)[swhite_20@meta.data$seurat_clusters==0],sep = "_") #0
white.nuclei.20.1=paste("3",rownames(swhite_20@meta.data)[swhite_20@meta.data$seurat_clusters==1],sep = "_") #1
white.nuclei.20.6=paste("3",rownames(swhite_20@meta.data)[swhite_20@meta.data$seurat_clusters==6],sep = "_") #2
swhite_0_20@meta.data$type=factor("day.0.cells.pread",levels = c("day.0.cells.pread","day.0.nuclei.pread","day.20.cells.pread","day.20.cells.adipo","day.20.nuclei.pread","day.20.nuclei.adipo","day.20.nuclei.mitotic"))
swhite_0_20@meta.data[white_nuclei_singlets,"type"]="day.0.nuclei.pread"
swhite_0_20@meta.data[white.cells.20.0,"type"]="day.20.cells.pread"
swhite_0_20@meta.data[white.cells.20.1,"type"]="day.20.cells.adipo"
swhite_0_20@meta.data[white.nuclei.20.0,"type"]="day.20.nuclei.pread"
swhite_0_20@meta.data[white.nuclei.20.1,"type"]="day.20.nuclei.adipo"
swhite_0_20@meta.data[white.nuclei.20.6,"type"]="day.20.nuclei.mitotic"
Idents(swhite_0_20)="type"
UMAPPlot(swhite_0_20,label=TRUE,label.size=6,pt.size=1)+theme_classic(base_size = 20)+theme(legend.position = "top")
# Plot cluster tree without integration
swhite_0_20@reductions$pca=swhite_0_20@reductions$scVI
swhite_0_20=BuildClusterTree(object = swhite_0_20,reorder = TRUE,dims = 1:10)
PlotClusterTree(swhite_0_20)
# Performing same analysis but WITH integration
# Add latent space inferred from scVI with batch correction and generate UMAP
lwhite_0_20 <- read.csv("additional_files/latent_space/with_integration.csv", row.names=1)
lwhite_0_20=as.matrix(lwhite_0_20)
rownames(lwhite_0_20)=rownames(swhite_0_20@meta.data)
swhite_0_20[["scVI"]] <- CreateDimReducObject(embeddings =lwhite_0_20,key = "scVI_")
swhite_0_20=RunUMAP(swhite_0_20,reduction="scVI",dims = 1:10)
UMAPPlot(swhite_0_20)
# Plot cluster tree
swhite_0_20@reductions$pca=swhite_0_20@reductions$scVI
swhite_0_20=BuildClusterTree(object = swhite_0_20,reorder = TRUE,dims = 1:10)
PlotClusterTree(swhite_0_20)
FeaturePlot(test,"MKI67")
dim(test)
dim(swhite_0_20)
FeaturePlot(swhite_0_20,"MKI67")
FeaturePlot(test,"MKI67")
FeaturePlot(swhite_0_20,"MKI67")
load("/Users/anushka/Desktop/nuclei_v_cells/RData/merged_seurat_singlet_object_categorical_Plate.rdata")
scellenone=seurat_singlet_object
rm(seurat_singlet_object)
#This seurat object has brown cells. However, doublets and negatives have been removed.
# Therefore, subsample to white cells and extract the count and mete data for white cells
# Then, intiate a new seurat object
scellenone=subset(scellenone,Type=="Sub")
count=scellenone@assays$RNA@counts
meta=scellenone@meta.data
scellenone=CreateSeuratObject(counts = count,meta.data = meta)
preadipocytes=ReadH5AD(file ="/Users/anushka/Desktop/nuclei_v_cells/adata/anndata_preadipocytes.h5ad")
white_cell_singlets=read.delim("/Users/anushka/Desktop/nuclei_v_cells/barcodes/singlets.high.quality.white.cells.txt",header = FALSE)
white_cells=subset(preadipocytes,cells = white_cell_singlets$V1)
white_nuclei_0=ReadH5AD('/Users/anushka/Desktop/nuclei_v_cells/adata/anndata_Day_00_WAT.h5ad')
white_nuclei_singlets = read.delim("/Users/anushka/Desktop/nuclei_v_cells/barcodes/singlets.high.quality.white.nuclei.unsupervised.txt",header=FALSE)
white_nuclei_0=subset(white_nuclei_0,cells = white_nuclei_singlets$V1)
white_nuclei_20=ReadH5AD('/Users/anushka/Desktop/nuclei_v_cells/adata/anndata_Day_20_WAT_No_Dounce.h5ad')
white_nuclei_singlets = read.delim("/Users/anushka/Desktop/nuclei_v_cells/barcodes/barcodes_white_20.txt",header=FALSE)
white_nuclei_20=subset(white_nuclei_20,cells = white_nuclei_singlets$V1)
swhite_0_20=merge(white_cells, y = c(scellenone, white_nuclei_0,white_nuclei_20), add.cell.ids = c("0", "1", "2","3"))
swhite_0_20$batch=substr(colnames(swhite_0_20),start = 1,stop = 1)
lwhite_0_20 <- read.csv("/Users/anushka/Desktop/nuclei_v_cells/latent_space/white_cells_nuclei_0_20_4_batches_scvi_tools.csv", row.names=1)
lwhite_0_20=as.matrix(lwhite_0_20)
rownames(lwhite_0_20)=rownames(swhite_0_20@meta.data)
swhite_0_20[["scVI"]] <- CreateDimReducObject(embeddings =lwhite_0_20,key = "scVI_")
# Generate UMAP
load("/Users/anushka/Desktop/nuclei_v_cells/RData/seurat_white_20.Rdata")
load("/Users/anushka/Desktop/nuclei_v_cells/RData/seurat_cellenone.RData")
swhite_0_20=RunUMAP(swhite_0_20,reduction="scVI",dims = 1:10)
UMAPPlot(swhite_0_20)
white.cells.0=read.table("/Users/anushka/Desktop/nuclei_v_cells/barcodes/singlets.high.quality.white.cells.txt", quote="\"", comment.char="")
white.nuclei.0=read.table("/Users/anushka/Desktop/nuclei_v_cells/barcodes/singlets.high.quality.white.nuclei.unsupervised.txt", quote="\"", comment.char="")
white.cells.0=white.cells.0$V1
white.nuclei.0=white.nuclei.0$V1
white.cells.0=paste("0",white.cells.0,sep = "_")
white.nuclei.0=paste("2",white.nuclei.0,sep = "_")
white.cells.20.0=paste("1",rownames(scellenone@meta.data)[scellenone@meta.data$seurat_clusters==0],sep = "_")
white.cells.20.1=paste("1",rownames(scellenone@meta.data)[scellenone@meta.data$seurat_clusters==1],sep = "_")
white.nuclei.20.0=paste("3",rownames(swhite_20@meta.data)[swhite_20@meta.data$seurat_clusters==0],sep = "_") #0
white.nuclei.20.1=paste("3",rownames(swhite_20@meta.data)[swhite_20@meta.data$seurat_clusters==1],sep = "_") #1
white.nuclei.20.6=paste("3",rownames(swhite_20@meta.data)[swhite_20@meta.data$seurat_clusters==6],sep = "_") #2
swhite_0_20@meta.data$type=factor("day.0.cells.pread",levels = c("day.0.cells.pread","day.0.nuclei.pread","day.20.cells.pread","day.20.cells.adipo","day.20.nuclei.pread","day.20.nuclei.adipo","day.20.nuclei.mitotic"))
swhite_0_20@meta.data[white.nuclei.0,"type"]="day.0.nuclei.pread"
swhite_0_20@meta.data[white.cells.20.0,"type"]="day.20.cells.pread"
swhite_0_20@meta.data[white.cells.20.1,"type"]="day.20.cells.adipo"
swhite_0_20@meta.data[white.nuclei.20.0,"type"]="day.20.nuclei.pread"
swhite_0_20@meta.data[white.nuclei.20.1,"type"]="day.20.nuclei.adipo"
swhite_0_20@meta.data[white.nuclei.20.6,"type"]="day.20.nuclei.mitotic"
Idents(swhite_0_20)="type"
library(ggplot2)
UMAPPlot(swhite_0_20,label=TRUE,label.size=6,pt.size=1)+theme_classic(base_size = 20)+theme(legend.position = "top")
swhite_0_20@reductions$pca=swhite_0_20@reductions$scVI
swhite_0_20=BuildClusterTree(object = swhite_0_20,reorder = TRUE,dims = 1:10)
PlotClusterTree(swhite_0_20)
FeaturePlot(swhite_0_20,"MKI67")
swhite_0_20=NormalizeData(swhite_0_20)
FeaturePlot(swhite_0_20,"MKI67")
