Closed susheelbhanu closed 4 years ago
Hi Susheel
Yes ordered characters in R are called factors. So if the particular variable in your sample metadata is a character, it will be alphabetical. To set a specific order, convert it to factor with appropriate levels. That is exactly what the order_x_by
argument does, but when using both group_by
and facet_by
it gets a little more complicated. A combined grouping variable will be created under the hood, so the values are the separated by a space " "
. Try setting factor levels in your metadata first and let me know. You can do that with base R code fx: d$metadata$group <- factor(d$metadata$group, levels = c("A", "B", ...)))
. Using d$metadata$group <- as.factor(d$metadata$group)
instead will automatically order alphabetically.
Awesome. Thanks a lot. That seems to have done the trick.
Hi, Thanks for a great package. When I plot the heatmap, the facetting is done based on a column of groups, however, the arrangement is alphabetical. Is there a way to preserve the order of samples/facet groups based on the given order?
That is to avoid alphabetical re-ordering. Here's my code:
Thank you, Susheel