@@ -37,9 +37,9 @@ baseline_scores = run_quality_metrics(
3737# Data with progressively higher cumulative sums
3838high_scores = run_quality_metrics(
3939 base_df_10 ,
40- c(rep( 0 .1 , 5 ), seq(2.0 , 5.0 , length.out = 5 )), # mean_increase
41- c(rep( 0 .1 , 5 ), seq(2.0 , 5.0 , length.out = 5 )), # mean_decrease
42- c(rep( 0 .1 , 5 ), seq(2.0 , 5.0 , length.out = 5 )) # dispersion_increase
40+ c(seq( 0 , 0 .1 , length.out = 5 ), seq(2.0 , 5.0 , length.out = 5 )), # mean_increase
41+ c(seq( 0 , 0 .1 , length.out = 5 ), seq(2.0 , 5.0 , length.out = 5 )), # mean_decrease
42+ c(seq( 0 , 0 .1 , length.out = 5 ), seq(2.0 , 5.0 , length.out = 5 )) # dispersion_increase
4343)
4444
4545# The last 5 rows (with high values) should have higher mean anomaly scores
@@ -51,9 +51,9 @@ base_df_20 = create_base_df(20)
5151
5252extreme_scores = run_quality_metrics(
5353 base_df_20 ,
54- c(rep( 0 .1 , 19 ), 10.0 ), # Last value is extreme
55- c(rep( 0 .1 , 19 ), 8.0 ), # Last value is extreme
56- c(rep( 0 .1 , 19 ), 12.0 ) # Last value is extreme
54+ c(seq( 0 , 0 .1 , length.out = 19 ), 10.0 ), # Last value is extreme
55+ c(seq( 0 , 0 .1 , length.out = 19 ), 8.0 ), # Last value is extreme
56+ c(seq( 0 , 0 .1 , length.out = 19 ), 12.0 ) # Last value is extreme
5757)
5858
5959# The extreme outlier (last row) should have the highest anomaly score
@@ -267,9 +267,9 @@ base_df_6_rank = create_base_df(6)
267267# Create data with obvious ranking: Row 6 > Row 5 > Row 4 > Rows 1,2,3
268268ranking_scores = run_quality_metrics(
269269 base_df_6_rank ,
270- c(0.1 , 0.1 , 0.1 , 1.0 , 2.0 , 5.0 ),
271- c(0.1 , 0.1 , 0.1 , 1.0 , 2.0 , 5.0 ),
272- c(0.1 , 0.1 , 0.1 , 1.0 , 2.0 , 5.0 )
270+ c(0.1 , 0.11 , 0.12 , 1.0 , 2.0 , 5.0 ),
271+ c(0.1 , 0.11 , 0.12 , 1.0 , 2.0 , 5.0 ),
272+ c(0.1 , 0.11 , 0.12 , 1.0 , 2.0 , 5.0 )
273273)
274274
275275# Row 5 should have highest score, Row 4 second highest, etc.
@@ -367,3 +367,21 @@ low_abundance_excluded = MSstatsConvert:::.prepareSpectronautAnomalyInput(
367367 missing_run_count = 0.95 )
368368expect_true(" AFPLAEWQPSDVDQR" %in% low_abundance_excluded $ PeptideSequence )
369369expect_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