svCorrDotPLOT <- function (dat) {
selection <- markOC3 %>%
rownames_to_column (var = "gene" ) %>%
filter (
p_val_adj < 0.0000000001 ,
str_detect (string = gene, pattern = "^mt-" , negate = T),
str_detect (string = gene, pattern = "^Gm" , negate = T)
) %>%
top_n (n = 40 , wt = avg_log2FC) %>%
top_n (n = 20 , wt = pct.1 ) %>%
dplyr:: arrange (desc (pct.1 )) %>%
.$ gene
selection2 <- markOC3 %>%
rownames_to_column (var = "gene" ) %>%
filter (
p_val_adj < 0.0000000001 ,
str_detect (string = gene, pattern = "^mt-" , negate = T),
str_detect (string = gene, pattern = "^Gm" , negate = T)
) %>%
top_n (n = 25 , wt = p_val_adj) %>%
top_n (n = 20 , wt = pct.1 ) %>%
top_n (n = 15 , wt = avg_log2FC) %>%
dplyr:: arrange (desc (pct.1 )) %>%
.$ gene
srt_onecut_filtered_ages <-
GetAssayData (dat, "data" , "RNA" ) %>%
as.data.frame () %>%
t ()
filt_age_oc_sum <-
colSums (srt_onecut_filtered_ages) %>%
.[. > 10 ] %>%
names () %>%
.[. %in% c (
selection,
"Onecut1" ,
"Onecut2" ,
"Onecut3"
)]
srt_onecut_filtered_ages %<>% .[, filt_age_oc_sum]
oc_age_corr_genes <- corrr:: correlate (srt_onecut_filtered_ages)
oc3_age_corr_genes <-
oc_age_corr_genes %>%
arrange (- Onecut3) %>%
select (term, Onecut3, Onecut2)
threshold.min.pct.Onecut2 <- .3
threshold.min.pct.OC3 <- .3
threshold.max.pct.Onecut2 <- .95
threshold.max.pct.OC3 <- .95
oc3_age_corr_genes_intersect_2 <-
intersect (
x = oc3_age_corr_genes %>%
slice_min (
order_by = Onecut2,
prop = threshold.min.pct.Onecut2
),
y = oc3_age_corr_genes %>%
slice_min (
order_by = Onecut3,
prop = threshold.max.pct.OC3
)
)
highlight_oc3_age_corr_genes <-
union (
oc3_age_corr_genes_intersect_2$ term,
selection2
)
additional_genes <-
c (
"Onecut2" , "Pias2" , "Tp53" , "Trio" , "Fas" , "Rhoa" , "Limk1" , "Vegfa" , "Bcar1" ,
"Ywhab" , "Nf1" , "Eif4e" , "Rb1" , "Sp1" , "Rps13" , "Rps3a" , "Traf6" , "Fgfr1op" ,
"Ifi16" , "Irf3" , "Emg1" , "Myc" , "Pten" , "Sirt1" , "E2f1" , "Nr0b2" , "Crp" , "Erg" ,
"Foxa1" , "Spi1" , "Nfkb1" , "Nfkbia" , "Pan2" , "Eif4a1" , "Gfra1" , "Stat6" , "Agt" ,
"Onecut1" , "Grb2" ,
intersect_neuro2a$ gene_name %>%
str_to_sentence ()
) %>%
.[! . %in% highlight_oc3_age_corr_genes] %>%
unique () %>%
.[. %in% rownames (dat)]
plot_dot_oc23_age_corr_genes <-
DotPlot (
dat,
assay = "RNA" ,
features = c (additional_genes, highlight_oc3_age_corr_genes),
group.by = "age"
) + RotatedAxis ()
save_plot (
filename = paste0 (plots_dir, "/plot_dot_age_corrr_expression_wtin_OC23.pdf" ),
plot = plot_dot_oc23_age_corr_genes,
base_height = 6 ,
base_aspect_ratio = 2
)
return (highlight_oc3_age_corr_genes)
}
# oc_list <- Seurat::SplitObject(holder_srt$rar2020.srt.cont.oc2or3, split.by = "age")