# NOT RUN {
# }
# NOT RUN {
set.seed(12345);
simple.data <- data.frame(
x = c(rep(rnorm(50),5)),
y = as.factor(sample(LETTERS[1:5],250,TRUE))
);
create.stripplot(
filename = paste0(tempdir(),'/Stripplot_simple.tiff'),
formula = x ~ y,
data = simple.data
);
# load real datasets
stripplot.data <- data.frame(
values = c(t(microarray[1:10, 1:58])),
genes = rep(rownames(microarray)[1:10], each = 58),
sex = patient$sex
);
# Minimal Input using real data
create.stripplot(
filename = paste0(tempdir(),'/Stripplot_Minimal_Input.tiff'),
formula = genes ~ values,
data = stripplot.data,
main = 'Minimal input',
description = 'Stripplot created by BoutrosLab.plotting.general'
);
# Axes & Labels
create.stripplot(
filename = paste0(tempdir(),'/Stripplot_Axes_Labels.tiff'),
formula = genes ~ values,
data = stripplot.data,
main = 'Axes & labels',
# formatting axes
xlab.label = 'Change in gene expression',
ylab.label = 'Gene',
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.cex = 1,
yaxis.cex = 1,
xaxis.fontface = 1,
yaxis.fontface = 1,
xlimits = c(0,13),
xat = seq(0,12,2),
description = 'Stripplot created by BoutrosLab.plotting.general'
);
# Colour & Legend
create.stripplot(
filename = paste0(tempdir(),'/Stripplot_Colour_Legend.tiff'),
formula = genes ~ values,
data = stripplot.data,
main = 'Colour & legend',
xlab.label = 'Change in gene expression',
ylab.label = 'Gene',
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.cex = 1,
yaxis.cex = 1,
xaxis.fontface = 1,
yaxis.fontface = 1,
xlimits = c(0,13),
xat = seq(0,12,2),
# Colour & points adjustment
groups = stripplot.data$sex,
col = c('pink', 'skyblue'),
pch = 19,
colour.alpha = 0.5,
cex = 1,
# Legend
key = list(
space = 'right',
text = list(
lab = levels(stripplot.data$sex),
cex = 1,
col = 'black'
),
points = list(
pch = 19,
col = c('pink','skyblue'),
alpha = 0.5,
cex = 1
),
padding.text = 3
),
description = 'Stripplot created by BoutrosLab.plotting.general'
);
# Jitter
create.stripplot(
filename = paste0(tempdir(),'/Stripplot_Jitter.tiff'),
formula = genes ~ values,
data = stripplot.data,
main = 'Low Jitter',
xlab.label = 'Change in gene expression',
ylab.label = 'Gene',
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.cex = 1,
yaxis.cex = 1,
xaxis.fontface = 1,
yaxis.fontface = 1,
xlimits = c(0,13),
xat = seq(0,12,2),
groups = stripplot.data$sex,
col = c('pink', 'skyblue'),
pch = 19,
colour.alpha = 0.5,
cex = 1,
key = list(
space = 'right',
text = list(
lab = levels(stripplot.data$sex),
cex = 1,
col = 'black'
),
points = list(
pch = 19,
col = c('pink','skyblue'),
alpha = 0.4,
cex = 1
),
padding.text = 3
),
# Custom jitter
jitter.data = TRUE,
description = 'Stripplot created by BoutrosLab.plotting.general'
);
# Jitter
create.stripplot(
filename = paste0(tempdir(),'/Stripplot_High_Jitter.tiff'),
formula = genes ~ values,
data = stripplot.data,
main = 'High Jitter',
xlab.label = 'Change in gene expression',
ylab.label = 'Gene',
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.cex = 1,
yaxis.cex = 1,
xaxis.fontface = 1,
yaxis.fontface = 1,
xlimits = c(0,13),
xat = seq(0,12,2),
groups = stripplot.data$sex,
col = c('pink', 'skyblue'),
pch = 19,
colour.alpha = 0.5,
cex = 1,
key = list(
space = 'right',
text = list(
lab = levels(stripplot.data$sex),
cex = 1,
col = 'black'
),
points = list(
pch = 19,
col = c('pink','skyblue'),
alpha = 0.4,
cex = 1
),
padding.text = 3
),
# Custom jitter
jitter.data = TRUE,
jitter.factor = 0.5,
jitter.amount = 0.33,
description = 'Stripplot created by BoutrosLab.plotting.general'
);
# Nature style
create.stripplot(
filename = paste0(tempdir(),'/Stripplot_Nature_style.tiff'),
formula = genes ~ values,
data = stripplot.data,
main = 'Nature style',
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.cex = 1,
yaxis.cex = 1,
xaxis.fontface = 1,
yaxis.fontface = 1,
xlimits = c(0,13),
xat = seq(0,12,2),
groups = stripplot.data$sex,
col = c('pink', 'skyblue'),
pch = 19,
colour.alpha = 0.5,
cex = 1,
key = list(
space = 'right',
text = list(
lab = levels(stripplot.data$sex),
cex = 1,
col = 'black'
),
points = list(
pch = 19,
col = c('pink','skyblue'),
alpha = 0.4,
cex = 1
),
padding.text = 3
),
jitter.data = TRUE,
jitter.factor = 0.5,
jitter.amount = 0.33,
# set style to Nature
style = 'Nature',
# demonstrating how to italicize character variables
ylab.label = expression(paste('italicized ', italic('a'))),
# demonstrating how to create en-dashes
xlab.label = expression(paste('en dashs: 1','\u2013', '10'^'\u2013', ''^3)),
description = 'Stripplot created by BoutrosLab.plotting.general'
);
# }
Run the code above in your browser using DataCamp Workspace