Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ICS-lcsb
IPSCs_PINK1
Commits
e0a807d6
Commit
e0a807d6
authored
Sep 09, 2020
by
Dimitrios Kyriakis
Browse files
Snakemake Pipeline
parent
ce4649c5
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1983 additions
and
0 deletions
+1983
-0
Scripts/Snakemake/1.Preprocessing.R
Scripts/Snakemake/1.Preprocessing.R
+315
-0
Scripts/Snakemake/2.1.Conserved_Markers.R
Scripts/Snakemake/2.1.Conserved_Markers.R
+50
-0
Scripts/Snakemake/2.2.Conserved_Markers_IPSCsAvg.R
Scripts/Snakemake/2.2.Conserved_Markers_IPSCsAvg.R
+52
-0
Scripts/Snakemake/2.3.Conserved_Markers_3Timepoints.R
Scripts/Snakemake/2.3.Conserved_Markers_3Timepoints.R
+49
-0
Scripts/Snakemake/2.4.Pairwise.R
Scripts/Snakemake/2.4.Pairwise.R
+105
-0
Scripts/Snakemake/3.VennDiagrams.R
Scripts/Snakemake/3.VennDiagrams.R
+164
-0
Scripts/Snakemake/4.Network_Validation.R
Scripts/Snakemake/4.Network_Validation.R
+234
-0
Scripts/Snakemake/5.Correlation_Plots.R
Scripts/Snakemake/5.Correlation_Plots.R
+896
-0
Scripts/Snakemake/Snakefile
Scripts/Snakemake/Snakefile
+118
-0
No files found.
Scripts/Snakemake/1.Preprocessing.R
0 → 100644
View file @
e0a807d6
options
(
future.globals.maxSize
=
2122317824
)
# py_config()
#library(ICSWrapper)
library
(
sctransform
)
library
(
Seurat
)
library
(
RColorBrewer
)
library
(
tictoc
)
library
(
crayon
)
library
(
stringr
)
library
(
Routliers
)
library
(
jcolors
)
library
(
cluster
)
library
(
NMF
)
library
(
ggplot2
)
library
(
ggpubr
)
library
(
cowplot
)
set.seed
(
123
)
tool
=
"seurat"
project
=
"IPSCs_pink1"
dataset
<-
project
DATADIR
<-
"home/users/dkyriakis/PhD/Projects/Michi_Data/DATA/"
list_of_files
<-
c
(
paste0
(
DATADIR
,
"DADA1_S1_DGE.txt"
),
paste0
(
DATADIR
,
"DADA2_S2_DGE.txt"
),
paste0
(
DATADIR
,
"DADA3_S3_DGE.txt"
),
paste0
(
DATADIR
,
"DADA4_S4_DGE.txt"
),
paste0
(
DATADIR
,
"DADA5_S1_DGE.txt"
),
paste0
(
DATADIR
,
"DADA6_S2_DGE.txt"
),
paste0
(
DATADIR
,
"DADA8_S4_DGE.txt"
),
paste0
(
DATADIR
,
"DADD5_S2_DGE.txt"
),
paste0
(
DATADIR
,
"DADD6_S3_DGE.txt"
))
condition_names
<-
c
(
"Control_D21"
,
"Control_D15"
,
"Control_D10"
,
"Control_D06"
,
"PINK1_D21"
,
"PINK1_D15"
,
"PINK1_D06"
,
"Control_IPSCs"
,
"PINK1_IPSCs"
)
organism
<-
"human"
dir.create
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess"
)
setwd
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess"
)
colormap_d
<-
c
(
'#a6cee3'
,
'#1f78b4'
,
'#b2df8a'
,
'#33a02c'
,
'#fb9a99'
,
'#e31a1c'
,
'#fdbf6f'
,
'#ff7f00'
,
'#cab2d6'
,
'#6a3d9a'
,
'#ffff99'
,
'#b15928'
,
"black"
,
"gray"
)
color_cond
<-
c
(
brewer.pal
(
8
,
"Dark2"
),
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
)[
c
(
5
,
1
,
2
,
3
,
4
,
9
,
6
,
7
,
8
)]
color_cond
<-
c
(
brewer.pal
(
5
,
"Dark2"
),
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
])[
c
(
5
,
1
,
2
,
3
,
4
,
9
,
6
,
7
,
8
)]
color_clust
<-
c
(
brewer.pal
(
12
,
"Paired"
)[
-11
],
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
],
brewer.pal
(
8
,
"Dark2"
))
color_cells
<-
c
(
brewer.pal
(
9
,
"Set1"
)[
-6
],
"goldenrod4"
,
"darkblue"
,
"seagreen4"
)
color_list
<-
list
(
condition
=
color_cond
,
Cluster
=
color_clust
,
Cell_Type
=
color_cells
,
State
=
color_clust
)
# color_cells <-primary.colors(15, steps = 3, no.white = TRUE)
# ================================ SETTING UP ======================================== #
# Number of cells to use
imputation
=
FALSE
remove_mt
=
FALSE
remove_ribsomal
=
FALSE
n_cores
=
1
elbow
=
TRUE
SCT
=
TRUE
criteria_pass
=
3
min.cells
<-
10
min.features
<-
200
## ----read------------------------------------------------------------------------------------
# options(future.globals.maxSize= 2122317824)
# ==============================================================================================
# ================================ Setup the Seurat objects ====================================
# ==============================================================================================
# ======== Perform an integrated analysis ====
#NewDir <- paste0(Sys.Date(),"_",tool,"_elbow_",elbow,"_Mito-",remove_mt,"_Ribo-",remove_ribsomal,"_SCT-",SCT,"_criteria_pass-",criteria_pass)
#dir.create(NewDir)
#setwd(NewDir)
dir.create
(
"QC"
)
setwd
(
"QC"
)
# debugonce(create_cds)
Return_fun
<-
ICSWrapper
::
create_cds2
(
list_of_files
=
list_of_files
,
condition_names
=
condition_names
,
min.features
=
min.features
,
min.cells
=
min.cells
,
remove_mt
=
remove_mt
,
data_10x
=
data_10x
,
elbow
=
elbow
,
tool
=
tool
,
n_cores
=
1
,
SCT
=
SCT
,
criteria_pass
=
criteria_pass
,
vars.to.regress
=
c
(
"nCount_RNA"
))
Combined
<-
Return_fun
$
Combined
Data_List
<-
Return_fun
$
Data_List
setwd
(
"../"
)
## ----remapping-------------------------------------------------------------------------------
dir.create
(
"Aligned_Cond_RegPhase"
)
setwd
(
"Aligned_Cond_RegPhase"
)
# ================================== ALLIGN CONDITIONS =========================================
DefaultAssay
(
Combined
)
<-
"RNA"
Combined
$
condition
<-
factor
(
as.factor
(
Combined
$
condition
),
levels
=
c
(
"Control_IPSCs"
,
"Control_D06"
,
"Control_D10"
,
"Control_D15"
,
"Control_D21"
,
"PINK1_IPSCs"
,
"PINK1_D06"
,
"PINK1_D15"
,
"PINK1_D21"
))
Combined
$
Treatment
<-
as.vector
(
Combined
$
condition
)
Combined
$
Treatment
[
grep
(
"Control"
,
Combined
$
Treatment
)]
<-
"Control"
Combined
$
Treatment
[
grep
(
"PINK"
,
Combined
$
Treatment
)]
<-
"PINK"
pink.list
<-
SplitObject
(
Combined
,
split.by
=
"Treatment"
)
for
(
i
in
1
:
length
(
pink.list
))
{
pink.list
[[
i
]]
<-
SCTransform
(
pink.list
[[
i
]],
verbose
=
FALSE
,
vars.to.regress
=
c
(
"G2M.Score"
,
"S.Score"
))
}
# doi: https://doi.org/10.1101/576827
int.features
<-
SelectIntegrationFeatures
(
object.list
=
pink.list
,
nfeatures
=
3000
)
pink.list
<-
PrepSCTIntegration
(
object.list
=
pink.list
,
anchor.features
=
int.features
,
verbose
=
FALSE
)
int.anchors
<-
FindIntegrationAnchors
(
object.list
=
pink.list
,
normalization.method
=
"SCT"
,
anchor.features
=
int.features
,
verbose
=
FALSE
)
Seurat.combined
<-
IntegrateData
(
anchorset
=
int.anchors
,
normalization.method
=
"SCT"
,
verbose
=
FALSE
)
DefaultAssay
(
object
=
Seurat.combined
)
<-
"integrated"
#Seurat.combined$condition <- Idents(object = Seurat.combined)
Combined
<-
Seurat.combined
setwd
(
"../"
)
## ----Clustering------------------------------------------------------------------------------
# ================================== Clustering =========================================
dir.create
(
"Clusters"
)
setwd
(
"Clusters"
)
# Combined <- ReduceDim(Combined,method="umap",project=project)$Combined
# debugonce(reduce_dim)
Combined
<-
ICSWrapper
::
reduce_dim
(
Combined
,
project
=
project
,
assay
=
"SCT"
)
$
Combined
#,resolution=c(0.1))$Combined
pdf
(
paste
(
Sys.Date
(),
project
,
"tsne"
,
"projection.pdf"
,
sep
=
"_"
))
ICSWrapper
::
plot_cells
(
Combined
,
target
=
"condition"
,
leg_pos
=
"right"
,
save
=
FALSE
,
ncol
=
1
,
color_list
=
color_list
)
ICSWrapper
::
plot_cells
(
Combined
,
target
=
"Cluster"
,
leg_pos
=
"right"
,
save
=
FALSE
,
ncol
=
1
,
color_list
=
color_list
)
dev.off
()
ICSWrapper
::
plot_nFeatures
(
Combined
,
title
=
""
,
save
=
TRUE
,
tiff
=
FALSE
,
reduce
=
"t-SNE"
,
p3D
=
FALSE
)
ICSWrapper
::
plot_tot_mRNA
(
Combined
,
title
=
""
,
save
=
TRUE
,
tiff
=
FALSE
,
reduce
=
"t-SNE"
,
p3D
=
FALSE
)
if
(
tolower
(
tool
)
==
"seurat"
&
elbow
){
p3
<-
DimPlot
(
object
=
Combined
,
reduction
=
"umap"
,
group.by
=
"condition"
,
cols
=
color_cond
)
p4
<-
DimPlot
(
object
=
Combined
,
reduction
=
"umap"
,
label
=
TRUE
,
cols
=
color_clust
)
pdf
(
paste
(
Sys.Date
(),
project
,
"umap"
,
"Seurat.pdf"
,
sep
=
"_"
))
print
(
p3
)
print
(
p4
)
dev.off
()
}
setwd
(
"../"
)
saveRDS
(
Combined
,
paste0
(
"Clustered_"
,
NewDir
,
".rds"
))
pdf
(
paste
(
Sys.Date
(),
project
,
"_projection_Aligned_Treatment.pdf"
,
sep
=
"_"
))
ICSWrapper
::
plot_cells
(
Combined
,
target
=
"condition"
,
leg_pos
=
"right"
,
save
=
FALSE
,
ncol
=
1
,
reduction
=
"umap"
,
color_list
=
color_list
)
ICSWrapper
::
plot_cells
(
Combined
,
target
=
"Cluster"
,
leg_pos
=
"right"
,
save
=
FALSE
,
ncol
=
1
,
reduction
=
"umap"
,
color_list
=
color_list
)
ICSWrapper
::
plot_cells
(
Combined
,
target
=
"Phase"
,
leg_pos
=
"right"
,
save
=
FALSE
,
ncol
=
1
,
reduction
=
"umap"
,
color_list
=
color_list
)
ICSWrapper
::
plot_cells
(
Combined
,
target
=
"condition"
,
leg_pos
=
"right"
,
save
=
FALSE
,
ncol
=
1
,
reduction
=
"tsne"
,
color_list
=
color_list
)
ICSWrapper
::
plot_cells
(
Combined
,
target
=
"Cluster"
,
leg_pos
=
"right"
,
save
=
FALSE
,
ncol
=
1
,
reduction
=
"tsne"
,
color_list
=
color_list
)
ICSWrapper
::
plot_cells
(
Combined
,
target
=
"Phase"
,
leg_pos
=
"right"
,
save
=
FALSE
,
ncol
=
1
,
reduction
=
"tsne"
,
color_list
=
color_list
)
dev.off
()
# ---------------------------------------------------------------------------------------
pdf
(
"Combined_QC.pdf"
)
res
<-
ICSWrapper
::
scatter_gene
(
Combined
,
features
=
c
(
"nCount_RNA"
,
"nFeature_RNA"
,
"percent.mito"
,
"percent.rb"
),
size
=
0.9
)
print
(
res
)
dev.off
()
## ----Developmental_Markers-------------------------------------------------------------------
# ================================== Developmental Stages =========================================
dir.create
(
"Developmental_Markers"
)
setwd
(
"Developmental_Markers"
)
DefaultAssay
(
Combined
)
<-
"RNA"
file
<-
paste0
(
WORKDIR
,
"/Gene_Lists/Paper_IPCS_genes.txt"
)
genes_state
<-
read.table
(
file
)
for
(
category
in
levels
(
as.factor
(
genes_state
$
V1
))){
category_genes
<-
toupper
(
as.vector
(
genes_state
[
genes_state
$
V1
==
category
,
2
]))
category_genes_l
<-
category_genes
[
category_genes
%in%
rownames
(
Combined
)]
Combined
<-
AddModuleScore
(
Combined
,
features
=
list
(
category_genes_l
),
name
=
category
)
pdf
(
paste0
(
category
,
"_umap_projection_condition_regPhase.pdf"
),
width
=
8
,
height
=
8
)
res
<-
ICSWrapper
::
scatter_gene
(
Combined
,
features
=
category_genes_l
,
ncol
=
2
,
nrow
=
2
,
size
=
1.1
)
plot
(
res
)
dev.off
()
}
# early_genes <- toupper(as.vector(genes_state[genes_state$V1=="Early",2]))
# mid_genes <- toupper(as.vector(genes_state[genes_state$V1=="Mid",2]))
# late_genes <- toupper(as.vector(genes_state[genes_state$V1=="Late",2]))
# early_genes_l <- early_genes[early_genes%in%rownames(Combined)]
# mid_genes_l <- mid_genes[mid_genes%in%rownames(Combined)]
# late_genes_l <- late_genes[late_genes%in%rownames(Combined)]
#
# Combined <- AddModuleScore(Combined,features = list(early_genes_l),name = "Early")
# Combined <- AddModuleScore(Combined,features = list(mid_genes_l),name = "Mid")
# Combined <- AddModuleScore(Combined,features = list(late_genes_l),name = "Late")
#
# pdf("Early_umap_projection_condition_regPhase.pdf",width = 8,height = 8)
# res <- ICSWrapper::scatter_gene(Combined,features = early_genes_l,ncol = 2,nrow = 2,size=1.1)
# ggarrange(plotlist=res,ncol = 2,nrow = 2)
# dev.off()
# pdf("Mid_umap_projection_condition_regPhase.pdf",width = 8,height = 8)
# res <- ICSWrapper::scatter_gene(Combined,features = mid_genes_l,ncol = 2,nrow = 2,size=1.1)
# ggarrange(plotlist=res,ncol = 2,nrow = 2)
# dev.off()
# pdf("Late_umap_projection_condition_regPhase.pdf",width = 8,height = 8)
# res <- ICSWrapper::scatter_gene(Combined,features = late_genes_l,ncol = 2,nrow = 2,size=1.1)
# ggarrange(plotlist=res,ncol = 2,nrow = 2)
# dev.off()
features
<-
c
(
"iPSC_identity1"
,
"Mda_identity_stage11"
,
"Mda_identity_stage21"
,
"Mda_identity_stage31"
,
"Mda_identity_stage41"
,
"Non.Mda1"
)
pdf
(
"Development_umap_projection_condition_regPhase.pdf"
,
width
=
12
,
height
=
8
)
res
<-
ICSWrapper
::
scatter_gene
(
Combined
,
features
=
features
,
ncol
=
3
,
nrow
=
2
,
size
=
1.1
)
print
(
ggarrange
(
plotlist
=
res
,
ncol
=
3
,
nrow
=
2
))
dev.off
()
scan_dim
<-
function
(
object
,
group.by
=
"Cell_Type"
,
features
,
assay
=
"RNA"
,
method
=
"heat"
,
organism
=
"human"
,
cellheight
=
20
,
cellwidth
=
20
,
width
=
10
)
{
title
<-
paste0
(
Sys.Date
(),
"_"
,
group.by
)
require
(
NMF
)
require
(
ggplot2
)
require
(
dplyr
)
require
(
viridis
)
require
(
Seurat
)
graphics.off
()
scaled_data
<-
t
(
as.matrix
(
object
@
assays
[[
assay
]]
@
counts
)[
features
,
])
df
<-
as.data.frame
(
scaled_data
)
if
(
organism
!=
"human"
)
{
colnames
(
df
)
<-
unlist
(
lapply
(
tolower
(
colnames
(
df
)),
ICSWrapper
::
simpleCap
))
features
<-
unlist
(
lapply
(
tolower
(
colnames
(
df
)),
ICSWrapper
::
simpleCap
))
}
df
[[
group.by
]]
<-
object
[[
group.by
]]
heat_cl
<-
aggregate
(
df
[,
1
:
dim
(
df
)[
2
]
-
1
],
list
(
df
[,
dim
(
df
)[
2
]])[[
1
]],
mean
)
row.names
(
heat_cl
)
<-
heat_cl
[[
group.by
]]
heat_cl
[[
group.by
]]
<-
NULL
print
(
"The heatmap created with c1 scale"
)
aheatmap
(
heat_cl
,
color
=
viridis
(
1000
),
scale
=
"column"
,
distfun
=
"correlation"
,
cellwidth
=
cellwidth
,
Rowv
=
NA
,
cellheight
=
cellheight
,
border_color
=
"gray"
,
filename
=
paste0
(
title
,
"_Mean_heat_extra.pdf"
),
width
=
10
,
height
=
8
)
library
(
reshape2
)
id
<-
df
[[
group.by
]]
df
[[
group.by
]]
<-
NULL
df
<-
cbind
(
id
=
id
,
df
)
melted_df
<-
melt
(
df
)
violin_df
<-
melted_df
library
(
ggplot2
)
print
(
"The Violin created with log1p counts"
)
pdf
(
paste0
(
title
,
"_Violin_extra_log.pdf"
),
width
=
20
)
plot
(
ggplot
(
violin_df
,
aes
(
x
=
variable
,
y
=
log1p
(
value
),
fill
=
get
(
group.by
)))
+
geom_violin
(
scale
=
"width"
,
width
=
0.7
)
+
facet_grid
(
get
(
group.by
)
~
.
,
switch
=
"y"
,
space
=
"free"
)
+
cowplot
::
theme_cowplot
()
+
theme
(
axis.text.x
=
element_text
(
angle
=
45
,
hjust
=
1
),
strip.text.y
=
element_text
(
angle
=
180
),
strip.placement
=
"outside"
,
strip.background
=
element_rect
(
colour
=
"white"
,
fill
=
"white"
))
+
scale_x_discrete
(
limits
=
features
)
+
NoLegend
()
+
ylab
(
""
)
+
xlab
(
""
)
+
scale_fill_manual
(
values
=
color_list
[[
group.by
]],
name
=
group.by
,
na.value
=
"gray"
))
dev.off
()
pdf
(
paste0
(
title
,
"_Jitter_extra_log.pdf"
),
width
=
20
)
plot
(
ggplot
(
violin_df
,
aes
(
x
=
variable
,
y
=
log1p
(
value
),
fill
=
get
(
group.by
)))
+
geom_jitter
(
aes
(
color
=
get
(
group.by
)))
+
scale_fill_manual
(
values
=
color_list
[[
group.by
]],
name
=
group.by
,
na.value
=
"gray"
)
+
facet_grid
(
get
(
group.by
)
~
.
,
switch
=
"y"
,
space
=
"free"
)
+
cowplot
::
theme_cowplot
()
+
theme
(
axis.text.x
=
element_text
(
angle
=
45
,
hjust
=
1
),
strip.text.y
=
element_text
(
angle
=
180
),
strip.placement
=
"outside"
,
strip.background
=
element_rect
(
colour
=
"white"
,
fill
=
"white"
))
+
scale_x_discrete
(
limits
=
features
)
+
NoLegend
()
+
ylab
(
""
)
+
xlab
(
""
))
dev.off
()
}
Combined
<-
ScaleData
(
Combined
,
rownames
(
Combined
))
category_genes
<-
toupper
(
as.vector
(
genes_state
[,
2
]))
category_genes_l
<-
category_genes
[
category_genes
%in%
rownames
(
Combined
)]
ICSWrapper
::
annotated_heat
(
Combined
,
row_annotation
=
c
(
1
),
gene_list
=
category_genes_l
,
ordering
=
"condition"
,
title
=
"Development_Markers"
)
ics_scanpy
(
Combined
,
features
=
category_genes_l
,
group.by
=
"condition"
,
Rowv
=
NA
,
scale
=
"c1"
)
setwd
(
"../"
)
# --------------------------------------------------------------------------------------------------
save.image
(
"IPSCs_PINK.RData"
)
saveRDS
(
Combined
,
"IPSCs_Combined.rds"
)
\ No newline at end of file
Scripts/Snakemake/2.1.Conserved_Markers.R
0 → 100644
View file @
e0a807d6
## ----setup, include=FALSE--------------------------------------------------------------------
set.seed
(
123
)
# library(reticulate)
options
(
future.globals.maxSize
=
2122317824
)
library
(
sctransform
)
library
(
Seurat
)
library
(
RColorBrewer
)
library
(
tictoc
)
library
(
crayon
)
library
(
stringr
)
library
(
Routliers
)
library
(
jcolors
)
library
(
cluster
)
library
(
NMF
)
library
(
ggplot2
)
library
(
ggpubr
)
library
(
cowplot
)
colormap_d
<-
c
(
'#a6cee3'
,
'#1f78b4'
,
'#b2df8a'
,
'#33a02c'
,
'#fb9a99'
,
'#e31a1c'
,
'#fdbf6f'
,
'#ff7f00'
,
'#cab2d6'
,
'#6a3d9a'
,
'#ffff99'
,
'#b15928'
,
"black"
,
"gray"
)
color_cond
<-
c
(
brewer.pal
(
5
,
"Dark2"
),
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
])[
c
(
5
,
1
,
2
,
3
,
4
,
9
,
6
,
7
,
8
)]
olor_clust
<-
c
(
brewer.pal
(
12
,
"Paired"
)[
-11
],
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
],
brewer.pal
(
8
,
"Dark2"
))
color_cells
<-
c
(
brewer.pal
(
9
,
"Set1"
)[
-6
],
"goldenrod4"
,
"darkblue"
,
"seagreen4"
)
color_list
<-
list
(
condition
=
color_cond
,
Cluster
=
color_clust
,
Cell_Type
=
color_cells
,
State
=
color_clust
)
Combined
<-
readRDS
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds"
)
dir.create
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_All/"
)
setwd
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_All/"
)
Conserved_M
<-
subset
(
Combined
,
subset
=
condition
!=
"Control_D10"
)
DefaultAssay
(
Conserved_M
)
<-
"RNA"
Conserved_M
<-
NormalizeData
(
Conserved_M
)
Conserved_M
<-
ScaleData
(
Conserved_M
)
Conserved_M
$
Timepoints
<-
as.vector
(
Conserved_M
$
condition
)
Conserved_M
$
Timepoints
[
grep
(
"IPSC"
,
Conserved_M
$
condition
)]
<-
"IPSCs"
Conserved_M
$
Timepoints
[
grep
(
"D06"
,
Conserved_M
$
condition
)]
<-
"Day06"
Conserved_M
$
Timepoints
[
grep
(
"D15"
,
Conserved_M
$
condition
)]
<-
"Day15"
Conserved_M
$
Timepoints
[
grep
(
"D21"
,
Conserved_M
$
condition
)]
<-
"Day21"
Idents
(
Conserved_M
)
<-
"Treatment"
markers
<-
FindConservedMarkers
(
Conserved_M
,
ident.1
=
"Control"
,
ident.2
=
"PINK"
,
grouping.var
=
"Timepoints"
,
test.use
=
"MAST"
,
latent.vars
=
"nCount_RNA"
,
logfc.threshold
=
0.0
)
index_fc
<-
c
(
sign
(
markers
$
IPSCs_avg_logFC
)
==
sign
(
markers
$
Day06_avg_logFC
)
&
sign
(
markers
$
Day06_avg_logFC
)
==
sign
(
markers
$
Day15_avg_logFC
)
&
sign
(
markers
$
Day15_avg_logFC
)
==
sign
(
markers
$
Day21_avg_logFC
))
sub_markers
<-
markers
[
markers
$
max_pval
<
0.01
&
index_fc
,]
sub_markers
$
avg_FC
<-
rowMeans
(
sub_markers
[,
c
(
"IPSCs_avg_logFC"
,
"Day06_avg_logFC"
,
"Day15_avg_logFC"
,
"Day21_avg_logFC"
)])
sub_markers2
<-
sub_markers
[
abs
(
sub_markers
$
avg_FC
)
>
0.1
,]
dim
(
sub_markers2
)
write.table
(
sub_markers2
,
"Conserved_all.txt"
)
\ No newline at end of file
Scripts/Snakemake/2.2.Conserved_Markers_IPSCsAvg.R
0 → 100644
View file @
e0a807d6
## ----setup, include=FALSE--------------------------------------------------------------------
set.seed
(
123
)
# library(reticulate)
options
(
future.globals.maxSize
=
2122317824
)
library
(
sctransform
)
library
(
Seurat
)
library
(
RColorBrewer
)
library
(
tictoc
)
library
(
crayon
)
library
(
stringr
)
library
(
Routliers
)
library
(
jcolors
)
library
(
cluster
)
library
(
NMF
)
library
(
ggplot2
)
library
(
ggpubr
)
library
(
cowplot
)
colormap_d
<-
c
(
'#a6cee3'
,
'#1f78b4'
,
'#b2df8a'
,
'#33a02c'
,
'#fb9a99'
,
'#e31a1c'
,
'#fdbf6f'
,
'#ff7f00'
,
'#cab2d6'
,
'#6a3d9a'
,
'#ffff99'
,
'#b15928'
,
"black"
,
"gray"
)
color_cond
<-
c
(
brewer.pal
(
5
,
"Dark2"
),
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
])[
c
(
5
,
1
,
2
,
3
,
4
,
9
,
6
,
7
,
8
)]
olor_clust
<-
c
(
brewer.pal
(
12
,
"Paired"
)[
-11
],
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
],
brewer.pal
(
8
,
"Dark2"
))
color_cells
<-
c
(
brewer.pal
(
9
,
"Set1"
)[
-6
],
"goldenrod4"
,
"darkblue"
,
"seagreen4"
)
color_list
<-
list
(
condition
=
color_cond
,
Cluster
=
color_clust
,
Cell_Type
=
color_cells
,
State
=
color_clust
)
Combined
<-
readRDS
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds"
)
dir.create
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_IPSCsAvg/"
)
setwd
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_IPSCsAvg/"
)
Conserved_M
<-
subset
(
Combined
,
subset
=
condition
!=
"Control_D10"
)
DefaultAssay
(
Conserved_M
)
<-
"RNA"
Conserved_M
<-
NormalizeData
(
Conserved_M
)
Conserved_M
<-
ScaleData
(
Conserved_M
)
Conserved_M
$
Timepoints
<-
as.vector
(
Conserved_M
$
condition
)
Conserved_M
$
Timepoints
[
grep
(
"IPSC"
,
Conserved_M
$
condition
)]
<-
"IPSCs"
Conserved_M
$
Timepoints
[
grep
(
"D06"
,
Conserved_M
$
condition
)]
<-
"Day06"
Conserved_M
$
Timepoints
[
grep
(
"D15"
,
Conserved_M
$
condition
)]
<-
"Day15"
Conserved_M
$
Timepoints
[
grep
(
"D21"
,
Conserved_M
$
condition
)]
<-
"Day21"
Idents
(
Conserved_M
)
<-
"Treatment"
markers
<-
FindConservedMarkers
(
Conserved_M
,
ident.1
=
"Control"
,
ident.2
=
"PINK"
,
grouping.var
=
"Timepoints"
,
test.use
=
"MAST"
,
latent.vars
=
"nCount_RNA"
,
logfc.threshold
=
0.0
)
index_fc
<-
c
(
sign
(
markers
$
Day06_avg_logFC
)
==
sign
(
markers
$
Day15_avg_logFC
)
&
sign
(
markers
$
Day15_avg_logFC
)
==
sign
(
markers
$
Day21_avg_logFC
))
sub_markers
<-
markers
[
markers
$
max_pval
<
0.01
&
index_fc
,]
sub_markers
$
avg_FC
<-
rowMeans
(
sub_markers
[,
c
(
"IPSCs_avg_logFC"
,
"Day06_avg_logFC"
,
"Day15_avg_logFC"
,
"Day21_avg_logFC"
)])
sub_markers2
<-
sub_markers
[
abs
(
sub_markers
$
avg_FC
)
>
0.1
,]
dim
(
sub_markers2
)
write.table
(
sub_markers2
,
"Conserved_all_alt.txt"
)
Scripts/Snakemake/2.3.Conserved_Markers_3Timepoints.R
0 → 100644
View file @
e0a807d6
## ----setup, include=FALSE--------------------------------------------------------------------
set.seed
(
123
)
# library(reticulate)
options
(
future.globals.maxSize
=
2122317824
)
library
(
sctransform
)
library
(
Seurat
)
library
(
RColorBrewer
)
library
(
tictoc
)
library
(
crayon
)
library
(
stringr
)
library
(
Routliers
)
library
(
jcolors
)
library
(
cluster
)
library
(
NMF
)
library
(
ggplot2
)
library
(
ggpubr
)
library
(
cowplot
)
colormap_d
<-
c
(
'#a6cee3'
,
'#1f78b4'
,
'#b2df8a'
,
'#33a02c'
,
'#fb9a99'
,
'#e31a1c'
,
'#fdbf6f'
,
'#ff7f00'
,
'#cab2d6'
,
'#6a3d9a'
,
'#ffff99'
,
'#b15928'
,
"black"
,
"gray"
)
color_cond
<-
c
(
brewer.pal
(
5
,
"Dark2"
),
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
])[
c
(
5
,
1
,
2
,
3
,
4
,
9
,
6
,
7
,
8
)]
olor_clust
<-
c
(
brewer.pal
(
12
,
"Paired"
)[
-11
],
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
],
brewer.pal
(
8
,
"Dark2"
))
color_cells
<-
c
(
brewer.pal
(
9
,
"Set1"
)[
-6
],
"goldenrod4"
,
"darkblue"
,
"seagreen4"
)
color_list
<-
list
(
condition
=
color_cond
,
Cluster
=
color_clust
,
Cell_Type
=
color_cells
,
State
=
color_clust
)
dir.create
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_3Timepoints"
)
setwd
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_3Timepoints"
)
Combined
<-
readRDS
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds"
)
Conserved_M
<-
subset
(
Combined
,
subset
=
condition
%in%
c
(
"Control_D06"
,
"Control_D15"
,
"Control_D21"
,
"PINK1_D06"
,
"PINK1_D15"
,
"PINK1_D21"
))
DefaultAssay
(
Conserved_M
)
<-
"RNA"
Conserved_M
<-
NormalizeData
(
Conserved_M
)
Conserved_M
<-
ScaleData
(
Conserved_M
)
Conserved_M
$
Timepoints
<-
as.vector
(
Conserved_M
$
condition
)
Conserved_M
$
Timepoints
[
grep
(
"D06"
,
Conserved_M
$
condition
)]
<-
"Day06"
Conserved_M
$
Timepoints
[
grep
(
"D15"
,
Conserved_M
$
condition
)]
<-
"Day15"
Conserved_M
$
Timepoints
[
grep
(
"D21"
,
Conserved_M
$
condition
)]
<-
"Day21"
Idents
(
Conserved_M
)
<-
"Treatment"
markers
<-
FindConservedMarkers
(
Conserved_M
,
ident.1
=
"Control"
,
ident.2
=
"PINK"
,
grouping.var
=
"Timepoints"
,
test.use
=
"MAST"
,
latent.vars
=
"nCount_RNA"
,
logfc.threshold
=
0.0
)
index_fc
<-
c
(
sign
(
markers
$
Day06_avg_logFC
)
==
sign
(
markers
$
Day15_avg_logFC
)
&
sign
(
markers
$
Day15_avg_logFC
)
==
sign
(
markers
$
Day21_avg_logFC
))
sub_markers
<-
markers
[
markers
$
max_pval
<
0.01
&
index_fc
,]
sub_markers
$
avg_FC
<-
rowMeans
(
sub_markers
[,
c
(
"Day06_avg_logFC"
,
"Day15_avg_logFC"
,
"Day21_avg_logFC"
)])
sub_markers2
<-
sub_markers
[
abs
(
sub_markers
$
avg_FC
)
>
0.1
,]
dim
(
sub_markers2
)
write.table
(
sub_markers2
,
"Conserved_3.txt"
)
Scripts/Snakemake/2.4.Pairwise.R
0 → 100644
View file @
e0a807d6
## ----setup, include=FALSE--------------------------------------------------------------------
set.seed
(
123
)
# library(reticulate)
options
(
future.globals.maxSize
=
2122317824
)
library
(
sctransform
)
library
(
Seurat
)
library
(
RColorBrewer
)
library
(
tictoc
)
library
(
crayon
)
library
(
stringr
)
library
(
Routliers
)
library
(
jcolors
)
library
(
cluster
)
library
(
NMF
)
library
(
ggplot2
)
library
(
ggpubr
)
library
(
cowplot
)
## ----Venn------------------------------------------------------------------------------------
library
(
VennDiagram
)
library
(
EnhancedVolcano
)
colormap_d
<-
c
(
'#a6cee3'
,
'#1f78b4'
,
'#b2df8a'
,
'#33a02c'
,
'#fb9a99'
,
'#e31a1c'
,
'#fdbf6f'
,
'#ff7f00'
,
'#cab2d6'
,
'#6a3d9a'
,
'#ffff99'
,
'#b15928'
,
"black"
,
"gray"
)
color_cond
<-
c
(
brewer.pal
(
5
,
"Dark2"
),
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
])[
c
(
5
,
1
,
2
,
3
,
4
,
9
,
6
,
7
,
8
)]
olor_clust
<-
c
(
brewer.pal
(
12
,
"Paired"
)[
-11
],
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
],
brewer.pal
(
8
,
"Dark2"
))
color_cells
<-
c
(
brewer.pal
(
9
,
"Set1"
)[
-6
],
"goldenrod4"
,
"darkblue"
,
"seagreen4"
)
color_list
<-
list
(
condition
=
color_cond
,
Cluster
=
color_clust
,
Cell_Type
=
color_cells
,
State
=
color_clust
)
dir.create
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Pairwise"
)
setwd
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Pairwise"
)
Combined
<-
readRDS
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds"
)
# =============================== PAIRWISE DF ===============================================
Combined
$
condition
<-
as.factor
(
Combined
$
condition
)
Idents
(
Combined
)
<-
as.factor
(
Combined
$
condition
)
cl_combinations
<-
combn
(
levels
(
Combined
$
condition
),
2
)
cl_combinations
<-
cl_combinations
[,
c
(
5
,
19
,
25
,
30
)]
DefaultAssay
(
Combined
)
<-
"RNA"
Combined
<-
NormalizeData
(
Combined
)
Combined
<-
ScaleData
(
Combined
,
rownames
(
Combined
@
assays
$
RNA
@
counts
))
library
(
parallel
)
pairwise_df
<-
function
(
comb
,
object
,
cl_combinations
){
DefaultAssay
(
object
)
<-
"RNA"
# for(comb in 1:dim(cl_combinations)[2]){
title
<-
paste
(
cl_combinations
[,
comb
],
collapse
=
"_"
)
dir.create
(
title
)
setwd
(
title
)
target
<-
"condition"
idents
<-
as.vector
(
cl_combinations
[,
comb
])
ident.1
<-
idents
[
1
]
print
(
ident.1
)
ident.2
<-
idents
[
2
]
pbmc.markers
<-
FindMarkers
(
object
=
object
,
ident.1
=
ident.1
,
ident.2
=
ident.2
,
assay
=
"RNA"
,
min.pct
=
0.1
,
logfc.threshold
=
0.0
,
only.pos
=
FALSE
,
test.use
=
"MAST"
,
latent.vars
=
c
(
"nCount_RNA"
))
pbmc.markers
$
gene
<-
rownames
(
pbmc.markers
)
qvalue
<-
p.adjust
(
pbmc.markers
$
p_val
,
method
=
"BH"
,
n
=
dim
(
object
@
assays
$
RNA
@
counts
)[
1
])
pbmc.markers
$
qvalue
<-
qvalue
top
<-
pbmc.markers
[
pbmc.markers
$
p_val_adj
<
0.05
,]
to_fc
<-
top
[
order
(
abs
(
top
$
avg_logFC
),
decreasing
=
TRUE
),]
to_fc_gene
<-
rownames
(
to_fc
)[
1
:
50
]
#top10 <- top %>% top_n(n = 50, wt = abs(avg_logFC))
#top10_genes<- rownames(top10)
temp
<-
object
[,
object
$
condition
%in%
c
(
ident.1
,
ident.2
)]
temp
$
condition
<-
as.factor
(
as.vector
(
temp
$
condition
))
# debugonce(annotated_heat)
pdf
(
"Volcano.pdf"
)
plot
(
EnhancedVolcano
(
pbmc.markers
,
lab
=
pbmc.markers
$
gene
,
x
=
'avg_logFC'
,
y
=
'p_val_adj'
,
subtitle
=
paste
(
ident.1
,
"vs"
,
ident.2
,
"(FCcutoff=0.6)"
),
xlim
=
c
(
-2
,
2
),
FCcutoff
=
0.6
))
dev.off
()
ICSWrapper
::
annotated_heat
(
object
=
temp
,
row_annotation
=
c
(
1
),
gene_list
=
to_fc_gene
,
Rowv
=
TRUE
,
gene_list_name
=
"DF_genes"
,
title
=
title
,
ordering
=
"condition"
,
One_annot
=
TRUE
)
DefaultAssay
(
temp
)
<-
"integrated"
write.table
(
pbmc.markers
,
file
=
paste0
(
Sys.Date
(),
"_TO_EXP_each_"
,
target
,
"_"
,
title
,
".tsv"
),
row.names
=
FALSE
,
na
=
""
,
sep
=
"\t"
)
setwd
(
"../"
)
}
mclapply
(
c
(
1
:
dim
(
cl_combinations
)[
2
]),
FUN
=
pairwise_df
,
object
=
Combined
,
cl_combinations
=
cl_combinations
,
mc.cores
=
1
)
setwd
(
"../"
)
# ----------------------------------------------------------------------------------------------
Scripts/Snakemake/3.VennDiagrams.R
0 → 100644
View file @
e0a807d6
## ----setup, include=FALSE--------------------------------------------------------------------
set.seed
(
123
)
# library(reticulate)
options
(
future.globals.maxSize
=
2122317824
)
library
(
sctransform
)
library
(
Seurat
)
library
(
RColorBrewer
)
library
(
tictoc
)
library
(
crayon
)
library
(
stringr
)
library
(
Routliers
)
library
(
jcolors
)
library
(
cluster
)
library
(
NMF
)
library
(
ggplot2
)
library
(
ggpubr
)
library
(
cowplot
)
## ----Venn------------------------------------------------------------------------------------
library
(
VennDiagram
)
colormap_d
<-
c
(
'#a6cee3'
,
'#1f78b4'
,
'#b2df8a'
,
'#33a02c'
,
'#fb9a99'
,
'#e31a1c'
,
'#fdbf6f'
,
'#ff7f00'
,
'#cab2d6'
,
'#6a3d9a'
,
'#ffff99'
,
'#b15928'
,
"black"
,
"gray"
)
color_cond
<-
c
(
brewer.pal
(
5
,
"Dark2"
),
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
])[
c
(
5
,
1
,
2
,
3
,
4
,
9
,
6
,
7
,
8
)]
olor_clust
<-
c
(
brewer.pal
(
12
,
"Paired"
)[
-11
],
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
],
brewer.pal
(
8
,
"Dark2"
))
color_cells
<-
c
(
brewer.pal
(
9
,
"Set1"
)[
-6
],
"goldenrod4"
,
"darkblue"
,
"seagreen4"
)
color_list
<-
list
(
condition
=
color_cond
,
Cluster
=
color_clust
,
Cell_Type
=
color_cells
,
State
=
color_clust
)
dir.create
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/3.Venn_Pairwise/"
)
setwd
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/3.Venn_Pairwise"
)
Combined
<-
readRDS
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds"
)
# ===================== OPEN FILES TAKE THE P.Adj- FC Genes
dirs_pairs
<-
list.dirs
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Pairwise/"
,
full.names
=
TRUE
)[
-1
]
dirs_pairs
<-
grep
(
'IPSC|D06.*D06|D15.*D15|D21.*D21'
,
dirs_pairs
,
value
=
TRUE
)
df_return_nt_cntrl
<-
list
()
df_return_nt_pink
<-
list
()
df_return_nt_all
<-
list
()
for
(
iter
in
1
:
length
(
dirs_pairs
)){
dirs_iter
<-
dirs_pairs
[
iter
]
file
<-
paste0
(
dirs_iter
,
"/"
,
dir
(
dirs_iter
,
"*.tsv"
))
l1
<-
read.table
(
file
,
header
=
TRUE
)
l1
$
cluster
<-
l1
$
avg_logFC
l1
$
cluster
[
l1
$
avg_logFC
<
0
]
<-
"PINK"
l1
$
cluster
[
l1
$
avg_logFC
>
0
]
<-
"Control"
ctrl_l1
<-
l1
[
grep
(
"Control"
,
l1
$
cluster
),]
pink_l1
<-
l1
[
grep
(
"PINK"
,
l1
$
cluster
),]
all_l1
<-
l1
df_return_nt_cntrl
[[
iter
]]
<-
as.vector
(
ctrl_l1
[
ctrl_l1
$
p_val_adj
<
0.01
&
abs
(
ctrl_l1
$
avg_logFC
)
>
0.4
,
"gene"
])
df_return_nt_pink
[[
iter
]]
<-
as.vector
(
pink_l1
[
pink_l1
$
p_val_adj
<
0.01
&
abs
(
pink_l1
$
avg_logFC
)
>
0.4
,
"gene"
])
print
(
length
(
df_return_nt_cntrl
[[
iter
]]))
print
(
length
(
df_return_nt_pink
[[
iter
]]))
df_return_nt_all
[[
iter
]]
<-
c
(
df_return_nt_cntrl
[[
iter
]]
,
df_return_nt_pink
[[
iter
]])
}
# # ============= Intersect Common Genes
cntrl_intesect
<-
Reduce
(
intersect
,
df_return_nt_cntrl
)
print
(
cntrl_intesect
)
pink_intesect
<-
Reduce
(
intersect
,
df_return_nt_pink
)
print
(
pink_intesect
)
all_intesect
<-
Reduce
(
intersect
,
df_return_nt_all
)
print
(
all_intesect
)
pdf
(
"All_venn_diagramm.pdf"
)
myCol
<-
brewer.pal
(
3
,
"Pastel2"
)
draw.triple.venn
(
area1
=
117
,
area2
=
110
,
area3
=
114
,
n12
=
23
,
n23
=
18
,
n13
=
10
,
n123
=
7
,
category
=
c
(
"Day06"
,
"Day15"
,
"Day21"
),
fill
=
myCol
)
dev.off
()
# =========== Venn Diagrams DF genes
library
(
RColorBrewer
)
library
(
VennDiagram
)
myCol
<-
brewer.pal
(
4
,
"Pastel2"
)
pdf
(
"Control_venn_diagramm.pdf"
)
day06
<-
df_return_nt_cntrl
[[
1
]]
day15
<-
df_return_nt_cntrl
[[
2
]]
day21
<-
df_return_nt_cntrl
[[
3
]]
IPSC
<-
df_return_nt_cntrl
[[
4
]]
# Generate plot
v
<-
venn.diagram
(
list
(
Day06
=
day06
,
Day15
=
day15
,
Day21
=
day21
,
IPSC
=
IPSC
),
fill
=
myCol
,
alpha
=
c
(
0.5
,
0.5
,
0.5
,
0.5
),
cat.cex
=
1.5
,
cex
=
1.5
,
filename
=
NULL
)
# have a look at the default plot
grid.newpage
()
grid.draw
(
v
)
# have a look at the names in the plot object v
lapply
(
v
,
names
)
# We are interested in the labels
lapply
(
v
,
function
(
i
)
i
$
label
)
v
[[
14
]]
$
label
<-
paste
(
intersect
(
intersect
(
intersect
(
day06
,
day15
),
day21
),
IPSC
),
collapse
=
"\n"
)
# plot
grid.newpage
()
grid.draw
(
v
)
dev.off
()
pdf
(
"Pink1_venn_diagramm.pdf"
)
day06
<-
df_return_nt_pink
[[
1
]]
day15
<-
df_return_nt_pink
[[
2
]]
day21
<-
df_return_nt_pink
[[
3
]]
IPSC
<-
df_return_nt_pink
[[
4
]]
# Generate plot
v
<-
venn.diagram
(
list
(
Day06
=
day06
,
Day15
=
day15
,
Day21
=
day21
,
IPSC
=
IPSC
),
fill
=
myCol
,
alpha
=
c
(
0.5
,
0.5
,
0.5
,
0.5
),
cat.cex
=
1.5
,
cex
=
1.5
,
filename
=
NULL
)
# have a look at the default plot
grid.newpage
()
grid.draw
(
v
)
# have a look at the names in the plot object v
lapply
(
v
,
names
)
# We are interested in the labels
lapply
(
v
,
function
(
i
)
i
$
label
)
v
[[
14
]]
$
label
<-
paste
(
intersect
(
intersect
(
intersect
(
day06
,
day15
),
day21
),
IPSC
),
collapse
=
"\n"
)
# plot
grid.newpage
()
grid.draw
(
v
)
dev.off
()
myCol
<-
brewer.pal
(
3
,
"Pastel2"
)
pdf
(
"Summary_venn_diagramm.pdf"
)
day06
<-
c
(
df_return_nt_cntrl
[[
1
]],
df_return_nt_pink
[[
1
]])
day15
<-
c
(
df_return_nt_cntrl
[[
2
]],
df_return_nt_pink
[[
2
]])
day21
<-
c
(
df_return_nt_cntrl
[[
3
]],
df_return_nt_pink
[[
3
]])
# Generate plot
v
<-
venn.diagram
(
list
(
Day06
=
day06
,
Day15
=
day15
,
Day21
=
day21
),
fill
=
myCol
,
alpha
=
c
(
0.5
,
0.5
,
0.5
),
cat.cex
=
1.5
,
cex
=
1.5
,
filename
=
NULL
)
# have a look at the default plot
grid.newpage
()
grid.draw
(
v
)
# have a look at the names in the plot object v
lapply
(
v
,
names
)
# We are interested in the labels
lapply
(
v
,
function
(
i
)
i
$
label
)
v
[[
11
]]
$
label
<-
paste
(
intersect
(
intersect
(
day06
,
day15
),
day21
),
collapse
=
"\n"
)
# plot
grid.newpage
()
grid.draw
(
v
)
dev.off
()
\ No newline at end of file
Scripts/Snakemake/4.Network_Validation.R
0 → 100644
View file @
e0a807d6
## ----setup, include=FALSE--------------------------------------------------------------------
set.seed
(
123
)
# library(reticulate)
options
(
future.globals.maxSize
=
2122317824
)
library
(
sctransform
)
library
(
Seurat
)
library
(
RColorBrewer
)
library
(
tictoc
)
library
(
crayon
)
library
(
stringr
)
library
(
Routliers
)
library
(
jcolors
)
library
(
cluster
)
library
(
NMF
)
library
(
ggplot2
)
library
(
ggpubr
)
library
(
cowplot
)
library
(
STRINGdb
)
library
(
igraph
)
colormap_d
<-
c
(
'#a6cee3'
,
'#1f78b4'
,
'#b2df8a'
,
'#33a02c'
,
'#fb9a99'
,
'#e31a1c'
,
'#fdbf6f'
,
'#ff7f00'
,
'#cab2d6'
,
'#6a3d9a'
,
'#ffff99'
,
'#b15928'
,
"black"
,
"gray"
)
color_cond
<-
c
(
brewer.pal
(
5
,
"Dark2"
),
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
])[
c
(
5
,
1
,
2
,
3
,
4
,
9
,
6
,
7
,
8
)]
olor_clust
<-
c
(
brewer.pal
(
12
,
"Paired"
)[
-11
],
"black"
,
"gray"
,
"magenta4"
,
"seagreen4"
,
brewer.pal
(
9
,
"Set1"
)[
-6
],
brewer.pal
(
8
,
"Dark2"
))
color_cells
<-
c
(
brewer.pal
(
9
,
"Set1"
)[
-6
],
"goldenrod4"
,
"darkblue"
,
"seagreen4"
)
color_list
<-
list
(
condition
=
color_cond
,
Cluster
=
color_clust
,
Cell_Type
=
color_cells
,
State
=
color_clust
)
dir.create
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/4.Network_Validation/"
)
setwd
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/4.Network_Validation/"
)
Combined
<-
readRDS
(
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds"
)
# === READ DF GROUPS
g1
<-
read.table
(
"Conserved_all.txt"
)
g2
<-
read.table
(
"Conserved_all_alt.txt"
)
g3
<-
read.table
(
"Conserved_3.txt"
)
all_g
<-
rownames
(
Combined
@
assays
$
RNA
@
counts
)
write.table
(
all_g
,
"All_genes.txt"
)
length
(
all_g
)
all_df_g
<-
unique
(
c
(
rownames
(
g1
),
rownames
(
g2
),
rownames
(
g3
)))
length
(
all_df_g
)
rest
<-
all_g
[
!
all_g
%in%
all_df_g
]
mean_l
<-
c
()
median_l
<-
c
()
degree_l
<-
list
()
num_nodes
<-
c
()
num_inter
<-
c
()
string_db
=
STRINGdb
$
new
(
version
=
"10"
,
species
=
9606
)
string_plot_net
<-
function
(
i
,
mean_l
,
median_l
,
degree_l
){
r_list1
<-
sample
(
rest
,
292
)
write.table
(
r_list1
,
paste0
(
'Random_Genes'
,
i
,
".txt"
),
row.names
=
F
,
col.names
=
F
)
Genes
<-
string_db
$
mp
(
r_list1
)
#string_db$plot_network(Genes)
inter_g
<-
string_db
$
get_interactions
(
Genes
)
full.graph
<-
string_db
$
get_subnetwork
(
Genes
)
degrees_f
<-
degree
(
full.graph
)
mean_l
<-
c
(
mean_l
,
mean
(
degrees_f
))
median_l
<-
c
(
median_l
,
median
(
degrees_f
))
num_nodes
<-
c
(
num_nodes
,
length
(
degrees_f
))
degree_l
[[
i
]]
<-
degrees_f
num_inter
<-
c
(
num_inter
,
ecount
(
full.graph
))
return
(
list
(
"mean_l"
=
mean_l
,
"median_l"
=
median_l
,
"degree_l"
=
degree_l
,
"num_nodes"
=
num_nodes
,
"num_inter"
=
num_inter
))
}
for
(
i
in
1
:
50
){
return_res
<-
string_plot_net
(
i
,
mean_l
,
median_l
,
degree_l
)
mean_l
<-
return_res
$
mean_l
median_l
<-
return_res
$
median_l
num_nodes
<-
return_res
$
num_nodes
degree_l
<-
return_res
$
degree_l
num_inter
<-
return_res
$
num_inter
}
pdf
(
"Ours.pdf"
)
write.table
(
all_df_g
,
paste0
(
'all_df_g'
,
51
,
".txt"
),
row.names
=
F
,
col.names
=
F
)
string_db
=
STRINGdb
$
new
(
version
=
"10"
,
species
=
9606
)
Genes
<-
string_db
$
mp
(
all_df_g
)
string_db
$
plot_network
(
Genes
)
full.graph
<-
string_db
$
get_subnetwork
(
Genes
)
degrees_f
<-
degree
(
full.graph
)
mean_l
<-
c
(
mean_l
,
mean
(
degrees_f
))
median_l
<-
c
(
median_l
,
median
(
degrees_f
))
num_nodes
<-
c
(
num_nodes
,
length
(
degrees_f
))
num_inter
<-
c
(
num_inter
,
ecount
(
full.graph
))
degree_l
[[
51
]]
<-
degrees_f
dev.off
()
rest_degree
<-
unlist
(
degree_l
[
1
:
50
])
deg_degree
<-
unlist
(
degree_l
[
51
])
df
<-
data.frame
(
"degree"
=
unlist
(
degree_l
))
length
(
deg_degree
)
length
(
unlist
(
degree_l
))
n_random
<-
length
(
unlist
(
degree_l
))
-
length
(
deg_degree
)
df
$
ord
<-
"Random"
df
$
ord
[
n_random
:
length
(
unlist
(
degree_l
))]
<-
"DEG"
rest_num_nodes
<-
unlist
(
num_nodes
[
1
:
50
])
deg_num_nodes
<-
unlist
(
num_nodes
[
51
])
rest_num_inter
<-
unlist
(
num_inter
[
1
:
50
])
deg_num_inter
<-
unlist
(
num_inter
[
51
])
d
<-
density
(
rest_num_nodes
)
library
(
plyr
)
mu
<-
ddply
(
df
,
"ord"
,
summarise
,
grp.mean
=
mean
(
degree
))
p1
<-
df
%>%
ggplot
(
aes
(
x
=
degree
,
fill
=
ord
))
+
geom_density
(
alpha
=
0.8
)
+
geom_vline
(
data
=
mu
,
aes
(
xintercept
=
grp.mean
,
color
=
ord
),
size
=
2
,
linetype
=
"dashed"
)
+
theme_cowplot
()
+
theme
(
legend.position
=
"none"
)
+
ylab
(
"Degree distribution"
)
+
xlab
(
"Degree"
)
df
<-
data.frame
(
"nodes"
=
rest_num_nodes
)
df
$
ord
<-
"RANDOM"
p2
<-
df
%>%
ggplot
(
aes
(
x
=
nodes
,
color
=
ord
))
+
geom_density
(
fill
=
"#00BFC4"
,
color
=
"#00BFC4"
,
alpha
=
0.8
)
+
geom_vline
(
xintercept
=
deg_num_nodes
,
color
=
"#F8766D"
,
linetype
=
"dashed"
,
size
=
2
)
+
theme_cowplot
()
+
theme
(
legend.position
=
"top"
)
+
ylab
(
"Probability"
)
+
xlab
(
"Number of nodes"
)
# annotate(geom="text", x=225, y=0.045, label="Random",color="#00BFC4",size=4)+
# annotate(geom="text", x=245, y=0.045, label="DEG",color="#F8766D",size=4)+
df
<-
data.frame
(
"interactions"
=
rest_num_inter
)
df
$
ord
<-
"RANDOM"
p6
<-
df
%>%
ggplot
(
aes
(
x
=
interactions
,
color
=
ord
))
+
geom_density
(
fill
=
"#00BFC4"
,
color
=
"#00BFC4"
,
alpha
=
0.8
)
+
geom_vline
(
xintercept
=
deg_num_inter
,
color
=
"#F8766D"
,
linetype
=
"dashed"
,
size
=
2
)
+
theme_cowplot
()
+
theme
(
legend.position
=
"top"
)
+
ylab
(
"Probability"
)
+
xlab
(
"Number of interactions"
)
+
xlim
(
c
(
400
,
1550
))
#annotate(geom="text", x=840, y=0.003, label="Random",color="#00BFC4",size=4)+
#annotate(geom="text", x=1360, y=0.003, label="DEG",color="#F8766D",size=4)+
# #69b3a2
# #e9ecef
library
(
jsonlite
)
library
(
purrr
)
library
(
data.table
)
dt_list
<-
map
(
degree_l
,
as.data.table
)
dt
<-
rbindlist
(
dt_list
,
fill
=
TRUE
,
idcol
=
T
)
colnames
(
dt
)[
2
]
<-
"Degree"
dt
$
ord
<-
"RANDOM"
dt
$
ord
[
dt
$
.id
==
51
]
<-
"DEG"
colnames
(
dt
)[
3
]
<-
"Condition"
pdf
(
"292.pdf"
)
plot
(
mean_l
,
median_l
)
plot
(
mean_l
,
num_nodes
)
plot
(
median_l
,
num_nodes
)
dev.off
()
p3
<-
ggplot
(
dt
,
aes
(
x
=
.id
,
y
=
Degree
,
group
=
.id
,
fill
=
Condition
))
+
geom_boxplot
()
+
theme_cowplot
()
# ggboxplot(dt, x = ".id", y = "V1",group=".id")+
# stat_compare_means() + # Global p-value
# stat_compare_means(ref.group = 51, label = "p.signif",
# label.y = c(22, 29))
p4
<-
ggboxplot
(
dt
,
x
=
"Condition"
,
y
=
"Degree"
,
fill
=
"Condition"
)
+
stat_compare_means
(
comparisons
=
my_comparisons
)
+
# Add pairwise comparisons p-value
stat_compare_means
(
label.y
=
50
)
+
theme_cowplot
()
+
ylab
(
"Degree"
)
my_comparisons
<-
list
(
c
(
"DEG"
,
"RANDOM"
))
dt2
<-
dt
[
order
(
Condition
),]
p4
<-
ggboxplot
(
dt2
,
x
=
"Condition"
,
y
=
"Degree"
,
fill
=
"Condition"
)
+
stat_compare_means
(
comparisons
=
my_comparisons
,
ref.group
=
"RANDOM"
)
+
#annotate(geom="text", x="DEG", y=90, label="***",color="black",size=5)+theme_cowplot()+
theme
(
legend.position
=
"none"
)
+
ylab
(
"Degree"
)
+
xlab
(
"Condition"
)
p5
<-
ggplot
(
dt
,
aes
(
x
=
Condition
,
y
=
Degree
,
group
=
Condition
,
fill
=
Condition
))
+
geom_boxplot
()
+
stat_compare_means
(
method
=
"wilcox.test"
)
+
# Add global p-value
stat_compare_means
(
label
=
"p.signif"
,
method
=
"t.test"
,
ref.group
=
"RANDOM"
)
+
theme_cowplot
()
+
theme
(
legend.position
=
"top"
)
p12
<-
ggarrange
(
plotlist
=
list
(
p1
,
p2
),
nrow
=
1
)
p45
<-
ggarrange
(
plotlist
=
list
(
p4
,
p5
),
nrow
=
1
)
pdf
(
"QC_292.pdf"
,
height
=
12
,
width
=
8
)
ggarrange
(
plotlist
=
list
(
p12
,
p3
,
p45
),
nrow
=
3
)
dev.off
()
pdf
(
"QC2_292.pdf"
,
height
=
8
,
width
=
15
)
p125
<-
ggarrange
(
plotlist
=
list
(
p1
,
p2
,
p6
,
p4
),
ncol
=
4
)
ggarrange
(
plotlist
=
list
(
p125
,
p3
),
nrow
=
2
)
dev.off
()
pdf
(
"QC3_292.pdf"
,
width
=
15
,
height
=
10
)
ggarrange
(
plotlist
=
list
(
p2
,
p1
,
p6
,
p4
),
nrow
=
2
,
ncol
=
2
)
dev.off
()
pdf
(
"QC4_292.pdf"
,
width
=
8
,
height
=
4
)
p2
p1
p6
p4
dev.off
()
Scripts/Snakemake/5.Correlation_Plots.R
0 → 100644
View file @
e0a807d6
This diff is collapsed.
Click to expand it.
Scripts/Snakemake/Snakefile
0 → 100644
View file @
e0a807d6
rule all:
input:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_All/Conserved_all.txt",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_IPSCsAvg/Conserved_all_alt.txt",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_3Timepoints/Conserved_3.txt",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Pairwise/Volcano.pdf",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/3.Venn_Pairwise/Summary_venn_diagramm.pdf",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/4.Network_Validation/QC4_292.pdf",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/5.Correlation_Net/Network_extented.pdf"
# ==================================================================== Preprocessing ======================================================================
rule Preprocess:
input:
"home/users/dkyriakis/PhD/Projects/Michi_Data/DATA/DADA1_S1_DGE.txt",
"home/users/dkyriakis/PhD/Projects/Michi_Data/DATA/DADA2_S2_DGE.txt",
"home/users/dkyriakis/PhD/Projects/Michi_Data/DATA/DADA3_S3_DGE.txt",
"home/users/dkyriakis/PhD/Projects/Michi_Data/DATA/DADA4_S4_DGE.txt",
"home/users/dkyriakis/PhD/Projects/Michi_Data/DATA/DADA5_S1_DGE.txt",
"home/users/dkyriakis/PhD/Projects/Michi_Data/DATA/DADA6_S2_DGE.txt",
"home/users/dkyriakis/PhD/Projects/Michi_Data/DATA/DADA8_S4_DGE.txt",
"home/users/dkyriakis/PhD/Projects/Michi_Data/DATA/DADD5_S2_DGE.txt",
"home/users/dkyriakis/PhD/Projects/Michi_Data/DATA/DADD6_S3_DGE.txt"
output:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds"
shell:
"Rscript 1.Preprocessing.R"
# ------------------------------------------------------------------------------------------------------------------------------------------------------
# ==================================================================== Conserved_Markers_All ======================================================================
rule Conserved_Markers_All:
input:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds"
output:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_All/Conserved_all.txt"
shell:
"Rscript 2.1.Conserved_Markers.R"
# ------------------------------------------------------------------------------------------------------------------------------------------------------
# ==================================================================== Conserved_Markers_IPSCsAvg ======================================================================
rule Conserved_Markers_IPSCsAvg:
input:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds"
output:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_IPSCsAvg/Conserved_all_alt.txt"
shell:
"Rscript 2.2.Conserved_Markers_IPSCsAvg.R"
# ------------------------------------------------------------------------------------------------------------------------------------------------------
# ==================================================================== Conserved_Markers_3Timepoints ======================================================================
rule Conserved_Markers_3Timepoints:
input:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds"
output:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_3Timepoints/Conserved_3.txt"
shell:
"Rscript 2.3.Conserved_Markers_3Timepoints.R"
# ------------------------------------------------------------------------------------------------------------------------------------------------------
# ==================================================================== DF Pairwise ======================================================================
rule Pairwise:
input:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds"
output:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Pairwise/Volcano.pdf",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Pairwise/",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Pairwise/",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Pairwise/"
shell:
"Rscript 2.4.Pairwise.R"
# ------------------------------------------------------------------------------------------------------------------------------------------------------
# ==================================================================== Venn_diagramm ======================================================================
rule Venn_diagramm:
input:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/1.Preprocess/IPSCs_Combined.rds"
output:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/3.Venn_Pairwise/Summary_venn_diagramm.pdf"
shell:
"Rscript 3.VennDiagrams.R"
# ------------------------------------------------------------------------------------------------------------------------------------------------------
# ==================================================================== Correlation_Net ======================================================================
rule Correlation_Net:
input:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_All/Conserved_all.txt",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_IPSCsAvg/Conserved_all_alt.txt",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_3Timepoints/Conserved_3.txt"
output:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/5.Correlation_Net/Network_extented.pdf"
shell:
"Rscript 5.Correlation_Plots.R"
# ------------------------------------------------------------------------------------------------------------------------------------------------------
# ==================================================================== Network_Validation ======================================================================
rule Network_Validation:
input:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_All/Conserved_all.txt",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_IPSCsAvg/Conserved_all_alt.txt",
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/2.Differential_Epression/Conserved_Markers_3Timepoints/Conserved_3.txt"
output:
"/home/users/dkyriakis/PhD/Projects/IPSCs_pink1/4.Network_Validation/QC4_292.pdf"
shell:
"Rscript 4.Network_Validation.R"
# ------------------------------------------------------------------------------------------------------------------------------------------------------
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