-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed fig 3D, import of female data twice instead of female/male data
- Loading branch information
1 parent
44e23d3
commit 551fe2f
Showing
3 changed files
with
273 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
library(ggplot2) | ||
library(readr) | ||
library(dplyr) | ||
library(scales) | ||
library(readxl) | ||
library(cowplot) | ||
library(readxl) | ||
Early_JP <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageEarly.xlsx") %>% rename("Year" = "X Value", "Model" = "Modeleded Y Value", "Rate" = "Observed Y Value") %>% mutate(Year = as.integer(Year), Model = as.numeric(Model), Rate = as.numeric(Rate), AgeCategory = "Early") | ||
Middle_JP <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageMiddle.xlsx") %>% rename("Year" = "X Value", "Model" = "Modeleded Y Value", "Rate" = "Observed Y Value") %>% mutate(Year = as.integer(Year), Model = as.numeric(Model), Rate = as.numeric(Rate), AgeCategory = "Middle") | ||
Late_JP <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageLate.xlsx") %>% rename("Year" = "X Value", "Model" = "Modeleded Y Value", "Rate" = "Observed Y Value") %>% mutate(Year = as.integer(Year), Model = as.numeric(Model), Rate = as.numeric(Rate), AgeCategory = "Late") | ||
AllAges_JP <- rbind(Early_JP, Middle_JP, Late_JP) | ||
AllAges_JP$AgeCategory <- factor(AllAges_JP$AgeCategory, levels = c("Early","Middle","Late")) | ||
colorclasses <- c("Localized" = "#016b0b","Distant" = "#be0306","Regional" = "#ffb401") | ||
shapes <- c(8, 15, 17) | ||
lwds <- c(3, 4, 2, 1) | ||
Figure2A <- ggplot() + | ||
geom_point(data=AllAges_JP, aes(x=Year, y=Rate, col=Stage, group=Stage, shape=Stage), size=2) + | ||
geom_line(data = AllAges_JP, aes(x=Year, y=Model, group=Stage, col=Stage)) + | ||
facet_wrap( ~ AgeCategory, scales = "free_y") + | ||
scale_x_continuous(breaks=c(1998, 2000, 2005, 2010, 2014), labels = c("1998", "2000", "2005", "2010", "2014"), minor_breaks = seq(1998,2014,1)) + | ||
ylab("Incidence rate (per 100,000)") | ||
Figure2A_themed <- Figure2A + | ||
scale_color_manual(name="Stage",values = colorclasses) + | ||
scale_shape_manual(values=shapes) + | ||
theme_classic() + | ||
theme( | ||
legend.position = "none", | ||
axis.title = element_text(size = 12, face="bold"), | ||
axis.text = element_text(size=10), | ||
axis.text.x = element_text(angle=45, vjust=0.5) | ||
) | ||
Figure2A_themed | ||
Prox_JP <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageProximal.xlsx") %>% rename("Year" = "X Value", "Rate" = "Observed Y Value", "Model" = "Modeleded Y Value") %>% mutate(Year = as.integer(Year), Rate = as.numeric(Rate), Model = as.numeric(Model), Side = "Proximal") | ||
Dist_JP <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageDistal.xlsx") %>% rename("Year" = "X Value", "Rate" = "Observed Y Value", "Model" = "Modeleded Y Value") %>% mutate(Year = as.integer(Year), Rate = as.numeric(Rate), Model = as.numeric(Model), Side = "Distal") | ||
AllSides_JP <- rbind(Prox_JP, Dist_JP) | ||
AllSides_JP$Side <- factor(AllSides_JP$Side, levels=c("Proximal","Distal")) | ||
AllSides_JP$Stage <- factor(AllSides_JP$Stage, levels = c("Localized","Regional","Distant")) | ||
colorclasses <- c("Localized" = "#016b0b", "Distant" = "#be0306", "Regional" = "#ffb401") | ||
shapes <- c(15, 17, 8) | ||
lwds <- c(3, 4, 2, 1) | ||
Figure2B <- ggplot(AllSides_JP) + | ||
geom_point(aes(x=Year, y=Rate, col=Stage, group=Stage, shape=Stage), size=2) + | ||
geom_line(aes(x=Year, y=Model, col=Stage, group=Stage)) + | ||
facet_wrap(~ Side) + | ||
scale_x_continuous(breaks=c(1998, 2000, 2005, 2010, 2014), labels = c("1998", "2000", "2005", "2010", "2014"), minor_breaks = seq(1998,2014,1)) + | ||
ylab("Incidence rate (per 100,000)") | ||
Figure2B_themed <- Figure2B + | ||
scale_color_manual(name="Stage",values = colorclasses) + | ||
scale_shape_manual(values=shapes) + | ||
theme_classic() + | ||
theme( | ||
legend.position = "none", | ||
axis.title = element_text(size = 12, face="bold"), | ||
axis.text = element_text(size=10), | ||
axis.text.x = element_text(angle=45, vjust=0.5) | ||
) | ||
Figure2B_themed | ||
#ggsave(plot=Figure2B_themed, filename="Figure2B.tiff", path="C:/Users/gaugustus/Documents/Success_Docs/Pubs/DistantCRC_BriefComm", device = "tiff", width=16, height=10, units="cm", dpi = 300) | ||
CRCSites <- readr::read_delim("K:/SEER_DataTables/SEER_2000-2014_CRC_StageDistribution_Race.txt", "\t", escape_double = FALSE, trim_ws = TRUE) | ||
colnames(CRCSites) <- c("Year","Race", "Stage","Rate", "Count", "Population") | ||
CRCSites2 <- CRCSites %>% filter(!grepl("-", Year)) %>% filter(Stage %in% c("Distant","Localized","Regional","Unknown/unstaged")) %>% filter(Year >= 1998) %>% filter(! Race %in% c("Unknown")) | ||
CRCSites2$Year <- as.integer(CRCSites2$Year) | ||
CRCSites2$Stage <- factor(CRCSites2$Stage, levels=c("Unknown/unstaged","Localized","Regional","Distant")) | ||
CRCSites2$Race <- factor(CRCSites2$Race, levels=c("Black", "American Indian/Alaska Native","Asian or Pacific Islander","White"), labels = c("Black or African American", "American Indian/Alaska Native","Asian or Pacific Islander","White")) | ||
CRCSites2 | ||
library(readxl) | ||
AI_JPs <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageAmericanIndian.xlsx", sheet=3) %>% mutate(Race = "American Indian/Alaska Native") %>% rename("Year" = "X Value", "Model" = "Modeleded Y Value") %>% mutate(Year = as.integer(Year), Model = as.numeric(Model), APC=NULL) | ||
A_JPs <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageAsian.xlsx", sheet=3) %>% mutate(Race = "Asian or Pacific Islander") %>% rename("Year" = "X Value", "Model" = "Modeleded Y Value") %>% mutate(Year = as.integer(Year), Model = as.numeric(Model)) | ||
B_JPs <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageBlack.xlsx", sheet=1) %>% mutate(Race = "Black or African American") %>% rename("Year" = "X Value", "Model" = "Modeleded Y Value") %>% mutate(Year = as.integer(Year), Model = as.numeric(Model)) | ||
W_JPs <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageWhite.xlsx", sheet=1) %>% mutate(Race = "White") %>% rename("Year" = "X Value", "Model" = "Modeleded Y Value") %>% mutate(Year = as.integer(Year), Model = as.numeric(Model)) | ||
AllRace_JPs <- rbind(AI_JPs, A_JPs, B_JPs, W_JPs) | ||
AllRace_JPs <- rbind(AI_JPs, A_JPs, B_JPs, W_JPs) | ||
dim(AI_JPs) | ||
dim(A_JPs) | ||
dim(B_JPs) | ||
dim(W_JPs) | ||
colnames(W_JPs) | ||
head(W_JPs) | ||
colnames(B_JPs) | ||
View(W_JPs) | ||
W_JPs <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageWhite.xlsx", sheet=1) %>% | ||
mutate(Race = "White") %>% rename("Year" = "X Value", "Model" = "Modeleded Y Value") %>% | ||
mutate(Year = as.integer(Year), Model = as.numeric(Model), X__1=NULL, X__2=NULL) | ||
AllRace_JPs <- rbind(AI_JPs, A_JPs, B_JPs, W_JPs) | ||
colorclasses <- c("Localized" = "#016b0b","Distant" = "#be0306","Regional" = "#ffb401") | ||
shapes <- c(15, 17, 8) | ||
lwds <- c(3, 2, 1) | ||
Races <- list( | ||
'Black or African American'="Black or\nAfrican American", | ||
'American Indian/Alaska Native'="Native American\nAlaska Native", | ||
'Asian or Pacific Islander'="Asian or\nPacific Islander", | ||
'White' = "White" | ||
) | ||
Races_labeller <- function(variable,value){ | ||
return(Races[value]) | ||
} | ||
Figure2C <- ggplot() + | ||
geom_point(data=CRCSites2 %>% filter(Stage != "Unknown/unstaged"), aes(x=Year, y=Rate, col=Stage, group=Stage, shape=Stage), size=2) + | ||
geom_line(data=AllRace_JPs, aes(x=Year, y=Model, group=Stage, col=Stage)) + | ||
facet_grid(. ~ Race, labeller = Races_labeller) + | ||
scale_x_continuous(breaks=c(1998, 2000, 2005, 2010, 2014), labels = c("1998", "2000", "2005", "2010", "2014"), minor_breaks = seq(1998,2014,1)) + | ||
scale_y_continuous() + | ||
ylab("Incidence rate (per 100,000)") + | ||
ggtitle(" ") | ||
Figure2C_themed <- Figure2C + | ||
scale_color_manual(name="Stage", values = colorclasses) + | ||
scale_shape_manual(values=shapes) + | ||
theme_classic() + | ||
theme( | ||
legend.position = "none", | ||
axis.title = element_text(size = 12, face="bold"), | ||
axis.text = element_text(size=10), | ||
axis.text.x = element_text(angle=45, vjust=0.5) | ||
) | ||
Figure2C_themed | ||
#ggsave(plot=Figure2C_themed, filename="Figure2C.tiff", path="C:/Users/gaugustus/Documents/Success_Docs/Pubs/DistantCRC_BriefComm/", device = "tiff", width=16, height=10, units="cm", dpi = 300) | ||
RateFemale_JP <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageFemale.xlsx") %>% rename("Year" = "X Value", "Rate" = "Observed Y Value", "Model" = "Modeleded Y Value") %>% mutate(Year = as.integer(Year), Rate = as.numeric(Rate), Model = as.numeric(Model), Sex = "Female") | ||
RateMale_JP <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageFemale.xlsx") %>% rename("Year" = "X Value", "Rate" = "Observed Y Value", "Model" = "Modeleded Y Value") %>% mutate(Year = as.integer(Year), Rate = as.numeric(Rate), Model = as.numeric(Model), Sex = "Male") | ||
AllSex_JP <- rbind(RateFemale_JP, RateMale_JP) | ||
RateFemale_JP == RateMale_JP | ||
RateFemale_JP <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageFemale.xlsx") %>% | ||
rename("Year" = "X Value", "Rate" = "Observed Y Value", "Model" = "Modeleded Y Value") %>% | ||
mutate(Year = as.integer(Year), Rate = as.numeric(Rate), Model = as.numeric(Model), Sex = "Female") | ||
RateMale_JP <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageMale.xlsx") %>% | ||
rename("Year" = "X Value", "Rate" = "Observed Y Value", "Model" = "Modeleded Y Value") %>% | ||
mutate(Year = as.integer(Year), Rate = as.numeric(Rate), Model = as.numeric(Model), Sex = "Male") | ||
AllSex_JP <- rbind(RateFemale_JP, RateMale_JP) | ||
colorclasses <- c("Localized" = "#016b0b", "Distant" = "#be0306", "Regional" = "#ffb401") | ||
shapes <- c(8, 15, 17) | ||
lwds <- c(3, 4, 2, 1) | ||
Figure2D <- ggplot(AllSex_JP) + | ||
geom_point(aes(x=Year, y=Rate, col=Stage, group=Stage, shape=Stage), size=2) + | ||
geom_line(aes(x=Year, y=Model, col=Stage, group=Stage)) + | ||
facet_wrap(~ Sex) + | ||
scale_x_continuous(breaks=c(1998, 2000, 2005, 2010, 2014), labels = c("1998", "2000", "2005", "2010", "2014"), minor_breaks = seq(1998,2014,1)) + | ||
ylab("Incidence rate (per 100,000)") | ||
Figure2D_themed <- Figure2D + | ||
scale_color_manual(name="Stage",values = colorclasses) + | ||
scale_shape_manual(values=shapes) + | ||
theme_classic() + | ||
theme( | ||
legend.position = "none", | ||
axis.title = element_text(size = 12, face="bold"), | ||
axis.text = element_text(size=10), | ||
axis.text.x = element_text(angle=45, vjust=0.5) | ||
) | ||
Figure2D_themed | ||
Legend <- get_legend(Figure2B_themed + theme(legend.position = "bottom", | ||
legend.title = element_text(size=12, face="bold"), | ||
legend.text = element_text(size=10))) | ||
prow <- plot_grid(Figure2A_themed, Figure2B_themed, Figure2C_themed, Figure2D_themed, labels = c("A", "B", "C", "D"), hjust = -1, nrow = 2, align = "vh", label_size = 26) | ||
p <- plot_grid(prow, Legend, ncol=1, rel_heights = c(1, .1)) | ||
p | ||
#ggsave(plot=p, filename="Figure2.tiff", path="C:/Users/gaugustus/Documents/Success_Docs/Pubs/DistantCRC_BriefComm", device = "tiff", width=33, height=20, units="cm", dpi = 300) | ||
#ggsave(plot=p, filename="Figure2_Proof.tiff", path="C:/Users/gaugustus/Documents/Success_Docs/Pubs/DistantCRC_BriefComm", device = "tiff", width=33, height=20, units="cm", dpi = 72) | ||
ggsave(plot=p, filename="Figure3_1200px.tiff", path="U:/Box Sync/Distant CRC - JNCI Brief Comm", device = "tiff", width=12, height=7.5, units = "in", dpi=100) | ||
ggsave(plot=p, filename="Figure3.tiff", path="U:/Box Sync/Distant CRC - JNCI Brief Comm", device = "tiff", width=12, height=7.5, units = "in", dpi=300) | ||
sessionInfo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.