Alpha Diversity. Error in `geom_boxplot()`:

Plot by metric & host order
I ran this command:
to_keep = c('Observed', 'Shannon')
p = ggplot(alpha_div_exp %>% filter(Index %in% to_keep), aes(order, Index_value)) + geom_boxplot() + labs(x='Order', y='Value') + facet_wrap(~ Index, scales='free_y') + theme_bw() + theme(axis.text.x = element_text(angle=45, hjust=1))
options(repr.plot.width=5, repr.plot.height=3)

But an Error in geom_boxplot() keeps appearing:
Don't know how to automatically pick scale for object of type . Defaulting to continuous.
Error in geom_boxplot():
! Problem while computing aesthetics.
:information_source: Error occurred in the 1st layer.
Caused by error in compute_aesthetics():
! Aesthetics are not valid data columns.
:heavy_multiplication_x: The following aesthetics are invalid:
:heavy_multiplication_x: x = order
:information_source: Did you mistype the name of a data column or forget to add after_stat()?

  1. plot(p)
  2. plot.ggplot(p)..
    ...23. signal_abort(cnd, .file) lasts long.
    Command attached in the photo was used before the #plot by metric & host order step

    Can you please help me how can I solve this problem? What cause this Error?
    Thank you in advance!

Hello Bayan,

There is no data column called 'order' in your data.frame.

The reason for this is that your metadata object does not have metadata, it just has the alpha diversity values again.

Once you inner_join() with metadata that has an order column, this should work fine.

1 Like

Hello dear Colin,
Thank you so much!! Just created an order column, and it worked well. Have a good day!

1 Like