# NOT RUN {
# }
# NOT RUN {
set.seed(12345);
create.qqplot.fit(
filename = paste0(tempdir(),'/QQfit_Simple.tiff'),
x = rnorm(300),
# choosing to compare against a uniform distribution
distribution = qunif
);
# Minimal Input
create.qqplot.fit(
filename = paste0(tempdir(),'/QQfit_Minimal_Input.tiff'),
x = microarray[1:500,1],
# choosing to compare against a uniform distribution
distribution = qunif,
main = 'Minimal input',
description = 'QQplot fit created by BoutrosLab.plotting.general'
);
# Axes and Labels
create.qqplot.fit(
filename = paste0(tempdir(),'/QQfit_Axes_Labels.tiff'),
x = microarray[1:500,1],
distribution = qunif,
main = 'Axes & labels',
# Adding axes labels
xlab.label = 'qunif',
ylab.label = 'sample values',
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xaxis.cex = 1,
yaxis.cex = 1,
add.grid = TRUE,
description = 'QQplot fit created by BoutrosLab.plotting.general'
);
# Confidence bands
create.qqplot.fit(
filename = paste0(tempdir(),'/QQfit_Confidence_Bands.tiff'),
x = microarray[1:500,1],
distribution = qunif,
main = 'Confidence bands',
xlab.label = 'qunif',
ylab.label = 'sample values',
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xaxis.cex = 1,
yaxis.cex = 1,
add.grid = TRUE,
# Adding confidence bands (auto-generates legend)
confidence.bands = TRUE,
confidence.method = 'both',
description = 'QQplot fit created by BoutrosLab.plotting.general'
);
# Multiple qq plot conditioned on a variable
# 'Formula' format of data
chr.locations <- microarray$Chr[1:500];
chr.locations <- replace(chr.locations, which(chr.locations == 1), 'Chromosome 1');
chr.locations <- replace(chr.locations, which(chr.locations == 2), 'Chromosome 2');
qqplot.data <- data.frame(
value = microarray[1:500,1],
chr = chr.locations
);
create.qqplot.fit(
filename = paste0(tempdir(),'/QQfit_Multiple.tiff'),
x = ~ value | chr,
data = qqplot.data,
distribution = qunif,
main = 'Multiple plots',
xlab.label = 'qunif',
ylab.label = 'sample values',
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xaxis.cex = 1,
yaxis.cex = 1,
add.grid = TRUE,
confidence.bands = TRUE,
confidence.method = 'simultaneous',
description = 'QQplot fit created by BoutrosLab.plotting.general'
);
# Grouped qq plot
create.qqplot.fit(
filename = paste0(tempdir(),'/QQfit_Grouped.tiff'),
x = ~ value,
data = qqplot.data,
# Adding groups
groups = qqplot.data$chr,
# Colouring groups
col = default.colours(2),
# Setting different plotting characters
pch = c(15, 19),
distribution = qunif,
main = 'Grouped & legend',
xlab.label = 'qunif',
ylab.label = 'sample values',
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xaxis.cex = 1,
yaxis.cex = 1,
add.grid = TRUE,
confidence.bands = TRUE,
confidence.method = 'simultaneous',
# Adding legend for groups
key = list(
text = list(
lab = c('1','2'),
cex = 1,
col = 'black'
),
points = list(
pch = c(15, 19),
col = default.colours(2),
cex = 1
),
x = 0.04,
y = 0.95,
padding.text = 2
),
description = 'QQplot fit created by BoutrosLab.plotting.general'
);
# Correlation Key
create.qqplot.fit(
filename = paste0(tempdir(),'/QQfit_Correlation_Key.tiff'),
x = ~ value,
data = qqplot.data,
groups = qqplot.data$chr,
col = default.colours(2),
pch = c(15, 19),
distribution = qunif,
main = 'Correlation key',
xlab.label = 'qunif',
ylab.label = 'sample values',
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xaxis.cex = 1,
yaxis.cex = 1,
add.grid = TRUE,
confidence.bands = TRUE,
confidence.method = 'simultaneous',
# Adjusting legend to contain multiple keys
legend = list(
inside = list(
fun = draw.key,
args = list(
key = list(
text = list(
lab = c('1','2'),
cex = 1,
col = 'black'
),
points = list(
pch = c(15, 19),
col = default.colours(2),
cex = 1
),
x = 0.14,
y = 0.80,
padding.text = 2
)
)
),
inside = list(
fun = draw.key,
args = list(
key = get.corr.key(
x = runif(500),
y = qqplot.data$value,
label.items = c('spearman', 'kendall','beta1'),
alpha.background = 0,
key.cex = 1
)
),
x = 0.75,
y = 0.20,
corner = c(0,1)
)
),
description = 'QQplot fit created by BoutrosLab.plotting.general'
);
# Nature style
create.qqplot.fit(
filename = paste0(tempdir(),'/QQfit_Nature_style.tiff'),
x = microarray[1:500,1],
distribution = qunif,
main = 'Nature style',
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xaxis.cex = 1,
yaxis.cex = 1,
add.grid = TRUE,
confidence.bands = TRUE,
confidence.method = 'both',
# 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 = 'QQplot fit created by BoutrosLab.plotting.general'
);
# }
Run the code above in your browser using DataCamp Workspace