-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstress_granule_data_visualization.Rmd
More file actions
122 lines (105 loc) · 4.03 KB
/
stress_granule_data_visualization.Rmd
File metadata and controls
122 lines (105 loc) · 4.03 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
title: "AAV-SHKBP1 Analysis"
author: "Lucia Liu"
date: "`r Sys.Date()`"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(dplyr)
library(ggplot2)
```
```{r}
# Input your csv pathname below
df <- read.csv('/Users/lucialiu/Downloads/2025.12.16 Ctrl-SHKBP1 DDC diet 2wks p62/czi/40x/Ctrl-SHKBP1 Final Output/Analysis Results/Ctrl_SHKBP1_summary.csv')
df_chow <- df %>% slice(1:10)
df_ddc <- df %>% slice(11:21)
```
```{r}
dark_blue <- "#12436D"
teal <- "#28A197"
orange <- "#F46A25"
lavender <- "#A285D1"
dark_red <- "#801650"
light_blue <- "#6BACE6"
medium_blue <- "#2073BC"
```
``` {r}
plot_bar_chart <- function(df, y_var, fill_color, y_label, title_label) {
ggplot(data = df, aes(x=Slice, y={{ y_var }})) +
geom_bar(stat = "identity", fill = fill_color) +
theme(plot.title = element_text(hjust = 0.5),
axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(x = 'Slice',
y = y_label,
title = title_label) +
geom_text(aes(label={{ y_var }}), vjust=-0.75, size=2.5)
}
```
``` {r}
plot_bar_chart(df_chow, Area.of.C1...Area.of.C2, dark_blue,
'Total Area of C1 / Total Area of C2',
'Distribution of Ratio of Total Area of Chow Mice')
plot_bar_chart(df_chow, Area.of.Particles..C1....Cell, dark_blue,
'Area of Particles Per Cell',
'Distribution of Area of Particles Per Cell of Chow Mice')
```
``` {r}
plot_bar_chart(df_ddc, Area.of.C1...Area.of.C2, medium_blue,
'Total Area of C1 / Total Area of C2',
'Distribution of Ratio of Total Area of DDC Mice')
plot_bar_chart(df_ddc, Area.of.Particles..C1....Cell, medium_blue,
'Area of Particles Per Cell',
'Distribution of Area of Particles Per Cell of DDC Mice')
```
``` {r}
plot_combined_bar_chart <- function(y_var, label_size, y_label, title_label) {
ggplot(data = df, aes(x=Slice, y={{ y_var }}, fill=Diet)) +
geom_bar(stat = "identity") +
theme(plot.title = element_text(hjust = 0.5),
axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_fill_manual(values = c("Chow" = dark_blue, "DDC" = medium_blue)) +
labs(x = 'Slice',
y = y_label,
title = title_label) +
geom_text(aes(label={{ y_var }}), vjust=-0.75, size=label_size)
}
```
``` {r fig.width=8, dpi=300}
save_graph <- function(plot_name, filename) {
ggsave(filename = paste0(filename, ".pdf"), plot = plot_name, device = "pdf", width = 7, height = 4.5, dpi = 350, units = "in")
ggsave(filename = paste0(filename, ".svg"), plot = plot_name, device = "svg",width = 7, height = 4.5, units = "in")
}
```
``` {r fig.width=8, dpi=300}
total_area_graph <- plot_combined_bar_chart(Total.Area.C1, 1.5,
'Total Area of Particles (µm^2)',
'Distribution of Total Area of Particles')
save_graph(total_area_graph, 'total_area_distribution')
total_area_graph
area_per_cell_graph <- plot_combined_bar_chart(Area.of.Particles..C1....Cell, 1.8,
'Area of Particles Per Cell',
'Distribution of Area of Particles Per Cell')
save_graph(area_per_cell_graph, 'area_per_cell')
area_per_cell_graph
area_ratio_graph <- plot_combined_bar_chart(Area.of.C1...Area.of.C2, 1.8,
'Total Area of C1 / Total Area of C2',
'Distribution of Ratio of Total Area')
save_graph(area_ratio_graph, 'area_ratio')
area_ratio_graph
avg_particle_size_graph <- plot_combined_bar_chart(Avg.Particle.Size, 2,
'Average Particle Size (µm^2)',
'Distribution of Average Particle Size')
save_graph(avg_particle_size_graph, 'avg_particle_size')
avg_particle_size_graph
```
``` {r}
summary(df_chow$Total.Area.C1)
summary(df_ddc$Total.Area.C1)
summary(df_chow$Avg.Particle.Size)
summary(df_ddc$Avg.Particle.Size)
summary(df_chow$Area.of.Particles..C1....Cell)
summary(df_ddc$Area.of.Particles..C1....Cell)
summary(df_chow$Area.of.C1...Area.of.C2)
summary(df_ddc$Area.of.C1...Area.of.C2)
```