 Hi, everyone. Welcome to the last talk of this session. This will be Daniel Holmes talking about using R to produce clinical reports in patient records. Thanks very much for the introduction and thank you to Stefan Kedaki for inviting me to speak today. I'm going to be picking up on some of the things that Steven Masters spoke about earlier and maybe make allusion to what Patrick Matthias will be speaking about later on. I'm going to talk about how we use R to produce clinical reports in specific reference to a condition called primary aldosteranism where R plays a role in the entire data automation and reporting pipeline. So what is primary aldosteranism? It is the most common form of curable form of hypertension. Most hypertension doesn't have a well-defined cause and so it's just treated with medications. The primary aldosteranism has a specific underlying cause. It can either be from excessive growth of the adrenal glands or it can be due to a tumor of the adrenal gland usually on one side and occasionally on both sides. When it's caused by a tumor and it's only on one side, you can just take that tumor out with an adrenalectomy. Otherwise you can use medications that are specifically targeted to block the effect of aldosterone. This causes people to have a chronic hypertension that's particularly resistant to medication and to have low potassium. So these patients have specific clinical features that will help identify them as possibly having primary aldosteranism. They tend to be resistant to the usual medications like ACE inhibitors and beta blockers. They tend to present with an incidentally discovered adrenal mass. Medicine is notorious for having unusual nomenclature. We call these incidentalomas. They're discovered incidentally on CT scan. Hypertension in a young person or hypokalemia that is low blood potassium in response to the normally employed diuretic medications. So biochemical screening is undertaken with the concomitant measurement of aldosterone and plasma renin activity. And in allusion to what Steven spoke about earlier, these two measurements are notorious for high variability between the vendors who manufacture the kits to measure them. And so the thresholds for diagnosis and screening are heavily linked to the analytical methodology that you're using, whether that be a lab develop test or a commercially available kit. In any case, clinicians being what they are, they need something simple. So the combined information of aldosterone and plasma ren activity is taken by means of a ratio of those two. And that is what people usually use to help screen for primary aldosteronism. This is an illustration of the so-called renin angiotensin aldosterone system. And not terribly important to us, except to say that the target analyte for measuring plasma renin activity is the ability to generate angiotensin one over a period of time. So there's endogenous angiotensinogen. And we measure how much angiotensin one is generated over a period of time buffered at pH 6.5. And then, of course, we measure aldosterone itself. And this is just an illustration of aldosterone's actions, which are to retain potassium and to waste water. If you think about that, if the water has to, sorry, retain sodium and waste potassium is what I meant to say. When you retain sodium, water has to come with it and it causes the intravascular volume to expand and causes the high blood pressure. So these data are generated off a mass spectrometer, as I'll show you in in a moment using a lab develop test. And our data workflow strategy when we started out was to manually transcribe them, which is one of my beefs is that we spend a lot of time trying to make perfect analytical chemistry. And then we manually transcribe the results into our lab systems. So that doesn't make a lot of sense. And we were manually adding our interpretive comments also, which often are canned or just stock comments. So here's the analytical and data workflow that we developed. The patient sample is taken. Well, first, actually, it's taken to this liquid handling robot from Hamilton. It's subjected to a number of treatments for aldosterone. It's extracted with methyl tert butyl ether that is dried down, reconstituted and and then thank you Citrix for telling me that I need to update. You can bounce there in the right corner for a few minutes. And then after the extraction, the methyl butyl ether is dried off and and the sample reconstituted in methanol water. And then we can measure aldosterone using a multiplexed HPLC system connect to a sci-x mass spectrometer to get patient identifiers. What's actually just the barcode that's on the tube, which isn't a patient identifier, it's a sample identifier. But to get it across, we use R to just do some some data munging. It's through a shared folder ends up over at the mass spectrometer. And then again, ASCII text output comes from the mass spectrometer, but we can't interpret those results by themselves. We need to marry them with the clinical data, which is not on the patient barcode identifier. So in order to marry it with the clinical data, we have to get that clinical data out. Now at the time that I developed this workflow, data innovations, which is appearing down here was not available. And so and the lab information system people did not want to help me with this because they were stretched with other things. So I discovered this language expect, which I use to strip information directly through a text interface to the lab system. This is all run by bash under Ubuntu. And using that, we get data from the laboratory information system, which is SunQuest. We marry that clinical data produce an Excel file, I know shameful. And the Excel file is used to to review the interpretive comments that have been auto generated. And then a flat file is sent over to data innovations and then goes to SunQuest into the electronic health record. So I would just like to talk a little bit about expect because it is kind of a hack that is useful in certain circumstances. It's a it's an automation language for text based interfaces. We were not permitted to have an ODBC connection to the lab information system. And so because we had a text command line interaction with the lab information system, we could use we could automate that interaction and get the information from the text file that gets dumped. So expect is an extension of the TCL language that is, you know, used for for automating any kind of text command line interaction. There's alternatives to this in in the modern era, using a specific automation languages. But since we're working on a macOS and Linux, we didn't have we didn't have the benefit of auto hotkey, which is a good example. There is no there is no extension of R that lets you use expect. So these are having to be run by daughter processes. But there is a Python extension that will allow you to imitate the expect language. This is the interpretive process that is applied to our samples. In the middle, we have mostly normal people. These patients with a high aldosterone to plasma renin activity are considered a positive screen for primary aldosteronism. We have an indeterminate screen in the orange. We have other conditions where you have high aldosterone, high plasma renin activity, such as renal artery stenosis, reninoma, laxative abuse, etc. We have medication effects, Addison's disease, that is to have low adrenal activity. And the pink domain is sort of like prolonged recumbents that is patients in hospital or something like that. And a couple of other miscellaneous categories. But this is the interpretive algorithm that is applied by the R script from from the mass spectrometer, uniting it with the clinical data. So R has permitted us to find some other conditions to we found a number of cases of ACTH dependent Cushing syndrome caused by ectopic carcinoid syndrome, carcinoid tumors. We found lots of Addison's disease we found inappropriate dexamethasone administration before primary aldosteronism screening that just happened yesterday. For example, we have a few opportunities for improvement. I've been using TCL widgets because this was developed before shiny existence, we could move this whole thing to a shiny interface and we could incorporate, incorporate more mass spectrometry quality metrics in the reporting. And it would be nice to have full automation of some of the interpretive letters that we need to write for the tumor localization procedures, which I haven't had a chance to talk about here. I would like to acknowledge people that help me tirelessly Grace Vandergoogten, who does all our mass spectrometry, assay development and MSACL for promoting applications of R and Python to mass spectrometry. And of course, our laboratory technologists who make this possible. Also Dr. Janet Simons and Dr. Andre Matman, who are my user base. We are a user base of three for this. But they provide me important feedback on how to improve the process. And, and I appreciate that very much. And with that, I will I'll stop and I will tell Citrix to remind me later. Thanks very much, Daniel. If you have questions for Daniel, you're welcome to contact him. At this point, we're going to start the birds of a feather for today. Thank you very much.