Plot RF imoprtance
library(tidyverse)
library(ggstance)
library(grid)
imp_data <- read_csv("~/Downloads/importance-1.csv", col_names = T, trim_ws = T) %>%
dplyr::select(-X1) %>%
dplyr::rename(dec_node_imp = `Total decrease in node impurities`) %>%
filter(class != "ectoine")
imp_data$domain<- factor(imp_data$domain, levels = imp_data %>% arrange(desc(class), (dec_node_imp)) %>% .$domain
)
ggplot(imp_data, aes(dec_node_imp, domain, color = class, label = round(dec_node_imp, 1))) +
geom_segment(aes(x = 0, y = domain, xend = dec_node_imp, yend = domain), color = "black", alpha = 1) +
geom_rect(aes(ymin = as.numeric(domain) - 0.5 , ymax = as.numeric(domain) + 0.5, xmin=-0.3,
xmax=26, fill = class, color = NULL), alpha=.5) +
geom_point(size = 1, color = "black") +
scale_x_continuous(position = "top", expand = c(0, 0)) +
xlab("Total decrease in node impurities") +
ylab("BGC domain") +
guides(color = FALSE, alpha = FALSE) +
scale_fill_manual(values = c("#ECD078", "#D95B43", "#C02942", "#542437", "#53777A"), name = "BGC class") +
scale_color_manual(values = c("#ECD078", "#D95B43", "#C02942", "#542437", "#53777A")) +
theme_light() +
theme(axis.text = element_text(size = 8),
axis.title = element_text(size = 9),
legend.text = element_text(size = 8),
legend.title = element_text(size = 9))