Skip to content

Commit 539229d

Browse files
committed
add unit tests for duplicitiy
1 parent c9ea825 commit 539229d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

inst/tinytest/test_utils_anomaly_score.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,21 @@ low_abundance_excluded = MSstatsConvert:::.prepareSpectronautAnomalyInput(
367367
missing_run_count = 0.95)
368368
expect_true("AFPLAEWQPSDVDQR" %in% low_abundance_excluded$PeptideSequence)
369369
expect_false("LowAbundancePeptide" %in% low_abundance_excluded$PeptideSequence)
370+
371+
372+
# Test 11: Testing duplicity of quality metrics, applicable considering
373+
# multiple fragments share the same precursor level metrics
374+
375+
# Data with progressively higher cumulative sums
376+
duplicate_metrics = run_quality_metrics(
377+
base_df_10,
378+
c(rep(0.1, 5), seq(2.0, 4.0, length.out = 5)), # mean_increase
379+
c(rep(0.1, 5), seq(2.0, 4.0, length.out = 5)), # mean_decrease
380+
c(rep(0.1, 5), seq(2.0, 4.0, length.out = 5)) # dispersion_increase
381+
)
382+
383+
# The last 5 rows (with high values) should have lower mean anomaly scores
384+
# Since they are all clumped between 2 and 4, whereas 0.1 is by itself
385+
expect_true(mean(duplicate_metrics$AnomalyScores[6:10]) < mean(duplicate_metrics$AnomalyScores[1:5]),
386+
info = "Rows 6-10 (values clumped 2-4) should have lower
387+
anomaly scores than rows 1-5 (isolated value of 0.1)")

0 commit comments

Comments
 (0)