@@ -176,15 +176,14 @@ setMethod(f="chart_plot",
176
176
} else {
177
177
slabels = dobj $ sample_meta [[obj $ label_factor ]]
178
178
}
179
- obj $ factor_name = obj $ factor_name [[1 ]] # only use the first factor from now on
180
-
179
+
181
180
x = dobj $ data [,obj $ xcol ]
182
181
y = dobj $ data [,obj $ ycol ]
183
182
xlabel = obj $ xcol
184
183
ylabel = obj $ ycol
185
184
186
185
# get the factor from meta data
187
- groups = dobj $ sample_meta [[obj $ factor_name ]]
186
+ groups = dobj $ sample_meta [[obj $ factor_name [[ 1 ]] ]]
188
187
189
188
# add a space to the front of the labels to offset them from the points, because nudge_x is in data units
190
189
for (i in 1 : length(slabels )) {
@@ -210,24 +209,21 @@ setMethod(f="chart_plot",
210
209
# add invisible sample points for ellipse
211
210
out = out + geom_point(data = A ,aes_string(x = ' x' ,y = ' y' ),alpha = 0 ,show.legend = FALSE )
212
211
213
-
214
- if (length(obj $ factor_name )== 2 ) {
212
+ if (length(shapes )> 1 ) {
215
213
out = out + geom_point(data = A , aes_(x = ~ x ,y = ~ y ,colour = ~ group ,shape = ~ shapes ))
216
- } else {
217
- out = out + geom_point(data = A , aes_(x = ~ x ,y = ~ y ,colour = ~ group ))
214
+ } else {
215
+ out = out + geom_point(data = A , aes_(x = ~ x ,y = ~ y ,colour = ~ group ), shape = shapes )
218
216
}
219
-
220
-
221
217
out = out +
222
218
223
219
geom_point(na.rm = TRUE ) +
224
220
xlab(xlabel ) +
225
221
ylab(ylabel )
226
222
227
- if (length(obj $ factor_name ) == 2 ) {
223
+ if (length(shapes ) > 1 ) {
228
224
out = out + labs(shape = obj $ factor_name [[2 ]],colour = obj $ factor_name [[1 ]])
229
225
} else {
230
- out = out + labs(shape = obj $ factor_name [[1 ]])
226
+ out = out + labs(color = obj $ factor_name [[1 ]])
231
227
}
232
228
233
229
if (obj $ ellipse %in% c(' all' ,' group' )) {
@@ -237,10 +233,10 @@ setMethod(f="chart_plot",
237
233
238
234
if (is(groups ,' factor' )) { # if a factor then plot by group using the colours from pmp package
239
235
out = out + scale_colour_manual(values = plotClass $ manual_colors ,
240
- name = obj $ factor_name )
236
+ name = obj $ factor_name [[ 1 ]] )
241
237
}else {# assume continuous and use the default colour gradient
242
238
out = out + scale_colour_viridis_c(limits = quantile(groups ,
243
- c(0.05 ,0.95 ),na.rm = TRUE ),oob = squish ,name = obj $ factor_name )
239
+ c(0.05 ,0.95 ),na.rm = TRUE ),oob = squish ,name = obj $ factor_name [[ 1 ]] )
244
240
}
245
241
out = out + theme_Publication(base_size = 12 )
246
242
# add ellipse for all samples (ignoring group)
0 commit comments