Plotting principal coordinate axis 1 vs diversity in ggplot2
Code
This is where we started before the episode
library(tidyverse)
library(readxl)
library(ggtext)
library(glue)
pcoa <- read_tsv(file="raw_data/schubert.braycurtis.pcoa.axes")
metadata <- read_excel(path="raw_data/schubert.metadata.xlsx", na="NA")
alpha_diversity <- read_tsv("raw_data/schubert.groups.ave-std.summary") %>%
filter(method == "ave") %>%
select(-label, -method)
metadata_pcoa_alpha <- inner_join(metadata, pcoa, by=c('sample_id'='group')) %>%
mutate(disease_stat = factor(disease_stat,
levels=c("DiarrhealControl",
"Case",
"NonDiarrhealControl")
)
) %>%
inner_join(., alpha_diversity, by=c("sample_id"="group"))
explained <- read_tsv("raw_data/schubert.braycurtis.pcoa.loadings")
explained1 <- explained %>% filter(axis==1) %>% pull(loading) %>% round(1)
explained2 <- explained %>% filter(axis==2) %>% pull(loading) %>% round(1)
healthy_color <- "#BEBEBE"
diarrhea_color <- "#0000FF"
case_color <- "#FF0000"