Now that we have examined how to get examples of Endoscopic performance by analysis of documentation, we can perform the more interesting task of determining endoscopic performance by determining the pathology taken at endoscopy. This means we have to merge two datasets and then extract pathology based on the endoscopy results.
We will determine the dysplasia detection rate in our sample of Barrett’s endoscopies and we will do this per endoscopist so we can get an overview of who is the best at detecting dysplasia in Barrett’s oesopahgus. Note this is very similar to the concept of an adenoma detection rate in colonoscopy.
We start by defining our datasets. We have done this before as part of the Surveillance page so I’m not going to repeat it here. We can just start using it.
This is what the merged dataset looks like (truncated for ease of viewing):
EndoHistoMerge<-source('EndoPathMerged_ExternalCode.R')
EndoHistoMerge<-data.frame(EndoHistoMerge)
#Neaten up the names
names(EndoHistoMerge)<-gsub("value.","",names(EndoHistoMerge),fixed=T)
kable(head(EndoHistoMerge,5))
EndoHospNumId | EndoReports | Date.x | Endoscopist | Midazolam | Fentanyl | Indication | Diagnosis | BarrC | BarrM | Histop_dfHospNumId | HistoReport | Date.y | Macro | Diagnoses | Days | visible |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
U22415 | Date of Procedure 2013-12-01 Endoscopist: Dr Bugs Bunny Midazolam: 4mg Fentanyl: 75mcg Indication: Dysphagia/Odynophagia Diagnosis: Esophageal candidiasis .Oesophagitis. .Hiatus Hernia. .Food bolus obstructing the oesophagus..Extensive neoplastic looking esophageal lesion. .Post chemo-radiotherapy stricture .Possible achalasia. Barrett’s oesophagus length: C0M6 | 2013-12-01 | Bugs Bunny | 4 | 75 | Dysphagia/Odynophagia | Diagnosis: Esophageal candidiasis .Oesophagitis. .Hiatus Hernia. .Food bolus obstructing the oesophagus..Extensive neoplastic looking esophageal lesion. .Post chemo-radiotherapy stricture .Possible achalasia. Barrett’s oesophagus length: C0M6 | 0 | 6 | U22415 | Date received: 2013-11-29 Macrosopic description: 8 specimens collected the largest measuring 5 x 5 x 4 mm and the smallest 4 x 5 x 3 mm Diagnoses PAS staining shows occasional spores, consistent with candida..The biopsies of oesophageal squamous mucosa show surface erosion and active chronic inflammation..The appearances are those of Candida oesophagitis..Neither dysplasia nor malignancy is seen..No Helicobacter are seen..Numerous Candida spores and hyphae are present admixed with ulcer slough. | 2013-11-29 | 8 specimens collected the largest measuring 5 x 5 x 4 mm and the smallest 4 x 5 x 3 mm | PAS staining shows occasional spores, consistent with candida..The biopsies of oesophageal squamous mucosa show surface erosion and active chronic inflammation..The appearances are those of Candida oesophagitis..Neither dysplasia nor malignancy is seen..No Helicobacter are seen..Numerous Candida spores and hyphae are present admixed with ulcer slough. | 2 days | FALSE |
U22415 | Date of Procedure 2013-12-01 Endoscopist: Dr Bugs Bunny Midazolam: 4mg Fentanyl: 75mcg Indication: Dysphagia/Odynophagia Diagnosis: Esophageal candidiasis .Oesophagitis. .Hiatus Hernia. .Food bolus obstructing the oesophagus..Extensive neoplastic looking esophageal lesion. .Post chemo-radiotherapy stricture .Possible achalasia. Barrett’s oesophagus length: C0M6 | 2013-12-01 | Bugs Bunny | 4 | 75 | Dysphagia/Odynophagia | Diagnosis: Esophageal candidiasis .Oesophagitis. .Hiatus Hernia. .Food bolus obstructing the oesophagus..Extensive neoplastic looking esophageal lesion. .Post chemo-radiotherapy stricture .Possible achalasia. Barrett’s oesophagus length: C0M6 | 0 | 6 | U22415 | Date received: 2013-12-02 Macrosopic description: 4 specimens collected the largest measuring 1 x 3 x 5 mm and the smallest 5 x 3 x 1 mm Diagnoses There is no intercellular oedema in the surface epithelium..Intestinal metaplasia is present..Neither dysplasia nor malignancy is seen. | 2013-12-02 | 4 specimens collected the largest measuring 1 x 3 x 5 mm and the smallest 5 x 3 x 1 mm | There is no intercellular oedema in the surface epithelium..Intestinal metaplasia is present..Neither dysplasia nor malignancy is seen. | 1 days | FALSE |
O349253 | Date of Procedure 2013-09-19 Endoscopist: Dr Sal Addin Midazolam: 2mg Fentanyl: 125mcg Indication: chronic abdo pain and constipaton Diagnosis: Hiatus Hernia. .Esophageal candidiasis .Ulcer- Oesophageal. | 2013-09-19 | Sal Addin | 2 | 125 | chronic abdo pain and constipaton | Diagnosis: Hiatus Hernia. .Esophageal candidiasis .Ulcer- Oesophageal. | NA | NA | O349253 | Date received: 2013-09-17 Macrosopic description: 2 specimens collected the largest measuring 1 x 1 x 5 mm and the smallest 5 x 4 x 4 mm Diagnoses Neither dysplasia nor malignancy is seen..This is a dysplastic sample. There is no dysplasia and no invasive carcinoma..The appearances are consistent with, but not specific for Barrett’s (columnar lined) oesophagus..The biopsies of oesophageal squamous mucosa show surface erosion and active chronic inflammation..The appearances are consistent with the endoscopic diagnosis of Barrett’s oesophagus with active chronic inflammation..Basal hyperplasia is prominent.There is no significant increase in intraepithelial eosinophils. | 2013-09-17 | 2 specimens collected the largest measuring 1 x 1 x 5 mm and the smallest 5 x 4 x 4 mm | Neither dysplasia nor malignancy is seen..This is a dysplastic sample. There is no dysplasia and no invasive carcinoma..The appearances are consistent with, but not specific for Barrett’s (columnar lined) oesophagus..The biopsies of oesophageal squamous mucosa show surface erosion and active chronic inflammation..The appearances are consistent with the endoscopic diagnosis of Barrett’s oesophagus with active chronic inflammation..Basal hyperplasia is prominent.There is no significant increase in intraepithelial eosinophils. | 2 days | FALSE |
O349253 | Date of Procedure 2013-09-19 Endoscopist: Dr Sal Addin Midazolam: 2mg Fentanyl: 125mcg Indication: chronic abdo pain and constipaton Diagnosis: Hiatus Hernia. .Esophageal candidiasis .Ulcer- Oesophageal. | 2013-09-19 | Sal Addin | 2 | 125 | chronic abdo pain and constipaton | Diagnosis: Hiatus Hernia. .Esophageal candidiasis .Ulcer- Oesophageal. | NA | NA | O349253 | Date received: 2013-09-17 Macrosopic description: 5 specimens collected the largest measuring 1 x 2 x 3 mm and the smallest 4 x 1 x 2 mm Diagnoses The appearances are consistent with the endoscopic diagnosis of Barrett’s oesophagus with active chronic inflammation..Basal hyperplasia is prominent.No Helicobacter are seen..There is no dysplasia or malignancy..Neither dysplasia nor malignancy is seen..The biopsies of oesophageal squamous mucosa show surface erosion and active chronic inflammation..There is some ulceration..This is a dysplastic sample | 2013-09-17 | 5 specimens collected the largest measuring 1 x 2 x 3 mm and the smallest 4 x 1 x 2 mm | The appearances are consistent with the endoscopic diagnosis of Barrett’s oesophagus with active chronic inflammation..Basal hyperplasia is prominent.No Helicobacter are seen..There is no dysplasia or malignancy..Neither dysplasia nor malignancy is seen..The biopsies of oesophageal squamous mucosa show surface erosion and active chronic inflammation..There is some ulceration..This is a dysplastic sample | 2 days | FALSE |
P433224 | Date of Procedure 2014-08-12 Endoscopist: Dr Elmo Fudd Midazolam: 1mg Fentanyl: 150mcg Indication: Reflux-like Symptoms/Atypical Chest Pain Diagnosis: Gastritis.Post chemo-radiotherapy stricture Barrett’s oesophagus length: C1M5 | 2014-08-12 | Elmo Fudd | 1 | 150 | Reflux-like Symptoms/Atypical Chest Pain | Diagnosis: Gastritis.Post chemo-radiotherapy stricture Barrett’s oesophagus length: C1M5 | 1 | 5 | P433224 | Date received: 2014-08-10 Macrosopic description: 3 specimens collected the largest measuring 3 x 1 x 2 mm and the smallest 4 x 4 x 4 mm Diagnoses There is no dysplasia or malignancy..There is no significant increase in intraepithelial eosinophils..The biopsies of oesophageal squamous mucosa show surface erosion and active chronic inflammation..Intestinal metaplasia is present..There is some ulceration.. PAS staining shows occasional spores, consistent with candida..The appearances are consistent with, but not specific for Barrett’s (columnar lined) oesophagus..The appearances are those of Candida oesophagitis..No granulomas or viral inclusions are seen. | 2014-08-10 | 3 specimens collected the largest measuring 3 x 1 x 2 mm and the smallest 4 x 4 x 4 mm | There is no dysplasia or malignancy..There is no significant increase in intraepithelial eosinophils..The biopsies of oesophageal squamous mucosa show surface erosion and active chronic inflammation..Intestinal metaplasia is present..There is some ulceration.. PAS staining shows occasional spores, consistent with candida..The appearances are consistent with, but not specific for Barrett’s (columnar lined) oesophagus..The appearances are those of Candida oesophagitis..No granulomas or viral inclusions are seen. | 2 days | FALSE |
So the task now involves extracting the presence of dysplasia in those patients where Barrett’s was detected at endoscopy and then grouping them by endoscopist
So to spell out where each element of this comes from:
1. Detect rows that mention Barrett’s in the endoscopy report.
2. Also detect rows that mention dysplasia in the pathology report.
3. Group by endoscopist.
4. Then get the total number of reports that mention Barrett’s in the endoscopy report whether dyplasia is metioned or not, and group by endoscopist.
5. Calculate proportion by endoscopist then visualise it.
This is done using grepl. We will do a combined grepl so we can get the subset we are interested in and that mention dysplasia in the pathology report.
DysplasticBarretts<-EndoHistoMerge[grepl("[Bb]arrett",EndoHistoMerge$EndoReports)&grepl("[Dd]ysplasi",EndoHistoMerge$HistoReport),]
So you will note that there are several reports where it is mentioned that there is no dysplasia so we have to get rid of these. This is tricky but for the purposes of this site we will use the brute force technique
DysplasticBarretts<-DysplasticBarretts[!grepl("[Nn]either dysplasia",DysplasticBarretts$Diagnoses)&!grepl("[Nn]o [Dd]ysplasia",DysplasticBarretts$Diagnoses),]
There are two ways of doing this. The first way is to use dplyr as follows:
EndoscopistDDRBarretts<-DysplasticBarretts%>%group_by(Endoscopist)%>%summarise(n=n())
kable(EndoscopistDDRBarretts)
Endoscopist | n |
---|---|
Bilbo Baggins | 95 |
Bugs Bunny | 111 |
Charles Dickens | 82 |
Chubby Checker | 97 |
Davy Jones | 98 |
Elmo Fudd | 112 |
Elvis Presley | 94 |
Florence Nightingale | 109 |
Frank Sinatra | 90 |
Jimminey Cricket | 114 |
Jonny Begood | 75 |
Joseph Conrad | 95 |
King Richard III | 87 |
Rara Rasputin | 95 |
Sal Addin | 119 |
Alternatively we can just use the table function which has a neater input but gives a messier output:
DDRtable<-table(EndoscopistDDRBarretts)
kable(DDRtable)
75 | 82 | 87 | 90 | 94 | 95 | 97 | 98 | 109 | 111 | 112 | 114 | 119 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Bilbo Baggins | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bugs Bunny | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
Charles Dickens | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Chubby Checker | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
Davy Jones | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
Elmo Fudd | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
Elvis Presley | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Florence Nightingale | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
Frank Sinatra | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Jimminey Cricket | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
Jonny Begood | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Joseph Conrad | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
King Richard III | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Rara Rasputin | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Sal Addin | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
So now we know who is picking up dysplasia we can express this as a proportion of all the Barrett’s endoscopy they have done as follows:
AllBarretts<-EndoHistoMerge[grepl("[Bb]arrett",EndoHistoMerge$EndoReports),]
Endoscopist_All_Barretts<-AllBarretts%>%group_by(Endoscopist)%>%summarise(n=n())
Now we just calulate the proportions to get the DDR. We have to bind Endoscopist_All_Barretts and EndoscopistDDRBarretts to calculate this. We merge by endoscopist
#For a bit of variety we are going to do the merge using dplyr join functions instead of base R merge functions:
DDRTable<-full_join(Endoscopist_All_Barretts, EndoscopistDDRBarretts, by = "Endoscopist")
And finally the proportions:
DDRTable$Prop<-(DDRTable$n.y/DDRTable$n.x)*100
DDRTable<-data.frame(DDRTable)
#Lets get rid of NA values by replacing with "0"
DDRTable$Prop[is.na(DDRTable$Prop)] <- 0
#Lets plot it out
barplot(DDRTable$Prop,names.arg=DDRTable$Endoscopist, ylab = "% dysplasia",
cex.lab = 1.5,cex.axis=1.0,cex.main = 1.0,cex.names=1.0,main = "Barrett's Endoscopic Dysplasia detection proportion",las=2)
….Looks like some people need more training…