Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simon CHEVOLLEAU
Embryo functions
Commits
b4725309
Commit
b4725309
authored
Mar 09, 2022
by
Simon CHEVOLLEAU
💻
Browse files
Add legend_title argument for one dimension function et multiple one dimension function
parent
383d79b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
functions.R
View file @
b4725309
...
...
@@ -303,7 +303,7 @@ distinctPaletteColor <- function(factorVec) {
return
(
cols
)
}
one_dimension
<-
function
(
x
,
annot
,
text_annot
,
name_annot
,
size_point
=
3
,
segment_size
=
1
,
jitter_amount
=
0.3
,
arrow
=
FALSE
,
colors
=
NULL
){
one_dimension
<-
function
(
x
,
annot
,
text_annot
,
name_annot
,
size_point
=
3
,
segment_size
=
1
,
jitter_amount
=
0.3
,
arrow
=
FALSE
,
colors
=
NULL
,
legend_title
=
TRUE
){
library
(
ggplot2
)
library
(
viridis
)
y
<-
c
()
...
...
@@ -330,7 +330,7 @@ one_dimension <- function(x, annot, text_annot, name_annot, size_point = 3, segm
if
(
!
(
is.null
(
colors
))){
ggplot
(
df
,
aes
(
x
=
x
,
y
=
y
,
colour
=
annot
))
+
plot
<-
ggplot
(
df
,
aes
(
x
=
x
,
y
=
y
,
colour
=
annot
))
+
unlist
(
plot_annot
)
+
scale_x_continuous
(
limits
=
c
(
pos_text
[
2
],
max
(
df
$
x
)))
+
scale_y_continuous
(
limits
=
c
(
min
(
df
$
y
),
max
(
df
$
y
)))
+
...
...
@@ -341,10 +341,13 @@ one_dimension <- function(x, annot, text_annot, name_annot, size_point = 3, segm
geom_point
(
size
=
size_point
)
+
labs
(
colour
=
name_annot
)
+
scale_colour_manual
(
values
=
colors
)
if
(
legend_title
==
FALSE
)
plot
<-
plot
+
theme
(
legend.title
=
element_blank
())
}
else
{
ggplot
(
df
,
aes
(
x
=
x
,
y
=
y
))
+
plot
<-
ggplot
(
df
,
aes
(
x
=
x
,
y
=
y
))
+
unlist
(
plot_annot
)
+
scale_x_continuous
(
limits
=
c
(
pos_text
[
2
],
max
(
df
$
x
)))
+
scale_y_continuous
(
limits
=
c
(
min
(
df
$
y
),
max
(
df
$
y
)))
+
...
...
@@ -355,7 +358,11 @@ one_dimension <- function(x, annot, text_annot, name_annot, size_point = 3, segm
geom_point
(
aes
(
colour
=
annot
),
size
=
size_point
)
+
labs
(
colour
=
name_annot
)
+
scale_color_viridis
()
if
(
legend_title
==
FALSE
)
plot
<-
plot
+
theme
(
legend.title
=
element_blank
())
}
return
(
plot
)
}
getColors
<-
function
()
{
...
...
@@ -407,7 +414,7 @@ plotCompressedUmapAllKit <- function(dir_path, pdf_path, desired_annots, annotCo
ggsave
(
paste0
(
dir_path
,
"/compressed_"
,
pdf_path
),
marrangeGrob
(
plot_list_compressed
,
nrow
=
nrow
,
ncol
=
ncol
))
}
plotMultipleOneDimension
<-
function
(
table
,
pseudotimes
,
dir_path
,
colors
=
NULL
,
size_point
=
1
)
{
plotMultipleOneDimension
<-
function
(
table
,
pseudotimes
,
dir_path
,
colors
=
NULL
,
size_point
=
1
,
legend_title
=
TRUE
)
{
for
(
gene
in
rownames
(
table
)){
psdtp_list
<-
list
();
annot_list
<-
list
();
text_annot
<-
list
()
...
...
@@ -433,6 +440,6 @@ plotMultipleOneDimension <- function(table, pseudotimes, dir_path, colors = NULL
color
<-
NULL
}
ggsave
(
paste0
(
dir_path
,
"/"
,
gene
,
".pdf"
),
one_dimension
(
psdtp_list
,
annot_list
,
text_annot
,
gene
,
colors
=
color
,
size_point
=
1
))
ggsave
(
paste0
(
dir_path
,
"/"
,
gene
,
".pdf"
),
one_dimension
(
psdtp_list
,
annot_list
,
text_annot
,
gene
,
colors
=
color
,
size_point
=
1
,
legend_title
))
}
}
Write
Preview
Supports
Markdown
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