# Detecting anomalies in numeric measurements

I'm working with a dataset of 162k experimental protein-peptide affinity measurements. If we ignore mostly irrelevant metadata, we are left with the following fields:

1. protein sequence – each sequence can be treated as a unique identifier (about 100 different proteins);
2. peptide sequence – same as above (about 36k unique entries);
3. measurement method - a categorical variable (5 different categories);
4. affinity value – a nonnegative floating point variable;
5. measurement inequality - a categorical variable in ['=', '<', '>']; shows whether the affinity value falls outside ('<' or '>') of detection range (the range is method- and equipment-specific, but there is no information on the latter).
6. binary response - a binary representation of protein-peptide binding success (a random function of affinity value with unknown parameters; typically set by data submitters);

I'm developing a regressor to predict affinity values for a given peptide-protein pair and take special care of inexact observations (i.e., '<'/'>' cases); there are around 200 records explicitly labeled as '<' or '>'. The problem is that the label is missing in over 80% of the data. I've contacted the dataset's curators, and they've assured me that missing inequality labels can be treated as implicit '='. Having investigated the data, I find this recommendation hard to swallow. Here is the distribution of transformed1 affinity values with explicit '=' inequality labels:

Here is the distribution of transformed affinity values with missing inequality labels.

You can immediately see that something is not right here. If we inspect untransformed values in this group and count them, we will find an awful lot of suspiciously discrete (for a float) high-frequency (and mostly large) numbers. Here are the top-10 values by frequency (frequencies are given in the second column)

20000.000000     38837
70000.000000      2415
5000.000000       2160
50000.000000       767
10000.000000       624
77700.000000       452
78100.000000       416
77900.000000       414
1.000000           410
0.400000           335


For the sake of comparison, here are the top-10 values with explicit '='

1.00        600
0.00        482
12.00       374
18.00       321
24.00       278
0.10        268
30.00       250
2.00        220
36.00       212
6.00        207


Moreover, if we remove overrepresented affinities with missing inequality labels, the distribution of transformed affinities becomes very similar to that of data with explicit '=' labels. I'm attaching examples for maximum counts 500 and 200.

I believe the curators might be overestimating the safety of their assumption, and not all missing inequality values should be treated as '='. Moreover, the prevalence of extremely small and extremely large high-frequency numbers in this groups suggests that quite a few of them are actually detection range boundaries. Therefore, I need some way to detect these cases automatically.

Here is what I'm doing now:

1. Infer an unbiased normal model based on transformed data with explicit '=' inequality label while accounting for sample structure with respect to protein id and measurement method (by treating these variables as random effects) 2.
2. Optimise the maximum value-count threshold in transformed data with missing inequality labels by maximising log-likelihood with respect to the inferred model

I'm not particularly satisfied with this approach, because it forces me to make a lot of assumptions about the data and, most notably, believe that inexact values must behave like outliers, which might not always be the case. I've tried looking for existing approaches, but have found none whatsoever. Do you have alternative ideas or references to existing models?

1 $$f(x) = \log{ \frac{x + \epsilon}{300} }$$, where $$\epsilon$$ is used to avoid taking logs of zeros.

2 proteins naturally form a sequence space and can be projected into a metric space: ideally, I should parametrise their sequences as a weight matrix (e.g. BLUP for genotype data; see VanRaden, 2008 in case you are interested) instead of treating them as a discrete variable with no internal covariance structure, but I haven't gone into this, yet.