Title: | Easy Graphs for Data Visualisation and Linear Models for ANOVA |
---|---|
Description: | Easily explore data by plotting graphs with a few lines of code. Use these ggplot() wrappers to quickly draw graphs of scatter/dots with box-whiskers, violins or SD error bars, data distributions, before-after graphs, factorial ANOVA and more. Customise graphs in many ways, for example, by choosing from colour blind-friendly palettes (12 discreet, 3 continuous and 2 divergent palettes). Use the simple code for ANOVA as ordinary (lm()) or mixed-effects linear models (lmer()), including randomised-block or repeated-measures designs, and fit non-linear outcomes as a generalised additive model (gam) using mgcv(). Obtain estimated marginal means and perform post-hoc comparisons on fitted models (via emmeans()). Also includes small datasets for practising code and teaching basics before users move on to more complex designs. See vignettes for details on usage <https://grafify-vignettes.netlify.app/>. Citation: <doi:10.5281/zenodo.5136508>. |
Authors: | Avinash R Shenoy [cre, aut] |
Maintainer: | Avinash R Shenoy <[email protected]> |
License: | GPL (>= 2) |
Version: | 4.1.0 |
Built: | 2025-01-25 20:20:51 UTC |
Source: | https://github.com/ashenoy-cmbi/grafify |
These data are from in vitro measurements of death of host cells (measured as percentage of total cells) after infection with three different strains of a pathogenic bacterium, from five independent experiments. The three strains are three levels within the fixed factor Genotype. The five independent experiments are levels within the random variable Experiment. These data can be analysed using linear mixed effects modelling. These data are from Goddard et al, Cell Rep, 2019, doi.org/10.1016/j.celrep.2019.03.100
data_1w_death
data_1w_death
data.frame: 15 obs. of 3 variables.
Experiment - a random factor with 5 levels "Exp_1","Exp_2"...
Genotypes - a fixed factor with 3 levels: "WT","KO_1","KO_2".
Numerical dependent variable indicating percentage cell death.
Data from Festing, ILAR Journal (2014) 55, 472–476 <doi: 10.1093/ilar/ilu045>. These data are suitable for two-way linear mixed effects modelling. The activity of GST (numerical dependent variable) was measured in 4 strains of mice (levels with the fixed factor Strain) either treated or controls (levels within the fixed factor Treatment). Once mouse each was used in two randomised blocks, which is the random factor (Block).
data_2w_Festing
data_2w_Festing
data.frame: 16 obs. of 4 variables:
A random factor with 2 levels "A" and "B".
A fixed factor with 2 levels: "Control" & "Treated"
A fixed factor with 4 levels: "129Ola", "A/J", "NIH" & "BALB/C"
Numerical dependent variable indicating GST activity measurement
These are measurements of death of infected host cells (as percentage of total cells) upon infection with two strains of bacteria, measured at two time points, in 6 independent experiments. These data repeated-measures data suitable for two-way linear mixed effects modelling with experiment and subjects as random factors.
data_2w_Tdeath
data_2w_Tdeath
data.frame: 24 obs. of 6 variables:
A random factor with 6 levels "e1", "e2"...
A fixed factor with 2 levels: "t100" & "t300".
A numeric column that allows plotting data on a quantitative "Time" axis. The "Time" column has "factor" type values that should be used for the ANOVA..
A fixed factor with 2 levels that we want to compare "WT" & "KO".
A random factor with 12 levels: "s1", "s2"... These are cell culture wells that were measured at two time points, and indicate "subjects" that underwent repeated-measures within each of 6 experiments. Subject IDs for WT and KO are unique and clearly indicate different wells.
Numerical dependent variable indicating propidium iodide dye uptake as a measure of cell death. These are percentage of dead cells out of total cells plated.
An example dataset on measurements of blood cholesterol levels measured in 5 subjects measured before and after receiving a Drug. Five patients each were recruited at 5 hospitals (a-e), so that there are 25 different subjects (1-25) measured twice. Data are from Micro/Immuno Stats
data_cholesterol
data_cholesterol
tibble: 30 obs. of 3 variables:
Factor with 5 levels (a-e), representing different hospitals where subjects were recruited.
A factor with 25 levels denoting individuals on whom measurements were made twice.
A factor with 2 levels indicating when measurements were made, i.e. before and after drug.
Numerical dependent variable indicating measured doubling time in min.
An example dataset showing measurements of E. coli doubling times (in min) measured by 10 different students in 3 independent experiments each. Note that Experiments are just called Exp1-Exp3 even though Exp1 of any of the students are not connected in anyway - this will confuse R! Data are from Micro/Immuno Stats
data_doubling_time
data_doubling_time
tibble: 30 obs. of 3 variables:
Factor with 10 levels, representing different students.
A factor with 3 levels representing independent experiments.
Numerical dependent variable indicating measured doubling time in min.
An example dataset for paired difference Student's t test. These are bodyweight (Mass) in grams of same mice left untreated or treated, which are two groups to be compared. The data are in a longtable format, and the two groups are levels within the factor "Condition". The Subject column lists ID of matched mice that were measured without and with treatment. These data are from Sanchez-Garrido et al, Sci Signal, 2018, DOI: 10.1126/scisignal.aat6903.
data_t_pdiff
data_t_pdiff
data.frame: 20 obs. of 3 variables:
Factor with 10 levels, denoted by capital letters, representing individuals or subjects.
A fixed factor with 2 levels: "Untreated" & "Treated".
Numerical dependent variable indicating body mass of mice
An example dataset for paired ratio Student's t test. These are Cytokine measurements by ELISA (in ng/ml) from 33 independent in vitro experiments performed on two Genotypes that we want to compare. The data are in a longtable format, and the two groups are levels within the factor "Genotype". The Experiment column lists ID of matched experiments.
data_t_pratio
data_t_pratio
data.frame: 66 obs. of 3 variables:
Factor with 2 levels, representing genotypes to be compared ("WT" & "KO").
A random factor with 33 levels representing independent experiments, denoted as "Exp_1", "Exp_2"...
Numerical dependent variable indicating cytokine measured by ELISA.
A subset of data from (Lathro RC, 2000) (doi:10.6073/pasta/ec3d0186753985147d4f283252388e05) provided by the Wisconsin Department of Natural Resources
data_zooplankton
data_zooplankton
tibble: 1127 obs. of 8 variables:
Numeric integer variable.
Numeric integer variable of years during which data were collected.
This data is for lake Menona; data for other others not included in this subset.
Names of zooplankton taxa as factor of 8 levels.
Numeric values of density of measurements.
Numeric values of adjusted density .
Numeric values of minimum densities.
Numeric value of scaled density.
gam
)One of two functions for fitting generalised additive models (gam
) with the mgcv
package. It will use the gam()
function in mgcv
for ANOVA designs with up to two categorical fixed factors (with two or more levels; Fixed_Factor
), and exactly one factor is a continuous variable (e.g. time), which is called Smooth_Factor
.
ga_anova( data, Y_value, Fixed_Factor, Smooth_Factor, Random_Factor = NULL, Nodes = NULL, ... )
ga_anova( data, Y_value, Fixed_Factor, Smooth_Factor, Random_Factor = NULL, Nodes = NULL, ... )
data |
a data frame where categorical independent variables are converted to factors using |
Y_value |
name of column containing quantitative (dependent) variable, provided within "quotes". |
Fixed_Factor |
name(s) of categorical fixed factors (independent variables) provided as a vector if more than one or within "quotes". Convert to factors first with |
Smooth_Factor |
the continuous variable to fit smoothly with a basis function, provided within "quotes" (only 1 Smooth_Factor allowed). |
Random_Factor |
name(s) of random factors to be provided in "quotes" (only 1 Random_Factor allowed). Convert to factor with |
Nodes |
number of nodes (the parameter |
... |
any additional variables to pass on to |
A smooth function is fitted with factor-wise smooth basis function (by =
). A default value for number of nodes (the argument k
in gam
) may work, but a specific number can be provided using the Nodes
argument. The model is fit using the REML
method. When two categorical fixed factors are provided, an interaction term is included for main effects and smooth basis functions.
If a Random_Factor
is also provided, it is fitted using bs = "re"
smooth.
ANOVA table of class "anova" and "data.frame".
#with zooplankton data ga_anova(data = data_zooplankton, Y_value = "log(density_adj)", Fixed_Factor = "taxon", Smooth_Factor = "day")
#with zooplankton data ga_anova(data = data_zooplankton, Y_value = "log(density_adj)", Fixed_Factor = "taxon", Smooth_Factor = "day")
gam
)One of two functions for fitting generalised additive models (gam
) with the mgcv
package. It will use the gam()
function in mgcv
for ANOVA designs with up to two categorical fixed factors (with two or more levels; Fixed_Factor
), and exactly one factor is a continuous variable (e.g. time), which is called Smooth_Factor
.
A smooth function is fitted with factor-wise smooth basis function (by =
). A default value for number of nodes (the argument k
in gam
) may work, but a specific number can be provided using the Nodes
argument. The model is fit using the REML
method. When two categorical fixed factors are provided, an interaction term is included for main effects and smooth basis functions.
ga_model( data, Y_value, Fixed_Factor, Smooth_Factor, Random_Factor = NULL, Nodes = "NULL", ... )
ga_model( data, Y_value, Fixed_Factor, Smooth_Factor, Random_Factor = NULL, Nodes = "NULL", ... )
data |
a data frame where categorical independent variables are converted to factors using |
Y_value |
name of column containing quantitative (dependent) variable, provided within "quotes". |
Fixed_Factor |
name(s) of categorical fixed factors (independent variables) provided as a vector if more than one or within "quotes". Convert to factors first with |
Smooth_Factor |
the continuous variable to fit smoothly with a basis function, provided within "quotes" (only 1 Smooth_Factor allowed). |
Random_Factor |
name(s) of random factors to be provided in "quotes" (only 1 Random_Factor allowed). Convert to factor with |
Nodes |
number of nodes (the parameter |
... |
any additional variables to pass on to |
If a Random_Factor
is also provided, it is fitted using bs = "re"
smooth.
This function gives a generalised additive model object of class "gam", "lm" and "glm".
#fit a model with zooplankton data z1 <- ga_model(data = data_zooplankton, Y_value = "log(density_adj)", Fixed_Factor = "taxon", Smooth_Factor = "day")
#fit a model with zooplankton data z1 <- ga_model(data = data_zooplankton, Y_value = "log(density_adj)", Fixed_Factor = "taxon", Smooth_Factor = "day")
Function to make grafify colour scheme. Thank you Dr Simon.
get_graf_colours(...)
get_graf_colours(...)
... |
internal |
To visualise grafify colours use plot_grafify_palette
.
This function returns names and hexcodes of colours in grafify as a character vector.
grafify
palettes for scale & fill functionsgraf_col_palette
and graf_col_palette_default
functions generate colours for grafify
scale functions.
graf_col_palette
picks sequential colours when the number of discrete colours needed is less than that in the palette. This is the default for grafify
with ColoSeq = TRUE
. If the number of colours required is more than that in the discrete palette, it fills intervening colours using the colorRampPalette[grDevices]
function.
graf_col_palette(palette = "okabe_ito", reverse = FALSE, ...)
graf_col_palette(palette = "okabe_ito", reverse = FALSE, ...)
palette |
internal |
reverse |
internal |
... |
additional parameters |
graf_col_palette_default
picks the most distant colours within the palette, rather than in the sequence they are in the palette, when the number of colours required is less than that in the palette.
Colour order can be reversed in both functions.
When only one colour discreet is required, and you want to reverse
the colour palette, ColSeq
should be set to FALSE
.
This generates required number of sequential colours from the chosen grafify palette when called by scale functions of ggplot2.
grafify
palettes for scale & fill functionsgraf_col_palette
and graf_col_palette_default
functions generate colours for grafify
scale functions.
graf_col_palette
picks sequential colours when the number of discrete colours needed is less than that in the palette. This is the default for grafify
with ColoSeq = TRUE
. If the number of colours required is more than that in the discrete palette, it fills intervening colours using the colorRampPalette[grDevices]
function.
graf_col_palette_default(palette = "okabe_ito", reverse = FALSE, ...)
graf_col_palette_default(palette = "okabe_ito", reverse = FALSE, ...)
palette |
internal |
reverse |
internal |
... |
additional parameters |
graf_col_palette_default
picks the most distant colours within the palette, rather than in the sequence they are in the palette, when the number of colours required is less than that in the palette.
Colour order can be reversed in both functions.
When only one colour discreet is required, and you want to reverse
the colour palette, ColSeq
should be set to FALSE
.
This generates required number of distant colours from the chosen grafify palette when called by scale functions of ggplot2.
To visualise these colours use plot_grafify_palette
. okabe_ito
, bright
, contrast
, dark
, light
, muted
, pale
, vibrant
, yello_conti
from Paul Tol's post. Zesty, Pastel, Elegant from this link. Colour hexcodes for fishy
, kelly
, r4
, safe
, OrBl_div
, PrGn_div
, blue_conti
, grey_conti
taken from cols4all:c4a_gui package. All schemes are colour blind-friendly.
graf_colours
graf_colours
An object of class character
of length 154.
This is a character vector with names and hexcodes of colours used by palette functions. It is used by get_graf_colours
to generate palettes.
To visualise these colours use plot_grafify_palette
.
graf_palettes
graf_palettes
An object of class list
of length 18.
This function returns a list of palettes in grafify with names and hexcodes of colours in those palettes. Names of palettes available are as follows:
Categorical/discreet palettes:
okabe_ito
bright
contrast
dark
kelly
light
muted
pale
r4
safe
vibrant
Sequential quantitative palettes:
grey_conti
blue_conti
yellow_conti
Divergent quantitative palettes:
OrBl_div
PrGn_div
The make_1way_data
, make_1way_rb_data
, make_2way_data
and make_2way_rb_data
functions generate independent or randomised block (rb) design data of one-way or two-way designs.
make_1way_data(Group_means, Num_obs, Residual_SD)
make_1way_data(Group_means, Num_obs, Residual_SD)
Group_means |
a vector with means of each level of the first fixed factor (FixFac_X1) measured within Group 1. |
Num_obs |
a single numeric value indicating the number of independent measurements, i.e. levels within the random factor Experiment. |
Residual_SD |
a single numeric value indicating residual SD in the model. |
Random variates from the normal distribution based on user provided mean and SD provided are generated. For independent designs, the Residual_SD
argument is used to set expected residual SD from the linear model. Exp_SD is used to set experiment-to-experiment SD, that will be assigned to the random factor for rb designs.
Num_exp sets the number of independent measurements per group.
For one-way designs, the user provides Group_means as a vector. Number of levels are recognised based on number of means. For two-way designs, two vectors are to be provided by the user containing means of levels of a second factor. Number of means in both vectors should be the same. These functions can only handle balanced designs, i.e. same number of observations in all groups.
The output is a data frame with one or two columns denoting the fixed factor with levels that match the number of means entered. For rb data, the column for RandFac denotes levels of the blocking factor. The quantitative response variables are in the numeric Values column.
This function produces a data.frame
object containing simulated data.
#Basic usage with three levels within Factor_X, #20 observations in each group, with residual SD 15 one_independent_tab <- make_1way_data(c(350, 250, 100), 15, 20) str(one_independent_tab) head(one_independent_tab)
#Basic usage with three levels within Factor_X, #20 observations in each group, with residual SD 15 one_independent_tab <- make_1way_data(c(350, 250, 100), 15, 20) str(one_independent_tab) head(one_independent_tab)
The make_1way_data
, make_1way_rb_data
, make_2way_data
and make_2way_rb_data
functions generate independent or randomised block (rb) design data of one-way or two-way designs.
make_1way_rb_data(Group_means, Num_exp, Exp_SD, Residual_SD)
make_1way_rb_data(Group_means, Num_exp, Exp_SD, Residual_SD)
Group_means |
a vector with means of each level of the first fixed factor (FixFac_X1) measured within Group 1. |
Num_exp |
a single numeric value. indicating the number of independent measurements, i.e. levels within the random factor RandFac. |
Exp_SD |
a single numeric value indicating the standard deviation (SD) between experiments, i.e. within RandFac. |
Residual_SD |
a single numeric value indicating residual SD in the model. |
Random variates from the normal distribution based on user provided mean and SD provided are generated. For independent designs, the Residual_SD
argument is used to set expected residual SD from the linear model. Exp_SD is used to set experiment-to-experiment SD, that will be assigned to the random factor for rb designs.
Num_exp sets the number of independent measurements per group.
For one-way designs, the user provides Group_means as a vector. Number of levels are recognised based on number of means. For two-way designs, two vectors are to be provided by the user containing means of levels of a second factor. Number of means in both vectors should be the same. These functions can only handle balanced designs, i.e. same number of observations in all groups.
The output is a data frame with one or two columns denoting the fixed factor with levels that match the number of means entered. For rb data, the column for RandFac denotes levels of the blocking factor. The quantitative response variables are in the numeric Values column.
This function produces a data.frame
object containing simulated data.
#Basic usage with two levels within FactorX2, #20 experiments with inter-experiment SD 20, and residual SD 15 two_rb_tab <- make_2way_rb_data(c(100, 20), c(200, 300), 20, 20, 15) str(two_rb_tab) head(two_rb_tab)
#Basic usage with two levels within FactorX2, #20 experiments with inter-experiment SD 20, and residual SD 15 two_rb_tab <- make_2way_rb_data(c(100, 20), c(200, 300), 20, 20, 15) str(two_rb_tab) head(two_rb_tab)
The make_1way_data
, make_1way_rb_data
, make_2way_data
and make_2way_rb_data
functions generate independent or randomised block (rb) design data of one-way or two-way designs.
make_2way_data(Group_1_means, Group_2_means, Num_obs, Residual_SD)
make_2way_data(Group_1_means, Group_2_means, Num_obs, Residual_SD)
Group_1_means |
a vector with means of each level of the first fixed factor (FixFac_X1) measured within Group 1. |
Group_2_means |
only for |
Num_obs |
a single numeric value indicating the number of independent measurements, i.e. levels within the random factor Experiment. |
Residual_SD |
a single numeric value indicating residual SD in the model. |
Random variates from the normal distribution based on user provided mean and SD provided are generated. For independent designs, the Residual_SD
argument is used to set expected residual SD from the linear model. Exp_SD is used to set experiment-to-experiment SD, that will be assigned to the random factor for rb designs.
Num_obs sets the number of independent measurements per group.
For one-way designs, the user provides Group_means as a vector. Number of levels are recognised based on number of means. For two-way designs, two vectors are to be provided by the user containing means of levels of a second factor. Number of means in both vectors should be the same. These functions can only handle balanced designs, i.e. same number of observations in all groups.
The output is a data frame with one or two columns denoting the fixed factor with levels that match the number of means entered. For rb data, the column for RandFac denotes levels of the blocking factor. The quantitative response variables are in the numeric Values column.
This function produces a data.frame
object containing simulated data.
#Basic usage with two levels within FactorX2, 20 observations in each group, with residual SD 15 two_independent_tab <- make_2way_data(c(100, 20), c(200, 300), 20, 15) #Four levels with 5 observations and residual SD 5 two_independent_tab <- make_2way_data(c(100, 20, 1500, 20), c(150, 5, 1450, 25), 5, 5)
#Basic usage with two levels within FactorX2, 20 observations in each group, with residual SD 15 two_independent_tab <- make_2way_data(c(100, 20), c(200, 300), 20, 15) #Four levels with 5 observations and residual SD 5 two_independent_tab <- make_2way_data(c(100, 20, 1500, 20), c(150, 5, 1450, 25), 5, 5)
The make_1way_data
, make_1way_rb_data
, make_2way_data
and make_2way_rb_data
functions generate independent or randomised block (rb) design data of one-way or two-way designs.
make_2way_rb_data(Group1_means, Group2_means, Num_exp, Exp_SD, Residual_SD)
make_2way_rb_data(Group1_means, Group2_means, Num_exp, Exp_SD, Residual_SD)
Group1_means |
a vector with means of each level of the first fixed factor (FixFac_X1) measured within Group 1. |
Group2_means |
only for |
Num_exp |
a single numeric value indicating the number of independent measurements, i.e. levels within the random factor RandFac. |
Exp_SD |
a single numeric value indicating the standard deviation (SD) between experiment, i.e. within RandFac. |
Residual_SD |
a single numeric value indicating residual SD in the model. |
Random variates from the normal distribution based on user provided mean and SD provided are generated. For independent designs, the Residual_SD
argument is used to set expected residual SD from the linear model. Exp_SD is used to set experiment-to-experiment SD, that will be assigned to the random factor (RandFac) for rb designs.
Num_exp sets the number of independent measurements per group.
For one-way designs, the user provides Group_means as a vector. Number of levels are recognised based on number of means. For two-way designs, two vectors are to be provided by the user containing means of levels of a second factor. Number of means in both vectors should be the same. These functions can only handle balanced designs, i.e. same number of observations in all groups.
The output is a data frame with one or two columns denoting the fixed factor with levels that match the number of means entered. For rb data, the column for RandFac denotes levels of the blocking factor. The quantitative response variables are in the numeric Values column.
This function produces a data.frame
object containing simulated data.
#Basic usage with two levels within FactorX2, #20 experiments with inter-experiment SD 20, and residual SD 15 two_rb_tab <- make_2way_rb_data(c(100, 20), c(200, 300), 20, 20, 15) str(two_rb_tab) head(two_rb_tab)
#Basic usage with two levels within FactorX2, #20 experiments with inter-experiment SD 20, and residual SD 15 two_rb_tab <- make_2way_rb_data(c(100, 20), c(200, 300), 20, 20, 15) str(two_rb_tab) head(two_rb_tab)
One of four related functions for mixed effects analyses (based on lmer
and as_lmerModLmerTest
) to get a linear model for downstream steps, or an ANOVA table.
mixed_model
mixed_anova
mixed_model_slopes
mixed_anova_slopes
.
mixed_anova( data, Y_value, Fixed_Factor, Random_Factor, Df_method = "Kenward-Roger", SS_method = "II", ... )
mixed_anova( data, Y_value, Fixed_Factor, Random_Factor, Df_method = "Kenward-Roger", SS_method = "II", ... )
data |
a data table object, e.g. data.frame or tibble. |
Y_value |
name of column containing quantitative (dependent) variable, provided within "quotes". |
Fixed_Factor |
name(s) of categorical fixed factors (independent variables) provided as a vector if more than one or within "quotes". |
Random_Factor |
name(s) of random factors to allow random intercepts; to be provided as a vector when more than one or within "quotes". |
Df_method |
method for calculating degrees of freedom. Default is Kenward-Roger, can be changed to "Satterthwaite". |
SS_method |
type of sum of square, default is type II, can be changed to "I", "III", "1" or "2", or others. |
... |
any additional arguments to pass on to |
These functions require a data table, one dependent variable (Y_value), one or more independent variables (Fixed_Factor), and at least one random factor (Random_Factor). These should match names of variables in the long-format data table exactly.
Outputs of mixed_model
and mixed_model_slopes
can be used for post-hoc comparisons with posthoc_Pairwise
, posthoc_Levelwise
, posthoc_vsRef
, posthoc_Trends_Pairwise
, posthoc_Trends_Levelwise
and posthoc_Trends_vsRef
or with emmeans
.
More than one fixed factors can be provided as a vector (e.g. c("A", "B")). A full model with interaction term is fitted.
This means when Y_value = Y, Fixed_factor = c("A", "B"), Random_factor = "R"
are entered as arguments, these are passed on as Y ~ A*B + (1|R)
(which is equivalent to Y ~ A + B + A:B + (1|R)
).
In mixed_model_slopes
and mixed_anova_slopes
, the following kind of formula is used: Y ~ A*B + (S|R)
(which is equivalent to Y ~ A + B + A:B + (S|R)
).
In this experimental implementation, random slopes and intercepts are fitted ((Slopes_Factor|Random_Factor)
). Only one term each is allowed for Slopes_Factor
and Random_Factor
.
ANOVA table of class "anova" and "data.frame".
#Usage with one fixed (Student) and random factor (Experiment) mixed_anova(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student", Random_Factor = "Experiment") #two fixed factors provided as a vector mixed_anova(data = data_cholesterol, Y_value = "Cholesterol", Fixed_Factor = c("Treatment", "Hospital"), Random_Factor = "Subject")
#Usage with one fixed (Student) and random factor (Experiment) mixed_anova(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student", Random_Factor = "Experiment") #two fixed factors provided as a vector mixed_anova(data = data_cholesterol, Y_value = "Cholesterol", Fixed_Factor = c("Treatment", "Hospital"), Random_Factor = "Subject")
One of four related functions for mixed effects analyses (based on lmer
and as_lmerModLmerTest
) to get a linear model for downstream steps, or an ANOVA table.
mixed_model
mixed_anova
mixed_model_slopes
mixed_anova_slopes
.
mixed_anova_slopes( data, Y_value, Fixed_Factor, Slopes_Factor, Random_Factor, Df_method = "Kenward-Roger", SS_method = "II", ... )
mixed_anova_slopes( data, Y_value, Fixed_Factor, Slopes_Factor, Random_Factor, Df_method = "Kenward-Roger", SS_method = "II", ... )
data |
a data table object, e.g. data.frame or tibble. |
Y_value |
name of column containing quantitative (dependent) variable, provided within "quotes". |
Fixed_Factor |
name(s) of categorical fixed factors (independent variables) provided as a vector if more than one or within "quotes". |
Slopes_Factor |
name of factor to allow varying slopes on. |
Random_Factor |
name(s) of random factors to allow random intercepts; to be provided as a vector when more than one or within "quotes". |
Df_method |
method for calculating degrees of freedom. Default is Kenward-Roger, can be changed to "Satterthwaite". |
SS_method |
type of sum of square, default is type II, can be changed to "I", "III", "1" or "2", or others. |
... |
any additional arguments to pass on to |
These functions require a data table, one dependent variable (Y_value), one or more independent variables (Fixed_Factor), and at least one random factor (Random_Factor). These should match names of variables in the long-format data table exactly.
Outputs of mixed_model
and mixed_model_slopes
can be used for post-hoc comparisons with posthoc_Pairwise
, posthoc_Levelwise
, posthoc_vsRef
, posthoc_Trends_Pairwise
, posthoc_Trends_Levelwise
and posthoc_Trends_vsRef
or with emmeans
.
More than one fixed factors can be provided as a vector (e.g. c("A", "B")). A full model with interaction term is fitted.
This means when Y_value = Y, Fixed_factor = c("A", "B"), Random_factor = "R"
are entered as arguments, these are passed on as Y ~ A*B + (1|R)
(which is equivalent to Y ~ A + B + A:B + (1|R)
).
In mixed_model_slopes
and mixed_anova_slopes
, the following kind of formula is used: Y ~ A*B + (S|R)
(which is equivalent to Y ~ A + B + A:B + (S|R)
).
In this experimental implementation, random slopes and intercepts are fitted ((Slopes_Factor|Random_Factor)
). Only one term each is allowed for Slopes_Factor
and Random_Factor
.
ANOVA table of class "anova" and "data.frame".
mixed_anova_slopes(data = data_2w_Tdeath, Y_value = "PI", Fixed_Factor = c("Genotype", "Time"), Slopes_Factor = "Time", Random_Factor = "Experiment")
mixed_anova_slopes(data = data_2w_Tdeath, Y_value = "PI", Fixed_Factor = c("Genotype", "Time"), Slopes_Factor = "Time", Random_Factor = "Experiment")
One of four related functions for mixed effects analyses (based on lmer
and as_lmerModLmerTest
) to get a linear model for downstream steps, or an ANOVA table.
mixed_model
mixed_anova
mixed_model_slopes
mixed_anova_slopes
.
mixed_model(data, Y_value, Fixed_Factor, Random_Factor, ...)
mixed_model(data, Y_value, Fixed_Factor, Random_Factor, ...)
data |
a data table object, e.g. data.frame or tibble. |
Y_value |
name of column containing quantitative (dependent) variable, provided within "quotes". |
Fixed_Factor |
name(s) of categorical fixed factors (independent variables) provided as a vector if more than one or within "quotes". |
Random_Factor |
name(s) of random factors to allow random intercepts; to be provided as a vector when more than one or within "quotes". |
... |
any additional arguments to pass on to |
These functions require a data table, one dependent variable (Y_value), one or more independent variables (Fixed_Factor), and at least one random factor (Random_Factor). These should match names of variables in the long-format data table exactly.
Outputs of mixed_model
and mixed_model_slopes
can be used for post-hoc comparisons with posthoc_Pairwise
, posthoc_Levelwise
, posthoc_vsRef
, posthoc_Trends_Pairwise
, posthoc_Trends_Levelwise
and posthoc_Trends_vsRef
or with emmeans
.
More than one fixed factors can be provided as a vector (e.g. c("A", "B")). A full model with interaction term is fitted.
This means when Y_value = Y, Fixed_factor = c("A", "B"), Random_factor = "R"
are entered as arguments, these are passed on as Y ~ A*B + (1|R)
(which is equivalent to Y ~ A + B + A:B + (1|R)
).
In mixed_model_slopes
and mixed_anova_slopes
, the following kind of formula is used: Y ~ A*B + (S|R)
(which is equivalent to Y ~ A + B + A:B + (S|R)
).
In this experimental implementation, random slopes and intercepts are fitted ((Slopes_Factor|Random_Factor)
). Only one term each is allowed for Slopes_Factor
and Random_Factor
.
This function returns an S4 object of class "lmerModLmerTest".
#one fixed factor and random factor mixed_model(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student", Random_Factor = "Experiment") #two fixed factors as a vector, one random factor mixed_model(data = data_cholesterol, Y_value = "Cholesterol", Fixed_Factor = c("Treatment", "Hospital"), Random_Factor = "Subject") #save model model <- mixed_model(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student", Random_Factor = "Experiment") #get model summary summary(model)
#one fixed factor and random factor mixed_model(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student", Random_Factor = "Experiment") #two fixed factors as a vector, one random factor mixed_model(data = data_cholesterol, Y_value = "Cholesterol", Fixed_Factor = c("Treatment", "Hospital"), Random_Factor = "Subject") #save model model <- mixed_model(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student", Random_Factor = "Experiment") #get model summary summary(model)
One of four related functions for mixed effects analyses (based on lmer
and as_lmerModLmerTest
) to get a linear model for downstream steps, or an ANOVA table.
mixed_model
mixed_anova
mixed_model_slopes
mixed_anova_slopes
.
mixed_model_slopes( data, Y_value, Fixed_Factor, Slopes_Factor, Random_Factor, ... )
mixed_model_slopes( data, Y_value, Fixed_Factor, Slopes_Factor, Random_Factor, ... )
data |
a data table object, e.g. data.frame or tibble. |
Y_value |
name of column containing quantitative (dependent) variable, provided within "quotes". |
Fixed_Factor |
name(s) of categorical fixed factors (independent variables) provided as a vector if more than one or within "quotes". |
Slopes_Factor |
name of factor to allow varying slopes on. |
Random_Factor |
name(s) of random factors to allow random intercepts; to be provided as a vector when more than one or within "quotes". |
... |
any additional arguments to pass on to |
These functions require a data table, one dependent variable (Y_value), one or more independent variables (Fixed_Factor), and at least one random factor (Random_Factor). These should match names of variables in the long-format data table exactly.
Outputs of mixed_model
and mixed_model_slopes
can be used for post-hoc comparisons with posthoc_Pairwise
, posthoc_Levelwise
, posthoc_vsRef
, posthoc_Trends_Pairwise
, posthoc_Trends_Levelwise
and posthoc_Trends_vsRef
or with emmeans
.
More than one fixed factors can be provided as a vector (e.g. c("A", "B")). A full model with interaction term is fitted.
This means when Y_value = Y, Fixed_factor = c("A", "B"), Random_factor = "R"
are entered as arguments, these are passed on as Y ~ A*B + (1|R)
(which is equivalent to Y ~ A + B + A:B + (1|R)
).
In mixed_model_slopes
and mixed_anova_slopes
, the following kind of formula is used: Y ~ A*B + (S|R)
(which is equivalent to Y ~ A + B + A:B + (S|R)
).
In this experimental implementation, random slopes and intercepts are fitted ((Slopes_Factor|Random_Factor)
). Only one term each is allowed for Slopes_Factor
and Random_Factor
.
This function returns an S4 object of class "lmerModLmerTest".
#two fixed factors as a vector, #exactly one slope factor and random factor mod <- mixed_model_slopes(data = data_2w_Tdeath, Y_value = "PI", Fixed_Factor = c("Genotype", "Time"), Slopes_Factor = "Time", Random_Factor = "Experiment") #get summary summary(mod)
#two fixed factors as a vector, #exactly one slope factor and random factor mod <- mixed_model_slopes(data = data_2w_Tdeath, Y_value = "PI", Fixed_Factor = c("Genotype", "Time"), Slopes_Factor = "Time", Random_Factor = "Experiment") #get summary summary(mod)
One of 4 related functions for plotting 1-way ANOVA designs with a blocking factor.
plot_3d_point_sd
(mean & SD, SEM or CI95 error bars)
plot_3d_scatterbar
(bar & SD, SEM or CI95 error bars)
plot_3d_scatterbox
(box & whiskers)
plot_3d_scatterviolin
(box & whiskers, violin)
plot_3d_point_sd( data, xcol, ycol, shapes, facet, ErrorType = "SD", symsize = 3.5, s_alpha = 1, symshape = 22, all_alpha = 0.3, all_size = 2.5, all_shape = 0, all_jitter = 0, ewid = 0.2, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, ethick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_3d_point_sd( data, xcol, ycol, shapes, facet, ErrorType = "SD", symsize = 3.5, s_alpha = 1, symshape = 22, all_alpha = 0.3, all_size = 2.5, all_shape = 0, all_jitter = 0, ewid = 0.2, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, ethick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table, e.g. data.frame or tibble. |
xcol |
name of the column with the categorical factor to be plotted on X axis. |
ycol |
name of the column with quantitative variable to plot on the Y axis. |
shapes |
name of the column with the blocking factor or another categorical variable. |
facet |
add another variable from the data table to create faceted graphs using |
ErrorType |
select the type of error bars to display. Default is "SD" (standard deviation). Other options are "SEM" (standard error of the mean) and "CI95" (95% confidence interval based on t distributions). |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 0.8 (i.e. 80% opacity). Set |
symshape |
The mean is shown with symbol of the shape number 21 (default, filled circle). Pick a number between 0-25 to pick a different type of symbol from ggplot2. |
all_alpha |
fractional opacity of all data points (default = 0.3). Set to non-zero value if you would like all data points plotted in addition to the mean. |
all_size |
size of symbols of all data points, if shown (default = 2.5). |
all_shape |
all data points are shown with symbols of the shape number 0 (default, open square). Pick a number between 0-25 to pick a different type of symbol from ggplot2. |
all_jitter |
reduce overlap of all data points, if shown, by setting a value between 0-1 (default = 0). |
ewid |
width of error bars, default set to 0.2. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
ethick |
thickness of error bar lines; default |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass. |
The blocking factor (or any other categorical variable) can be mapped to the shapes
argument (up to 25 levels allowed). Variables passed to xcol
and shapes
are internally converted to factors even if they are numeric or other type of variables.
In plot_3d_point_sd
and plot_3d_scatterbar
, the default error bar is SD (can be changed to SEM or CI95). In plot_3d_point_sd
, a large coloured symbol is plotted at the mean, all other data are shown as smaller symbols. Boxplot uses geom_boxplot
to depict median (thicker line), box (interquartile range (IQR)) and the whiskers (1.5*IQR).
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
(logical TRUE/FALSE) decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
The resulting ggplot2
graph can take additional geometries or other layers.
This function returns a ggplot2
object of class "gg" and "ggplot".
#3d version for 1-way data with blocking #use plot_point_sd when no a blocking factor is not used plot_3d_point_sd(data = data_1w_death, xcol = Genotype, ycol = Death, shapes = Experiment)
#3d version for 1-way data with blocking #use plot_point_sd when no a blocking factor is not used plot_3d_point_sd(data = data_1w_death, xcol = Genotype, ycol = Death, shapes = Experiment)
One of 4 related functions for plotting 1-way ANOVA designs with a blocking factor.
plot_3d_point_sd
(mean & SD, SEM or CI95 error bars)
plot_3d_scatterbar
(bar & SD, SEM or CI95 error bars)
plot_3d_scatterbox
(box & whiskers)
plot_3d_scatterviolin
(box & whiskers, violin)
plot_3d_scatterbar( data, xcol, ycol, shapes, facet, ErrorType = "SD", symsize = 3, s_alpha = 0.8, b_alpha = 1, jitter = 0.1, ewid = 0.2, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_3d_scatterbar( data, xcol, ycol, shapes, facet, ErrorType = "SD", symsize = 3, s_alpha = 0.8, b_alpha = 1, jitter = 0.1, ewid = 0.2, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table, e.g. data.frame or tibble. |
xcol |
name of the column with the categorical factor to be plotted on X axis. |
ycol |
name of the column with quantitative variable to plot on the Y axis. |
shapes |
name of the column with the second categorical factor, for example from a two-way ANOVA design. |
facet |
add another variable from the data table to create faceted graphs using |
ErrorType |
select the type of error bars to display. Default is "SD" (standard deviation). Other options are "SEM" (standard error of the mean) and "CI95" (95% confidence interval based on t distributions). |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 0.8 (i.e. 80% opacity). Set |
b_alpha |
fractional opacity of boxes. Default is set to 0, which results in white boxes inside violins. Change to any value >0 up to 1 for different levels of transparency. |
jitter |
extent of jitter (scatter) of symbols, default is 0.1. Increase to reduce symbol overlap, set to 0 for aligned symbols. |
ewid |
width of error bars, default set to 0.2. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
thickness (in 'pt' units) of lines of boxes; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass. |
The blocking factor (or any other categorical variable) can be mapped to the shapes
argument (up to 25 levels allowed). Variables passed to xcol
and shapes
are internally converted to factors even if they are numeric or other type of variables.
In plot_3d_point_sd
and plot_3d_scatterbar
, the default error bar is SD (can be changed to SEM or CI95). In plot_3d_point_sd
, a large coloured symbol is plotted at the mean, all other data are shown as smaller symbols. Boxplot uses geom_boxplot
to depict median (thicker line), box (interquartile range (IQR)) and the whiskers (1.5*IQR).
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
(logical TRUE/FALSE) decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
The resulting ggplot2
graph can take additional geometries or other layers.
This function returns a ggplot2
object of class "gg" and "ggplot".
#3d version for 1-way data with blocking #use plot_scatterbar_sd without blocking factor plot_3d_scatterbar(data = data_1w_death, xcol = Genotype, ycol = Death, shapes = Experiment)
#3d version for 1-way data with blocking #use plot_scatterbar_sd without blocking factor plot_3d_scatterbar(data = data_1w_death, xcol = Genotype, ycol = Death, shapes = Experiment)
One of 4 related functions for plotting 1-way ANOVA designs with a blocking factor.
plot_3d_point_sd
(mean & SD, SEM or CI95 error bars)
plot_3d_scatterbar
(bar & SD, SEM or CI95 error bars)
plot_3d_scatterbox
(box & whiskers)
plot_3d_scatterviolin
(box & whiskers, violin)
plot_3d_scatterbox( data, xcol, ycol, shapes, facet, symsize = 3, s_alpha = 0.8, b_alpha = 1, bwid = 0.5, jitter = 0.1, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_3d_scatterbox( data, xcol, ycol, shapes, facet, symsize = 3, s_alpha = 0.8, b_alpha = 1, bwid = 0.5, jitter = 0.1, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table, e.g. data.frame or tibble. |
xcol |
name of the column with the categorical factor to be plotted on X axis. If your table has numeric X, enter |
ycol |
name of the column with quantitative variable to plot on the Y axis. |
shapes |
name of the column with the second categorical factor in a two-way ANOVA design. |
facet |
add another variable from the data table to create faceted graphs using |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 0.8 (i.e. 80% opacity). Set |
b_alpha |
fractional opacity of boxes. Default is set to 0, which results in white boxes inside violins. Change to any value >0 up to 1 for different levels of transparency. |
bwid |
width of boxes; default 0.5. |
jitter |
extent of jitter (scatter) of symbols, default is 0.1. Increase to reduce symbol overlap, set to 0 for aligned symbols. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
thickness (in 'pt' units) of lines of boxes; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
The blocking factor (or any other categorical variable) can be mapped to the shapes
argument (up to 25 levels allowed). Variables passed to xcol
and shapes
are internally converted to factors even if they are numeric or other type of variables.
In plot_3d_point_sd
and plot_3d_scatterbar
, the default error bar is SD (can be changed to SEM or CI95). In plot_3d_point_sd
, a large coloured symbol is plotted at the mean, all other data are shown as smaller symbols. Boxplot uses geom_boxplot
to depict median (thicker line), box (interquartile range (IQR)) and the whiskers (1.5*IQR).
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
(logical TRUE/FALSE) decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
The resulting ggplot2
graph can take additional geometries or other layers.
This function returns a ggplot2
object of class "gg" and "ggplot".
#3d version for 1-way data with blocking plot_3d_scatterbox(data = data_1w_death, xcol = Genotype, ycol = Death, shapes = Experiment) #use plot_scatterbox without a blocking factor
#3d version for 1-way data with blocking plot_3d_scatterbox(data = data_1w_death, xcol = Genotype, ycol = Death, shapes = Experiment) #use plot_scatterbox without a blocking factor
One of 4 related functions for plotting 1-way ANOVA designs with a blocking factor.
plot_3d_point_sd
(mean & SD, SEM or CI95 error bars)
plot_3d_scatterbar
(bar & SD, SEM or CI95 error bars)
plot_3d_scatterbox
(box & whiskers)
plot_3d_scatterviolin
(box & whiskers, violin)
plot_3d_scatterviolin( data, xcol, ycol, shapes, facet, symsize = 3, s_alpha = 0.8, b_alpha = 0, v_alpha = 1, bwid = 0.3, vadjust = 1, jitter = 0.1, TextXAngle = 0, scale = "width", trim = TRUE, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, vthick, bvthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_3d_scatterviolin( data, xcol, ycol, shapes, facet, symsize = 3, s_alpha = 0.8, b_alpha = 0, v_alpha = 1, bwid = 0.3, vadjust = 1, jitter = 0.1, TextXAngle = 0, scale = "width", trim = TRUE, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, vthick, bvthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table, e.g. data.frame or tibble. |
xcol |
name of the column with the categorical factor to be plotted on X axis. If your table has numeric X, enter |
ycol |
name of the column with quantitative variable to plot on the Y axis. |
shapes |
name of the column with the second categorical factor in a two-way ANOVA design. |
facet |
add another variable from the data table to create faceted graphs using |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 0.8 (i.e. 80% opacity). Set |
b_alpha |
fractional opacity of boxes. Default is set to 0, which results in white boxes inside violins. Change to any value >0 up to 1 for different levels of transparency. |
v_alpha |
fractional opacity of violins, default set to 1. |
bwid |
width of boxes (default 0.3). |
vadjust |
number to adjust the smooth/wigglyness of violin plot (default is 1). |
jitter |
extent of jitter (scatter) of symbols, default is 0.1. Increase to reduce symbol overlap, set to 0 for aligned symbols. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
scale |
set to "area" by default, can be changed to "count" or "width". |
trim |
set whether tips of violin plot should be trimmed at high/low data. Default |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
thickness (in 'pt' units) of boxplots; default = |
vthick |
thickness (in 'pt' units) of violins; default = |
bvthick |
thickness (in 'pt' units) of both violins and boxplots; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
The blocking factor (or any other categorical variable) can be mapped to the shapes
argument (up to 25 levels allowed). Variables passed to xcol
and shapes
are internally converted to factors even if they are numeric or other type of variables.
In plot_3d_point_sd
and plot_3d_scatterbar
, the default error bar is SD (can be changed to SEM or CI95). In plot_3d_point_sd
, a large coloured symbol is plotted at the mean, all other data are shown as smaller symbols. Boxplot uses geom_boxplot
to depict median (thicker line), box (interquartile range (IQR)) and the whiskers (1.5*IQR).
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
(logical TRUE/FALSE) decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
The resulting ggplot2
graph can take additional geometries or other layers.
This function returns a ggplot2
object of class "gg" and "ggplot".
#3d version for 1-way data with blocking plot_3d_scatterviolin(data = data_1w_death, xcol = Genotype, ycol = Death, shapes = Experiment) #use plot_scatterviolin without a blocking factor
#3d version for 1-way data with blocking plot_3d_scatterviolin(data = data_1w_death, xcol = Genotype, ycol = Death, shapes = Experiment) #use plot_scatterviolin without a blocking factor
There are 4 related functions for 2-way ANOVA type plots. In addition to a categorical variable along the X-axis, a grouping factor is passed to either points
, bars
or boxes
argument in these functions. A blocking factor (or any other categorical variable) can be optionally passed to the shapes
argument.
plot_4d_point_sd
(mean & SD, SEM or CI95 error bars)
plot_4d_scatterbar
(bar & SD, SEM or CI95 error bars)
plot_4d_scatterbox
(box & whiskers)
plot_4d_scatterviolin
(box & whiskers, violin)
plot_4d_point_sd( data, xcol, ycol, points, shapes, facet, ErrorType = "SD", symsize = 3.5, s_alpha = 1, symshape = 22, all_alpha = 0.3, all_size = 2.5, all_shape = 0, all_jitter = 0, ewid = 0.2, group_wid = 0.8, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, ethick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, ... )
plot_4d_point_sd( data, xcol, ycol, points, shapes, facet, ErrorType = "SD", symsize = 3.5, s_alpha = 1, symshape = 22, all_alpha = 0.3, all_size = 2.5, all_shape = 0, all_jitter = 0, ewid = 0.2, group_wid = 0.8, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, ethick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, ... )
data |
a data table, e.g. data.frame or tibble. |
xcol |
name of the column with the variable to plot on X axis (will be converted to a factor/categorical variable). |
ycol |
name of the column to plot on quantitative variable on the Y axis. |
points |
name of the column with grouping within the factor plotted on X-axis (will be converted to a factor/categorical variable). |
shapes |
name of the column that contains matched observations (e.g. subject IDs, experiment number) or another variable to pass on to symbol shapes (will be converted to a factor/categorical variable). If not provided, the shapes for all groups is the same, and can be changed with |
facet |
add another variable from the data table to create faceted graphs using |
ErrorType |
select the type of error bars to display. Default is "SD" (standard deviation). Other options are "SEM" (standard error of the mean) and "CI95" (95% confidence interval based on t distributions). |
symsize |
size of symbols, default set to 3.5. |
s_alpha |
fractional opacity of symbols, default set to 1 (i.e. fully opaque). |
symshape |
The mean is shown with symbol of the shape number 21 (default, filled circle). Pick a number between 0-25 to pick a different type of symbol from ggplot2. |
all_alpha |
fractional opacity of all data points (default = 0.3). |
all_size |
size of symbols of all data points, if shown (default = 2.5). |
all_shape |
all data points are shown with symbols of the shape number 0 (default, open square). Pick a number between 0-25 to pick a different type of symbol from ggplot2. This argument only has an effect if |
all_jitter |
reduce overlap of all data points, if shown, by setting a value between 0-1 (default = 0). |
ewid |
width of error bars, default set to 0.2. |
group_wid |
space between the factors along X-axis, i.e., dodge width. Default |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
ethick |
thickness of error bar lines; default |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
... |
any additional arguments to pass to |
These can be especially useful when the fourth variable shapes
is a random factor or blocking factor (up to 25 levels are allowed; there will be an error with more levels). The shapes
argument can be left blank to plot ordinary 2-way ANOVAs without blocking.
In plot_4d_point_sd
and plot_4d_scatterbar
, the default error bar is SD (can be changed to SEM or CI95). In plot_4d_point_sd
, a large coloured symbol is plotted at the mean, all other data are shown as smaller symbols. Boxplot uses geom_boxplot
to depict median (thicker line), box (interquartile range (IQR)) and the whiskers (1.5*IQR).
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
(logical TRUE/FALSE) decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
The resulting ggplot2
graph can take additional geometries or other layers.
This function returns a ggplot2
object of class "gg" and "ggplot".
#4d version for 2-way data with blocking plot_4d_point_sd(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, points = Time, shapes = Experiment) #4d version without blocking factor #`shapes` can be left blank plot_4d_point_sd(data = data_2w_Festing, xcol = Strain, ycol = GST, points = Treatment)
#4d version for 2-way data with blocking plot_4d_point_sd(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, points = Time, shapes = Experiment) #4d version without blocking factor #`shapes` can be left blank plot_4d_point_sd(data = data_2w_Festing, xcol = Strain, ycol = GST, points = Treatment)
There are 4 related functions for 2-way ANOVA type plots. In addition to a categorical variable along the X-axis, a grouping factor is passed to either points
, bars
or boxes
argument in these functions. A blocking factor (or any other categorical variable) can be optionally passed to the shapes
argument.
plot_4d_point_sd
(mean & SD, SEM or CI95 error bars)
plot_4d_scatterbar
(bar & SD, SEM or CI95 error bars)
plot_4d_scatterbox
(box & whiskers)
plot_4d_scatterviolin
(box & whiskers, violin)
plot_4d_scatterbar( data, xcol, ycol, bars, shapes, facet, ErrorType = "SD", symsize = 3, s_alpha = 0.8, b_alpha = 1, bwid = 0.7, jitter = 0.1, ewid = 0.2, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, group_wid = 0.8, symthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColRev = FALSE, ColSeq = TRUE, ... )
plot_4d_scatterbar( data, xcol, ycol, bars, shapes, facet, ErrorType = "SD", symsize = 3, s_alpha = 0.8, b_alpha = 1, bwid = 0.7, jitter = 0.1, ewid = 0.2, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, group_wid = 0.8, symthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColRev = FALSE, ColSeq = TRUE, ... )
data |
a data table, e.g. data.frame or tibble. |
xcol |
name of the column with the categorical factor to plot on X axis. If column is numeric, enter as |
ycol |
name of the column to plot on quantitative variable on the Y axis. |
bars |
name of the column containing grouping within the factor plotted on X axis. Can be categorical or numeric X. If your table has numeric X and you want to plot as factor, enter |
shapes |
name of the column that contains matched observations (e.g. subject IDs, experiment number) or another variable to pass on to symbol shapes. If not provided, the shapes for all groups is the same. |
facet |
add another variable from the data table to create faceted graphs using |
ErrorType |
select the type of error bars to display. Default is "SD" (standard deviation). Other options are "SEM" (standard error of the mean) and "CI95" (95% confidence interval based on t distributions). |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 0.8 (i.e. 80% opacity). Set |
b_alpha |
fractional opacity of boxes. Default is set to 0, which results in white boxes inside violins. Change to any value >0 up to 1 for different levels of transparency. |
bwid |
width of boxes; default 0.7. |
jitter |
extent of jitter (scatter) of symbols, default is 0.1. Increase to reduce symbol overlap, set to 0 for aligned symbols. |
ewid |
width of error bars, default set to 0.2. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
group_wid |
space between the factors along X-axis, i.e., dodge width. Default |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
thickness (in 'pt' units) of bar and error bar lines; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
... |
any additional arguments to pass to |
These can be especially useful when the fourth variable shapes
is a random factor or blocking factor (up to 25 levels are allowed; there will be an error with more levels). The shapes
argument can be left blank to plot ordinary 2-way ANOVAs without blocking.
In plot_4d_point_sd
and plot_4d_scatterbar
, the default error bar is SD (can be changed to SEM or CI95). In plot_4d_point_sd
, a large coloured symbol is plotted at the mean, all other data are shown as smaller symbols. Boxplot uses geom_boxplot
to depict median (thicker line), box (interquartile range (IQR)) and the whiskers (1.5*IQR).
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
(logical TRUE/FALSE) decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
The resulting ggplot2
graph can take additional geometries or other layers.
This function returns a ggplot2
object of class "gg" and "ggplot".
#4d version for 2-way data with blocking plot_4d_scatterbar(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, bars = Time, shapes = Experiment) #4d version without blocking factor #`shapes` can be left blank plot_4d_scatterbar(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, bars = Time)
#4d version for 2-way data with blocking plot_4d_scatterbar(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, bars = Time, shapes = Experiment) #4d version without blocking factor #`shapes` can be left blank plot_4d_scatterbar(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, bars = Time)
There are 4 related functions for 2-way ANOVA type plots. In addition to a categorical variable along the X-axis, a grouping factor is passed to either points
, bars
or boxes
argument in these functions. A blocking factor (or any other categorical variable) can be optionally passed to the shapes
argument.
plot_4d_point_sd
(mean & SD, SEM or CI95 error bars)
plot_4d_scatterbar
(bar & SD, SEM or CI95 error bars)
plot_4d_scatterbox
(box & whiskers)
plot_4d_scatterviolin
(box & whiskers, violin)
plot_4d_scatterbox( data, xcol, ycol, boxes, shapes, facet, symsize = 3, s_alpha = 0.8, b_alpha = 1, bwid = 0.7, jitter = 0.1, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, group_wid = 0.8, symthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, ... )
plot_4d_scatterbox( data, xcol, ycol, boxes, shapes, facet, symsize = 3, s_alpha = 0.8, b_alpha = 1, bwid = 0.7, jitter = 0.1, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, group_wid = 0.8, symthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, ... )
data |
a data table, e.g. data.frame or tibble. |
xcol |
name of the column with the categorical factor to plot on X axis. If column is numeric, enter as |
ycol |
name of the column to plot on quantitative variable on the Y axis. |
boxes |
name of the column containing grouping within the factor plotted on X axis. Can be categorical or numeric X. If your table has numeric X and you want to plot as factor, enter |
shapes |
name of the column that contains matched observations (e.g. subject IDs, experiment number) or another variable to pass on to symbol shapes. If not provided, the shapes for all groups is the same. |
facet |
add another variable from the data table to create faceted graphs using |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 0.8 (i.e. 80% opacity). Set |
b_alpha |
fractional opacity of boxes. Default is set to 0, which results in white boxes inside violins. Change to any value >0 up to 1 for different levels of transparency. |
bwid |
width of boxes; default 0.7. |
jitter |
extent of jitter (scatter) of symbols, default is 0.1. Increase to reduce symbol overlap, set to 0 for aligned symbols. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
group_wid |
space between the factors along X-axis, i.e., dodge width. Default |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
thickness (in 'pt' units) of boxplot lines; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
... |
any additional arguments to pass to |
These can be especially useful when the fourth variable shapes
is a random factor or blocking factor (up to 25 levels are allowed; there will be an error with more levels). The shapes
argument can be left blank to plot ordinary 2-way ANOVAs without blocking.
In plot_4d_point_sd
and plot_4d_scatterbar
, the default error bar is SD (can be changed to SEM or CI95). In plot_4d_point_sd
, a large coloured symbol is plotted at the mean, all other data are shown as smaller symbols. Boxplot uses geom_boxplot
to depict median (thicker line), box (interquartile range (IQR)) and the whiskers (1.5*IQR).
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
(logical TRUE/FALSE) decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
The resulting ggplot2
graph can take additional geometries or other layers.
This function returns a ggplot2
object of class "gg" and "ggplot".
#4d version for 2-way data with blocking plot_4d_scatterbox(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, boxes = Time, shapes = Experiment) #4d version without blocking factor #`shapes` can be left blank plot_4d_scatterbox(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, boxes = Time)
#4d version for 2-way data with blocking plot_4d_scatterbox(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, boxes = Time, shapes = Experiment) #4d version without blocking factor #`shapes` can be left blank plot_4d_scatterbox(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, boxes = Time)
There are 4 related functions for 2-way ANOVA type plots. In addition to a categorical variable along the X-axis, a grouping factor is passed to either points
, bars
or boxes
argument in these functions. A blocking factor (or any other categorical variable) can be optionally passed to the shapes
argument.
plot_4d_point_sd
(mean & SD, SEM or CI95 error bars)
plot_4d_scatterbar
(bar & SD, SEM or CI95 error bars)
plot_4d_scatterbox
(box & whiskers)
plot_4d_scatterviolin
(box & whiskers, violin)
plot_4d_scatterviolin( data, xcol, ycol, boxes, shapes, facet, symsize = 3, s_alpha = 0.8, v_alpha = 1, b_alpha = 0, bwid = 0.3, vadjust = 1, jitter = 0.1, TextXAngle = 0, scale = "width", trim = TRUE, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, group_wid = 0.8, symthick, bthick, vthick, bvthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, ... )
plot_4d_scatterviolin( data, xcol, ycol, boxes, shapes, facet, symsize = 3, s_alpha = 0.8, v_alpha = 1, b_alpha = 0, bwid = 0.3, vadjust = 1, jitter = 0.1, TextXAngle = 0, scale = "width", trim = TRUE, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, group_wid = 0.8, symthick, bthick, vthick, bvthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, ... )
data |
a data table, e.g. data.frame or tibble. |
xcol |
name of the column with the categorical factor to plot on X axis. If column is numeric, enter as |
ycol |
name of the column to plot on quantitative variable on the Y axis. |
boxes |
name of the column containing grouping within the factor plotted on X axis. Can be categorical or numeric X. If your table has numeric X and you want to plot as factor, enter |
shapes |
name of the column that contains matched observations (e.g. subject IDs, experiment number) or another variable to pass on to symbol shapes. If not provided, the shapes for all groups is the same. |
facet |
add another variable from the data table to create faceted graphs using |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 0.8 (i.e. 80% opacity). Set |
v_alpha |
fractional opacity of violins, default set to 1. |
b_alpha |
fractional opacity of boxes. Default is set to 0, which results in white boxes inside violins. Change to any value >0 up to 1 for different levels of transparency. |
bwid |
width of boxes; default 0.3. |
vadjust |
number to adjust the smooth/wigglyness of violin plot (default set to 1). |
jitter |
extent of jitter (scatter) of symbols, default is 0.1. Increase to reduce symbol overlap, set to 0 for aligned symbols. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
scale |
set to "area" by default, can be changed to "count" or "width". |
trim |
set whether tips of violin plot should be trimmed at high/low data. Default |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
group_wid |
space between the factors along X-axis, i.e., dodge width. Default |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
thickness (in 'pt' units) of boxplots; default = |
vthick |
thickness (in 'pt' units) of violins; default = |
bvthick |
thickness (in 'pt' units) of both violins and boxplots; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
... |
any additional arguments to pass to |
These can be especially useful when the fourth variable shapes
is a random factor or blocking factor (up to 25 levels are allowed; there will be an error with more levels). The shapes
argument can be left blank to plot ordinary 2-way ANOVAs without blocking.
In plot_4d_point_sd
and plot_4d_scatterbar
, the default error bar is SD (can be changed to SEM or CI95). In plot_4d_point_sd
, a large coloured symbol is plotted at the mean, all other data are shown as smaller symbols. Boxplot uses geom_boxplot
to depict median (thicker line), box (interquartile range (IQR)) and the whiskers (1.5*IQR).
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
(logical TRUE/FALSE) decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
The resulting ggplot2
graph can take additional geometries or other layers.
This function returns a ggplot2
object of class "gg" and "ggplot".
#4d version for 2-way data with blocking plot_4d_scatterviolin(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, boxes = Time, shapes = Experiment) #4d version without blocking factor #`shapes` can be left blank plot_4d_scatterviolin(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, boxes = Time)
#4d version for 2-way data with blocking plot_4d_scatterviolin(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, boxes = Time, shapes = Experiment) #4d version without blocking factor #`shapes` can be left blank plot_4d_scatterviolin(data = data_2w_Tdeath, xcol = Genotype, ycol = PI, boxes = Time)
One of 3 related functions to plot matching data joined by lines. The variable containing information for matching (e.g. matched subjects or experiments etc.) is passed to the match
argument.
plot_befafter_box( data, xcol, ycol, match, facet, PlotShapes = FALSE, symsize = 3, s_alpha = 0.8, b_alpha = 1, bwid = 0.4, jitter = 0.1, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, lthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_befafter_box( data, xcol, ycol, match, facet, PlotShapes = FALSE, symsize = 3, s_alpha = 0.8, b_alpha = 1, bwid = 0.4, jitter = 0.1, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, lthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table object, e.g. data.frame or tibble. |
xcol |
name of the column containing the categorical variable to be plotted on the X axis. |
ycol |
name of the column containing the quantitative Y values. |
match |
name of the column with the grouping variable to pass on to |
facet |
add another variable from the data table to create faceted graphs using |
PlotShapes |
logical TRUE or FALSE (default = FALSE) if the shape of the symbol is to be mapped to the |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 0.8 (i.e., 80% opacity). |
b_alpha |
fractional opacity of boxes, default set to 1. |
bwid |
width of boxplots; default 0.4. |
jitter |
extent of jitter (scatter) of symbols, default is 0.1. Increase to reduce symbol overlap, set to 0 for aligned symbols. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
thickness (in 'pt' units) of boxes; default = |
lthick |
thickness (in 'pt' units) of lines; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
In plot_befafter_colours
/plot_befafter_colors
and plot_befafter_shapes
setting Boxplot = TRUE
will also plot a box and whiskers plot.
Note that only 25 shapes are available, and there will be errors with plot_befafter_shapes
when there are fewer than 25 matched observations; instead use plot_befafter_colours
instead.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
To plot a graph with a single colour along the X axis variable, use the SingleColour
argument.
The resulting ggplot2
graph can take additional geometries or other layers.
This function returns a ggplot2
object of class "gg" and "ggplot".
plot_befafter_box(data = data_t_pdiff, xcol = Condition, ycol = Mass, match = Subject) #with PlotShapes = TRUE plot_befafter_box(data = data_t_pdiff, xcol = Condition, ycol = Mass, match = Subject, PlotShapes = TRUE)
plot_befafter_box(data = data_t_pdiff, xcol = Condition, ycol = Mass, match = Subject) #with PlotShapes = TRUE plot_befafter_box(data = data_t_pdiff, xcol = Condition, ycol = Mass, match = Subject, PlotShapes = TRUE)
One of 3 related functions to plot matching data joined by lines. The variable containing information for matching (e.g. matched subjects or experiments etc.) is passed to the match
argument.
plot_befafter_colours( data, xcol, ycol, match, facet, Boxplot = FALSE, symsize = 3, s_alpha = 1, jitter = 0.1, bwid = 0.4, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, lthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... ) plot_befafter_colors( data, xcol, ycol, match, facet, Boxplot = FALSE, symsize = 3, s_alpha = 1, jitter = 0.1, bwid = 0.4, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, lthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_befafter_colours( data, xcol, ycol, match, facet, Boxplot = FALSE, symsize = 3, s_alpha = 1, jitter = 0.1, bwid = 0.4, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, lthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... ) plot_befafter_colors( data, xcol, ycol, match, facet, Boxplot = FALSE, symsize = 3, s_alpha = 1, jitter = 0.1, bwid = 0.4, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, lthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table object, e.g. data.frame or tibble. |
xcol |
name of the column containing the categorical variable to be plotted on the X axis. |
ycol |
name of the column containing the quantitative Y values. |
match |
name of the column with the matching variable to pass on to |
facet |
add another variable from the data table to create faceted graphs using |
Boxplot |
logical TRUE/FALSE, whether to show box and whisker plot or not (default is FALSE) |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 1 (i.e. maximum opacity & zero transparency). |
jitter |
extent of jitter (scatter) of symbols, default is 0.1. Increase to reduce symbol overlap, set to 0 for aligned symbols. |
bwid |
width of boxplots; default 0.4. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
thickness (in 'pt' units) of boxes; default = |
lthick |
thickness (in 'pt' units) of lines; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
In plot_befafter_colours
/plot_befafter_colors
and plot_befafter_shapes
setting Boxplot = TRUE
will also plot a box and whiskers plot.
Note that only 25 shapes are available, and there will be errors with plot_befafter_shapes
when there are fewer than 25 matched observations; instead use plot_befafter_colours
instead.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
To plot a graph with a single colour along the X axis variable, use the SingleColour
argument.
The resulting ggplot2
graph can take additional geometries or other layers.
This function returns a ggplot2
object of class "gg" and "ggplot".
#plot without legends if necessary plot_befafter_colours(data = data_t_pdiff, xcol = Condition, ycol = Mass, match = Subject, s_alpha = .9, ColSeq = FALSE)+ guides(fill = "none", colour = "none") #remove guides #plot with boxplot plot_befafter_colours(data = data_t_pdiff, xcol = Condition, ycol = Mass, match = Subject, s_alpha = .9, ColSeq = FALSE, Boxplot = TRUE)+ guides(fill = "none", colour = "none") #remove guides
#plot without legends if necessary plot_befafter_colours(data = data_t_pdiff, xcol = Condition, ycol = Mass, match = Subject, s_alpha = .9, ColSeq = FALSE)+ guides(fill = "none", colour = "none") #remove guides #plot with boxplot plot_befafter_colours(data = data_t_pdiff, xcol = Condition, ycol = Mass, match = Subject, s_alpha = .9, ColSeq = FALSE, Boxplot = TRUE)+ guides(fill = "none", colour = "none") #remove guides
One of 3 related functions to plot matching data joined by lines. The variable containing information for matching (e.g. matched subjects or experiments etc.) is passed to the match
argument.
plot_befafter_shapes( data, xcol, ycol, match, facet, Boxplot = FALSE, symsize = 3, s_alpha = 1, bwid = 0.4, jitter = 0.1, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, lthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_befafter_shapes( data, xcol, ycol, match, facet, Boxplot = FALSE, symsize = 3, s_alpha = 1, bwid = 0.4, jitter = 0.1, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, lthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table object, e.g. data.frame or tibble. |
xcol |
name of the column containing the categorical variable to be plotted on the X axis. |
ycol |
name of the column containing the quantitative Y values. |
match |
name of the column with the matching variable to pass on to |
facet |
add another variable from the data table to create faceted graphs using |
Boxplot |
logical TRUE/FALSE, whether to show box and whisker plot or not (default is FALSE) |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 1. |
bwid |
width of boxplots; default 0.4. |
jitter |
extent of jitter (scatter) of symbols, default is 0.1. Increase to reduce symbol overlap, set to 0 for aligned symbols. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
thickness (in 'pt' units) of boxes; default = |
lthick |
thickness (in 'pt' units) of lines; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
In plot_befafter_colours
/plot_befafter_colors
and plot_befafter_shapes
setting Boxplot = TRUE
will also plot a box and whiskers plot.
Note that only 25 shapes are available, and there will be errors with plot_befafter_shapes
when there are fewer than 25 matched observations; instead use plot_befafter_colours
instead.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
To plot a graph with a single colour along the X axis variable, use the SingleColour
argument.
The resulting ggplot2
graph can take additional geometries or other layers.
This function returns a ggplot2
object of class "gg" and "ggplot".
#plot without legends if necessary plot_befafter_colors(data = data_t_pdiff, xcol = Condition, ycol = Mass, match = Subject, s_alpha = .9, ColSeq = FALSE)+ guides(fill = "none", colour = "none") #remove guides #plot with boxplot plot_befafter_colors(data = data_t_pdiff, xcol = Condition, ycol = Mass, match = Subject, s_alpha = .9, ColSeq = FALSE, Boxplot = TRUE)+ guides(fill = "none", colour = "none") #remove guides
#plot without legends if necessary plot_befafter_colors(data = data_t_pdiff, xcol = Condition, ycol = Mass, match = Subject, s_alpha = .9, ColSeq = FALSE)+ guides(fill = "none", colour = "none") #remove guides #plot with boxplot plot_befafter_colors(data = data_t_pdiff, xcol = Condition, ycol = Mass, match = Subject, s_alpha = .9, ColSeq = FALSE, Boxplot = TRUE)+ guides(fill = "none", colour = "none") #remove guides
This function takes a data table, ycol
of quantitative variable and a categorical grouping variable (group
), if available, and plots a density graph using geom_density
). Alternatives are plot_histogram
, or plot_qqline
.
plot_density( data, ycol, group, facet, PlotType = c("Density", "Counts", "Normalised counts"), c_alpha = 0.2, TextXAngle = 0, facet_scales = "fixed", fontsize = 20, linethick, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = NULL, ... )
plot_density( data, ycol, group, facet, PlotType = c("Density", "Counts", "Normalised counts"), c_alpha = 0.2, TextXAngle = 0, facet_scales = "fixed", fontsize = 20, linethick, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = NULL, ... )
data |
a data table e.g. data.frame or tibble. |
ycol |
name of the column containing the quantitative variable whose density distribution is to be plotted. |
group |
name of the column containing a categorical grouping variable (optional since v4.1.0). |
facet |
add another variable from the data table to create faceted graphs using |
PlotType |
the default ( |
c_alpha |
fractional opacity of filled colours under the curve, default set to 0.2 (i.e. 20% opacity). |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
linethick |
thickness of symbol border, default set to |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
Note that the function requires the quantitative Y variable first, and groups them based on an X variable. The group variable is mapped to the fill
and colour
aesthetics in geom_density
.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments. Colours available can be seen quickly with plot_grafify_palette
.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
This function returns a ggplot2
object of class "gg" and "ggplot".
plot_density(data = data_t_pratio, ycol = log(Cytokine), group = Genotype) #with faceting plot_density(data = data_cholesterol, ycol = Cholesterol, group = Treatment, facet = Treatment, fontsize = 12) #Counts plot_density(data = data_cholesterol, ycol = Cholesterol, group = Treatment, PlotType = "Counts", facet = Treatment, fontsize = 12)
plot_density(data = data_t_pratio, ycol = log(Cytokine), group = Genotype) #with faceting plot_density(data = data_cholesterol, ycol = Cholesterol, group = Treatment, facet = Treatment, fontsize = 12) #Counts plot_density(data = data_cholesterol, ycol = Cholesterol, group = Treatment, PlotType = "Counts", facet = Treatment, fontsize = 12)
There are three types of plot_dot_
functions that plot data as "dots" using the geom_dotplot
geometry. They all take a data table, a categorical X variable and a numeric Y variable.
plot_dotbar_sd (bar & SD, SEM or CI95 error bars)
plot_dotbox (box & whiskers)
plot_dotviolin (box & whiskers, violin)
plot_dotbar_sd( data, xcol, ycol, facet, ErrorType = "SD", dotsize = 1.5, d_alpha = 0.8, b_alpha = 1, bwid = 0.5, ewid = 0.2, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, dotthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_dotbar_sd( data, xcol, ycol, facet, ErrorType = "SD", dotsize = 1.5, d_alpha = 0.8, b_alpha = 1, bwid = 0.5, ewid = 0.2, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, dotthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table object, e.g. data.frame or tibble. |
xcol |
name of the column to plot on X axis. This should be a categorical variable. |
ycol |
name of the column to plot on quantitative Y axis. This should be a quantitative variable. |
facet |
add another variable from the data table to create faceted graphs using |
ErrorType |
select the type of error bars to display. Default is "SD" (standard deviation). Other options are "SEM" (standard error of the mean) and "CI95" (95% confidence interval based on t distributions). |
dotsize |
size of dots relative to binwidth used by |
d_alpha |
fractional opacity of dots, default set to 0.8 (i.e., 80% opacity). |
b_alpha |
fractional opacity of bars, default set to 1. |
bwid |
width of bars; default 0.5. |
ewid |
width of error bars, default set to 0.2. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
dotthick |
thickness of dot border ( |
bthick |
thickness (in 'pt' units) of bar and error bar lines; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
Related plot_scatter_
variants show data symbols using the geom_point
geometry. These are plot_scatterbar_sd (or SEM or CI95 error bars), plot_scatterbox and plot_scatterviolin. Over plotting in plot_scatter
variants can be reduced with the jitter
argument.
The X variable is mapped to the fill
aesthetic of dots, symbols, bars, boxes and violins.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments. Colours available can be seen quickly with plot_grafify_palette
.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
If you prefer a single colour for the graph, use the SingleColour
argument.
This function returns a ggplot2
object of class "gg" and "ggplot".
plot_dotbar_sd(data = data_cholesterol, xcol = Treatment, ycol = Cholesterol) plot_dotbar_sd(data = data_1w_death, xcol = Genotype, ycol = Death, ColPal = "pale", ColSeq = FALSE, ColRev = TRUE) #single colour along X plot_dotbar_sd(data = data_1w_death, xcol = Genotype, ycol = Death, SingleColour = "light_orange")
plot_dotbar_sd(data = data_cholesterol, xcol = Treatment, ycol = Cholesterol) plot_dotbar_sd(data = data_1w_death, xcol = Genotype, ycol = Death, ColPal = "pale", ColSeq = FALSE, ColRev = TRUE) #single colour along X plot_dotbar_sd(data = data_1w_death, xcol = Genotype, ycol = Death, SingleColour = "light_orange")
There are three types of plot_dot_
functions that plot data as "dots" using the geom_dotplot
geometry. They all take a data table, a categorical X variable and a numeric Y variable.
plot_dotbar_sd (bar & SD, SEM or CI95 error bars)
plot_dotbox (box & whiskers)
plot_dotviolin (box & whiskers, violin)
plot_dotbox( data, xcol, ycol, facet, dotsize = 1.5, d_alpha = 0.8, b_alpha = 1, bwid = 0.5, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, dotthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_dotbox( data, xcol, ycol, facet, dotsize = 1.5, d_alpha = 0.8, b_alpha = 1, bwid = 0.5, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, dotthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table object, e.g. data.frame or tibble. |
xcol |
name of the column to plot on X axis. This should be a categorical variable. |
ycol |
name of the column to plot on quantitative Y axis. This should be a quantitative variable. |
facet |
add another variable from the data table to create faceted graphs using |
dotsize |
size of dots relative to binwidth used by |
d_alpha |
fractional opacity of dots, default set to 0.8 (i.e., 80% opacity). |
b_alpha |
fractional opacity of boxes, default set to 1. |
bwid |
width of boxplots; default 0.5. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
dotthick |
thickness of dot border ( |
bthick |
thickness (in 'pt' units) of boxplot lines; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
Related plot_scatter_
variants show data symbols using the geom_point
geometry. These are plot_scatterbar_sd (or SEM or CI95 error bars), plot_scatterbox and plot_scatterviolin. Over plotting in plot_scatter
variants can be reduced with the jitter
argument.
The X variable is mapped to the fill
aesthetic of dots, symbols, bars, boxes and violins.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments. Colours available can be seen quickly with plot_grafify_palette
.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
If you prefer a single colour for the graph, use the SingleColour
argument.
This function returns a ggplot2
object of class "gg" and "ggplot".
plot_dotbox(data = data_1w_death, xcol = Genotype, ycol = Death) plot_dotbox(data = data_1w_death, xcol = Genotype, ycol = Death, ColPal = "vibrant", b_alpha = 0.5) plot_dotbox(data = data_1w_death, xcol = Genotype, ycol = Death, SingleColour = "safe_bluegreen", b_alpha = 0.5)
plot_dotbox(data = data_1w_death, xcol = Genotype, ycol = Death) plot_dotbox(data = data_1w_death, xcol = Genotype, ycol = Death, ColPal = "vibrant", b_alpha = 0.5) plot_dotbox(data = data_1w_death, xcol = Genotype, ycol = Death, SingleColour = "safe_bluegreen", b_alpha = 0.5)
There are three types of plot_dot_
functions that plot data as "dots" using the geom_dotplot
geometry. They all take a data table, a categorical X variable and a numeric Y variable.
plot_dotbar_sd (bar & SD, SEM or CI95 error bars)
plot_dotbox (box & whiskers)
plot_dotviolin (box & whiskers, violin)
plot_dotviolin( data, xcol, ycol, facet, dotsize = 1.5, d_alpha = 0.8, b_alpha = 0, v_alpha = 1, bwid = 0.3, vadjust = 1, trim = TRUE, scale = "width", TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, dotthick, bthick, vthick, bvthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_dotviolin( data, xcol, ycol, facet, dotsize = 1.5, d_alpha = 0.8, b_alpha = 0, v_alpha = 1, bwid = 0.3, vadjust = 1, trim = TRUE, scale = "width", TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, dotthick, bthick, vthick, bvthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table object, e.g. data.frame or tibble. |
xcol |
name of the column to plot on X axis. This should be a categorical variable. |
ycol |
name of the column to plot on quantitative Y axis. This should be a quantitative variable. |
facet |
add another variable from the data table to create faceted graphs using |
dotsize |
size of dots relative to |
d_alpha |
fractional opacity of dots, default set to 0.8 (i.e., 80% opacity). |
b_alpha |
fractional opacity of boxplots. Default is set to 0, which results in white boxes inside violins. Change to any value >0 up to 1 for different levels of transparency. |
v_alpha |
fractional opacity of violins, default set to 1. |
bwid |
width of boxplots; default 0.3. |
vadjust |
number to adjust the smooth/wigglyness of violin plot (default set to 1). |
trim |
set whether tips of violin plot should be trimmed at high/low data. Default |
scale |
set to "area" by default, can be changed to "count" or "width". |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
dotthick |
thickness of dot border ( |
bthick |
thickness (in 'pt' units) of boxplots; default = |
vthick |
thickness (in 'pt' units) of violins; default = |
bvthick |
thickness (in 'pt' units) of both violins and boxplots; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
Related plot_scatter_
variants show data symbols using the geom_point
geometry. These are plot_scatterbar_sd (or SEM or CI95 error bars), plot_scatterbox and plot_scatterviolin. Over plotting in plot_scatter
variants can be reduced with the jitter
argument.
The X variable is mapped to the fill
aesthetic of dots, symbols, bars, boxes and violins.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments. Colours available can be seen quickly with plot_grafify_palette
.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
If you prefer a single colour for the graph, use the SingleColour
argument.
This function returns a ggplot2
object of class "gg" and "ggplot".
#plot with trim = FALSE plot_dotviolin(data = data_t_pdiff, xcol = Condition, ycol = Mass, dotsize = 2, trim = FALSE) plot_dotviolin(data = data_t_pdiff, xcol = Condition, ycol = Mass, trim = FALSE, b_alpha = 0.5, ColPal = "pale", ColSeq = FALSE) #single colour along X plot_dotviolin(data = data_t_pdiff, xcol = Condition, ycol = Mass, trim = FALSE, b_alpha = 0.5, SingleColour = "pale_cyan")
#plot with trim = FALSE plot_dotviolin(data = data_t_pdiff, xcol = Condition, ycol = Mass, dotsize = 2, trim = FALSE) plot_dotviolin(data = data_t_pdiff, xcol = Condition, ycol = Mass, trim = FALSE, b_alpha = 0.5, ColPal = "pale", ColSeq = FALSE) #single colour along X plot_dotviolin(data = data_t_pdiff, xcol = Condition, ycol = Mass, trim = FALSE, b_alpha = 0.5, SingleColour = "pale_cyan")
gam
modelPlot prediction of gam
model
plot_gam_predict( Model, xcol, ycol, ByFactor, symsize = 1, s_alpha = 0.1, smooth_alpha = 0.7, linethick, fontsize = 20, ... )
plot_gam_predict( Model, xcol, ycol, ByFactor, symsize = 1, s_alpha = 0.1, smooth_alpha = 0.7, linethick, fontsize = 20, ... )
Model |
a generalised additive model ( |
xcol |
the smooth in the |
ycol |
the dependent variable in |
ByFactor |
the |
symsize |
size of symbols (default = 1) |
s_alpha |
opacity of symbols (default = 0.1) |
smooth_alpha |
opacity of the predicted CI interval (default = 0.7) |
linethick |
thickness of symbol lines (default = fontsize/22) |
fontsize |
base font size for graph |
... |
additional arguments to pass to |
This function returns a ggplot2
object of class "gg" and "ggplot".
#fit zooplankton data z1 <- ga_model(data = data_zooplankton, Y_value = "log(density_adj)", Fixed_Factor = "taxon", Smooth_Factor = "day") #plot fitted data plot_gam_predict(Model = z1, xcol = day, ycol = `log(density_adj)`, ByFactor = taxon)
#fit zooplankton data z1 <- ga_model(data = data_zooplankton, Y_value = "log(density_adj)", Fixed_Factor = "taxon", Smooth_Factor = "day") #plot fitted data plot_gam_predict(Model = z1, xcol = day, ycol = `log(density_adj)`, ByFactor = taxon)
This simple function allows quick visualisation of colours in grafify palettes and their hex codes. It uses plot_scatterbar_sd
and some arguments are similar and can be adjusted.
plot_grafify_palette( palette = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant", "OrBl_div", "PrGn_div", "blue_conti", "grey_conti", "yellow_conti"), fontsize = 14, ... )
plot_grafify_palette( palette = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant", "OrBl_div", "PrGn_div", "blue_conti", "grey_conti", "yellow_conti"), fontsize = 14, ... )
palette |
name of grafify palettes: "okabe_ito", "vibrant, "bright", "pale", "muted", "dark", "light", "contrast" or "all_grafify". |
fontsize |
font size. |
... |
any additional parameters to pass to |
This function returns a ggplot2
object of class "gg" and "ggplot".
plot_grafify_palette("pale") plot_grafify_palette("contrast")
plot_grafify_palette("pale") plot_grafify_palette("contrast")
This function takes a data table, a quantitative variable (ycol
) and a grouping variable (group
), if available, and plots a histogram graph using geom_histogram
). Alternatives are plot_density
, or plot_qqline
.
plot_histogram( data, ycol, group, facet, PlotType = c("Counts", "Normalised counts"), BinSize = 30, c_alpha = 0.8, TextXAngle = 0, facet_scales = "fixed", fontsize = 20, linethick, alpha, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = NULL, ... )
plot_histogram( data, ycol, group, facet, PlotType = c("Counts", "Normalised counts"), BinSize = 30, c_alpha = 0.8, TextXAngle = 0, facet_scales = "fixed", fontsize = 20, linethick, alpha, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = NULL, ... )
data |
a data table e.g. data.frame or tibble. |
ycol |
name of the column containing the quantitative variable whose histogram distribution is to be plotted. |
group |
name of the column containing a categorical grouping variable. |
facet |
add another variable from the data table to create faceted graphs using |
PlotType |
the default ( |
BinSize |
number of distinct bins to use on X-axis, default set to 30. |
c_alpha |
fractional opacity of colour filled within histograms, default set to 0.8 (i.e. 80% opacity). |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
linethick |
thickness of symbol border, default set to |
alpha |
deprecated old argument for |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
Note that the function requires the quantitative Y variable first, and groups them based on a categorical variable passed on via the group
argument. The grouping variable is mapped to the fill
aesthetics in geom_histogram
.
ColPal & ColRev options are applied to both fill
and colour
scales. Colours available can be seen quickly with plot_grafify_palette
.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
This function returns a ggplot2
object of class "gg" and "ggplot".
#Basic usage plot_histogram(data = data_t_pratio, ycol = Cytokine, group = Genotype, BinSize = 10) #with log transformation plot_histogram(data = data_t_pratio, ycol = log(Cytokine), group = Genotype, BinSize = 10) #Normalised counts plot_histogram(data = data_t_pratio, ycol = log(Cytokine), group = Genotype, PlotType = "Normalised counts", BinSize = 10)
#Basic usage plot_histogram(data = data_t_pratio, ycol = Cytokine, group = Genotype, BinSize = 10) #with log transformation plot_histogram(data = data_t_pratio, ycol = log(Cytokine), group = Genotype, BinSize = 10) #Normalised counts plot_histogram(data = data_t_pratio, ycol = log(Cytokine), group = Genotype, PlotType = "Normalised counts", BinSize = 10)
This function takes a linear model, and up to three variables and plots observe data (circles) and model predictions (squares). If the X-variable is categorical, a box and whiskers plot is overlaid. A variable (ByFactor
) can be used for faceting.
plot_lm_predict( Model, xcol, ycol, ByFactor, obs_size = 2, obs_alpha = 0.3, pred_size = 2, pred_alpha = 0.8, linethick, base_size = 15, ... )
plot_lm_predict( Model, xcol, ycol, ByFactor, obs_size = 2, obs_alpha = 0.3, pred_size = 2, pred_alpha = 0.8, linethick, base_size = 15, ... )
Model |
a linear model saved with |
xcol |
variable along the X axis (should match one of the dependent variables in model exactly). |
ycol |
independent variable along the Y axis (should match independent variable in model exactly). |
ByFactor |
optional faceting variable (should match one of the variables in model exactly). |
obs_size |
size of symbols for observed data (default = 2). |
obs_alpha |
opacity of symbols for observed data (default = 0.3). |
pred_size |
size of symbols for predicted data (default = 2). |
pred_alpha |
opacity of symbols for predicted data (default = 0.8). |
linethick |
thickness of border lines for boxes and symbols (default is base_size/20). |
base_size |
base fontsize for |
... |
any other parameters to be passed to |
This function returns a ggplot2
object of class "gg" and "ggplot".
#fit a model deathm1 <- mixed_model(data_2w_Tdeath, "PI", c("Genotype", "Time"), "Experiment") #plot model plot_lm_predict(deathm1, Genotype, PI, Time) #fit zooplankton data z1 <- ga_model(data = data_zooplankton, Y_value = "log(density_adj)", Fixed_Factor = "taxon", Smooth_Factor = "day") #plot fitted data plot_lm_predict(Model = z1, xcol = day, ycol = `log(density_adj)`, ByFactor = taxon)
#fit a model deathm1 <- mixed_model(data_2w_Tdeath, "PI", c("Genotype", "Time"), "Experiment") #plot model plot_lm_predict(deathm1, Genotype, PI, Time) #fit zooplankton data z1 <- ga_model(data = data_zooplankton, Y_value = "log(density_adj)", Fixed_Factor = "taxon", Smooth_Factor = "day") #plot fitted data plot_lm_predict(Model = z1, xcol = day, ycol = `log(density_adj)`, ByFactor = taxon)
This function allows "log10" or "log2" transformation of X or Y axes. With "log10" transformation, log10 ticks are also added on the outside.
plot_logscale( Plot, LogYTrans = "log10", LogXTrans, LogYBreaks = waiver(), LogXBreaks = waiver(), LogYLimits = NULL, LogXLimits = NULL, LogYLabels = waiver(), LogXLabels = waiver(), fontsize = 22, ... )
plot_logscale( Plot, LogYTrans = "log10", LogXTrans, LogYBreaks = waiver(), LogXBreaks = waiver(), LogYLimits = NULL, LogXLimits = NULL, LogYLabels = waiver(), LogXLabels = waiver(), fontsize = 22, ... )
Plot |
a ggplot2 object. |
LogYTrans |
transform Y axis into "log10" (default) or "log2" |
LogXTrans |
transform X axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogXBreaks |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
LogXLimits |
a vector of length two specifying the range (minimum and maximum) of the X axis. |
LogYLabels |
argument for |
LogXLabels |
argument for |
fontsize |
this parameter sets the linewidth of the |
... |
any other arguments to pass to |
Arguments allow for axes limits, breaks and labels to passed on.
This function returns a ggplot2
object of class "gg" and "ggplot".
#save a ggplot object P <- ggplot(data_t_pratio, aes(Genotype,Cytokine))+ geom_jitter(shape = 21, size = 5, width = .2, aes(fill = Genotype), alpha = .7) #transform Y axis plot_logscale(Plot = P) #or in one go plot_logscale(ggplot(data_t_pratio, aes(Genotype,Cytokine))+ geom_jitter(shape = 21, size = 5, width = .2, aes(fill = Genotype), alpha = .7))
#save a ggplot object P <- ggplot(data_t_pratio, aes(Genotype,Cytokine))+ geom_jitter(shape = 21, size = 5, width = .2, aes(fill = Genotype), alpha = .7) #transform Y axis plot_logscale(Plot = P) #or in one go plot_logscale(ggplot(data_t_pratio, aes(Genotype,Cytokine))+ geom_jitter(shape = 21, size = 5, width = .2, aes(fill = Genotype), alpha = .7))
There are 4 related functions that use geom_point
to plot a categorical variable along the X axis.
plot_point_sd (mean & SD, SEM or CI95 error bars)
plot_scatterbar_sd (bar & SD, SEM or CI95 error bars)
plot_scatterbox (box & whiskers)
plot_scatterviolin (box & whiskers, violin)
plot_point_sd( data, xcol, ycol, facet, ErrorType = "SD", symsize = 3.5, s_alpha = 1, symshape = 22, all_alpha = 0.3, all_size = 2.5, all_shape = 1, all_jitter = 0, ewid = 0.2, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, ethick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_point_sd( data, xcol, ycol, facet, ErrorType = "SD", symsize = 3.5, s_alpha = 1, symshape = 22, all_alpha = 0.3, all_size = 2.5, all_shape = 1, all_jitter = 0, ewid = 0.2, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, ethick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table object, e.g. data.frame or tibble. |
xcol |
name of the column with a X variable (will be forced to be a factor/categorical variable). |
ycol |
name of the column with quantitative Y variable. |
facet |
add another variable from the data table to create faceted graphs using |
ErrorType |
select the type of error bars to display. Default is "SD" (standard deviation). Other options are "SEM" (standard error of the mean) and "CI95" (95% confidence interval based on t distributions). |
symsize |
size of point symbols, default set to 3.5. |
s_alpha |
fractional opacity of symbols, default set to 1 (i.e. maximum opacity & zero transparency). |
symshape |
The mean is shown with symbol of the shape number 22 (default, filled square). Pick a number between 21-25 to pick a different type of symbol from ggplot2. |
all_alpha |
fractional opacity of all data points (default = 0.3). Set to non-zero value if you would like all data points plotted in addition to the mean. |
all_size |
size of symbols of all data points, if shown (default = 2.5). |
all_shape |
all data points are shown with symbols of the shape number 1 (default, transparent circle). Pick a number between 0-25 to pick a different type of symbol from ggplot2. |
all_jitter |
reduce overlap of all data points, if shown, by setting a value between 0-1 (default = 0). |
ewid |
width of error bars, default set to 0.2. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
symthick |
thickness of symbol border, default set to |
ethick |
thickness of error bar lines; default |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
These functions take a data table, categorical X and numeric Y variables, and plot various geometries. The X variable is mapped to the fill
aesthetic of symbols.
In plot_point_sd and plot_scatterbar_sd, default error bars are SD, which can be changed to SEM or CI95.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments. Colours available can be seen quickly with plot_grafify_palette
.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
(logical TRUE/FALSE) decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
If there are many groups along the X axis and you prefer a single colour for the graph,use the SingleColour
argument.
This function returns a ggplot2
object of class "gg" and "ggplot".
#Basic usage plot_point_sd(data = data_doubling_time, xcol = Student, ycol = Doubling_time)
#Basic usage plot_point_sd(data = data_doubling_time, xcol = Student, ycol = Doubling_time)
This is a clone of the appraise
function in the gratia
package (rewritten to avoid depending on gratia
package for these plots). This function will plot 4 diagnostic plots when given a generalised additive model fitted with ga_model
or mgcv
. It creates graphs that use grafify
colours and theme_grafify()
.
plot_qq_gam( Model, symsize = 2, s_colour = "#E69F00", s_alpha = 0.6, line_col = "black", base_size = 12, linethick, n_bins = c("sturges", "scott", "fd") )
plot_qq_gam( Model, symsize = 2, s_colour = "#E69F00", s_alpha = 0.6, line_col = "black", base_size = 12, linethick, n_bins = c("sturges", "scott", "fd") )
Model |
a model of class |
symsize |
size of symbols (default = 2) |
s_colour |
colour of symbols (default = |
s_alpha |
opacity of symbols (default = 0.8) |
line_col |
colour of lines (default = |
base_size |
font size for theme (default = 12) |
linethick |
thickness in 'pt' units of lines and symbol orders (default = base_size/22) |
n_bins |
one of either "sturges", "scott", "fd" |
This function returns an object of classes "ggplot" and "gg".
This function returns a ggplot2
object of class "gg" and "ggplot".
This function takes a data table, a quantitative variable (ycol
), and a categorical grouping variable (group
), if available, and plots a QQ graph using stat_qq
and stat_qq_line
. Alternatives are plot_histogram
, or plot_qqline
.
plot_qqline( data, ycol, group, facet, symsize = 3, s_alpha = 0.8, TextXAngle = 0, facet_scales = "fixed", fontsize = 20, symthick, linethick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, ... )
plot_qqline( data, ycol, group, facet, symsize = 3, s_alpha = 0.8, TextXAngle = 0, facet_scales = "fixed", fontsize = 20, symthick, linethick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, ... )
data |
a data table e.g. data.frame or tibble. |
ycol |
name of the column containing the quantitative variable whose distribution is to be plotted. |
group |
name of the column containing a categorical grouping variable. |
facet |
add another variable from the data table to create faceted graphs using |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 1 (i.e. maximum opacity & zero transparency). |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
symthick |
thickness of symbol border, default set to |
linethick |
thickness of lines, default set to |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
... |
any additional arguments to pass to |
Note that the function requires the quantitative Y variable first, and a grouping variable as group
if required. The graph plots sample quantiles on Y axis & theoretical quantiles on X axis. The X variable is mapped to the fill
aesthetic instat_qq
and colour
aesthetic for the stat_qq_line
.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments. Colours available can be seen quickly with plot_grafify_palette
. When only one level is present within group
, symbols will receive "ok_orange" colour.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
This function returns a ggplot2
object of class "gg" and "ggplot".
plot_qqline(data = data_cholesterol, ycol = Cholesterol, group = Treatment)
plot_qqline(data = data_cholesterol, ycol = Cholesterol, group = Treatment)
This function takes a linear model (simple or mixed effects) and plots a QQ graph after running rstudent
from rstudent
to generate a table of Studentised model residuals on an ordinary (simple_model
), mixed model (mixed_model
or mixed_model_slopes
. The graph plots studentised residuals from the model (sample) on Y axis & Theoretical quantiles on X axis.
plot_qqmodel( Model, symsize = 3, s_alpha = 0.8, fontsize = 20, symthick, linethick, SingleColour = "#E69F00" )
plot_qqmodel( Model, symsize = 3, s_alpha = 0.8, fontsize = 20, symthick, linethick, SingleColour = "#E69F00" )
Model |
name of a saved model generated by |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 0.8 (i.e., 80% opacity). |
fontsize |
parameter of |
symthick |
thickness of symbol border, default set to |
linethick |
thickness of line, default set to |
SingleColour |
colour of symbols (default = |
For generalised additive models fit with mgcv
, scaled Pearson residuals are plotted.
The function uses geom_qq
and geom_qq_line
geometries. Symbols receive "ok_orange" colour by default.
This function returns a ggplot2
object of class "gg" and "ggplot".
#Basic usage m1 <- simple_model(data = data_2w_Festing, Y_value = "GST", Fixed_Factor = c("Treatment", "Strain")) plot_qqmodel(m1)
#Basic usage m1 <- simple_model(data = data_2w_Festing, Y_value = "GST", Fixed_Factor = c("Treatment", "Strain")) plot_qqmodel(m1)
There are 4 related functions that use geom_point
to plot a categorical variable along the X axis.
plot_point_sd (mean & SD, SEM or CI95 error bars)
plot_scatterbar_sd (bar & SD, SEM or CI95 error bars)
plot_scatterbox (box & whiskers)
plot_scatterviolin (box & whiskers, violin)
plot_scatterbar_sd( data, xcol, ycol, facet, ErrorType = "SD", symsize = 3, s_alpha = 0.8, b_alpha = 1, bwid = 0.5, ewid = 0.3, jitter = 0.1, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_scatterbar_sd( data, xcol, ycol, facet, ErrorType = "SD", symsize = 3, s_alpha = 0.8, b_alpha = 1, bwid = 0.5, ewid = 0.3, jitter = 0.1, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table object, e.g. data.frame or tibble. |
xcol |
name of the column to plot on X axis. This should be a categorical variable. |
ycol |
name of the column to plot on quantitative Y axis. This should be a quantitative variable. |
facet |
add another variable from the data table to create faceted graphs using |
ErrorType |
select the type of error bars to display. Default is "SD" (standard deviation). Other options are "SEM" (standard error of the mean) and "CI95" (95% confidence interval based on t distributions). |
symsize |
size of point symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 0.8 (i.e, 80% opacity). |
b_alpha |
fractional opacity of boxes, default set to .5 (i.e. 50% transparent). |
bwid |
width of bars, default set to 0.5. |
ewid |
width of error bars, default set to 0.3. |
jitter |
extent of jitter (scatter) of symbols, default is 0.1. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all facet facet graphs. Can be |
fontsize |
parameter of |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
thickness (in 'pt' units) of both bar and error bar lines; default = |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
These functions take a data table, categorical X and numeric Y variables, and plot various geometries. The X variable is mapped to the fill
aesthetic of symbols.
In plot_point_sd and plot_scatterbar_sd, default error bars are SD, which can be changed to SEM or CI95.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments. Colours available can be seen quickly with plot_grafify_palette
.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
If you prefer a single colour for the graph, use the SingleColour
argument.
This function returns a ggplot2
object of class "gg" and "ggplot".
#with jitter plot_scatterbar_sd(data = data_cholesterol, xcol = Treatment, ycol = Cholesterol) plot_scatterbar_sd(data = data_doubling_time, xcol = Student, ycol = Doubling_time, SingleColour = "ok_grey")
#with jitter plot_scatterbar_sd(data = data_cholesterol, xcol = Treatment, ycol = Cholesterol) plot_scatterbar_sd(data = data_doubling_time, xcol = Student, ycol = Doubling_time, SingleColour = "ok_grey")
There are 4 related functions that use geom_point
to plot a categorical variable along the X axis.
plot_point_sd (mean & SD, SEM or CI95 error bars)
plot_scatterbar_sd (bar & SD, SEM or CI95 error bars)
plot_scatterbox (box & whiskers)
plot_scatterviolin (box & whiskers, violin)
plot_scatterbox( data, xcol, ycol, facet, symsize = 3, s_alpha = 0.8, b_alpha = 1, bwid = 0.5, jitter = 0.1, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, Ylabels = waiver(), ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_scatterbox( data, xcol, ycol, facet, symsize = 3, s_alpha = 0.8, b_alpha = 1, bwid = 0.5, jitter = 0.1, TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, Ylabels = waiver(), ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table object, e.g. data.frame or tibble. |
xcol |
name of the column to plot on X axis. This should be a categorical variable. |
ycol |
name of the column to plot on quantitative Y axis. This should be a quantitative variable. |
facet |
add another variable from the data table to create faceted graphs using |
symsize |
size of symbols, default set to 3. |
s_alpha |
fractional opacity of symbols, default set to 0.8 (i.e, 80% opacity). |
b_alpha |
fractional opacity of boxes, default set to 1. |
bwid |
width of boxplots; default 0.5. |
jitter |
extent of jitter (scatter) of symbols, default is 0.1. |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all graphs. Can be |
fontsize |
parameter of |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
thickness (in 'pt' units) of boxplot lines; default = |
Ylabels |
deprecated, use |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
These functions take a data table, categorical X and numeric Y variables, and plot various geometries. The X variable is mapped to the fill
aesthetic of symbols.
In plot_point_sd and plot_scatterbar_sd, default error bars are SD, which can be changed to SEM or CI95.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments. Colours available can be seen quickly with plot_grafify_palette
.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
If you prefer a single colour for the graph, use the SingleColour
argument.
This function returns a ggplot2
object of class "gg" and "ggplot".
plot_scatterbox(data = data_cholesterol, xcol = Treatment, ycol = Cholesterol) plot_scatterbox(data = data_doubling_time, xcol = Student, ycol = Doubling_time, SingleColour = "ok_grey")
plot_scatterbox(data = data_cholesterol, xcol = Treatment, ycol = Cholesterol) plot_scatterbox(data = data_doubling_time, xcol = Student, ycol = Doubling_time, SingleColour = "ok_grey")
There are 4 related functions that use geom_point
to plot a categorical variable along the X axis.
plot_point_sd (mean & SD, SEM or CI95 error bars)
plot_scatterbar_sd (bar & SD, SEM or CI95 error bars)
plot_scatterbox (box & whiskers)
plot_scatterviolin (box & whiskers, violin)
plot_scatterviolin( data, xcol, ycol, facet, symsize = 3, s_alpha = 0.8, b_alpha = 0, v_alpha = 1, bwid = 0.3, vadjust = 1, jitter = 0.1, trim = TRUE, scale = "width", TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, vthick, bvthick, Ylabels = waiver(), ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
plot_scatterviolin( data, xcol, ycol, facet, symsize = 3, s_alpha = 0.8, b_alpha = 0, v_alpha = 1, bwid = 0.3, vadjust = 1, jitter = 0.1, trim = TRUE, scale = "width", TextXAngle = 0, LogYTrans, LogYBreaks = waiver(), LogYLabels = waiver(), LogYLimits = NULL, facet_scales = "fixed", fontsize = 20, symthick, bthick, vthick, bvthick, Ylabels = waiver(), ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, SingleColour = "NULL", ... )
data |
a data table object, e.g. data.frame or tibble. |
xcol |
name of the column to plot on X axis. This should be a categorical variable. |
ycol |
name of the column to plot on quantitative Y axis. This should be a quantitative variable. |
facet |
add another variable from the data table to create faceted graphs using |
symsize |
size of dots relative to |
s_alpha |
fractional opacity of symbols, default set to to 0.8 (i.e, 80% opacity). Set |
b_alpha |
fractional opacity of boxplots. Default is set to 0, which results in white boxes inside violins. Change to any value >0 up to 1 for different levels of transparency. |
v_alpha |
fractional opacity of violins, default set to 1. |
bwid |
width of boxplots; default 0.3. |
vadjust |
number to adjust the smooth/wigglyness of violin plot (default set to 1). |
jitter |
extent of jitter (scatter) of symbols, default is 0 (i.e. aligned symbols). To reduce symbol overlap, try 0.1-0.3 or higher. |
trim |
set whether tips of violin plot should be trimmed at high/low data. Default |
scale |
set to "area" by default, can be changed to "count" or "width". |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogYLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all graphs. Can be |
fontsize |
parameter of |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
thickness (in 'pt' units) of boxplots; default = |
vthick |
thickness (in 'pt' units) of violins; default = |
bvthick |
thickness (in 'pt' units) of both violins and boxplots; default = |
Ylabels |
deprecated, use |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
SingleColour |
a colour hexcode (starting with #), a number between 1-154, or names of colours from |
... |
any additional arguments to pass to |
These functions take a data table, categorical X and numeric Y variables, and plot various geometries. The X variable is mapped to the fill
aesthetic of symbols.
In plot_point_sd and plot_scatterbar_sd, default error bars are SD, which can be changed to SEM or CI95.
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments. Colours available can be seen quickly with plot_grafify_palette
.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
If you prefer a single colour for the graph, use the SingleColour
argument.
This function returns a ggplot2
object of class "gg" and "ggplot".
#plot without jitter plot_scatterviolin(data = data_t_pdiff, xcol = Condition, ycol = Mass, symsize = 2, trim = FALSE) #no symbols plot_scatterviolin(data = data_t_pdiff, xcol = Condition, ycol = Mass, s_alpha = 0, symsize = 2, trim = FALSE)
#plot without jitter plot_scatterviolin(data = data_t_pdiff, xcol = Condition, ycol = Mass, symsize = 2, trim = FALSE) #no symbols plot_scatterviolin(data = data_t_pdiff, xcol = Condition, ycol = Mass, s_alpha = 0, symsize = 2, trim = FALSE)
This function takes a data table, quantitative X and Y variables along with a categorical grouping variable, and a and plots a graph with using geom_point
. The categorical CatGroup
variable is mapped to the fill
aesthetic of symbols.
plot_xy_CatGroup( data, xcol, ycol, CatGroup, facet, Boxplot = FALSE, symsize = 3, s_alpha = 0.8, TextXAngle = 0, LogYTrans, LogXTrans, LogYBreaks = waiver(), LogXBreaks = waiver(), LogYLabels = waiver(), LogXLabels = waiver(), LogYLimits = NULL, LogXLimits = NULL, facet_scales = "fixed", fontsize = 20, bwid = 0.3, b_alpha = 0.3, l_alpha = 0.8, symthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, ... )
plot_xy_CatGroup( data, xcol, ycol, CatGroup, facet, Boxplot = FALSE, symsize = 3, s_alpha = 0.8, TextXAngle = 0, LogYTrans, LogXTrans, LogYBreaks = waiver(), LogXBreaks = waiver(), LogYLabels = waiver(), LogXLabels = waiver(), LogYLimits = NULL, LogXLimits = NULL, facet_scales = "fixed", fontsize = 20, bwid = 0.3, b_alpha = 0.3, l_alpha = 0.8, symthick, bthick, ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy", "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"), ColSeq = TRUE, ColRev = FALSE, ... )
data |
a data table object, e.g. data.frame or tibble. |
xcol |
name of the column with quantitative X variable. |
ycol |
name of the column with quantitative Y variable. |
CatGroup |
a categorical variable as grouping factor for colour of data points, should be a categorical variable for default colours to work. Will be converted to |
facet |
add another variable from the data table to create faceted graphs using |
Boxplot |
logical TRUE/FALSE to plot box and whiskers plot (default = FALSE). |
symsize |
size of symbols used by |
s_alpha |
fractional opacity of symbols, default set to to 0.8 (i.e, 80% opacity). |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogXTrans |
transform X axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogXBreaks |
argument for |
LogYLabels |
argument for |
LogXLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
LogXLimits |
a vector of length two specifying the range (minimum and maximum) of the X axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all graphs. Can be |
fontsize |
parameter of |
bwid |
width of boxplot (default = 0.3). |
b_alpha |
fractional opacity of boxes, (default = 0.3). |
l_alpha |
fractional opacity of lines joining boxes, (default = 0.8). |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
size (in 'pt' units) of outline of boxes, whisker and joining lines ( |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
... |
any additional arguments to pass on. |
A box and whisker plot with lines joining the medians can be plotted with Boxplot = TRUE
. If only box plot is needed without the line, set the opacity of the line to 0 (i.e., l_alpha = 0).
Colours can be changed using ColPal
, ColRev
or ColSeq
arguments. Colours available can be seen quickly with plot_grafify_palette
.
ColPal
can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast".
ColRev
(logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette.
ColSeq
(logical TRUE/FALSE) decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette
.
This plot is related to plot_xy_NumGroup
which requires a numeric grouping factor.
When summary statistics (mean/median) are required, use plot_3d_scatterbar
, plot_3d_scatterbox
or plot_4d_scatterbox
.
This function returns a ggplot2
object of class "gg" and "ggplot".
#The grouping factor cyl is automatically converted to categorical variable plot_xy_CatGroup(data = mtcars, xcol = mpg, ycol = disp, CatGroup = cyl, ColPal = "vibrant", ColSeq = FALSE) #with boxplot plot_xy_CatGroup(data = mpg, xcol = cyl, ycol = cty, CatGroup = fl, Boxplot = TRUE) #add another variable #with boxplot plot_xy_CatGroup(data = mpg, xcol = cyl, ycol = cty, CatGroup = fl, facet = drv, Boxplot = TRUE)
#The grouping factor cyl is automatically converted to categorical variable plot_xy_CatGroup(data = mtcars, xcol = mpg, ycol = disp, CatGroup = cyl, ColPal = "vibrant", ColSeq = FALSE) #with boxplot plot_xy_CatGroup(data = mpg, xcol = cyl, ycol = cty, CatGroup = fl, Boxplot = TRUE) #add another variable #with boxplot plot_xy_CatGroup(data = mpg, xcol = cyl, ycol = cty, CatGroup = fl, facet = drv, Boxplot = TRUE)
This function takes a data table, quantitative X and Y variables, and a numeric grouping variable, and a and plots a graph with using geom_point
. The numerical NumGroup
variable is mapped to the fill
aesthetic of symbols, which receives the scale_fill_grafify
default quantitative palette (blue_conti
). Alternatives are yellow_conti
, grey_conti
, OrBl_div
and PrGn_div
. Colour order can be reversed with ColRev = TRUE
(default is FALSE
).
plot_xy_NumGroup( data, xcol, ycol, NumGroup, facet, Boxplot = FALSE, symsize = 3, s_alpha = 0.8, TextXAngle = 0, LogYTrans, LogXTrans, LogYBreaks = waiver(), LogXBreaks = waiver(), LogYLabels = waiver(), LogXLabels = waiver(), LogYLimits = NULL, LogXLimits = NULL, facet_scales = "fixed", fontsize = 20, bwid = 0.3, b_alpha = 0.3, l_alpha = 0.8, symthick, bthick, ColPal = c("blue_conti", "yellow_conti", "grey_conti", "PrGn_div", "OrBl_div"), ColRev = FALSE, ... )
plot_xy_NumGroup( data, xcol, ycol, NumGroup, facet, Boxplot = FALSE, symsize = 3, s_alpha = 0.8, TextXAngle = 0, LogYTrans, LogXTrans, LogYBreaks = waiver(), LogXBreaks = waiver(), LogYLabels = waiver(), LogXLabels = waiver(), LogYLimits = NULL, LogXLimits = NULL, facet_scales = "fixed", fontsize = 20, bwid = 0.3, b_alpha = 0.3, l_alpha = 0.8, symthick, bthick, ColPal = c("blue_conti", "yellow_conti", "grey_conti", "PrGn_div", "OrBl_div"), ColRev = FALSE, ... )
data |
a data table object, e.g. data.frame or tibble. |
xcol |
name of the column with quantitative X variable. |
ycol |
name of the column with quantitative Y variable. |
NumGroup |
a numeric factor for |
facet |
add another variable from the data table to create faceted graphs using |
Boxplot |
logical TRUE/FALSE to plot box and whiskers plot (default = FALSE). |
symsize |
size of symbols used by |
s_alpha |
fractional opacity of symbols, default set to 0.8 (i.e, 80% opacity). |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
LogYTrans |
transform Y axis into "log10" or "log2" |
LogXTrans |
transform X axis into "log10" or "log2" |
LogYBreaks |
argument for |
LogXBreaks |
argument for |
LogYLabels |
argument for |
LogXLabels |
argument for |
LogYLimits |
a vector of length two specifying the range (minimum and maximum) of the Y axis. |
LogXLimits |
a vector of length two specifying the range (minimum and maximum) of the X axis. |
facet_scales |
whether or not to fix scales on X & Y axes for all graphs. Can be |
fontsize |
parameter of |
bwid |
width of boxplot (default = 0.3). |
b_alpha |
fractional opacity of boxes, (default = 0.3). |
l_alpha |
fractional opacity of lines joining boxes, (default = 0.8). |
symthick |
size (in 'pt' units) of outline of symbol lines ( |
bthick |
size (in 'pt' units) of outline of boxes, whisker and joining lines ( |
ColPal |
grafify colour palette to apply, default "okabe_ito"; see |
ColRev |
whether to reverse order of colour within the selected palette, default F (FALSE); can be set to T (TRUE). |
... |
any additional arguments to pass on. |
This plot is related to plot_xy_CatGroup
which requires a categorical grouping factor.
When summary statistics (mean/median) are required, use plot_3d_scatterbar
, plot_3d_scatterbox
or plot_4d_scatterbox
.
This function returns a ggplot2
object of class "gg" and "ggplot".
#The grouping factor gear is numeric plot_xy_NumGroup(data = mtcars, xcol = mpg, ycol = disp, NumGroup = cyl, s_alpha = 0.8) #change colour palette plot_xy_NumGroup(data = mtcars, xcol = mpg, ycol = disp, NumGroup = cyl, s_alpha = 0.8, ColPal = "grey_conti")
#The grouping factor gear is numeric plot_xy_NumGroup(data = mtcars, xcol = mpg, ycol = disp, NumGroup = cyl, s_alpha = 0.8) #change colour palette plot_xy_NumGroup(data = mtcars, xcol = mpg, ycol = disp, NumGroup = cyl, s_alpha = 0.8, ColPal = "grey_conti")
This function is a wrapper based on emmeans
, and needs a ordinary linear model produced by simple_model
or a mixed effects model produced by mixed_model
or mixed_model_slopes
(or generated directly with lm
, lme4
or lmerTest
calls). It also needs to know the fixed factor(s), which should match those in the model and data table.
posthoc_Levelwise(Model, Fixed_Factor, P_Adj = "fdr", Factor, ...)
posthoc_Levelwise(Model, Fixed_Factor, P_Adj = "fdr", Factor, ...)
Model |
a model object fit using |
Fixed_Factor |
one or more categorical variables, provided as a vector (see Examples), whose levels you wish to compare pairwise. Names of Fixed_Factor should match Fixed_Factor used to fit the model. When more than one factor is provided e.g. |
P_Adj |
method for correcting P values for multiple comparisons. Default is set to false discovery rate ("fdr"), can be changed to "none", "tukey", "bonferroni", "sidak". See Interaction analysis in emmeans in the manual for |
Factor |
old argument name for |
... |
additional arguments for |
The function will generate level-wise comparisons (as described in Comparisons and contrasts in emmeans), i.e. comparison between of every level of one factor separately at each level of the other factor.
By default, P values are corrected by the FDR method (which can be changed). If the model was fit by transforming the quantitative response variable using "log", "logit", "sqrt" etc., results will still be on the original scale, i.e. type = "response"
is the default; data will be back-transformed (check results to confirm this), and for log or logit see Transformations and link functions in emmeans, ratios will be compared.
The first part of the emmeans
results has the estimated marginal means, SE and CI ($emmeans
), which are generated from the fitted model, and not the original data table. The second part has the results of the comparisons ($contrasts
).
returns an "emm_list" object containing contrasts and emmeans through emmeans
.
#make a linear model first CholMod <- mixed_model(data = data_cholesterol, Y_value = "Cholesterol", Fixed_Factor = c("Hospital", "Treatment"), Random_Factor = "Subject") #note quotes used only for fixed Fixed_Factor #to get comparisons between different hospitals separately for each level of Treatment posthoc_Levelwise(Model = CholMod, Fixed_Factor = c("Hospital", "Treatment")) #get comparisons between treatments separately at each hospital posthoc_Levelwise(Model = CholMod, Fixed_Factor = c("Treatment", "Hospital"))
#make a linear model first CholMod <- mixed_model(data = data_cholesterol, Y_value = "Cholesterol", Fixed_Factor = c("Hospital", "Treatment"), Random_Factor = "Subject") #note quotes used only for fixed Fixed_Factor #to get comparisons between different hospitals separately for each level of Treatment posthoc_Levelwise(Model = CholMod, Fixed_Factor = c("Hospital", "Treatment")) #get comparisons between treatments separately at each hospital posthoc_Levelwise(Model = CholMod, Fixed_Factor = c("Treatment", "Hospital"))
This function is a wrapper based on emmeans
, and needs a ordinary linear model produced by simple_model
or a mixed effects model produced by mixed_model
or mixed_model_slopes
(or generated directly with lm
, lme4
or lmerTest
calls). It also needs to know the fixed factor(s), which should match those in the model and data table.
posthoc_Pairwise(Model, Fixed_Factor, P_Adj = "fdr", Factor, ...)
posthoc_Pairwise(Model, Fixed_Factor, P_Adj = "fdr", Factor, ...)
Model |
a model object fit using |
Fixed_Factor |
one or more categorical variables, provided as a vector (see Examples), whose levels you wish to compare pairwise. Names of Fixed_Factor should match Fixed_Factor used to fit the model. When more than one factor is provided e.g. |
P_Adj |
method for correcting P values for multiple comparisons. Default is set to false discovery rate ("fdr"), can be changed to "none", "tukey", "bonferroni", "sidak". See Interaction analysis in emmeans in the manual for |
Factor |
old argument name for |
... |
additional arguments for |
The function will generate pairwise comparisons of every level of every factor (as described in Comparisons and contrasts in emmeans). Too many comparisons will be generated and only use this when necessary.
By default, P values are corrected by the FDR method (which can be changed). If the model was fit by transforming the quantitative response variable using "log", "logit", "sqrt" etc., results will still be on the original scale, i.e. type = "response"
is the default; data will be back-transformed (check results to confirm this), and for log or logit see Transformations and link functions in emmeans, ratios will be compared.
The first part of the emmeans
results has the estimated marginal means, SE and CI ($emmeans
), which are generated from the fitted model, and not the original data table. The second part has the results of the comparisons ($contrasts
).
returns an "emm_list" object containing contrasts and emmeans through emmeans
.
#make linear models first DoublMod <- simple_model(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student") CholMod <- mixed_model(data = data_cholesterol, Y_value = "Cholesterol", Fixed_Factor = c("Hospital", "Treatment"), Random_Factor = "Subject") posthoc_Pairwise(Model = DoublMod, Fixed_Factor = "Student") #basic use with two Fixed_Factor provided as a vector posthoc_Pairwise(Model = CholMod, Fixed_Factor = c("Treatment", "Hospital")) #same call with "tukey" adjustment posthoc_Pairwise(Model = CholMod, Fixed_Factor = c("Treatment", "Hospital"), P_adj = "tukey")
#make linear models first DoublMod <- simple_model(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student") CholMod <- mixed_model(data = data_cholesterol, Y_value = "Cholesterol", Fixed_Factor = c("Hospital", "Treatment"), Random_Factor = "Subject") posthoc_Pairwise(Model = DoublMod, Fixed_Factor = "Student") #basic use with two Fixed_Factor provided as a vector posthoc_Pairwise(Model = CholMod, Fixed_Factor = c("Treatment", "Hospital")) #same call with "tukey" adjustment posthoc_Pairwise(Model = CholMod, Fixed_Factor = c("Treatment", "Hospital"), P_adj = "tukey")
This function is a wrapper based on emmeans
, and needs a ordinary linear model produced by simple_model
or a mixed effects model produced by mixed_model
or mixed_model_slopes
(or generated directly with lm
, lme4
or lmerTest
calls). At least one of the factors should be a numeric covariate whose slopes you wish to find. It also needs to know the fixed factor(s), which should match those in the model and data table.
posthoc_Trends_Levelwise( Model, Fixed_Factor, Trend_Factor, P_Adj = "sidak", ... )
posthoc_Trends_Levelwise( Model, Fixed_Factor, Trend_Factor, P_Adj = "sidak", ... )
Model |
a model object fit using |
Fixed_Factor |
one or more categorical variables, provided as a vector (see Examples), whose levels you wish to compare pairwise. Names of Fixed_Factor should match Fixed_Factor used to fit the model. When more than one factor is provided e.g. |
Trend_Factor |
a quantitative variable that interacts with a factor and whose slope (trend) is to be compared |
P_Adj |
method for correcting P values for multiple comparisons. Default is "sidak", can be changed to "bonferroni". See Interaction analysis in emmeans in the manual for |
... |
additional arguments for |
Checkout the Interactions with covariates section in the emmeans vignette for more details. One of the independent variables should be a quantitative (e.g. time points) variable whose slope (trend) you want to find at levels of the other factor.
returns an "emm_list" object containing slopes and their contrasts calculated through emtrends
.
#create an lm model #Time2 is numeric (time points) m1 <- simple_model(data = data_2w_Tdeath, Y_value = "PI", Fixed_Factor = c("Genotype", "Time2")) posthoc_Trends_Levelwise(Model = m1, Fixed_Factor = "Genotype", Trend_Factor = "Time2")
#create an lm model #Time2 is numeric (time points) m1 <- simple_model(data = data_2w_Tdeath, Y_value = "PI", Fixed_Factor = c("Genotype", "Time2")) posthoc_Trends_Levelwise(Model = m1, Fixed_Factor = "Genotype", Trend_Factor = "Time2")
This function is a wrapper based on emmeans
, and needs a ordinary linear model produced by simple_model
or a mixed effects model produced by mixed_model
or mixed_model_slopes
(or generated directly with lm
, lme4
or lmerTest
calls). At least one of the factors should be a numeric covariate whose slopes you wish to find. It also needs to know the fixed factor(s), which should match those in the model and data table.
posthoc_Trends_Pairwise( Model, Fixed_Factor, Trend_Factor, P_Adj = "sidak", ... )
posthoc_Trends_Pairwise( Model, Fixed_Factor, Trend_Factor, P_Adj = "sidak", ... )
Model |
a model object fit using |
Fixed_Factor |
one or more categorical variables, provided as a vector (see Examples), whose levels you wish to compare pairwise. Names of Fixed_Factor should match Fixed_Factor used to fit the model. When more than one factor is provided e.g. |
Trend_Factor |
a quantitative variable that interacts with a factor and whose slope (trend) is to be compared |
P_Adj |
method for correcting P values for multiple comparisons. Default is "sidak", can be changed to "bonferroni". See Interaction analysis in emmeans in the manual for |
... |
additional arguments for |
Checkout the Interactions with covariates section in the emmeans vignette for more details. One of the independent variables should be a quantitative (e.g. time points) variable whose slope (trend) you want to find at levels of the other factor.
returns an "emm_list" object containing slopes and their contrasts calculated through emtrends
.
#create an lm model #Time2 is numeric (time points) m1 <- simple_model(data = data_2w_Tdeath, Y_value = "PI", Fixed_Factor = c("Genotype", "Time2")) posthoc_Trends_Pairwise(Model = m1, Fixed_Factor = "Genotype", Trend_Factor = "Time2")
#create an lm model #Time2 is numeric (time points) m1 <- simple_model(data = data_2w_Tdeath, Y_value = "PI", Fixed_Factor = c("Genotype", "Time2")) posthoc_Trends_Pairwise(Model = m1, Fixed_Factor = "Genotype", Trend_Factor = "Time2")
This function is a wrapper based on emmeans
, and needs a ordinary linear model produced by simple_model
or a mixed effects model produced by mixed_model
or mixed_model_slopes
(or generated directly with lm
, lme4
or lmerTest
calls). At least one of the factors should be a numeric covariate whose slopes you wish to find. It also needs to know the fixed factor(s), which should match those in the model and data table.
posthoc_Trends_vsRef( Model, Fixed_Factor, Trend_Factor, Ref_Level = 1, P_Adj = "sidak", ... )
posthoc_Trends_vsRef( Model, Fixed_Factor, Trend_Factor, Ref_Level = 1, P_Adj = "sidak", ... )
Model |
a model object fit using |
Fixed_Factor |
one or more categorical variables, provided as a vector (see Examples), whose levels you wish to compare pairwise. Names of Fixed_Factor should match Fixed_Factor used to fit the model. When more than one factor is provided e.g. |
Trend_Factor |
a quantitative variable that interacts with a factor and whose slope (trend) is to be compared |
Ref_Level |
the level within that factor to be considered the reference or control to compare other levels to (to be provided as a number - by default R orders levels alphabetically); default |
P_Adj |
method for correcting P values for multiple comparisons. Default is "sidak", can be changed to "bonferroni". See Interaction analysis in emmeans in the manual for |
... |
additional arguments for |
Checkout the Interactions with covariates section in the emmeans vignette for more details. One of the independent variables should be a quantitative (e.g. time points) variable whose slope (trend) you want to find at levels of the other factor.
returns an "emm_list" object containing slopes and their contrasts calculated through emtrends
.
#create an lm model #Time2 is numeric (time points) m1 <- simple_model(data = data_2w_Tdeath, Y_value = "PI", Fixed_Factor = c("Genotype", "Time2")) posthoc_Trends_vsRef(Model = m1, Fixed_Factor = "Genotype", Trend_Factor = "Time2", Ref_Level = 2)
#create an lm model #Time2 is numeric (time points) m1 <- simple_model(data = data_2w_Tdeath, Y_value = "PI", Fixed_Factor = c("Genotype", "Time2")) posthoc_Trends_vsRef(Model = m1, Fixed_Factor = "Genotype", Trend_Factor = "Time2", Ref_Level = 2)
This function is a wrapper based on emmeans
, and needs a ordinary linear model produced by simple_model
or a mixed effects model produced by mixed_model
or mixed_model_slopes
(or generated directly with lm
, lme4
or lmerTest
calls). It also needs to know the fixed factor(s), which should match those in the model and data table.
posthoc_vsRef(Model, Fixed_Factor, Ref_Level = 1, P_Adj = "fdr", Factor, ...)
posthoc_vsRef(Model, Fixed_Factor, Ref_Level = 1, P_Adj = "fdr", Factor, ...)
Model |
a model object fit using |
Fixed_Factor |
Fixed_Factor one or more categorical variables, provided as a vector (see Examples), whose levels you wish to compare pairwise. Names of Fixed_Factor should match Fixed_Factor used to fit the model. When more than one factor is provided e.g. |
Ref_Level |
the level within that factor to be considered the reference or control to compare other levels to (to be provided as a number - by default R orders levels alphabetically); default |
P_Adj |
method for correcting P values for multiple comparisons. Default is set to false discovery rate ("fdr"), can be changed to "none", "tukey", "bonferroni", "sidak". See Interaction analysis in emmeans in the manual for |
Factor |
old argument name for |
... |
additional arguments for |
The function will generate treatment vs control type of comparisons (as described in Comparisons and contrasts in emmeans), i.e. comparison of each level of a factor to a reference level, which is set by default to the first level in the factor (Ref_Level = 1
).
By default, P values are corrected by the FDR method (which can be changed). If the model was fit by transforming the quantitative response variable using "log", "logit", "sqrt" etc., results will still be on the original scale, i.e. type = "response"
is the default; data will be back-transformed (check results to confirm this), and for log or logit see Transformations and link functions in emmeans, ratios will be compared.
The first part of the emmeans
results has the estimated marginal means, SE and CI ($emmeans
), which are generated from the fitted model, and not the original data table. The second part has the results of the comparisons ($contrasts
).
returns an "emm_list" object containing contrasts and emmeans through emmeans
.
#make linear models first DoublMod <- simple_model(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student") CholMod <- mixed_model(data = data_cholesterol, Y_value = "Cholesterol", Fixed_Factor = c("Hospital", "Treatment"), Random_Factor = "Subject") #to compare all students with student #9 posthoc_vsRef(Model = DoublMod, Fixed_Factor = "Student", Ref_Level = 9) #for comparison between hospital_a to every other hospital, separately at levels of Treatment posthoc_vsRef(Model = CholMod, Fixed_Factor = c("Hospital", "Treatment"), Ref_Level = 1)
#make linear models first DoublMod <- simple_model(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student") CholMod <- mixed_model(data = data_cholesterol, Y_value = "Cholesterol", Fixed_Factor = c("Hospital", "Treatment"), Random_Factor = "Subject") #to compare all students with student #9 posthoc_vsRef(Model = DoublMod, Fixed_Factor = "Student", Ref_Level = 9) #for comparison between hospital_a to every other hospital, separately at levels of Treatment posthoc_vsRef(Model = CholMod, Fixed_Factor = c("Hospital", "Treatment"), Ref_Level = 1)
scale_colour_
and scale_fill_
functionsThese let you apply grafify
discrete or continuous palettes as fill
or colour
aesthetics to any ggplot2
(scale_color_
spelling is also accepted).
scale_colour_grafify( palette = "okabe_ito", ColSeq = TRUE, reverse = FALSE, discrete = TRUE, ... ) scale_color_grafify( palette = "okabe_ito", ColSeq = TRUE, reverse = FALSE, discrete = TRUE, ... )
scale_colour_grafify( palette = "okabe_ito", ColSeq = TRUE, reverse = FALSE, discrete = TRUE, ... ) scale_color_grafify( palette = "okabe_ito", ColSeq = TRUE, reverse = FALSE, discrete = TRUE, ... )
palette |
Name of the |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours. |
reverse |
Whether the colour order should be reversed. |
discrete |
not used. |
... |
Additional parameters for |
The default is palette = "okabe_ito"
. The discrete
argument is not used at present. The following discrete and quantitative palettes can be used.
Categorical/discreet palettes:
okabe_ito
(default)
bright
contrast
dark
kelly
light
muted
pale
r4
safe
vibrant
By default, sequential colours from above palettes will be chosen. To choose the most distant colours set ColSeq = TRUE
.
Sequential quantitative palettes:
grey_conti
blue_conti
yellow_conti
Divergent quantitative palettes:
OrBl_div
PrGn_div
ggplot scale_fill function for discrete colours.
#add a grafify fill scheme to ggplot ggplot(emmeans::neuralgia, aes(x = Treatment, y = Duration))+ geom_boxplot(aes(fill = Treatment), alpha = .6)+ geom_point(aes(colour = Treatment, shape = Treatment), size = 3)+ scale_fill_grafify(palette = "bright")+ scale_colour_grafify(palette = "bright")+ facet_wrap("Sex")+ theme_classic() #distant colours `ColSeq = FALSE` ggplot(emmeans::neuralgia, aes(x = Treatment, y = Duration))+ geom_boxplot(aes(fill = Treatment), alpha = .6)+ geom_point(aes(colour = Treatment, shape = Treatment), size = 3)+ scale_fill_grafify(palette = "bright", ColSeq = FALSE)+ scale_colour_grafify(palette = "bright", ColSeq = FALSE)+ facet_wrap("Sex")+ theme_classic() #quantitative colour scheme ggplot(mtcars, aes(x = disp, y = mpg))+ geom_point(aes(colour = cyl), size = 3)+ scale_colour_grafify(palette = "blue_conti")
#add a grafify fill scheme to ggplot ggplot(emmeans::neuralgia, aes(x = Treatment, y = Duration))+ geom_boxplot(aes(fill = Treatment), alpha = .6)+ geom_point(aes(colour = Treatment, shape = Treatment), size = 3)+ scale_fill_grafify(palette = "bright")+ scale_colour_grafify(palette = "bright")+ facet_wrap("Sex")+ theme_classic() #distant colours `ColSeq = FALSE` ggplot(emmeans::neuralgia, aes(x = Treatment, y = Duration))+ geom_boxplot(aes(fill = Treatment), alpha = .6)+ geom_point(aes(colour = Treatment, shape = Treatment), size = 3)+ scale_fill_grafify(palette = "bright", ColSeq = FALSE)+ scale_colour_grafify(palette = "bright", ColSeq = FALSE)+ facet_wrap("Sex")+ theme_classic() #quantitative colour scheme ggplot(mtcars, aes(x = disp, y = mpg))+ geom_point(aes(colour = cyl), size = 3)+ scale_colour_grafify(palette = "blue_conti")
scale_colour_
and scale_fill_
functionsThese let you apply grafify
discrete or continuous palettes as fill
or colour
aesthetics to any ggplot2
(scale_color_
spelling is also accepted).
scale_fill_grafify( palette = "okabe_ito", ColSeq = TRUE, reverse = FALSE, discrete = TRUE, ... )
scale_fill_grafify( palette = "okabe_ito", ColSeq = TRUE, reverse = FALSE, discrete = TRUE, ... )
palette |
Name of the |
ColSeq |
logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours. |
reverse |
Whether the colour order should be reversed. |
discrete |
not used. |
... |
Additional parameters for |
The default is palette = "okabe_ito"
. The discrete
argument is not used at present. The following discrete and quantitative palettes can be used.
Categorical/discreet palettes:
okabe_ito
(default)
bright
contrast
dark
kelly
light
muted
pale
r4
safe
vibrant
By default, sequential colours from above palettes will be chosen. To choose the most distant colours set ColSeq = TRUE
.
Sequential quantitative palettes:
grey_conti
blue_conti
yellow_conti
Divergent quantitative palettes:
OrBl_div
PrGn_div
ggplot scale_fill function for discrete colours.
#add a grafify fill scheme to ggplot ggplot(emmeans::neuralgia, aes(x = Treatment, y = Duration))+ geom_boxplot(aes(fill = Treatment), alpha = .6)+ geom_point(aes(colour = Treatment, shape = Treatment), size = 3)+ scale_fill_grafify(palette = "bright")+ scale_colour_grafify(palette = "bright")+ facet_wrap("Sex")+ theme_classic() #distant colours `ColSeq = FALSE` ggplot(emmeans::neuralgia, aes(x = Treatment, y = Duration))+ geom_boxplot(aes(fill = Treatment), alpha = .6)+ geom_point(aes(colour = Treatment, shape = Treatment), size = 3)+ scale_fill_grafify(palette = "bright", ColSeq = FALSE)+ scale_colour_grafify(palette = "bright", ColSeq = FALSE)+ facet_wrap("Sex")+ theme_classic() #quantitative colour schemes ggplot(mtcars, aes(x = disp, y = mpg))+ geom_point(aes(colour = cyl), size = 3)+ scale_colour_grafify(palette = "blue_conti")
#add a grafify fill scheme to ggplot ggplot(emmeans::neuralgia, aes(x = Treatment, y = Duration))+ geom_boxplot(aes(fill = Treatment), alpha = .6)+ geom_point(aes(colour = Treatment, shape = Treatment), size = 3)+ scale_fill_grafify(palette = "bright")+ scale_colour_grafify(palette = "bright")+ facet_wrap("Sex")+ theme_classic() #distant colours `ColSeq = FALSE` ggplot(emmeans::neuralgia, aes(x = Treatment, y = Duration))+ geom_boxplot(aes(fill = Treatment), alpha = .6)+ geom_point(aes(colour = Treatment, shape = Treatment), size = 3)+ scale_fill_grafify(palette = "bright", ColSeq = FALSE)+ scale_colour_grafify(palette = "bright", ColSeq = FALSE)+ facet_wrap("Sex")+ theme_classic() #quantitative colour schemes ggplot(mtcars, aes(x = disp, y = mpg))+ geom_point(aes(colour = cyl), size = 3)+ scale_colour_grafify(palette = "blue_conti")
One of two functions for simple ANOVA tables and linear models without random effects, which use lm
to fit a linear models.
link{simple_anova}
link{simple_model}
simple_anova(data, Y_value, Fixed_Factor, ...)
simple_anova(data, Y_value, Fixed_Factor, ...)
data |
a data table object, e.g. data.frame or tibble. |
Y_value |
name of column containing quantitative (dependent) variable, provided within "quotes". |
Fixed_Factor |
name(s) of categorical fixed factors (independent variables) provided as a vector if more than one or within "quotes". |
... |
any additional argument to pass on to |
Update in v0.2.1: This function uses lm
to fit a linear model to data, passes it on to Anova
, and outputs the ANOVA table with type II sum of squares with F statistics and P values.
(Previous versions produced type I sum of squares using anova
call.)
It requires a data table, one quantitative dependent variable and one or more independent variables. If your experiment design has random factors, use the related function mixed_anova
.
This function is related to link{simple_model}
.
ANOVA table of class "anova" and "data.frame".
#Basic usage simple_anova(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student")
#Basic usage simple_anova(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student")
One of two functions for simple ANOVA tables and linear models without random effects, which use lm
to fit a linear models.
link{simple_anova}
link{simple_model}
simple_model(data, Y_value, Fixed_Factor, ...)
simple_model(data, Y_value, Fixed_Factor, ...)
data |
a data table object, e.g. data.frame or tibble. |
Y_value |
name of column containing quantitative (dependent) variable, provided within "quotes". |
Fixed_Factor |
name(s) of categorical fixed factors (independent variables) provided as a vector if more than one or within "quotes". |
... |
any additional arguments to pass on to |
Update in v0.2.1: This function uses lm
to fit a linear model to data, passes it on to Anova
, and outputs the ANOVA table with type II sum of squares with F statistics and P values.
(Previous versions produced type I sum of squares using anova
call.)
It requires a data table, one quantitative dependent variable and one or more independent variables.
The model output can be used to extract coefficients and other information, including post-hoc comparisons. If your experiment design has random factors, use the related function mixed_model
.
This function is related to link{simple_anova}
.
Output of this function can be used with posthoc_Pairwise
, posthoc_Levelwise
and posthoc_vsRef
, or with emmeans
.
This function returns an object of class "lm".
#fixed factors provided as a vector Doubmodel <- simple_model(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student") #get summary summary(Doubmodel)
#fixed factors provided as a vector Doubmodel <- simple_model(data = data_doubling_time, Y_value = "Doubling_time", Fixed_Factor = "Student") #get summary summary(Doubmodel)
This is a wrapper around aggregate
function in base R to obtain mean, median, standard deviation and count for quantitative variable(s) grouped by one or more factors. More than one column containing of quantitative variables can be passed on, and summaries for each is provided with column names with a .
.
table_summary(data, Ycol, ByGroup)
table_summary(data, Ycol, ByGroup)
data |
name of the data table. |
Ycol |
name of one column (in quotes) or a vector of column names containing the numerical variable to be summarised. |
ByGroup |
name of one column (in quotes) or a vector of column names containing the grouping factors |
this function takes in a data.frame or tibble and returns a data.frame or tibble.
table_summary(Ycol = "cty", ByGroup = c("fl", "drv"), data = mpg)
table_summary(Ycol = "cty", ByGroup = c("fl", "drv"), data = mpg)
This simple function takes in a data table and reorders groups (categorical variables or factors) to be plotted along the X-axis in a user-defined order.
table_x_reorder(data, xcol, OrderX, ...)
table_x_reorder(data, xcol, OrderX, ...)
data |
a data table |
xcol |
name of column in above data table (provided within quotes) whose levels are to be reordered |
OrderX |
a vector of group names in the desired order |
... |
any additional arguments for |
It uses two base R functions: as.factor
to first force the user-selected column into a factor, and factor
that reorders levels based on a user-provided vector.
This function returns a data frame with a selected column converted into factor with reordered levels.
#reorder levels within Genotype new_data <- table_x_reorder(data_t_pratio, xcol = "Genotype", OrderX = c("KO", "WT")) #compare plot_scatterbox(data_t_pratio, Genotype, Cytokine) #with plot_scatterbox(new_data, Genotype, Cytokine) #also works within the plot call plot_scatterbox(data = table_x_reorder(data_t_pratio, xcol = "Genotype", OrderX = c("KO", "WT")), xcol = Genotype, ycol = Cytokine)
#reorder levels within Genotype new_data <- table_x_reorder(data_t_pratio, xcol = "Genotype", OrderX = c("KO", "WT")) #compare plot_scatterbox(data_t_pratio, Genotype, Cytokine) #with plot_scatterbox(new_data, Genotype, Cytokine) #also works within the plot call plot_scatterbox(data = table_x_reorder(data_t_pratio, xcol = "Genotype", OrderX = c("KO", "WT")), xcol = Genotype, ycol = Cytokine)
theme_classic()
for grafify
-like graphs.This is a slightly modified theme_classic
with two key differences: no border & background for facet panel labels, and font size of text on axes is the same as that of the axes titles (prior to v3.2.0, this was 0.85 times the base font size). The size of text legend title is also same as base font.
theme_grafify( base_size = 20, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22, TextXAngle = 0, vjust = 0, hjust = 0, ... )
theme_grafify( base_size = 20, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22, TextXAngle = 0, vjust = 0, hjust = 0, ... )
base_size |
base font size for all text (default is 20). Other text is relative to this. |
base_family |
default font family |
base_line_size |
default line size (default is base font size/22) |
base_rect_size |
default size of rectangles (default is base font size/22) |
TextXAngle |
orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text. |
vjust |
vertical adjustment of X-axis text alignment (between 0 and 1). Set |
hjust |
horizontal adjustment of X-axis text alignment (between 0 and 1). Set |
... |
for any other arguments to pass to |
Since v3.2.0, theme_grafify
produces transparent backgrounds.
this returns an output with class "theme" and "gg".
ggplot(mpg, aes(drv, cty, colour = fl))+ geom_jitter(width = 0.2, size = 3, alpha = .7)+ theme_grafify()
ggplot(mpg, aes(drv, cty, colour = fl))+ geom_jitter(width = 0.2, size = 3, alpha = .7)+ theme_grafify()