Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ClusteringAnalysis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IGFL
J.Enriquez
Myo_ID
ClusteringAnalysis
Commits
f9ec40ba
Commit
f9ec40ba
authored
Apr 16, 2024
by
Gilquin
Browse files
Options
Downloads
Patches
Plain Diff
feat: change default behavior of visualize_markers
parent
466069c0
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/export.R
+38
-18
38 additions, 18 deletions
scripts/export.R
with
38 additions
and
18 deletions
scripts/export.R
+
38
−
18
View file @
f9ec40ba
...
...
@@ -405,6 +405,8 @@ visualize_markers <- function(
height
=
8
,
...
){
# catch extra arguments
extra_args
<-
list
(
...
)
# define colormap
cmap
<-
get
(
colormap
,
envir
=
loadNamespace
(
"pals"
))
cols
<-
unname
(
cmap
(
nlevels
(
object
@
active.ident
)))
...
...
@@ -418,34 +420,52 @@ visualize_markers <- function(
ifelse
(
!
dir.exists
(
file.path
(
savedir
,
subdir
)),
dir.create
(
file.path
(
savedir
,
subdir
),
recursive
=
TRUE
),
FALSE
)
# save the violin plot
filepath
<-
file.path
(
savedir
,
subdir
,
prefix
)
gg
<-
suppressMessages
(
VlnPlot
(
object
,
features
=
features
,
pt.size
=
0
,
cols
=
cols
)
for
(
feat
in
features
){
filepath
<-
file.path
(
savedir
,
subdir
,
feat
)
vln_args
<-
c
(
list
(
"object"
=
object
,
"features"
=
feat
,
"pt.size"
=
0
,
"cols"
=
cols
),
extra_args
[
names
(
extra_args
)
%in%
names
(
as.list
(
args
(
VlnPlot
)))]
)
gg
<-
suppressMessages
(
do.call
(
VlnPlot
,
vln_args
))
ggsave
(
file
=
paste0
(
filepath
,
"_vlnplot"
,
"."
,
device
),
device
=
device
,
width
=
width
,
height
=
width
,
gg
,
...
)
width
=
width
,
height
=
width
,
gg
)
}
# save the feature plot with custom gradient
max_cmap
<-
SeuratObject
::
FetchData
(
object
=
object
,
vars
=
features
,
slot
=
"data"
)
%>%
max
()
for
(
feat
in
features
){
filepath
<-
file.path
(
savedir
,
subdir
,
feat
)
feat_args
<-
c
(
list
(
"object"
=
object
,
"features"
=
feat
),
extra_args
[
names
(
extra_args
)
%in%
names
(
as.list
(
args
(
FeaturePlot
)))]
)
gg
<-
suppressMessages
(
FeaturePlot
(
object
,
features
=
feature
s
)
&
do.call
(
FeaturePlot
,
feat_arg
s
)
&
scale_color_gradientn
(
colors
=
cmap_vir
,
limits
=
c
(
na_cutoff
,
NA
),
na.value
=
na_color
)
colors
=
cmap_vir
,
limits
=
c
(
na_cutoff
,
max_cmap
),
na.value
=
na_color
)
)
ggsave
(
file
=
paste0
(
filepath
,
"_featplot"
,
"."
,
device
),
device
=
device
,
width
=
width
,
height
=
height
,
gg
,
...
)
width
=
width
,
height
=
height
,
gg
)
}
# save the dot plot with custom gradient
filepath
<-
file.path
(
savedir
,
subdir
,
prefix
)
dot_args
<-
c
(
list
(
"object"
=
object
,
"features"
=
features
),
extra_args
[
names
(
extra_args
)
%in%
names
(
as.list
(
args
(
DotPlot
)))]
)
gg
<-
suppressWarnings
(
suppressMessages
(
DotPlot
(
object
,
features
=
feature
s
)
&
do.call
(
DotPlot
,
dot_arg
s
)
&
theme_custom
()
&
scale_x_discrete
(
guide
=
guide_axis
(
n.dodge
=
2
))
&
scale_color_gradientn
(
colors
=
cmap_vir
,
limits
=
c
(
na_cutoff
,
NA
),
na.value
=
na_color
)
))
ggsave
(
file
=
paste0
(
filepath
,
"_dotplot"
,
"."
,
device
),
device
=
device
,
width
=
width
,
height
=
height
,
gg
,
...
)
width
=
width
,
height
=
height
,
gg
)
return
(
NULL
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment