vqv / ggbiplot

A biplot based on ggplot2
302 stars 159 forks source link

Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = decreasing)) : undefined columns selected #43

Open genomix opened 6 years ago

genomix commented 6 years ago

I am trying to create a biplot using ggbiplot. I am almost there; howver, I just cannot seem to add the group names to my biplot. I converted the group column to dataframe and got the above error message. However, if I retain the group column as a vector, I get this error message: "Error in names(ell) <- *vtmp* : 'names' attribute [2] must be the same length as the vector [0]" Rplot.pdf

g <- ggbiplot(pca_vistra_rms, obs.scale = 1, group=vistra.group, var.scale = 1, ellipse = TRUE, circle = TRUE)+ scale_color_discrete(name = '') + theme(legend.direction = 'horizontal', legend.position = 'top') print(g)

Hoohm commented 6 years ago

If you run with ellipse = FALSE it will run fine.

The issue is that you probably don't have enough samples per group to actually make the ellipses.

g <- ggbiplot(pca_vistra_rms, obs.scale = 1, group=vistra.group, var.scale = 1, ellipse = FALSE circle = TRUE)+ scale_color_discrete(name = '') + theme(legend.direction = 'horizontal', legend.position = 'top')
print(g)