-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fig4_Prediction_m4A.R
85 lines (69 loc) · 2.71 KB
/
Fig4_Prediction_m4A.R
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
###########################
#### scDVP Figure Code ####
###########################
#### -- Figure 4F -- ####
library(XML)
library(sf)
library(RColorBrewer)
library(ggpubr)
library(platetools)
## -- Prepare Workspace
cat("\014")
rm(list=ls())
## Load additional functions and environment
source("./Functions/fct_xml_to_polygon.R")
load("../output/variables/d_classes.R")
prediction_m4A <- read_csv("../data/imaging/shape_probability_m4A.csv") %>%
dplyr::select(-1) %>%
dplyr::rename(Index = `Shape Index`) %>%
gather(cluster, probability, 1:5) %>%
mutate(cluster = as.numeric(cluster) + 1) %>%
right_join(d_classes) %>%
mutate(median_weighted = probability * median) %>%
dplyr::select(Index, median_weighted, Protein) %>%
group_by(Index, Protein) %>%
mutate(int_weighted = sum(median_weighted)) %>%
mutate(bio_ID = "m4A")
polygons_m4A <- xml_to_polygon("../data/imaging/EXP-221117_scDVP_m4A_PREDICTION_237.xml")
level_of <- data.frame(Index = c(1:length(polygons_m4A))) %>%
left_join(prediction_m4A) %>%
filter(Protein == "P16460") %>%
distinct(Index, .keep_all = T)
st_sf(polygons_m4A, ID = as.factor(c(1:length(polygons_m4A))), level_of) %>%
ggplot()+
geom_sf(aes(fill = log2(int_weighted)))+
scale_fill_viridis_c()+
theme(legend.position="none") +
theme_classic()+
scale_y_continuous(limits = c(132000,145000))+
scale_x_continuous(limits = c(0, -14000)) -> plot_stsf_Ass1
rm(level_of)
level_of <- data.frame(Index = c(1:length(polygons_m4A))) %>%
left_join(prediction_m4A) %>%
filter(Protein == "P15105") %>%
distinct(Index, .keep_all = T)
st_sf(polygons_m4A, ID = as.factor(c(1:length(polygons_m4A))), level_of) %>%
ggplot()+
geom_sf(aes(fill = log2(int_weighted)))+
scale_fill_viridis_c()+
#geom_sf_text(aes(label = as.character(ID)), colour = "black") +
theme(legend.position="none") +
theme_classic()+
scale_y_continuous(limits = c(132000,145000))+
scale_x_continuous(limits = c(0, -14000)) -> plot_stsf_Glul
rm(level_of)
level_of <- data.frame(Index = c(1:length(polygons_m4A))) %>%
left_join(prediction_m4A) %>%
filter(Protein == "Q05421") %>%
distinct(Index, .keep_all = T)
st_sf(polygons_m4A, ID = as.factor(c(1:length(polygons_m4A))), level_of) %>%
ggplot()+
geom_sf(aes(fill = log2(int_weighted)))+
scale_fill_viridis_c()+
theme(legend.position="none") +
theme_classic()+
scale_y_continuous(limits = c(132000,145000))+
scale_x_continuous(limits = c(0, -14000)) -> plot_stsf_Cyp2e1
ggsave(plot_stsf_Cyp2e1, file = "../output/Figures/Spatialmap_Cyp2e1.pdf", width = 5, height = 5)
ggsave(plot_stsf_Ass1, file = "../output/Figures/Spatialmap_Ass1.pdf", width = 5, height = 5)
ggsave(plot_stsf_Glul, file = "../output/Figures/Spatialmap_Glul.pdf", width = 5, height = 5)