library(plotly)
library(readr)
PBPK <- read_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Actualizacion Profesional/DataScience Specialization JH/Datasets for the couses/DataProducts/PBPK.data")
#***********
# GRAPHICS:
#***********
library(ggplot2)
library(tidyr)
#==================
# PREPARE THE DATA
#==================
PBPK_tidy <- gather(PBPK,Compartment, Amount,-Time)
#------------------
# Define the theme
#------------------
pbpk_theme <- theme(panel.background = element_blank(),
panel.grid = element_line(),
legend.background = element_blank(),
legend.key = element_blank(),
legend.direction = "horizontal",
legend.position= "bottom",
axis.line = element_line(colour = "black"),
plot.title = element_text(size = 12, hjust = 0.5))
#---------------------------------
# Graph all the other compartments
#---------------------------------
#Amount
#Filter only the variables I want to compare:
Graph2 <- PBPK_tidy %>%
filter(Compartment !="AT" &Compartment !="OralDose" & Compartment != "AAbsorbed" & Compartment !="AVenous blood" & Compartment != "AExcreted" & Compartment != "CLiver" & Compartment != "CKidney" & Compartment != "CMuscle" & Compartment != "CFat" & Compartment != "COth")
#Graph example 1
g <- ggplot(Graph2, aes(Time, Amount, col=Compartment))+
geom_line()+
scale_y_continuous("Amount of Meloxicam per Compartment(ug)", limits=c(0,2540),breaks = seq(0,2540,by =200))+
scale_x_continuous("Time (h)", limits= c(0,48), breaks = seq(0,48,by=15))+
ggtitle("Predicted Amount of Meloxicam in each Compartment")+
facet_grid(.~Compartment)+
scale_color_hue(labels=c("Arterial Blood", "Intestine","Fat","Kidney","Liver","Muscle","Other Tissues"))+
pbpk_theme
ggplotly(g)