Skip to content

Commit c17a810

Browse files
committed
stricter typing of slots for entity objects
due to update in struct base package
1 parent 384d31b commit c17a810

21 files changed

+330
-70
lines changed

R/HSDEM_class.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,19 @@ HSDEM<-setClass(
4141
type='character',
4242
description='The method used to adjust for multiple comparisons.'
4343
),
44-
44+
params.formula=entity(name='Formula',
45+
value=y~x,
46+
type='formula',
47+
description='The formula to use'
48+
),
4549
outputs.p_value=entity.stato(name='p value',
4650
stato.id='STATO:0000175',
47-
type='numeric',
51+
type='data.frame',
4852
description='the probability of observing the calculated t-statistic.'
4953
),
5054
outputs.significant=entity(name='Significant features',
5155
#stato.id='STATO:0000069',
52-
type='logical',
56+
type='data.frame',
5357
description='TRUE if the calculated p-value is less than the supplied threhold (alpha)'
5458
)
5559
)
@@ -140,9 +144,9 @@ setMethod(f="method.apply",
140144
colnames(p_value)=as.data.frame(output[[1]])$contrast
141145

142146
# fdr correct
143-
M$p_value=apply(p_value,2,p.adjust,method=M$mtc)
147+
M$p_value=as.data.frame(apply(p_value,2,p.adjust,method=M$mtc))
144148

145-
M$significant=M$p_value<M$alpha
149+
M$significant=as.data.frame(M$p_value<M$alpha)
146150

147151
# reset contrasts
148152
options(O)

R/HSD_class.R

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,19 @@ HSD<-setClass(
5151
value=FALSE,
5252
type='logical'
5353
),
54+
params.formula=entity(name='Formula',
55+
value=y~x,
56+
type='formula',
57+
description='The formula to use'
58+
),
5459
outputs.p_value=entity.stato(name='p value',
5560
stato.id='STATO:0000175',
56-
type='numeric',
61+
type='data.frame',
5762
description='the probability of observing the calculated t-statistic.'
5863
),
5964
outputs.significant=entity(name='Significant features',
6065
#stato.id='STATO:0000069',
61-
type='logical',
66+
type='data.frame',
6267
description='TRUE if the calculated p-value is less than the supplied threhold (alpha)'
6368
)
6469
)
@@ -154,9 +159,9 @@ setMethod(f="method.apply",
154159
colnames(M$p_value)=rownames(output[[1]])
155160

156161
# fdr correct
157-
M$p_value=apply(M$p_value,2,p.adjust,method=M$mtc)
162+
M$p_value=as.data.frame(apply(M$p_value,2,p.adjust,method=M$mtc))
158163

159-
M$significant=M$p_value<M$alpha
164+
M$significant=as.data.frame(M$p_value<M$alpha)
160165

161166
difference=lapply(output,function(x) x$difference)
162167
difference=do.call(rbind,difference)

R/PLSDA_class.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ PLSDA<-setClass(
2424
prototype = list(name='Partial least squares discriminant analysis',
2525
type="classification",
2626
predicted='pred',
27-
params.number_components=entity(value = 2,name = 'Number of PLS components',description = 'The number of PLS components to use',type = 'numeric'),
28-
params.factor_name=entity(value = 'V1',name = 'Name of sample_meta column',description = 'The name of the sample_meta column to use for the PLS models',type = 'character')
27+
params.number_components=entity(value = 2,
28+
name = 'Number of PLS components',
29+
description = 'The number of PLS components to use',
30+
type = 'numeric'),
31+
params.factor_name=entity(value = 'V1',
32+
name = 'Name of sample_meta column',
33+
description = 'The name of the sample_meta column to use for the PLS models',
34+
type = 'character')
2935
)
3036
)
3137

R/anova_class.R

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ ANOVA<-setClass(
5151
type='character',
5252
description='The method used to adjust for multiple comparisons.'
5353
),
54+
params.formula=entity(name='ANOVA formula',
55+
value=y~x,
56+
type='formula',
57+
description='The formula to use for ANOVA'
58+
),
5459
params.type=enum(name='ANOVA type',
5560
description='I, II or [III]. The type of sums of squares to use. For balanced designs all types gives the same result.',
5661
value='III',
@@ -59,21 +64,19 @@ ANOVA<-setClass(
5964
),
6065
outputs.f_statistic=entity.stato(name='F-statistic',
6166
stato.id='STATO:0000176',
62-
type='numeric',
63-
description='the value of the calculated statistic which is converted to a p-value when compared to an F-distribution.',
64-
value=numeric(0)
67+
type='data.frame',
68+
description='the value of the calculated statistic which is converted to a p-value when compared to an F-distribution.'
6569
),
6670
outputs.p_value=entity.stato(name='p value',
6771
stato.id='STATO:0000175',
68-
type='numeric',
69-
description='the probability of observing the calculated t-statistic.',
70-
value=numeric(0)
72+
type='data.frame',
73+
description='the probability of observing the calculated t-statistic.'
7174
),
7275
outputs.significant=entity(name='Significant features',
7376
#stato.id='STATO:0000069',
74-
type='logical',
77+
type='data.frame',
7578
description='TRUE if the calculated p-value is less than the supplied threhold (alpha)',
76-
value=logical(0)
79+
value=data.frame()
7780
)
7881
)
7982
)
@@ -169,7 +172,7 @@ setMethod(f="method.apply",
169172
# populate the object
170173
M$f_statistic=f_statistic
171174
M$p_value=p_value
172-
M$significant=p_value<M$alpha
175+
M$significant=as.data.frame(p_value<M$alpha)
173176

174177
# reset the contrasts
175178
options(O)

R/classical_lsq_class.R

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,17 @@ classical_lsq<-setClass(
6565
description='The method used to adjust for multiple comparisons.'
6666
),
6767
outputs.coefficients=entity(name='Regression coefficients',
68-
type='numeric',
69-
description='The regression coefficients for each model.',
70-
value=numeric(0)
68+
type='data.frame',
69+
description='The regression coefficients for each model.'
7170
),
7271
outputs.p_value=entity.stato(name='p value',
7372
stato.id='STATO:0000175',
74-
type='numeric',
75-
description='the probability of observing the calculated t-statistic.',
76-
value=numeric(0)
73+
type='data.frame',
74+
description='the probability of observing the calculated t-statistic.'
7775
),
7876
outputs.significant=entity(name='Significant features',
79-
type='logical',
80-
description='TRUE if the calculated p-value is less than the supplied threhold (alpha)',
81-
value=logical(0)
77+
type='data.frame',
78+
description='TRUE if the calculated p-value is less than the supplied threhold (alpha)'
8279
)
8380
)
8481
)
@@ -154,9 +151,9 @@ setMethod(f="method.apply",
154151

155152

156153
# fdr correct the p-values
157-
M$p_value=apply(M$p_value,2,FUN=function(x) {p.adjust(x,M$mtc)})
154+
M$p_value=as.data.frame(apply(M$p_value,2,FUN=function(x) {p.adjust(x,M$mtc)}))
158155

159-
M$significant=M$p_value<M$alpha
156+
M$significant=as.data.frame(M$p_value<M$alpha)
160157

161158
return(M)
162159
}

R/confounders_clsq_class.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ confounders_lsq.barchart<-setClass(
189189
type="barchart",
190190
params.feature_to_plot=entity(name='Feature to plot',
191191
value=1,
192-
type='numeric',
192+
type=c('numeric','character'),
193193
description='The name of the feature to be plotted.'
194194
),
195195
params.threshold=entity(name='Threshold',

R/dataset_chart_classes.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ feature_boxplot<-setClass(
3838
),
3939
params.feature_to_plot=entity(name='Feature to plot',
4040
value='V1',
41-
type='character',
41+
type=c('character','numeric'),
4242
description='The column name of the feature to be plotted.'
4343
),
4444
params.factor_name=entity(name='Factor name',
@@ -159,6 +159,11 @@ mv_histogram<-setClass(
159159
value=TRUE,
160160
type='logical',
161161
description='(TRUE) to plot missing values per sample or FALSE to plot by feature.'
162+
),
163+
params.label_outliers=entity(name='Label outliers on the plot',
164+
value=FALSE,
165+
type='logical',
166+
description='TRUE or FALSE to include labels for outlying samples. Default FALSE'
162167
)
163168
)
164169
)

R/filter_by_name_class.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ filter_by_name<-setClass(
3838

3939
params.names=entity(name='Names',
4040
description = 'The name of features/samples to be filtered. Must be an exact match. Can also provide indexes (numeric) or logical.',
41-
type='character')
41+
type=c('character','numeric','logical'))
4242
)
4343
)
4444

R/linear_model_class.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ linear_model<-setClass(
4141
list=c('na.omit','na.fail','na.exclude','na.pass')
4242
),
4343
params.contrasts=entity(name='Contrasts',
44-
description='The contrasts associated with a factor. If NULL then the default contrasts are used.',
44+
description='The contrasts associated with a factor. If zero length then the default contrasts are used.',
4545
type='list'
4646
),
4747

@@ -74,7 +74,7 @@ setMethod(f="model.train",
7474
definition=function(M,D)
7575
{
7676
X=cbind(D$data,D$sample_meta)
77-
if (is.null(M$contrasts)) {
77+
if (length(M$contrasts)==0) {
7878
M$lm=lm(formula = M$formula, na.action = M$na_action,data=X) # default contrasts
7979
} else {
8080
M$lm=lm(formula = M$formula, na.action = M$na_action, contrasts = M$contrasts,data=X)

R/mixed_effect_class.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ setMethod(f="method.apply",
117117
# populate the object
118118
M$f_statistic=f_statistic
119119
M$p_value=p_value
120-
M$significant=p_value<M$alpha
120+
M$significant=as.data.frame(p_value<M$alpha)
121121

122122
# reset contrasts
123123
options(O)

0 commit comments

Comments
 (0)