@@ -97,3 +97,58 @@ expect_equal(MSstatsConvert:::.fixMissingValues(data.table::copy(no_duplicates4)
9797expect_equal(MSstatsConvert ::: .fixMissingValues(data.table :: copy(no_duplicates3 ), NULL )$ Intensity ,
9898 no_duplicates3 $ Intensity )
9999
100+ # .getFullDesign tests
101+
102+ # Test 1: H/L features expand over all runs in the group even if a label was only
103+ # observed in a subset of runs. NA-labeled features also expand to all group runs.
104+ # "b" has H only in run 1 and L only in run 2; "a" (NA) only in run 3.
105+ # All three should be filled out to all runs {1, 2, 3} in the group.
106+ gfd_mixed = data.table :: data.table(
107+ feature = c(" b" , " b" , " a" ),
108+ Run = c( 1 , 2 , 3 ),
109+ IsotopeLabelType = c(" H" , " L" , NA ),
110+ Fraction = 1L
111+ )
112+ gfd_result = MSstatsConvert ::: .getFullDesign(
113+ gfd_mixed , group_col = " Fraction" , feature_col = " feature" ,
114+ measurement_col = " Run" , is_tmt = FALSE )
115+ a_rows = gfd_result [gfd_result $ feature == " a" , ]
116+ expect_true(all(is.na(a_rows $ IsotopeLabelType )))
117+ expect_equal(nrow(a_rows ), 3L )
118+ b_rows = gfd_result [gfd_result $ feature == " b" , ]
119+ expect_equal(nrow(b_rows ), 6L )
120+ expect_true(all(sort(unique(b_rows $ IsotopeLabelType )) == c(" H" , " L" )))
121+
122+ # Test 2: All features have NA IsotopeLabelType — full design contains only NA labels,
123+ # not the empty H/L set that na.omit() would strip from the labels vector.
124+ gfd_all_na = data.table :: data.table(
125+ feature = c(" x" , " x" , " y" , " y" ),
126+ Run = c( 1 , 2 , 1 , 2 ),
127+ IsotopeLabelType = NA_character_ ,
128+ Fraction = 1L
129+ )
130+ gfd_na_result = MSstatsConvert ::: .getFullDesign(
131+ gfd_all_na , group_col = " Fraction" , feature_col = " feature" ,
132+ measurement_col = " Run" , is_tmt = FALSE )
133+ expect_true(all(is.na(gfd_na_result $ IsotopeLabelType )))
134+ expect_equal(nrow(gfd_na_result ), 4L )
135+
136+ # Test 3: NA-labeled features expand over ALL runs in the group, not just the runs
137+ # where they were observed. Feature "p" appears in runs 1 and 2 with H/L;
138+ # feature "q" appears only in run 3 with NA, but should be filled out to runs 1-3.
139+ gfd_separate_runs = data.table :: data.table(
140+ feature = c(" p" , " p" , " p" , " p" , " q" ),
141+ Run = c( 1 , 1 , 2 , 2 , 3 ),
142+ IsotopeLabelType = c(" L" , " H" , " L" , " H" , NA ),
143+ Fraction = 1L
144+ )
145+ gfd_sep_result = MSstatsConvert ::: .getFullDesign(
146+ gfd_separate_runs , group_col = " Fraction" , feature_col = " feature" ,
147+ measurement_col = " Run" , is_tmt = FALSE )
148+ p_rows = gfd_sep_result [gfd_sep_result $ feature == " p" , ]
149+ expect_equal(nrow(p_rows ), 6 )
150+ q_rows = gfd_sep_result [gfd_sep_result $ feature == " q" , ]
151+ expect_equal(nrow(q_rows ), 3L )
152+ expect_true(all(is.na(q_rows $ IsotopeLabelType )))
153+ expect_equal(sort(q_rows $ Run ), c(1L , 2L , 3L ))
154+
0 commit comments