Commit fe1537a3 authored by Matteo Barcella's avatar Matteo Barcella
Browse files

Updating script adding code for producing fig2D

parent 6eee7648
...@@ -11,7 +11,7 @@ library(clusterProfiler) ...@@ -11,7 +11,7 @@ library(clusterProfiler)
library(ComplexHeatmap) library(ComplexHeatmap)
library(circlize) library(circlize)
outdir <- "HSC_vs_Bulk_Focus_Supplemental_2C/" outdir <- "HSC_vs_Bulk_Focus_Supplemental_2CD/"
dir.create(outdir) dir.create(outdir)
obj_fig2C <- readRDS("Fig2C_Dataset.rds") obj_fig2C <- readRDS("Fig2C_Dataset.rds")
...@@ -141,3 +141,60 @@ p <- Heatmap(heatmap_mat_t, ...@@ -141,3 +141,60 @@ p <- Heatmap(heatmap_mat_t,
draw(p, padding = unit(c(2, 2, 2, 10), "mm")) # c(bottom, left, top, right) draw(p, padding = unit(c(2, 2, 2, 10), "mm")) # c(bottom, left, top, right)
dev.off() dev.off()
# fig Supplemental 2D
######### only TP53 ########
genes <- c( "TP53")
df <- FetchData(
object = obj_fig2C_Cs,
vars = c(genes, "Timepoint.f", "Group", "GroupTimepoint")
)
df_long <- df |>
tidyr::pivot_longer(
cols = all_of(genes),
names_to = "Gene",
values_to = "expr"
)
ggplot(df_long, aes(x = Timepoint.f, y = expr, fill = Group)) +
geom_boxplot(position = position_dodge(width = 0.8)) +
#facet_wrap(~ Gene, nrow = 1) +
theme_bw() +
labs(x = "Timepoint", y = "Expression", fill = "Group")
# line plot
df_summary <- df_long |>
group_by(Gene, Timepoint.f, Group) |>
summarise(
mean_expr = mean(expr),
median_expr = median(expr),
.groups = "drop"
)
mean_plot <- ggplot(df_summary, aes(x = Timepoint.f, y = mean_expr, color = Group, group = Group)) +
geom_line() +
geom_point() +
# facet_wrap(~ Gene, nrow = 1) +
theme_bw() +
theme(axis.title.x = element_blank())
median_plot <- ggplot(df_summary, aes(x = Timepoint.f, y = median_expr, color = Group, group = Group)) +
geom_line() +
geom_point() +
# facet_wrap(~ Gene, nrow = 1) +
theme_bw() +
theme(axis.title.x = element_blank())
pdf(file = paste0(outdir, "Fig_S2D_p53_expression_across_culture.pdf"), width = 3, height = 3)
mean_plot + labs(color = "") + ylab("Average Expression") +
ggtitle("TP53 expression") +
theme(legend.position = c(0.8,0.2), axis.text = element_text(size = 10),
plot.title = element_text(hjust = 0.5))
dev.off()
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