Closed slambrechts closed 4 years ago
Hi
It simply sets the factor levels of the particular metadata variable set by the sample_color_by
argument. An example below.
library(ampvis2)
#> Loading required package: ggplot2
#subset to one WWTP
d <- amp_subset_samples(AalborgWWTPs, Plant %in% "Aalborg West")
#> 35 samples and 2596 OTUs have been filtered
#> Before: 67 samples and 9430 OTUs
#> After: 32 samples and 6834 OTUs
#plot with default color order of the sample_color_by argument
amp_ordinate(d,
type = "pcoa",
transform = "none",
filter_species = 0,
num_threads = 30,
distmeasure = "wunifrac",
sample_color_by = "Period")
#plot with custom color order of the sample_color_by argument
##levels of metadata variable (even if not factor)
unique(AalborgWWTPs$metadata$Period)
#> [1] "Winter" "Spring" "Summer" "Fall"
#reorder and plot with new color order
newlevels <- unique(AalborgWWTPs$metadata$Period)[c(2,3,4,1)]
amp_ordinate(d,
type = "pcoa",
transform = "none",
filter_species = 0,
num_threads = 30,
distmeasure = "wunifrac",
sample_color_by = "Period",
sample_color_order = newlevels)
Created on 2020-03-02 by the reprex package (v0.3.0)
So you could also just set factor levels on the particular metadata variable manually if that's more transparent for you.
Hi there, I was wondering how to use the argument
sample_color_order
inamp_ordinate
? Could you please give an example?