Visualising time series of symptom scores (PANSS)

Visualising time series of symptom scores (PANSS)

 

Having just started a new project relating to clinical state/signatures, I need some quick ways of visualing e.g. PANSS scores measured on multiple time points.  Here's the resulting R code in case it's helpful for anyone else with an interest in the same. In case it's not obvious, I like heatmap representations. 

Sample Data 1 : CSV of one person's PANSS scores measured over 9 time points.

Sample Data 2 : a second person's PANSS scores

The R code - place this and the example data above in your working directory


You'll need to download the example CSV files, and source the R code in your working directory

# Uncomment and modify according to where you're working directory is
# source('visualisePANSSFunctions.R')
d1 <- read.csv('example_PANSS_data1.csv')
d2 <- read.csv('example_PANSS_data2.csv')
P1 P2 P3 P4 P5 P6 P7 N1 N2 N3 N4 N5 N6 N7 G1 G2 G3 G4 G5 G6 G7 G8 G9 G10 G11 G12 G13 G14 G15 G16
4 1 1 1 1 4 2 4 3 1 2 1 1 1 1 3 1 3 1 3 1 1 2 1 1 1 1 2 1 2
5 3 4 3 5 4 2 4 1 1 2 2 1 1 1 4 1 2 1 2 1 1 4 1 1 1 2 1 1 2
3 1 1 2 1 2 1 4 3 1 2 1 1 1 1 4 1 4 1 1 1 1 1 1 1 1 1 2 1 1
4 2 1 3 2 3 3 4 1 1 1 1 1 1 1 4 2 4 1 3 1 1 2 1 2 1 1 3 1 1
3 1 1 2 1 2 1 3 1 1 2 1 1 1 1 3 1 3 1 1 1 1 1 1 2 1 1 1 1 1
3 1 2 1 4 2 1 1 1 1 1 1 1 1 1 3 1 3 1 1 1 1 3 1 1 1 1 1 1 2
3 1 1 1 1 2 1 3 1 1 1 1 1 1 1 2 1 2 1 3 1 1 1 1 3 1 1 1 1 1
3 1 1 2 1 2 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 3 1 1 1 1 1 1 1
3 2 1 1 3 1 1 1 1 1 2 2 1 1 1 2 1 2 1 2 1 1 2 1 1 1 1 2 1 1

Visualise with Relative Scale

The lowest and highest scores are scaled 'within subject'

p1.rel <- HeatMapPANSS( d1, absoluteScale = FALSE )
(p1.rel)

plot of chunk unnamed-chunk-8

Visualise with Absolute Scale

In contrast to relative, red always represents highest score (7) and green the lowest (1)

p1.abs <- HeatMapPANSS( d2, absoluteScale = TRUE )
(p1.abs)

plot of chunk unnamed-chunk-9

The absolute scale has utility when comparing two sets of data

p1.abs <- HeatMapPANSS( d1, absoluteScale = TRUE)
p2.abs <- HeatMapPANSS( d2, absoluteScale = TRUE)
grid.arrange( p1.abs, p2.abs, ncol = 2 )

plot of chunk unnamed-chunk-10

Visualise Change in Scores

Sometimes, it's useful to see how the scores change over time (essentially, the first derivative of scores). For the two people above, compare side-by-side their changes:

p1.delta <- HeatMapChangePANSS( d1 )$plot
p2.delta <- HeatMapChangePANSS( d2 )$plot
grid.arrange( p1.delta, p2.delta, ncol = 2)

plot of chunk unnamed-chunk-11

 

Collaborating on Documents Avoiding MSoft Word

Getting RMarkdown onto a Blogpage