@@ -202,18 +202,19 @@ setMethod(f="chart_plot",
202
202
}
203
203
204
204
# build the plot
205
- A <- data.frame (group = groups ,x = x , y = y ,slabels = slabels )
205
+ A <- data.frame (group = groups ,x = x , y = y ,slabels = slabels , shape = shapes )
206
206
207
207
out = ggplot()
208
208
209
209
# add invisible sample points for ellipse
210
210
out = out + geom_point(data = A ,aes_string(x = ' x' ,y = ' y' ),alpha = 0 ,show.legend = FALSE )
211
211
212
212
if (length(shapes )> 1 ) {
213
- out = out + geom_point(data = A , aes_(x = ~ x ,y = ~ y ,colour = ~ group ,shape = ~ shapes ))
213
+ out = out + geom_point(data = A , aes_(x = ~ x ,y = ~ y ,colour = ~ group ,shape = ~ shape ))
214
214
} else {
215
- out = out + geom_point(data = A , aes_(x = ~ x ,y = ~ y ,colour = ~ group ),shape = shapes )
215
+ out = out + geom_point(data = A , aes_(x = ~ x ,y = ~ y ,colour = ~ group ),shape = shapes )
216
216
}
217
+
217
218
out = out +
218
219
219
220
geom_point(na.rm = TRUE ) +
@@ -227,16 +228,23 @@ setMethod(f="chart_plot",
227
228
}
228
229
229
230
if (obj $ ellipse %in% c(' all' ,' group' )) {
230
- out = out + stat_ellipse(data = A , aes_(x = ~ x ,y = ~ y ,colour = ~ group ),type = obj $ ellipse_type ,
231
+ if (is.factor(groups )) {
232
+ out = out + stat_ellipse(data = A , aes_(x = ~ x ,y = ~ y ,colour = ~ group ,group = ~ group ),type = obj $ ellipse_type ,
231
233
level = obj $ ellipse_confidence ) # ellipse for individual groups
234
+ } else {
235
+ if (is.factor(shapes )) {
236
+ out = out + stat_ellipse(data = A , aes_(x = ~ x ,y = ~ y ,group = ~ shape ),color = " #C0C0C0" ,type = obj $ ellipse_type ,
237
+ level = obj $ ellipse_confidence ) # ellipse for individual groups
238
+ }
239
+ }
232
240
}
233
241
234
242
if (is(groups ,' factor' )) { # if a factor then plot by group using the colours from pmp package
235
243
out = out + scale_colour_manual(values = plotClass $ manual_colors ,
236
244
name = obj $ factor_name [[1 ]])
237
- }else {# assume continuous and use the default colour gradient
245
+ } else {# assume continuous and use the default colour gradient
238
246
out = out + scale_colour_viridis_c(limits = quantile(groups ,
239
- c(0.05 ,0.95 ),na.rm = TRUE ),oob = squish ,name = obj $ factor_name [[1 ]])
247
+ c(0.05 ,0.95 ),na.rm = TRUE ),oob = scales :: squish ,name = obj $ factor_name [[1 ]])
240
248
}
241
249
out = out + theme_Publication(base_size = 12 )
242
250
# add ellipse for all samples (ignoring group)
0 commit comments