Skip to content

Commit 2e386a4

Browse files
authored
Merge pull request #47 from aberHRML/devel
v1.0.1
2 parents 88537c0 + 3b02dae commit 2e386a4

File tree

5 files changed

+67
-18
lines changed

5 files changed

+67
-18
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: assignments
22
Title: Molecular Formula Assignment For High Resolution ESI-MS Based Metabolomics Data
3-
Version: 1.0.0
3+
Version: 1.0.1
44
Authors@R: person("Jasen", "Finch", email = "jsf9@aber.ac.uk", role = c("aut", "cre"))
55
Description: A molecular formula assignment approach for electrospray ionisation high resolution mass spectrometry based metabolomics data.
66
Depends: R (>= 3.5.0),

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ importFrom(dplyr,full_join)
6868
importFrom(dplyr,group_by)
6969
importFrom(dplyr,group_split)
7070
importFrom(dplyr,inner_join)
71+
importFrom(dplyr,join_by)
7172
importFrom(dplyr,left_join)
7273
importFrom(dplyr,mutate)
7374
importFrom(dplyr,mutate_at)

NEWS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# assignments 1.0.1
2+
3+
* The default ppm threshold has been reduced to 4.
4+
5+
* The importance of the ^37^Cl adduct has been increased in the default negative mode adducts.
6+
7+
* The ^13^C2 isotope has been removed from the default isotopes.
8+
9+
* The default retention time difference limit for relationships has been changed to 2 seconds for RP-LC-HRMS and NP-LC-HRMS.
10+
11+
* The absolute values of correlation coefficients are now used to calculate average component weights.
12+
13+
* Where components contain a feature represented by more than one adduct and isotope combination, only the node with the highest AIS is now retained.
14+
115
# assignments 1.0.0
216

317
* Added a `NEWS.md` file to track changes to the package.

R/components.R

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ clean <- function(graph,adduct_rules_table){
4848
cleaned_graph <- cleaned_graph %>%
4949
bind_graphs()
5050
}
51-
51+
5252
return(cleaned_graph)
5353
}
5454

@@ -60,14 +60,14 @@ nComponents <- function(graph){
6060

6161
componentMetrics <- function(component,max_add_iso_total){
6262
component %>%
63-
mutate(Size = graph_size(),
64-
Nodes = n(),
65-
Degree = avg_degree(Nodes,Size),
66-
Density = (2 * Size) / (Nodes * (Nodes - 1)),
67-
Weight = sum(Weight) / Nodes,
68-
AIS = sum(AIS) / max_add_iso_total,
69-
`Component Plausibility` = plausibility(Degree,AIS,Weight)
70-
)
63+
mutate(Size = graph_size(),
64+
Nodes = n(),
65+
Degree = avg_degree(Nodes,Size),
66+
Density = (2 * Size) / (Nodes * (Nodes - 1)),
67+
Weight = sum(Weight) / Nodes,
68+
AIS = sum(AIS) / max_add_iso_total,
69+
`Component Plausibility` = plausibility(Degree,AIS,Weight)
70+
)
7171
}
7272

7373
componentFilters <- function(){
@@ -77,6 +77,38 @@ componentFilters <- function(){
7777
Direction = c(rep('max',2),'min'))
7878
}
7979

80+
#' @importFrom dplyr join_by
81+
82+
deduplicate <- function(graph){
83+
dedup_nodes <- graph %>%
84+
activate(nodes) %>%
85+
as_tibble() %>%
86+
group_split(
87+
Component,
88+
Feature
89+
) %>%
90+
future_map_dfr(
91+
~.x %>%
92+
arrange(
93+
desc(
94+
AIS
95+
)
96+
) %>%
97+
slice(1)
98+
)
99+
100+
graph %>%
101+
activate(nodes) %>%
102+
inner_join(
103+
dedup_nodes,
104+
by = join_by(
105+
name, Feature, RetentionTime,
106+
Isotope, Adduct, MF, `Theoretical M`, `Measured M`,
107+
`Theoretical m/z`, `Measured m/z`, `PPM error`,
108+
`MF Plausibility (%)`, AIS, ID, Component)
109+
)
110+
}
111+
80112
#' @importFrom tidygraph as_tbl_graph activate morph unmorph graph_size group_components tbl_graph
81113
#' @importFrom magrittr set_names
82114

@@ -88,6 +120,7 @@ calcComponents <- function(graph_nodes,
88120
activate(nodes) %>%
89121
left_join(graph_nodes,by = c('name' = 'Name')) %>%
90122
mutate(Component = group_components()) %>%
123+
deduplicate() %>%
91124
clean(adductRules(assignment))
92125

93126
if (nComponents(graph) > 0){
@@ -102,6 +135,7 @@ calcComponents <- function(graph_nodes,
102135
filter(Component == .x) %>%
103136
edges() %>%
104137
.$coefficient %>%
138+
abs() %>%
105139
mean() %>%
106140
tibble(Weight = .)
107141
},graph = graph) %>%

R/parameters.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ setClass('AssignmentParameters',
4141
maxCor = Inf),
4242
max_M = 800,
4343
MF_rank_threshold = 3,
44-
ppm = 6,
44+
ppm = 4,
4545
limit = 0.001,
4646
RT_diff_limit = numeric(),
47-
isotopes = c('13C','18O','13C2'),
48-
adducts = list(n = c("[M-H]1-", "[M+Cl]1-", "[M+K-2H]1-",
49-
"[M-2H]2-", "[M+Cl37]1-","[2M-H]1-"),
47+
isotopes = c('13C','18O'),
48+
adducts = list(n = c("[M-H]1-", "[M+Cl]1-", "[M+Cl37]1-", "[M+K-2H]1-",
49+
"[M-2H]2-", "[2M-H]1-"),
5050
p = c('[M+H]1+','[M+K]1+','[M+Na]1+','[M+K41]1+',
5151
'[M+2H]2+','[2M+H]1+')),
5252
transformations = transformation_rules()$`MF Change`,
@@ -548,12 +548,12 @@ assignmentParameters <- function(technique = availableTechniques()){
548548
`FIE-HRMS` = new('AssignmentParameters'),
549549
`RP-LC-HRMS` = new('AssignmentParameters',
550550
technique = 'RP-LC-HRMS',
551-
RT_diff_limit = 1/60),
551+
RT_diff_limit = 2/60),
552552
`NP-LC-HRMS` = new('AssignmentParameters',
553553
technique = 'NP-LC-HRMS',
554-
RT_diff_limit = 1/60,
555-
adducts = list(n = c("[M-H]1-", "[M+Cl]1-", "[M+K-2H]1-",
556-
"[M-2H]2-", "[M+Cl37]1-","[2M-H]1-"),
554+
RT_diff_limit = 2/60,
555+
adducts = list(n = c("[M-H]1-", "[M+Cl]1-", "[M+Cl37]1-", "[M+K-2H]1-",
556+
"[M-2H]2-","[2M-H]1-"),
557557
p = c('[M+H]1+','[M+K]1+','[M+Na]1+','[M+K41]1+',
558558
'[M+NH4]1+','[M+2H]2+','[2M+H]1+'))))
559559

0 commit comments

Comments
 (0)