Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MAGE_2020_Marker-Gene-Benchmarking
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioCellGen-public
MAGE_2020_Marker-Gene-Benchmarking
Commits
f5caa25a
Commit
f5caa25a
authored
2 years ago
by
Jeffrey Pullin
Browse files
Options
Downloads
Patches
Plain Diff
Add code to run scran::scoreMarkers
parent
19aa763c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#10815
passed
2 years ago
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
code/method-pars.R
+29
-3
29 additions, 3 deletions
code/method-pars.R
code/run-scran.R
+43
-10
43 additions, 10 deletions
code/run-scran.R
with
72 additions
and
13 deletions
code/method-pars.R
+
29
−
3
View file @
f5caa25a
...
...
@@ -11,12 +11,37 @@ suppressMessages({
# Read the overall config file.
config
<-
yaml
::
read_yaml
(
here
::
here
(
"config.yaml"
))
scran
_pars
<-
expand_grid
(
findMarkers
_pars
<-
expand_grid
(
method
=
"scran"
,
func
=
"findMarkers"
,
test.type
=
c
(
"t"
,
"wilcox"
,
"binom"
),
pval.type
=
c
(
"any"
,
"all"
,
"some"
)
)
%>%
mutate
(
file_name
=
paste0
(
method
,
"_"
,
test.type
,
"_"
,
pval.type
))
mutate
(
file_name
=
paste0
(
method
,
"_"
,
func
,
"_"
,
test.type
,
"_"
,
pval.type
))
scoreMarkers_pars
<-
expand_grid
(
method
=
"scran"
,
func
=
"scoreMarkers"
,
metric
=
c
(
"mean.logFC.cohen"
,
"min.logFC.cohen"
,
"median.logFC.cohen"
,
"max.logFC.cohen"
,
"rank.logFC.cohen"
,
"mean.AUC"
,
"min.AUC"
,
"max.AUC"
,
"rank.AUC"
,
"mean.logFC.detected"
,
"min.logFC.detected"
,
"median.logFC.detected"
,
"max.logFC.detected"
,
"rank.logFC.detected"
)
)
%>%
mutate
(
metric_readable
=
gsub
(
"\\."
,
"_"
,
metric
))
%>%
mutate
(
file_name
=
paste0
(
method
,
"_"
,
func
,
"_"
,
metric_readable
))
%>%
select
(
-
metric_readable
)
seurat_pars
<-
expand_grid
(
method
=
"seurat"
,
...
...
@@ -104,7 +129,8 @@ cosg_pars <- expand_grid(
mutate
(
file_name
=
paste0
(
method
))
method_pars_data
<-
list
(
scran_pars
,
findMarkers_pars
,
scoreMarkers_pars
,
seurat_pars
,
lm_pars
,
edger_pars
,
...
...
This diff is collapsed.
Click to expand it.
code/run-scran.R
+
43
−
10
View file @
f5caa25a
...
...
@@ -10,6 +10,8 @@
#'
run_scran
<-
function
(
sce
,
pars
)
{
if
(
pars
$
func
==
"findMarkers"
)
{
times
<-
system.time
({
raw_result
<-
scran
::
findMarkers
(
sce
,
...
...
@@ -48,26 +50,59 @@ run_scran <- function(sce, pars) {
p_value_adj
=
FDR
,
gene
=
gene
)
}
# We do know the log fold change when not using the Wilcox test, but it
# doesn't add any extra information.
x
<-
dplyr
::
mutate
(
x
,
log_fc
=
0
,
scaled_statistic
=
0
)
x
<-
dplyr
::
mutate
(
x
,
scaled_statistic
=
0
)
x
})
}
else
if
(
pars
$
func
==
"scoreMarkers"
)
{
metric
<-
pars
$
metric
rank_by
<-
pars
$
rank_by
times
<-
system.time
({
raw_result
<-
scran
::
scoreMarkers
(
sce
)
})
result
<-
lapply
(
raw_result
,
function
(
x
)
{
x
<-
as.data.frame
(
x
)
x
<-
x
[,
metric
,
drop
=
FALSE
]
x
<-
tibble
::
rownames_to_column
(
x
,
var
=
"gene"
)
x
<-
tibble
::
as_tibble
(
x
)
x
<-
dplyr
::
select
(
x
,
raw_statistic
=
!!
metric
,
gene
=
gene
,
)
x
<-
dplyr
::
mutate
(
x
,
scaled_statistic
=
0
,
p_value
=
0
,
p_value_adj
=
0
)
x
<-
dplyr
::
arrange
(
x
,
dplyr
::
desc
(
raw_statistic
))
})
}
cluster_names
<-
names
(
result
)
for
(
i
in
seq_along
(
result
))
{
result
[[
i
]]
<-
dplyr
::
mutate
(
result
[[
i
]],
cluster
=
cluster_names
[[
i
]])
}
result
<-
dplyr
::
bind_rows
(
!!!
result
)
# Add in one-vs-rest log fold changes.
result
$
log_fc
<-
calculate_log_fc
(
sce
,
genes
=
result
$
gene
,
clusters
=
result
$
cluster
)
validate_mgs_result
(
result
)
# Get the elapsed time.
...
...
@@ -75,5 +110,3 @@ run_scran <- function(sce, pars) {
list
(
time
=
time
,
result
=
result
,
raw_result
=
raw_result
,
pars
=
pars
)
}
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