assign_features: Assign measured feature to theoretical features

Description Usage Arguments Value Examples

View source: R/annotate_features.R

Description

Based on estimated posterior probabilities each measured feature is assigned to the most probable theoretical feature. Measured features are removed if the maximum probability is below the specified cutoff. In rare cases, several measured features are assigned to the same theoretical feature and the measured feature with the largest number of detected peaks or highest intensity will be kept.

Usage

1
assign_features(post.prob, dat, cutoff.prob = 0.8)

Arguments

post.prob

matrix with prior probabilities for each measured feature in rows and theoretical features in columns (e.g. as generated by the function compute_posterior_prob).

dat

data.frame with information about measured features with columns id (= unique identifier), mz (= measured mz value), intensity (= measured intensity).

cutoff.prob

Numeric. Probability cutoff which needs to be reached to keep the assignment of measured and theoretical feature (default = 0.8).

Value

data.frame with the following information about each assigned feature:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
data("se.example")
data("info.features")

dat = prepare_data_for_annotation(se = se.example)
hits.m = find_hits(info.features = info.features,
                   dat = dat,
                   ppm = 20)

prior.prob = compute_prior_prob(hits.m = hits.m,
                                info.features = info.features,
                                dat = dat,
                                ppm = 20)
add.m = generate_connectivity_matrix(info.features = info.features,
                                     type = "adducts")

set.seed(20200402)
post.prob = compute_posterior_prob(prior.prob = prior.prob,
                                   dat = dat,
                                   add.m = add.m,
                                   delta.add = 0.1)

info.assigned.use = assign_features(post.prob = post.prob,
                                    dat = dat)

szymczak-lab/preprocessHighResMS documentation built on Oct. 6, 2020, 12:50 a.m.