@@ -50,8 +50,8 @@ mv_sample_filter = function(mv_threshold=20,...) {
50
50
)
51
51
52
52
# ' @export
53
- # ' @template model_apply
54
- setMethod (f="model_apply ",
53
+ # ' @template model_train
54
+ setMethod (f="model_train ",
55
55
signature = c(" mv_sample_filter" ," DatasetExperiment" ),
56
56
definition = function (M ,D )
57
57
{
@@ -64,24 +64,8 @@ setMethod(f="model_apply",
64
64
# apply filter
65
65
filtered = pmp :: filter_samples_by_mv(x ,max_perc_mv = opt $ mv_threshold / 100 ,D $ sample_meta [,1 ],remove_samples = FALSE )
66
66
flags <- data.frame (attributes(filtered )$ flags )
67
- # remove samples
68
- D = D [flags $ filter_samples_by_mv_flags == 1 ,,drop = FALSE ]
69
- # fill output slots
70
- output_value(M ,' filtered' ) = D
71
67
output_value(M ,' flags' ) = data.frame (' flags' = flags [,2 ],row.names = rownames(x ))
72
68
output_value(M ,' percent_missing' )= data.frame (' precent_missing' = flags [,1 ],row.names = rownames(x ))
73
-
74
- return (M )
75
- }
76
- )
77
-
78
- # ' @export
79
- # ' @template model_train
80
- setMethod (f="model_train ",
81
- signature = c(" mv_sample_filter" ," DatasetExperiment" ),
82
- definition = function (M ,D )
83
- {
84
- M = model_apply(M ,D )
85
69
return (M )
86
70
}
87
71
)
@@ -92,7 +76,16 @@ setMethod(f="model_predict",
92
76
signature = c(" mv_sample_filter" ," DatasetExperiment" ),
93
77
definition = function (M ,D )
94
78
{
95
- M = model_apply(M ,D )
79
+ flags = M $ flags
80
+ # remove samples
81
+ RM = filter_by_name(
82
+ mode = ' exclude' ,
83
+ dimension = ' sample' ,
84
+ names = rownames(flags )[flags [,1 ]== 0 ]
85
+ )
86
+ RM = model_apply(RM ,D )
87
+ # fill output slots
88
+ output_value(M ,' filtered' ) = predicted(RM )
96
89
return (M )
97
90
}
98
91
)
0 commit comments