Closed timz0605 closed 5 months ago
glad you're finding microViz useful
To do this you need to recode your categorical data as numeric indicator variables. This is easy with ps_mutate
and if_else
or case_when
For nominal categorical variables like your locality
variable.
ps_microviz < - ps_microviz %>%
ps_mutate(
loc1 = if_else(locality == "placeA", true = 1L, false = 0L),
loc2 = if_else(locality == "placeB", true = 1L, false = 0L),
loc3 = if_else(locality == "placeC", true = 1L, false = 0L),
loc4 = if_else(locality == "placeD", true = 1L, false = 0L)
)
And for ordinal categorical variables like the high, med, low, impact
you mentioned could either do the same thing or alternative create something like this
ps_microviz < - ps_microviz %>%
ps_mutate(impact_num = case_when(
impact == "high" ~ 3,
impact == "medium" ~ 2,
impact == "low" ~ 1
))
and then just use these for the correlation heatmap
Hello David!
First of all, thank you for this amazing package!
I am trying to make some heatmaps to help visualize my data, and I am wondering if there are any ways to create correlation heatmaps between taxa and categorical variables? For example, my samples come from 4 sites (in metadata they are under the column
locality
), and each of the site could be classified as high, medium, or low impact. I was wondering if there is a way to create correlational heatmaps like that?As a reference, below is the code I use to generate a composition heatmap: