Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
shinyscreen
Manage
Activity
Members
Labels
Plan
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
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
Environmental Cheminformatics
shinyscreen
Commits
cce27875
Commit
cce27875
authored
1 year ago
by
Todor Kondić
Browse files
Options
Downloads
Patches
Plain Diff
Cleaned up make_eic_ms1_plot and related functions.
parent
b4d33bbe
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
R/plotting.R
+11
-14
11 additions, 14 deletions
R/plotting.R
tests/testthat/_snaps/plotting.md
+10
-10
10 additions, 10 deletions
tests/testthat/_snaps/plotting.md
tests/testthat/test-plotting.R
+4
-2
4 additions, 2 deletions
tests/testthat/test-plotting.R
with
25 additions
and
26 deletions
R/plotting.R
+
11
−
14
View file @
cce27875
...
...
@@ -285,27 +285,25 @@ get_data_4_eic_ms1 <- function(db,extr_ms1,summ_rows,kvals,labs) {
keys
=
names
(
kvals
)
actual_key
=
intersect
(
keys
,
names
(
extr_ms1
))
actual_kvals
=
kvals
[
actual_key
]
browser
()
## Subset extr_ms1 by the actual key.
tab
=
get_data_from_key
(
db
=
db
,
tab
=
extr_ms1
,
kvals
=
kvals
,
outcols
=
c
(
"mz"
,
"rt"
,
"intensity"
))
outcols
=
c
(
"catid"
,
"mz"
,
"rt"
,
"intensity"
))
## Group the plot data per label group (ie tags, or adducts, or
## both).
xlxx
=
intersect
(
labs
,
names
(
extr_ms1
))
xlxx
=
as.character
(
xlxx
)
pdata
=
tab
[,
.
(
rt
,
intensity
),
by
=
xlxx
]
meta
=
db
$
cat
[
tab
[,
.
(
catid
=
unique
(
catid
))],
on
=
.
(
catid
),
.SD
,
by
=
.EACHI
,
.SDcols
=
labs
]
## Attach catid information.
tab
=
meta
[
tab
,
on
=
.
(
catid
),
nomatch
=
NULL
]
pdata
=
tab
[,
.
(
rt
,
intensity
),
by
=
labs
]
## TODO: FIXME: This fails because summ_rows sux wrt calcing of ms1_rt for labels. #Now, add the RTs in.
## pdata[summ_rows,ms1_rt:=signif(i.ms1_rt,5),on=xlxx]
text_labels
=
labs
pdata
=
eval
(
bquote
(
pdata
[,
label
:=
make_line_label
(
..
(
lapply
(
text_labels
,
as.symbol
))),
by
=
text_labels
],
splice
=
T
))
setkeyv
(
pdata
,
cols
=
unique
(
as.character
(
text_labels
)))
## Create labels.
## xlxx <- unique(c(xlxx,"ms1_rt"))
pdata
=
eval
(
bquote
(
pdata
[,
label
:=
make_line_label
(
..
(
lapply
(
xlxx
,
as.symbol
))),
by
=
xlxx
],
splice
=
T
))
setkeyv
(
pdata
,
cols
=
unique
(
as.character
(
xlxx
),
"rt"
))
pdata
}
...
...
@@ -354,7 +352,6 @@ make_eic_ms1_plot <- function(db,extr_ms1,summ,kvals,labs,axis="linear",rt_range
## plots is wrong. Horrible and wrong. Will remove those labels
## until we fix.
summ_rows
=
narrow_summ
(
db
=
db
,
summ
,
kvals
,
labs
,
"mz"
,
"ms1_rt"
,
"ms1_int"
,
"Name"
,
"SMILES"
,
"qa_ms1_exists"
,
"scan"
,
"ms2_sel"
)
browser
()
rows_key
=
union
(
data.table
::
key
(
summ_rows
),
labs
)
summ_rows
$
sel_ms1_rt
=
NA_real_
summ_rows
[
ms2_sel
==
T
,
sel_ms1_rt
:=
ms1_rt
[
which.max
(
ms1_int
)],
by
=
rows_key
]
...
...
This diff is collapsed.
Click to expand it.
tests/testthat/_snaps/plotting.md
+
10
−
10
View file @
cce27875
...
...
@@ -3,16 +3,16 @@
Code
ns
Output
set ID
set ID
adduct tag mz ms1_rt ms1_int Name
1: AAs 4
AAs 4
[M+H]+ AA 120.0655 4 70481520 Threonine
2: AAs 4
AAs 4
[M+H]+ AA 120.0655 4 70481520 Threonine
3: AAs 4
AAs 4
[M+H]+ AA 120.0655 4 70481520 Threonine
4: AAs 4
AAs 4
[M+H]+ KO 120.0655 4 80851056 Threonine
5: AAs 4
AAs 4
[M+H]+ KO 120.0655 4 80851056 Threonine
6: AAs 4
AAs 4
[M+H]+ KO 120.0655 4 80851056 Threonine
7: AAs 4
AAs
4 [M+H]+ WT 120.0655 5 68987250 Threonine
8: AAs 4
AAs
4 [M+H]+ WT 120.0655 5 68987250 Threonine
9: AAs 4
AAs
4 [M+H]+ WT 120.0655 5 68987250 Threonine
set ID
precid
adduct tag mz ms1_rt ms1_int Name
1: AAs 4
6
[M+H]+ AA 120.0655 4 70481520 Threonine
2: AAs 4
6
[M+H]+ AA 120.0655 4 70481520 Threonine
3: AAs 4
6
[M+H]+ AA 120.0655 4 70481520 Threonine
4: AAs 4
26
[M+H]+ KO 120.0655 4 80851056 Threonine
5: AAs 4
26
[M+H]+ KO 120.0655 4 80851056 Threonine
6: AAs 4
26
[M+H]+ KO 120.0655 4 80851056 Threonine
7: AAs 4
4
6
[M+H]+ WT 120.0655 5 68987250 Threonine
8: AAs 4
4
6
[M+H]+ WT 120.0655 5 68987250 Threonine
9: AAs 4
4
6
[M+H]+ WT 120.0655 5 68987250 Threonine
SMILES qa_ms1_exists scan ms2_sel
1: C[C@@H](O)[C@H](N)C(O)=O TRUE F1.S000058 FALSE
2: C[C@@H](O)[C@H](N)C(O)=O TRUE F1.S000059 TRUE
...
...
This diff is collapsed.
Click to expand it.
tests/testthat/test-plotting.R
+
4
−
2
View file @
cce27875
...
...
@@ -11,8 +11,10 @@ test_that("make_eic_ms1_plot",{
m
=
PLOTTING_TEST_STATE
kvals
=
list
(
set
=
"AAs"
,
ID
=
"4"
)
labs
=
c
(
"adduct"
,
"tag"
)
plt
=
make_eic_ms1_plot
(
db
=
m
$
db
,
m
$
db
$
extr
$
cgm
$
ms1
,
m
$
out
$
tab
$
summ
,
kvals
,
labs
)
expect_equal
(
1
,
1
)
cd
=
define_colrdata
(
m
$
out
$
tab
$
comp
,
labs
)
plt
=
make_eic_ms1_plot
(
db
=
m
$
db
,
m
$
db
$
extr
$
cgm
$
ms1
,
m
$
out
$
tab
$
summ
,
kvals
,
labs
,
colrdata
=
cd
)
plt
$
data
=
NULL
expect_snapshot
(
plt
)
})
...
...
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