<jupyter_start><jupyter_text>GIST incidence and pathways in England by yearAuthor: <NAME>*This work uses data that has been provided by patients and collected by the NHS as part of their care and support. The data is collated, maintained and quality assured by the National Cancer Registration and Analysis Service, which is part of Public Health England (PHE). The data is taken from the Get Data Out tables.*Last update this notebook: 23 April 2020Data taken from: https://www.cancerdata.nhs.uk/getdataoutData download: 16 April 2020 SummaryThis notebook plots some data relating to GIST diagnosis from Public Health England (PHE) through time.  MethodsGraphical inspection of data from PHE. Focus on**Incidence**: Statistics on the number of new tumours diagnosed in each group and the incidence rate of cancer in this group with upper and lower confidence intervals. **Routes to Diagnosis**: Statistics on the number of tumours diagnosed by each 'route to diagnosis' and the % of tumours diagnosed by each route with the upper and lower confidence intervals. The eight standard diagnostic routes provided by PHE are - two week wait; GP referral; screening; other outpatient; inpatient elective; emergency presentation; death certificate only and unknown - are provided, along with a 'not classified' group. There is no screening program for GIST so this category is not included. Analysis<jupyter_code>## Load libraries
library("ggplot2")
library("tidyr")
## Load data

indta <- read.csv("../data/200104-GDO_data_wide_sarcoma.csv")

mydta <- indta[indta$Tumour.Type.2== "Gastrointestinal stromal sarcoma (GIST)", ]

selectcols <- c("Year", "Tumour.Type.3", "Age", "Incidence", "Population", "Incidence.Rate", "Incidence.Rate.LCI..95..", "Incidence.Rate.UCI..95..","Routes.Population", "Two.Week.Wait", "Two.Week.Wait.percentage", "Two.Week.Wait.LCI", "Two.Week.Wait.UCI", "GP.Referral", "GP.Referral.percentage", "GP.Referral.LCI", "GP.Referral.UCI", "Other.Outpatient", "Other.Outpatient.percentage", "Other.Outpatient.LCI", "Other.Outpatient.UCI", "Inpatient.Elective", "Inpatient.Elective.percentage", "Inpatient.Elective.LCI", "Inpatient.Elective.UCI", "Emergency.Presentation", "Emergency.Presentation.percentage", "Emergency.Presentation.LCI", "Emergency.Presentation.UCI", "DCO", "DCO.percentage", "DCO.LCI", "DCO.UCI", "Unknown.Route", "Unknown.Route.percentage", "Unknown.Route.LCI", "Unknown.Route.UCI", "Route.not.classified", "Route.not.classified.percentage","Route.not.classified.LCI", "Route.not.classified.UCI")

colids  <- which(colnames(mydta) %in% selectcols)

mydta2 <- mydta[,colids]
## Data manipulation for plots

myyr <- c(2013, 2014, 2015, 2016, 2017)

mydta3 <- mydta2[mydta2$Year%in%myyr,]

mydta3[,4:41]<-apply(mydta3[,4:41],2,function(ind) as.double(as.character(ind)))

mydta3$Year <- as.integer(as.character(mydta3$Year))

mydta4<- gather(mydta3, "key", "route", Two.Week.Wait.percentage, GP.Referral.percentage, Other.Outpatient.percentage, Inpatient.Elective.percentage, Emergency.Presentation.percentage, DCO.percentage, Unknown.Route.percentage, Route.not.classified.percentage)

mydta4$key  <- substr(mydta4$key, 1, nchar(mydta4$key)-11)

myordkey  <- rev(c("GP.Referral","Emergency.Presentation", "Other.Outpatient", "Two.Week.Wait", "Inpatient.Elective", "DCO",  "Route.not.classified"  , "Unknown.Route"))

mydta4<-mydta4[order(match(mydta4$key, myordkey)),]

mydta4$key <- factor(mydta4$key, levels=myordkey)
                     
mydta4$Year <- as.character(mydta4$Year)        
                     
##number not rate                     
mydta5<- gather(mydta3, "key", "route", Two.Week.Wait, GP.Referral, Other.Outpatient, Inpatient.Elective, Emergency.Presentation, DCO, Unknown.Route, Route.not.classified)

unique(mydta5$key)

myordkey  <- rev(c("GP.Referral","Emergency.Presentation", "Other.Outpatient", "Two.Week.Wait", "Inpatient.Elective", "DCO",  "Route.not.classified"  , "Unknown.Route"))

mydta5<-mydta5[order(match(mydta5$key, myordkey)),]

mydta5$key <- factor(mydta5$key, levels=myordkey)<jupyter_output>Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs introduced by coercion”Warning message in FUN(newX[, i], ...):
“NAs int[...]<jupyter_text>GIST Incidence by year<jupyter_code>## plot 1 - incidence rate by year                                                                                                                                                   

myplot1 <- ggplot(data = mydta3[mydta3$Age=="All ages",], aes(x = Year, y = Incidence.Rate, group=Tumour.Type.3)) +
        geom_line(aes(color=Tumour.Type.3, linetype=Tumour.Type.3), size=1) +
        geom_point(aes(color=Tumour.Type.3, shape=Tumour.Type.3), size=3) +
        geom_segment(aes(x = Year, xend = Year, y = Incidence.Rate.LCI..95.., yend = Incidence.Rate.UCI..95.., colour = Tumour.Type.3), size = 1) +
        ylim(0,1.8) +
        labs(title = "Crude GIST Incidence (95%CI) by year",
         x = "Year", y = "Incidence rate (per 100,000 population)") +
         theme(legend.title=element_blank())

##save chart
pdf("charts/plot1.pdf")
myplot1
dev.off()

png("charts/plot1.png")
myplot1
dev.off()

##show chart
myplot1


##plot 2 - number by year                                                                                                                                                            

t.inc<- mydta3$Age=="All ages" & mydta3$Tumour.Type.3!="All"

myplot1n <- ggplot(data = mydta3[t.inc,], aes(x = Year, y = Incidence)) +
    geom_col(aes(fill=Tumour.Type.3))+
    labs(title = "Number GIST diagnosed by year",
         x = "Year", y = "Number") +
     theme(legend.title=element_blank())

##save chart
pdf("charts/plot1n.pdf")
myplot1n
dev.off()

png("charts/plot1n.png")
myplot1n
dev.off()

##show chart
myplot1n<jupyter_output><empty_output><jupyter_text>GIST dignosis routes<jupyter_code>##plot 2 - route by year                                                                                                                                                             

myplot2 <- ggplot(mydta4[mydta4$Age=="All ages" & mydta4$Tumour.Type.3=="All",], aes(x = Year, y = route))+
  geom_col(aes(fill = key), width = 0.7) +
    labs(title = "Routes by year",
         x = "Year", y = "Percentage (%)")


##save chart
pdf("charts/plot2.pdf")
myplot2
dev.off()

png("charts/plot2.png")
myplot2
dev.off()

##show chart
myplot2<jupyter_output>Warning message:
“Removed 8 rows containing missing values (position_stack).”<jupyter_text>Stomach sub-type Incidence by age group<jupyter_code>## plot 3 - Stomach incidence by age group and year                                                                                                                                            

myplot3 <- ggplot(data = mydta3[mydta3$Tumour.Type.3=="Stomach" & mydta3$Age!="All ages",], aes(x = Year, y = Incidence.Rate, group=Age)) +
    geom_line(aes(color=Age, linetype=Age), size=1) +
    geom_point(aes(color=Age, shape=Age), size=3) +
    geom_segment(aes(x = Year, xend = Year, y = Incidence.Rate.LCI..95.., yend = Incidence.Rate.UCI..95.., colour = Age), size = 1) +
    labs(title = "GIST Stomach Tumour Incidence (95%CI)",
         x = "Year", y = "Incidence rate (per 100,000 population)") +
    theme(legend.title=element_blank())

##save chart
pdf("charts/plot3.pdf")
myplot3
dev.off()

png("charts/plot3.png")
myplot3
dev.off()

myplot3

### Number by age group
myplot3n <- ggplot(data = mydta3[mydta3$Tumour.Type.3=="Stomach" & mydta3$Age!="All ages",], aes(x = Year, y = Incidence, group=Age)) +
    geom_col(aes(fill=Age)) +
    labs(title = "GIST Stomach Tumour Number by year",
         x = "Year", y = "Number diagnosed") +
    theme(legend.title=element_blank())

##save chart
pdf("charts/plot3n.pdf")
myplot3n
dev.off()

png("charts/plot3n.png")
myplot3n
dev.off()

myplot3n<jupyter_output><empty_output><jupyter_text>Route (2013-16) by age group, number<jupyter_code>##plot 4 - stomach route by age                                                                                                                                                      

myplot4n <- ggplot(mydta5[mydta5$Tumour.Type.3=="Stomach" & (mydta5$Age!="All ages"),], aes(x=Age,y=route))+
    geom_col(aes(fill = key), width = 0.7) +
    labs(title = "Stomatch routes (2013-16) by age group",
         x = "Age group", y = "Number (total 2013-16)")

##save chart
pdf("charts/plot4n.pdf")
myplot4n
dev.off()

png("charts/plot4n.png")
myplot4n
dev.off()

myplot4n<jupyter_output>Warning message:
“Removed 32 rows containing missing values (position_stack).”<jupyter_text>Route (2013-16) by age group, percentage<jupyter_code>myplot4p <- ggplot(mydta5[mydta5$Tumour.Type.3=="Stomach",], aes(Age))+                                                                                                                     
    geom_bar(position="fill",aes(y=route,fill = key), width = 0.7, stat="identity") +                                                                                                
    scale_y_continuous(labels = scales::percent) +                                                                                                                                   
    labs(title = "Stomatch routes (2013-16) by age group",                                                                                                                           
         x = "Age group", y = "Percentage (%)")     

##save chart
pdf("charts/plot4p.pdf")
myplot4p
dev.off()

png("charts/plot4p.png")
myplot4p
dev.off()

myplot4p<jupyter_output>Warning message:
“Removed 40 rows containing missing values (position_stack).”
{'fraction_non_alphanumeric': 0.14059236757167268, 'fraction_numerical': 0.0224036453389026, 'mean_word_length': 2.742451154529307, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 22, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 54, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '309362', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 3636, 'n_tokens_neox': 3329, 'n_words': 803, 'path': 'analysis/gist-phe-analysis.ipynb', 'repo_name': 'brentnall/phe-gist', 'size': '10542'}