@@ -78,6 +78,8 @@ pca_scores_plot = function(
78
78
points_to_label = ' none' ,
79
79
factor_name ,
80
80
ellipse = ' all' ,
81
+ ellipse_type = ' norm' ,
82
+ ellipse_confidence = 0.95 ,
81
83
label_filter = character (0 ),
82
84
label_factor = ' rownames' ,
83
85
label_size = 3.88 ,
@@ -90,6 +92,8 @@ pca_scores_plot = function(
90
92
label_filter = label_filter ,
91
93
label_factor = label_factor ,
92
94
label_size = label_size ,
95
+ ellipse_type = ellipse_type ,
96
+ ellipse_confidence = ellipse_confidence ,
93
97
... )
94
98
return (out )
95
99
}
@@ -104,6 +108,8 @@ pca_scores_plot = function(
104
108
points_to_label = ' enum' ,
105
109
factor_name = ' entity' ,
106
110
ellipse = ' enum' ,
111
+ ellipse_type = ' enum' ,
112
+ ellipse_confidence = ' entity' ,
107
113
label_filter = ' entity' ,
108
114
label_factor = ' entity' ,
109
115
label_size = ' entity'
@@ -112,7 +118,9 @@ pca_scores_plot = function(
112
118
prototype = list (name = ' PCA scores plot' ,
113
119
description = ' Plots a 2d scatter plot of the selected components' ,
114
120
type = " scatter" ,
115
- .params = c(' components' ,' points_to_label' ,' factor_name' ,' ellipse' ,' label_filter' ,' label_factor' ,' label_size' ),
121
+ .params = c(' components' ,' points_to_label' ,' factor_name' ,' ellipse' ,
122
+ ' label_filter' ,' label_factor' ,' label_size' ,' ellipse_type' ,
123
+ ' ellipse_confidence' ),
116
124
117
125
components = entity(name = ' Components to plot' ,
118
126
value = c(1 ,2 ),
@@ -135,13 +143,34 @@ pca_scores_plot = function(
135
143
ellipse = enum(
136
144
name = ' Plot ellipses' ,
137
145
description = c(
138
- " all" = paste0(' Hotelling T2 95 \\ % ellipses are plotted for all groups and all samples.' ),
139
- " group" = ' Hotelling T2 95 \\ % ellipses are plotted for all groups.' ,
146
+ " all" = paste0(' Ellipses are plotted for all groups and all samples.' ),
147
+ " group" = ' Ellipses are plotted for all groups.' ,
140
148
" none" = ' Ellipses are not included on the plot.' ,
141
- " sample" = ' A Hotelling T2 95 \\ % ellipse is plotted for all samples (ignoring group)' ),
149
+ " sample" = ' An ellipse is plotted for all samples (ignoring group)' ),
142
150
allowed = c(' all' ,' group' ,' none' ,' sample' ),
143
151
value = ' all'
144
152
),
153
+
154
+ ellipse_type = enum(
155
+ name = ' Type of ellipse' ,
156
+ description = c(
157
+ ' norm' = paste0(' Multivariate normal (p = 0.95)' ),
158
+ ' t' = paste0(' Multivariate t (p = 0.95)' )
159
+ ),
160
+ value = ' norm' ,
161
+ type = ' character' ,
162
+ max_length = 1 ,
163
+ allowed = c(' norm' ,' t' )
164
+ ),
165
+
166
+ ellipse_confidence = entity(
167
+ name = ' Ellipse confidence level' ,
168
+ description = ' The confidence level for plotting ellipses.' ,
169
+ value = 0.95 ,
170
+ type = ' numeric' ,
171
+ max_length = 1
172
+ ),
173
+
145
174
label_filter = entity(
146
175
name = ' Label filter' ,
147
176
value = character (0 ),
@@ -246,19 +275,24 @@ setMethod(f="chart_plot",
246
275
}
247
276
248
277
if (obj $ ellipse %in% c(' all' ,' group' )) {
249
- out = out + stat_ellipse(type = ' norm' ) # ellipse for individual groups
278
+ out = out + stat_ellipse(type = obj $ ellipse_type ,
279
+ level = obj $ ellipse_confidence ) # ellipse for individual groups
250
280
}
251
281
252
282
if (is(opt $ groups ,' factor' )) { # if a factor then plot by group using the colours from pmp package
253
- out = out + scale_colour_manual(values = plotClass $ manual_colors ,name = opt $ factor_name )
283
+ out = out + scale_colour_manual(values = plotClass $ manual_colors ,
284
+ name = opt $ factor_name )
254
285
}
255
286
else {# assume continuous and use the default colour gradient
256
- out = out + scale_colour_viridis_c(limits = quantile(opt $ groups ,c(0.05 ,0.95 ),na.rm = TRUE ),oob = squish ,name = opt $ factor_name )
287
+ out = out + scale_colour_viridis_c(limits = quantile(opt $ groups ,
288
+ c(0.05 ,0.95 ),na.rm = TRUE ),oob = squish ,name = opt $ factor_name )
257
289
}
258
290
out = out + theme_Publication(base_size = 12 )
259
291
# add ellipse for all samples (ignoring group)
260
292
if (obj $ ellipse %in% c(' all' ,' sample' )) {
261
- out = out + stat_ellipse(type = ' norm' ,mapping = aes(x = x ,y = y ),colour = " #C0C0C0" ,linetype = ' dashed' ,data = A )
293
+ out = out + stat_ellipse(type = obj $ ellipse_type ,mapping = aes(x = x ,y = y ),
294
+ colour = " #C0C0C0" ,linetype = ' dashed' ,data = A ,
295
+ level = obj $ ellipse_confidence )
262
296
}
263
297
264
298
if (obj $ ellipse %in% c(' all' ,' sample' )) { # only do this if we plotted the sample ellipse
0 commit comments