-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Barretts.Rmd
164 lines (104 loc) · 7.9 KB
/
Barretts.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
---
title: "Barrett's Oesophagus"
author: "Sebastian Zeki"
date: '`r format(Sys.Date(), "%B %d, %Y")`'
output:
rmarkdown::html_document:
theme: lumen
toc: true
css: style.css
vignette: >
%\VignetteIndexEntry{Barretts}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include=FALSE}
library(knitr)
library(EndoMineR)
library(pander)
library(prettydoc)
```
```{r global_options, include=FALSE}
knitr::opts_chunk$set(echo=FALSE, warning=FALSE, message=FALSE)
```
<br>
## **Specific diseases - Barrett's oesophagus**
<br>
One particular disease that lends itself well to analytics, particularly as it is part of a surveillance programme, is the premalignant oesophageal condition Barrett's oesophagus. This is characterised by the growth of cells (called columnar lined epithelium) in the oesophagus. These cells usually occupy the lower part of the oesophagus as a continuous sheet from the top of the stomach to varying lengths up the oesophagus.
This condition requires endoscopic surveillance and the timing of this depends on the prior endoscopic features (namely the length of the Barretts segment as measured by the Prague score- explained below) and the pathological stage at that endoscopy (which for non-dysplastic samples, since the revised 2013 UK guidelines, means the presence or absence of intestinal metaplasia). This can be seen in the image below (from Fitzgerald RC, et al. Gut 2013;0:1–36. doi:10.1136/gutjnl-2013-305372)
<br>
```{r ,fig.align='center',echo=FALSE,fig.width=18, fig.height=12}
knitr::include_graphics("img/BarrettsGuide.png")
```
<br>
## **1. Pre-processing Barrett's samples**
<br>
Such a dataset needs some processing prior to the analysis so for this we can turn to a specific set of function for Barrett's oesophagus itself.
<br>
### **a) Prague score**
<br>
Firstly we need to extract the length of the Barrett’s segment. This is known as the [Prague score](https://services.nhslothian.scot/endoscopyunit/InformationForClinicalStaff/Documents/PRAGUE%20CRITERIA.pdf) and is made up of the length from the top of the gastric folds (just below the gastro-oesophageal junction) to the top of the circumferential extent of the Barrett's segment (C). In addition the maximal extent is from the top of the gastric folds to the top of the tongues of Barrett's segment (M). This gives an overall score such as C1M2.
<br>
After filtering for endoscopic indication (eg “Surveillance-Barrett’s”- this is stored in the 'Indication' column in our data set) the aim of the following function is to extract a C and M stage (Prague score) for Barrett’s samples. This is done using a regular expression where C and M stages are explicitly mentioned in the free text. Specifically it extracts the Prague score. This is usually mentoned in the 'Findings' column in our dataset but obviously the user can define which column should be searched.
```{r exampleBarretts_PragueScore,echo = TRUE,message=FALSE, warning=FALSE}
v<-Barretts_PragueScore(Myendo,'Findings','OGDReportWhole')
```
```{r exampleBarretts_PragueScore2,echo = FALSE,message=FALSE, warning=FALSE}
panderOptions('table.split.table', Inf)
pander(v[23:27,(ncol(v)-4):ncol(v)])
```
### **b) Worst pathological stage**
<br>
We also need to extract the worst pathological stage for a sample, and if non-dysplastic, determine whether the sample has intestinal metaplasia or not. This is done using 'degredation' so that it will look for the worst overall grade in the histology specimen and if not found it will look for the next worst and so on.
It looks per report not per biopsy (it is more common for histopathology reports to contain the worst overall grade rather than individual biopsy grades).
```{r exampleBarretts_PathStage, echo = TRUE,message=FALSE, warning=FALSE}
#The histology column is the one we are interested in:
Mypath$b <- Barretts_PathStage(Mypath, "Histology")
```
```{r exampleBarretts_PathStage2, echo = TRUE,message=FALSE, warning=FALSE,echo=FALSE}
panderOptions('table.split.table', Inf)
pander(Mypath[2:3,(ncol(Mypath)-4):ncol(Mypath)])
```
### **c)Follow-up groups**
<br>
Having done these pre-processing steps, the follow-up group to which the last endoscopy belongs (rather than the patient as their biopsy results or Barrett's segment length and therefore their follow-up timing, may fluctuate over time) can be determined.
The follow-up timing, as explained in the the original guideline flowchart above, depends on the length of the Barrett's segment and the presence of intestinal metaplasia (a type of columnar lined epithelium). If abnormal cells (dysplasia) are present the there is a different follow-up regime which we won't concern ourselves with at the moment.
The timing of follow-up is done with the function **Barretts_FUType.** This relies on the previous functions called **Barretts_PathStage** and **Barretts_PragueScore** having been run. The Barretts_FUType function will tell you which follow up Rule the patient should be on so that the timing of the next endoscopy can be determined. As these functions usually go together a wrapper function called **BarrettAll** is also provided.
<br>
```{r exampleBarretts_FUType, echo = TRUE,message=FALSE, warning=FALSE}
#Create the merged dataset
v<-Endomerge2(Myendo,"Dateofprocedure","HospitalNumber",Mypath,"Dateofprocedure","HospitalNumber")
#Find the worst pathological grade for that endoscopy
v$IMorNoIM <- Barretts_PathStage(v, "Histology")
#Find the Prague score for that endoscopy
b1<-Barretts_PragueScore(v, "Findings", "OGDReportWhole")
#Get the follow-up type for that endoscopy
b1$FU_Type<-Barretts_FUType(b1,"CStage","MStage","IMorNoIM")
```
```{r exampleBarretts_FUType2, echo = FALSE,message=FALSE, warning=FALSE,echo=FALSE}
panderOptions('table.split.table', Inf)
pander(b1[23:27,(ncol(b1)-4):ncol(b1)])
```
## **2.Quality assessment in Barrett's surveillance**
<br>
Many of the aspects of generic quality monitoring apply to Barrett's as well. For example, you may want to make sure that the endoscopy reports adhere to guidance about what should be in an endoscopy report. This can be assessed using the generic function **ListLookUp**
### **Quality of perfomance of Barrett's surveillance endoscopies as just by tissue sampling**
Some things are specific to Barrett's oesophagus however. One of the essential requirements to demonstrate adequate sampling of Barrett's oesophagus during endoscopy is that the endoscopist should adhere to the 'Seattle protocol' for biopsies which is to take 4 equally spaced biopsies at 2cm intervals in the circumferential part of the oesophagus. Because the macroscopic description of the pathological specimen tells us how many samples are taken overall (and rarely how many at each level but this is usually not the case for a variety of reasons) we can determine the shortfall in the number of biopsies taken, per endoscopist. Again pre-processing the Barrett's samples is pre-requisite. The Number of biopsies and their size should also be extracted using the histopathology functions.
```{r exampleBarrettsQuality_AnalysisBiopsyNumber,echo = FALSE,message=FALSE, warning=FALSE}
# The number of average number of biopsies is then calculated and
# compared to the average Prague C score so that those who are taking
# too few biopsies can be determined
#Lets just use the Surveillance endoscopies:
b1<-b1[grepl("[Ss]urv",b1$Indications),]
b1$NumBx<-HistolNumbOfBx(b1$Macroscopicdescription,'specimen')
b1$BxSize <- HistolBxSize(b1$Macroscopicdescription)
b2<-BarrettsBxQual(b1,'Date.x','HospitalNumber',
'Endoscopist')
```
```{r exampleBarrettsQuality_AnalysisBiopsyNumbertbl, echo = FALSE,message=FALSE, warning=FALSE,echo=FALSE}
#panderOptions('table.split.table', Inf)
panderOptions('table.split.table', Inf)
pander(b2)
```
<br>
This function will again return a dataframe with the number of biopsies taken that is outside of the number that should have been taken for a certain Prague score.