Create tract profile figures for each tract as a facet and for each y
value as a figure.
Usage
plot_tract_profiles(
df,
y,
tracts = NULL,
tract_col = "tractID",
node_col = "nodeID",
group_col = NULL,
n_groups = NULL,
group_pal = "cb",
participant_col = "subjectID",
ribbon_func = "mean_cl_boot",
ribbon_alpha = 0.25,
linewidth = 1,
save_figure = TRUE,
output_dir = getwd(),
...
)
Arguments
- df
The input dataframe.
- y
Column name(s) of the variables to plot on the y-axis.
- tracts
Name(s) of the tract tracts to plot per facet. Default: NULL
If NULL, will be all tracts in the data frame.- tract_col
The column name that encodes the tract information. Default: tractID
- node_col
The column name that encodes tract node positions. Default: "nodeID".
- group_col
Column name that encodes group information. Will be drawn by color. Default: NULL.
If
group_col
is a factor, will use unique values as groups.If
group_col
is a numeric, will use ggplot2::cut_interval to create equal rangen_groups
as groups.
- n_groups
Number of groups to split a numeric grouping variable. Only used if
group_col
is numeric. Default: NULL.- group_pal
Grouping color palette name. Valid options include: "cb" (colorblind), "cbb" (colorblind_black), and all named RColorBrewer palettes. Default: "cb" (colorblind)
- participant_col
The column name that encodes participant ID. Default: "subjectID".
- ribbon_func
Ribbon summarizing function that provides the y, ymin, and ymax for the ribbon. See
fun.data
argument from ggplot2::stat_summary for more information. Default: "mean_cl_boot"- ribbon_alpha
Ribbon alpha level. Default: 0.25
- linewidth
Line thickness of the tract profile line. Default: 1.
- save_figure
Boolean flag. If TRUE, save tract profiles. If FALSE, do not save tract profiles. Default: FALSE
- output_dir
Output directory for the figure image(s). Default: getwd (current working directory).
- ...
Keyword arguments to be passed to ggplot2::ggsave.
Details
If save_figure
is TRUE, the naming convention is as follows:
If
group_col
, "tract_by-(group_col)_param-(y)_profiles.png".If
group_col == NULL
, "tract_param-(y)_profiles.png"
Examples
if (FALSE) { # \dontrun{
df_sarica <- read_afq_sarica(na_omit = TRUE)
plot_handle <- plot_tract_profiles(
df = df,
y = c("fa", "md"),
tracts = c("Left Corticospinal", "Right Corticospinal"),
width = 12,
height = 6,
units = "in"
)
plot_handle <- plot_tract_profiles(
df = df,
y = c("fa", "md"),
tracts = c("Left Corticospinal", "Right Corticospinal"),
group_col = "group",
width = 12,
height = 6,
units = "in"
)
plot_handle <- plot_tract_profiles(
df = df,
y = "fa",
tracts = c("Left Corticospinal", "Right Corticospinal"),
group_col = "age",
n_groups = 5,
group_pal = "Spectral",
width = 12,
height = 6,
units = "in"
)} # }