Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
custom
Squadrito_LiverTumor2022
Squadrito_LiverTumor2022_Spatial
Commits
86b68056
Commit
86b68056
authored
Jul 25, 2023
by
Stefano Beretta
Browse files
Upload New File
parent
c42e67ff
Changes
1
Show whitespace changes
Inline
Side-by-side
scripts/2_SigZones_Visualization.R
0 → 100644
View file @
86b68056
library
(
Seurat
)
library
(
ggplot2
)
library
(
dplyr
)
library
(
openxlsx
)
########################
### General Settings ###
########################
# Working dir
wdir
<-
"~/Downloads/TIGET/Squadrito/scSquadrito/squadrito_livertumor2022_spatial"
# Data dir
data_dir
<-
paste
(
wdir
,
"data"
,
sep
=
"/"
)
# Results dir
out_dir
<-
paste
(
wdir
,
"results"
,
sep
=
"/"
)
dir.create
(
path
=
out_dir
,
showWarnings
=
F
)
# Read Obj
full_obj
<-
readRDS
(
file
=
paste
(
out_dir
,
"crc.integrated.rds"
,
sep
=
"/"
))
DefaultAssay
(
full_obj
)
<-
"Spatial"
signatures
<-
list
(
"KC_long"
=
c
(
"Vsig4"
,
"Clec4f"
,
"Marco"
,
"Fcna"
,
"Cd5l"
,
"C1qa"
,
"C1qb"
,
"C1qc"
,
"Slc40a1"
,
"Clec1b"
,
"Cd38"
,
"Ptgs1"
,
"Nr1h3"
),
"TAMs"
=
c
(
"Lyz2"
,
"Ahnak"
,
"Itgam"
,
"Chil3"
,
"S100a6"
,
"Anxa2"
,
"Lyz1"
,
"Mmp7"
,
"Spp1"
,
"Mmp12"
,
"Timp1"
),
"IFNa_TAMs"
=
c
(
"Ccl2"
,
"Chil3"
,
"Ly6c2"
,
"Arg1"
,
"Cxcl10"
,
"Slfn4"
,
"F10"
,
"Lyz2"
,
"Msrb1"
,
"Hp"
,
"Slfn1"
,
"Cebpb"
,
"Fcgr1"
,
"Ifi204"
,
"Plac8"
,
"Gm21188"
,
"Mafb"
,
"Tgm2"
,
"Ms4a4c"
,
"Ifi27l2a"
),
"Cancer_cells"
=
c
(
"Phlda1"
,
"Krt18"
,
"Krt8"
,
"Lars2"
,
"Krt19"
,
"Epcam"
,
"Jun"
,
"Cldn7"
,
"Lgals4"
,
"Cldn4"
,
"Cldn3"
,
"Krt7"
,
"Tcim"
,
"Egr1"
,
"Sox4"
,
"2200002D01Rik"
,
"Axin2"
,
"Gpx2"
,
"Taf1d"
,
"Plk2"
),
"Hepatocytes"
=
c
(
"Fabp1"
,
"Apoc1"
,
"Apoa2"
,
"Mt1"
,
"Alb"
,
"Serpina1e"
,
"Ttr"
,
"Gsta3"
,
"Serpina1c"
,
"Akr1c6"
,
"Gstm1"
,
"Serpina1a"
,
"Serpina1b"
,
"Gnmt"
,
"Apoc3"
,
"Cdo1"
,
"Bhmt"
,
"Rgn"
,
"Ass1"
,
"Ttc36"
)
)
for
(
sig
in
names
(
signatures
))
{
full_obj
<-
AddModuleScore
(
object
=
full_obj
,
features
=
list
(
signatures
[[
sig
]]),
name
=
sig
)
}
# IFN
miDB_sig2
<-
readRDS
(
paste
(
wdir
,
"reference"
,
"miDB_sig3.rds"
,
sep
=
"/"
))
#Ctrl
ifn_sig
<-
miDB_sig2
[[
"GOBP_RESPONSE_TO_TYPE_I_INTERFERON"
]]
ifn_sig_filt
<-
ifn_sig
[
ifn_sig
%in%
rownames
(
full_obj
)]
full_obj
<-
AddModuleScore
(
object
=
full_obj
,
features
=
list
(
ifn_sig_filt
),
name
=
"RespTypeIifn"
)
full_df_sig
<-
data.frame
()
for
(
sig
in
c
(
names
(
signatures
),
"RespTypeIifn"
))
{
df
<-
full_obj
@
meta.data
[,
c
(
paste0
(
sig
,
"1"
),
"Zones"
,
"TreatGroups"
,
"orig.ident"
)]
colnames
(
df
)
<-
c
(
"Sig"
,
"Zones"
,
"RNA_Group"
,
"Sample"
)
df
$
SigName
<-
sig
full_df_sig
<-
rbind
(
full_df_sig
,
df
)
}
full_df_cor_group
<-
full_df_sig
%>%
group_by
(
SigName
,
Zones
,
RNA_Group
)
%>%
summarise
(
MedianMS
=
median
(
Sig
))
min_sig
<-
full_df_cor_group
%>%
group_by
(
SigName
)
%>%
summarise
(
SigMin
=
min
(
MedianMS
))
full_df_cor_group
<-
merge
(
full_df_cor_group
,
min_sig
,
by
=
"SigName"
)
write.xlsx
(
x
=
list
(
"MedianSig"
=
full_df_cor_group
[,
-5
]),
file
=
paste
(
out_dir
,
"Full_SignaturesMedianModScore.xlsx"
,
sep
=
"/"
))
p
<-
ggplot
(
full_df_cor_group
,
aes
(
x
=
Zones
,
y
=
MedianMS
,
color
=
RNA_Group
,
fill
=
RNA_Group
,
group
=
RNA_Group
,
ymin
=
SigMin
,
ymax
=
MedianMS
))
+
theme_bw
()
+
theme
(
legend.position
=
"right"
,
legend.background
=
element_rect
(
color
=
"black"
),
axis.text.x
=
element_text
(
angle
=
45
,
hjust
=
1
))
+
#geom_line() +
geom_point
()
+
geom_ribbon
(
position
=
'identity'
,
alpha
=
.1
,)
+
xlab
(
""
)
+
ylab
(
"Median MScore"
)
+
facet_wrap
(
.
~
SigName
,
ncol
=
3
,
scales
=
"free"
)
ggsave
(
filename
=
paste
(
out_dir
,
"Full_SignaturesMedianModScore.pdf"
,
sep
=
"/"
),
plot
=
p
,
width
=
10
,
height
=
7
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment