stat545a-2013-hw06_inskip-jes

Homework_06: Final Project on workflow and automating R functions

I have tried to make this example as close as possible to my own lab workflow - i.e. it is imperfect in some ways! We combine a number of different physiological signals from different pieces of equipment into one proprietary software program (LabChart). I then export as a .csv file after testing. I have one .csv file for each subject that we test. In this case, the .csv files have been opened and saved as .csv files in excel - as is common in my lab - therefore, I have spent a great deal of my time working on the first script that cleans this data. This was a valuable exercise in learning how to manipulate messy data without the artisanal excel work, which is a specialty of my current supervisor.

The main outcome measure is how the blood flow to the brain is altered by different levels of carbon dioxide (CO2). We know that the cerebral vasculature is sensitive to changes in CO2 (a vasoconstrictor) and we suspect that the sensitivity might be altered in individuals with complete spinal cord injury that disrupts the nerves that control the blood vessels in the brain. The main two parameters that we are working with in this example are: end-tidal CO2 (ETCO2) which is the peak CO2 levels that you breathe out at the end of an exhale, and middle cerebral artery blood flow velocity (MCAv) which is used as a surrogate measure for blood flow as the vessel that we are investigating has been shown not to change diameter very much.

Subjects were individuals with no neurological damage (Controls), individuals with incomplete spinal cord injury (Incomplete), and individuals with complete high-level spinal cord injury (Complete). The data were recorded while subjects were supine and we were controlling the gasses that they breathe on a breath-by-breath basis (also known as end-tidal forcing or ETF). The main point of this experiment is to look at how the cerebral blood flow is affected by the levels of CO2. We manipulate CO2 by having individuals hyperventilate (this lowers CO2) and hypoventilate (this happens naturally at the end of hyperventilation - people breathe less often afterwards). Finally, we are using an end-tidal forcing system that allows us to increase CO2 to a high range (subjects breathe through a bag that we can fill with air of a variety of different gas compositions - more or less O2 and CO2).

Some research groups have shown that this is a linear relationship - while others argue that it is a segmented linear relationship - and still others treat the relationship as sigmoidal. Therefore, I am fitting each of these kinds of lines and record the goodness of fit. For the moment, I have just plotted the linear and sigmoidal relationships.

Instructions for use:

All necessary files can be found on GitHub Repository: https://github.com/jinskip/stat545a-2013-hw06_inskip-jes

Download into an empty directory (I would do this using Download ZIP option - or clone to Desktop):

Open R and start a fresh RStudio session:

Cleaned data:

Table 01: allFitsETFReactivityNormoxia. This table includes coefficient data from linear, segmented linear, and sigmoidal fits. It will be useful to help us determine which fits we use for further analysis, and can be used to create figures directly.

Figure 01: Quick xyplot of all subjects to review shape, outliers: overviewFigure_ETFDataNormoReact.pdf

Figure 02: Quick overview of sigmoid fits: quickLookSigmoidalNormoxiaBySubject.pdf

Figure 03: Linear cerebral reactivity by group: Controls Linear cerebral reactivity at normoxia_control.png

Figure 04: Linear cerebral reactivity by group: Complete SCI Linear cerebral reactivity at normoxia_complete.png

Figure 05: Linear cerebral reactivity by group: Incomplete SCI Linear cerebral reactivity at normoxia_incomplete.png

Figure 06: Sigmoidal cerebral reactivity by group: all groups sigmoidalAllGroupsETFReactivityNormoxia.pdf

It should be said that these are all kind of mid-stage exploratory figures - none of which are fit for print!

There are some errors to be expected due to the fact that all types of fits do not work with all datasets: