Skip to content

Commit aa33530

Browse files
committed
checked composition of entire data
1 parent 39faf6d commit aa33530

9 files changed

+122
-4
lines changed

Diff for: .DS_Store

0 Bytes
Binary file not shown.

Diff for: figure/DE_genes_grp6.pdf

550 KB
Binary file not shown.

Diff for: figure/LNG_comp.png

59.2 KB
Loading

Diff for: figure/OM_comp.png

60.1 KB
Loading

Diff for: figure/RM_comp.png

60.5 KB
Loading

Diff for: figure/composition_dpi_flu.png

66.9 KB
Loading

Diff for: figure/count_dpi_flu.png

54.4 KB
Loading

Diff for: mature_neuron.Rmd

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: "mature neuron"
3+
author: "Yifan Duan"
4+
date: "2024-09-10"
5+
output: html_document
6+
---
7+
8+
```{r setup, include=FALSE}
9+
knitr::opts_chunk$set(echo = TRUE)
10+
```
11+
12+
13+
```{r}
14+
library(Seurat)
15+
library(BPCells)
16+
library(dplyr)
17+
library(ggplot2)
18+
library(ggrepel)
19+
library(patchwork)
20+
library(Matrix)
21+
library(cowplot)
22+
library(irlba)
23+
```
24+
25+
26+
```{r visualizing composition change over time, eval=FALSE}
27+
# just ignore this one, this is diagnostic for composition
28+
flu_obj <- readRDS("data/flu.Rds")
29+
View(flu_obj)
30+
31+
levels(flu_obj$cell_type__ontology_label)
32+
33+
flu_obj$simple_label <- case_when(
34+
flu_obj$cell_type__ontology_label %in% c("neural progenitor cell", "vomeronasal sensory neuron", "olfactory receptor cell") ~ "Neuron",
35+
flu_obj$cell_type__ontology_label %in% c("basal cell", "brush cell", "ciliated epithelial cell", "epithelial cell", "glandular epithelial cell", "goblet cell", "ionocyte", "serous secreting cell") ~ "Epithelial",
36+
flu_obj$cell_type__ontology_label %in% c("alpha-beta T cell", "B cell", "CD4-positive, alpha-beta T cell", "CD8-positive, alpha-beta T cell", "dendritic cell", "gamma-delta T cell", "granulocyte monocyte progenitor cell", "group 2 innate lymphoid cell", "group 3 innate lymphoid cell", "macrophage", "mast cell", "monocyte", "natural killer cell", "neutrophil", "precursor B cell", "hematopoietic stem cell", "plasmacytoid dendritic cell", "plasma cell") ~ "Immune",
37+
TRUE ~ "Other")
38+
39+
flu_obj$simple_label <- as.factor(flu_obj$simple_label)
40+
41+
# list of "other" celltype
42+
# chondrocyte
43+
# endothelial cell
44+
# fibroblast
45+
# stromal cell
46+
# smooth muscle cell
47+
# pericyte
48+
# osteoclast
49+
# osteoblast
50+
# smooth muscle cell
51+
52+
lng_obj <- subset(flu_obj, subset = Tissue.Region == "LNG")
53+
54+
comp_change <- as.data.frame(table(lng_obj$simple_label, lng_obj$Time.Point))
55+
colnames(comp_change) <- c("Celltype", "Timepoint", "Counts")
56+
comp_change <- comp_change |>
57+
mutate(Timepoint = factor(Timepoint, levels = c("Naive", "2 dpi", "5 dpi", "8 dpi", "14 dpi")))
58+
59+
60+
# need to get the proportion of celltype per timepoint
61+
total_count <- comp_change |> group_by(Timepoint) |> summarise(total = sum(Counts)) |> ungroup()
62+
total_count |> ggplot(aes(x = Timepoint, y = total)) +
63+
geom_bar(stat = "identity") + theme_cowplot()
64+
65+
comp_change |> group_by(Timepoint, Celltype) |> summarise(avg_count = Counts) |> ungroup() |> mutate(total_count = rep(total_count$total, each = 4)) |> mutate(prop = avg_count / total_count) |>
66+
ggplot(aes(x = Timepoint, y = prop, fill = Celltype)) +
67+
geom_bar(stat = "identity") + theme_cowplot() +
68+
theme(legend.position = "top", axis.text.x = element_text(angle = 90, hjust = 1))
69+
```
70+
71+
72+
```{r}
73+
74+
```
75+

Diff for: neuron_analysis.Rmd

+47-4
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,12 @@ for (res in resolutions) {
8989
algorithm = 4) # leiden
9090
9191
# Store the clustering results with a label corresponding to the resolution
92-
cluster_column <- paste0("RNA_snn_res.", res)
93-
[email protected][[paste0("clusters_res_", res)]] <- [email protected][[cluster_column]]
92+
#cluster_column <- paste0("RNA_snn_res.", res)
9493
}
9594
96-
DimPlot(neuron_obj, reduction = "umap", group.by = "clusters_res_0.2")
95+
DimPlot(neuron_obj, reduction = "umap", group.by = "cell_type__ontology_label")
96+
DimPlot(neuron_obj, reduction = "umap", group.by = "donor_id")
97+
9798
```
9899

99100

@@ -102,8 +103,50 @@ DimPlot(neuron_obj, reduction = "umap", group.by = "clusters_res_0.2")
102103
neuron_obj[["RNA"]]$data <- neuron_obj[["RNA"]]$counts
103104
104105
Idents(neuron_obj) <- "RNA_snn_res.0.2"
105-
FindMarkers(neuron_obj, ident.1 = "1", assay = "RNA")
106+
#FindMarkers(neuron_obj, ident.1 = "6", assay = "RNA")
106107
107108
dim(neuron_obj[["RNA"]]$counts)
109+
110+
FeaturePlot(neuron_obj, features = c("Omp", "Stoml3", "Cnga2", "Adcy3"))
111+
```
112+
113+
114+
```{r investigating doublet}
115+
# 1. higher counts than the rest
116+
# 2. mixture of markers
117+
grp6_marker <- FindMarkers(neuron_obj, ident.1 = "6", assay = "RNA")
118+
doublet_obj <- subset(neuron_obj, subset = RNA_snn_res.0.2 == "6")
119+
120+
library(EnhancedVolcano)
121+
pdf("figure/DE_genes_grp6.pdf")
122+
EnhancedVolcano(grp6_marker,
123+
rownames(grp6_marker),
124+
x ="avg_log2FC",
125+
y ="p_val_adj")
126+
dev.off()
127+
128+
DimPlot(doublet_obj, reduction = "umap", group.by = "Cluster.Label")
129+
cluster_table <- table(doublet_obj$Cluster.Label)
130+
cluster_table <- cluster_table[cluster_table != 0]
131+
132+
VlnPlot(neuron_obj, features = "nCount_RNA", group.by = "seurat_clusters")
133+
VlnPlot(neuron_obj, features = "nFeature_RNA", group.by = "seurat_clusters")
134+
135+
library(DoubletFinder)
136+
neuron_obj <- doubletFinder_v3(neuron_obj, PCs = 1:10, pN = 0.25, pK = best_pK, nExp = 500)
137+
138+
139+
```
140+
141+
142+
```{r}
143+
saveRDS(neuron_obj, file = "data/neuron.Rds")
144+
145+
FeaturePlot(neuron_obj, features = c("Nqo1","Acsm4", "Nfix", "Ncam2"))
146+
# dorsal acsm4, nqo1
147+
# ventral nfix, ncam2
148+
149+
mature_neuron_obj <- subset(neuron_obj, subset = RNA_snn_res.0.2 == c("1", "2", "4", "6"))
150+
saveRDS(mature_neuron_obj, "data/mature_neuron.Rds")
108151
```
109152

0 commit comments

Comments
 (0)