No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
R
man
tests
.Rbuildignore
.gitignore
DESCRIPTION
NAMESPACE
README.Rmd
temp.R
tmp-data-review.Rproj
todo.txt

README.Rmd

PMXPLORE
=======

**UNDER DEVELOPMENT**

Functions for data review and exploratory data analysis commonly performed in pharmacometric analyses. Mainly containing wrapper functions for ggplot and GGally as well as functions for summary statistics.

```{r, message=F, error=F}
# library(pmxplore)
library(azrdatareview)
library(dplyr)
library(ggplot2)
library(GGally)

# To update: bad example dataset - must contain more covs. 
data <- Theoph
baselineData <- 
  data %>% filter(!duplicated(Subject)) 
```

## ggplot wrapper functions
Wrapper functions setting re-occuring layers of a ggplot object. The functions return a ggplot object so it is easy to add additional layers/labels *etc* as if it was a regular ggplot call. 

### Concentration-time graphics
```{r}
gg_conc_time(data, x=Time, y=conc, color=Subject) +
  guides(colour="none") + 
  labs(x="Concentration", y="Time") + 
  theme_bw()

# add a couple of other examples, e.g. individual plots. 
```

### Functions for evaluation of dose linearity
These graphics require the evaluted pharmacokinetic parameter to be calculated before hand.
```{r}
# Include short example for:
# dose_proportionality_anova()
# dose_proportionality_linear()
# dose_proportionality_power()
```

## Functions to use with GGally
pmxplore contains a set of funtions which can be used together with GGally to create a grid of plots: all these functions have the prefix 'ally'. Currently these functions are focused on correlation graphics appropriate for e.g. covariate correlations.

### Continous variables
Use e.g. ally_scatter_lm_cor in combination with ggpairs
```{r}
ggpairs(baselineData, columns = "Wt",
          diag = list(continuous = 'barDiag'),
          upper = list(continuous = ally_cor),
          lower = list(continuous = ally_scatter_lm_cor))
```

The diagonal graphs show histograms of each covariate. The off-diagonal graphs are scatter plots of observations (black open circles) with linear regression (black line) and its 95% confidence interval (grey shaded area). The graphs are displayed in red if the Pearson’s correlation coefficient (number within boxes) is > 0.4.

You can pass arguments to your pmxlore call using wrap().
```{r}
ggpairs(baselineData, columns = "Wt",
          diag = list(continuous = 'barDiag'),
          upper = list(continuous = wrap(ally_cor, 
                                         cor_method = "pearson", 
                                         cor_threshold = 0.3)),
          lower = list(continuous = wrap(ally_scatter_lm_cor, 
                                         cor_method = "pearson", 
                                         cor_threshold = 0.3)))
```

### Categorical variables
Use e.g. ally_bar and ally_count in combination with ggpairs
```{r}
# ggpairs(baselineData, columns = "X",
#         diag = list(discrete = ally_bar),
#         upper = list(discrete = "blank"),
#         lower = list(discrete = ally_count)) 
```

The diagonal graphs show bar charts of each covariate. The off-diagonal graphs show the correlation between covariate categories: the black point is a visual reference point, and the numbers are percentage of subjects of a covariate split by the groups of the other covariate. For example, the bottom left graph show that within the group with normal renal function, 19% are female and 81% are male (numbers aligned left of the reference point). Similarly, within the group of females, 29% have normal, 36% have mild, 21% have moderate renal impairment and 14% is missing information (numbers aligned above the reference point). NA refers to not available, i.e., missing. 

You can pass arguments to your pmxlore call using wrap().
```{r}
# ggpairs(baselineData, columns = "X",
#         diag = list(discrete = ally_bar),
#         upper = list(discrete = "blank"),
#         lower = list(discrete = wrap(ally_count, counts="abs"))) 
```

### For continous and categorical variables
Use e.g. ally_box in combination with ggduo
```{r}
# ggduo(baselineData, "vectorCat", "vectorCont",
#       types = list(comboVertical = ally_box))
```

The black line within the box shows the median and the box's upper and lower edges show the inter quartile range (IQR). Whiskers extend to the highest value that is within 1.5*IQR. Data beyond the end of the whiskers are outliers and plotted as points. NA refers to not available, i.e., missing.