Skip to content

Commit

Permalink
Fixed figure rendering R scripts, added data to plot figure 2
Browse files Browse the repository at this point in the history
  • Loading branch information
gaiusjaugustus committed Apr 6, 2018
1 parent 551fe2f commit 4d48b3b
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 80 deletions.
15 changes: 7 additions & 8 deletions Code/DistantCRC_Figures_Fig2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ library(ggplot2)
library(readr)
library(dplyr)
library(scales)
library(cowplot)
```


#Read in data
```{r, message=FALSE}
# Read in SEER extracted table
CRCStages <- readr::read_delim("K:/SEER_DataTables/SEER_2000-2014_StageDistribution_noStratify.txt", "\t", escape_double = FALSE, trim_ws = TRUE)
CRCStages <- readr::read_delim("../Data/SEER_2000-2014_StageDistribution_noStratify.txt", "\t", escape_double = FALSE, trim_ws = TRUE)
colnames(CRCStages) <- c("Year", "Stage","Rate", "Count", "Population")
CRCStages <- CRCStages %>% filter(Year != "2000-2014")
CRCStages$Year <- as.numeric(CRCStages$Year)
Expand Down Expand Up @@ -54,7 +53,7 @@ library(readxl)

```{r}
# Read in General CRC rate data
Stage_JPs <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageOnly.xlsx", sheet=1) %>% rename("Year" = "X Value", "Model" = "Modeleded Y Value") %>% mutate(Year = as.integer(Year), Model = as.numeric(Model))
Stage_JPs <- read_excel("../Data/JoinPoint/Rate_StageOnly.xlsx", sheet=1) %>% rename("Year" = "X Value", "Model" = "Modeleded Y Value") %>% mutate(Year = as.integer(Year), Model = as.numeric(Model))
```
Expand All @@ -72,21 +71,21 @@ lwds <- c(3, 4, 2, 1)

##Rates and Proportions by disease stage
```{r}
Figure1A <- ggplot() +
Figure2A <- ggplot() +
geom_point(data=CRCStages3 %>% filter(Stage %in% c("Localized","Regional","Distant")), aes(x=Year, y=Rate, group=Stage, col=Stage, shape=Stage), show.legend = FALSE) +
geom_line(data=Stage_JPs, aes(x=Year, y=Model, group=Stage, col=Stage), show.legend = FALSE) +
scale_x_continuous(breaks=c(1998, 2000, 2005, 2010, 2014), labels = c("1998", "2000", "2005", "2010", "2014"), minor_breaks = seq(1998,2014,1)) +
theme_classic() + theme(axis.text.x = element_text(angle=45, vjust=0.5), legend.position = "bottom") +
scale_color_manual(name="Stage",values = colorclasses) +
scale_shape_manual(values=shapes) +
ylab("Rate per 100,000")
Figure1A
Figure2A
```

# Format figure to export

```{r}
Figure1Export <- ggplot() +
Figure2Export <- ggplot() +
geom_point(data=(CRCStages3 %>% filter(Stage %in% c("Localized","Regional","Distant"))), aes(x=Year, y=Rate, group=Stage, col=Stage, shape=Stage)) +
geom_line(data=Stage_JPs, aes(x=Year, y=Model, group=Stage, col=Stage)) +
scale_x_continuous(breaks=c(1998, 2000, 2005, 2010, 2014),
Expand All @@ -105,8 +104,8 @@ Figure1Export <- ggplot() +
axis.text = element_text(size=10),
axis.text.x = element_text(angle=45, vjust=0.5)
)
Figure1Export
#ggsave(plot=Figure1Export, filename="Figure1.tiff", path="path/to/folder/DistantCRC_BriefComm", device = "tiff", width=16, height=10, units="cm", dpi = 300)
Figure2Export
#ggsave(plot=Figure2Export, filename="Figure2.tiff", path="path/to/folder/DistantCRC_BriefComm", device = "tiff", width=16, height=10, units="cm", dpi = 300)
```


Expand Down
99 changes: 49 additions & 50 deletions Code/DistantCRC_Figures_Fig2.nb.html

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions Code/DistantCRC_Figures_Fig3_cowplot.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Full Figure 2 with cowplot"
title: "Full Figure 3 with cowplot"
output:
html_notebook:
toc: true
Expand All @@ -24,9 +24,9 @@ library(readxl)


```{r}
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")
Early_JP <- read_excel("../Data/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("../Data/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("../Data/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"))
Expand Down Expand Up @@ -71,8 +71,8 @@ Figure2A_themed

# B: Sidedness
```{r}
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")
Prox_JP <- read_excel("../Data/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("../Data/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"))
Expand Down Expand Up @@ -143,19 +143,19 @@ library(readxl)
```

```{r}
AI_JPs <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageAmericanIndian.xlsx", sheet=3) %>%
AI_JPs <- read_excel("../Data/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) %>%
A_JPs <- read_excel("../Data/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) %>%
B_JPs <- read_excel("../Data/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) %>%
W_JPs <- read_excel("../Data/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)
Expand Down Expand Up @@ -216,10 +216,10 @@ Figure2C_themed

# D: Sex
```{r}
RateFemale_JP <- read_excel("U:/Box Sync/ProjectDocs/2017_DistantCRC/JoinPoint/Rate_StageFemale.xlsx") %>%
RateFemale_JP <- read_excel("../Data/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") %>%
RateMale_JP <- read_excel("../Data/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")
Expand Down
20 changes: 10 additions & 10 deletions Code/DistantCRC_Figures_Fig3_cowplot.nb.html

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions Data/SEER_2000-2014_StageDistribution_noStratify.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"Year of diagnosis" "Summary stage 2000 (1998+)" "Age-Adjusted Rate" "Count" "Population"
2000-2014 In situ 0.0 0 1257898299
2000-2014 Localized 18.3 228069 1257898299
2000-2014 Regional 16.1 201425 1257898299
2000-2014 Distant 8.8 110872 1257898299
2000-2014 Unknown/unstaged 2.7 33638 1257898299
2000-2014 Blank(s) 0.0 0 1257898299
2000 In situ 0.0 0 78996813
2000 Localized 21.2 15340 78996813
2000 Regional 20.0 14457 78996813
2000 Distant 9.4 6855 78996813
2000 Unknown/unstaged 3.8 2708 78996813
2000 Blank(s) 0.0 0 78996813
2001 In situ 0.0 0 79867817
2001 Localized 21.2 15539 79867817
2001 Regional 19.8 14550 79867817
2001 Distant 9.5 7044 79867817
2001 Unknown/unstaged 3.4 2475 79867817
2001 Blank(s) 0.0 0 79867817
2002 In situ 0.0 0 80629975
2002 Localized 21.0 15685 80629975
2002 Regional 19.0 14250 80629975
2002 Distant 9.7 7282 80629975
2002 Unknown/unstaged 3.3 2475 80629975
2002 Blank(s) 0.0 0 80629975
2003 In situ 0.0 0 81347854
2003 Localized 20.3 15516 81347854
2003 Regional 18.5 14151 81347854
2003 Distant 9.4 7232 81347854
2003 Unknown/unstaged 3.2 2389 81347854
2003 Blank(s) 0.0 0 81347854
2004 In situ 0.0 0 82055585
2004 Localized 19.7 15293 82055585
2004 Regional 17.8 13823 82055585
2004 Distant 9.3 7303 82055585
2004 Unknown/unstaged 2.9 2246 82055585
2004 Blank(s) 0.0 0 82055585
2005 In situ 0.0 0 80414394
2005 Localized 19.6 15105 80414394
2005 Regional 17.1 13190 80414394
2005 Distant 9.2 7134 80414394
2005 Unknown/unstaged 2.8 2129 80414394
2005 Blank(s) 0.0 0 80414394
2006 In situ 0.0 0 83099557
2006 Localized 19.2 15467 83099557
2006 Regional 16.6 13366 83099557
2006 Distant 9.0 7331 83099557
2006 Unknown/unstaged 2.8 2242 83099557
2006 Blank(s) 0.0 0 83099557
2007 In situ 0.0 0 83810676
2007 Localized 19.1 15777 83810676
2007 Regional 16.4 13554 83810676
2007 Distant 8.8 7295 83810676
2007 Unknown/unstaged 2.7 2212 83810676
2007 Blank(s) 0.0 0 83810676
2008 In situ 0.0 0 84618783
2008 Localized 18.8 15838 84618783
2008 Regional 15.9 13342 84618783
2008 Distant 8.8 7453 84618783
2008 Unknown/unstaged 2.5 2133 84618783
2008 Blank(s) 0.0 0 84618783
2009 In situ 0.0 0 85402713
2009 Localized 18.0 15515 85402713
2009 Regional 15.2 13058 85402713
2009 Distant 8.6 7482 85402713
2009 Unknown/unstaged 2.5 2151 85402713
2009 Blank(s) 0.0 0 85402713
2010 In situ 0.0 0 86160539
2010 Localized 16.7 14770 86160539
2010 Regional 14.6 12844 86160539
2010 Distant 8.5 7547 86160539
2010 Unknown/unstaged 2.4 2110 86160539
2010 Blank(s) 0.0 0 86160539
2011 In situ 0.0 0 86864476
2011 Localized 16.0 14436 86864476
2011 Regional 14.1 12708 86864476
2011 Distant 8.4 7622 86864476
2011 Unknown/unstaged 2.3 2136 86864476
2011 Blank(s) 0.0 0 86864476
2012 In situ 0.0 0 87543781
2012 Localized 15.8 14599 87543781
2012 Regional 13.9 12854 87543781
2012 Distant 8.1 7587 87543781
2012 Unknown/unstaged 2.2 1993 87543781
2012 Blank(s) 0.0 0 87543781
2013 In situ 0.0 0 88197699
2013 Localized 15.2 14381 88197699
2013 Regional 13.3 12537 88197699
2013 Distant 8.1 7700 88197699
2013 Unknown/unstaged 2.2 2056 88197699
2013 Blank(s) 0.0 0 88197699
2014 In situ 0.0 0 88887637
2014 Localized 15.2 14808 88887637
2014 Regional 13.2 12741 88887637
2014 Distant 8.2 8005 88887637
2014 Unknown/unstaged 2.2 2183 88887637
2014 Blank(s) 0.0 0 88887637

0 comments on commit 4d48b3b

Please sign in to comment.