Closed jsevereyn closed 11 months ago
Hi there
Sorry for the late reply, summer vacation times. The sample_color_order
simply sets the factor levels in the sample metadata before generating the plot. So you should provide a vector with values from the particular sample_color_by
variable that you've set. If you want to choose colors manually for each level use standard ggplot scale functions on top of the returned object.
require(ampvis2)
#> Loading required package: ampvis2
#> Loading required package: ggplot2
#auto color
amp_ordinate(
AalborgWWTPs,
sample_color_by = "Plant"
)
#> 8628 OTUs not present in more than 0.1% relative abundance in any sample have been filtered
#> Before: 9430 OTUs
#> After: 802 OTUs
#manual order
amp_ordinate(
AalborgWWTPs,
sample_color_by = "Plant",
sample_color_order = c("Aalborg West", "Aalborg East")
)
#> 8628 OTUs not present in more than 0.1% relative abundance in any sample have been filtered
#> Before: 9430 OTUs
#> After: 802 OTUs
Created on 2023-07-19 with reprex v2.0.2
I have my data and I sample_color_by a categorical variable (Site) in my metadata. Site has 10 levels Ctrl, H0, H1, H2, H3, H4, H5, H6, H7 and H8 site
Then I give it a vector, to assign a color to each site Sample_colors_order <- c("Ctrl"="#e6f598", "H0"="#9e0142", "H1"="#d53e4f", "H2"="#f46d43", "H3"="#fdae61", "H4"="#fee08b","H5"="#abdda4", "H6"="#66c2a5", "H7"="#3288bd", "H8"="#5e4fa2")
amp_ordinate(avI_DC, type = "PCOA", distmeasure = "chao", transform = "none", sample_color_by = "Site", sample_color_order = sample_color_order, sample_colorframe = "Site", sample_colorframe_label = "Site", sample_point_size = 4)
and I get the same error Error: Must request at least one colour from a hue palette.
regardless of the modifications I make to the Sample_colors_order vector