# NOT RUN {
# }
# NOT RUN {
set.seed(12345);
temp <- matrix(runif(1010), ncol = 10) + sort(runif(101));
simple.data <- data.frame(
x = 0:100,
max = apply(temp, 1, max),
min = apply(temp, 1, min)
);
create.polygonplot(
filename = paste0(tempdir(),'/Polygon_Simple.tiff'),
formula = NA ~ x,
data = simple.data,
max = simple.data$max,
min = simple.data$min,
main = 'Simple',
xlimits = c(0,100),
ylimits = c (0,2),
col = default.colours(1),
description = 'Polygon created by BoutrosLab.plotting.general'
);
# Compare two genes across increasing numbers of samples
data1 <- microarray[1,1:58];
data2 <- microarray[2,1:58];
gene1 <- as.data.frame(matrix(nrow = 58, ncol = 58));
gene2 <- as.data.frame(matrix(nrow = 58, ncol = 58));
fill.matrix <- function(x, gene, data){
for(i in x){
gene[i, 1:i] <- rep(NA, i);
gene[i, i:58] <- rep(as.numeric(data[i]), 58-i+1);
}
return(gene);
};
gene1 <- fill.matrix(1:58, gene1, data1);
gene1 <- t(matrix(unlist(gene1), ncol = 58, byrow = TRUE));
gene2 <- fill.matrix(1:58, gene2, data2);
gene2 <- t(matrix(unlist(gene2), ncol = 58, byrow = TRUE));
# Set up the data
polygon.data.gene1 <- data.frame(
x = 1:58,
max = apply(gene1, 2, function(x) {max(x, na.rm = TRUE)}),
median = apply(gene1, 2, function(x) {median(x, na.rm = TRUE)}),
min = apply(gene1, 2, function(x) {min(x, na.rm = TRUE)}),
set = rownames(microarray[1,]),
extra = apply(microarray[1:58], 2, function(x) {median(x)})
);
polygon.data.two.genes <- rbind(
polygon.data.gene1,
data.frame(
x = 1:58,
max = apply(gene2, 2, function(x) {max(x, na.rm = TRUE)}),
median = apply(gene2, 2, function(x) {median(x, na.rm = TRUE)}),
min = apply(gene2, 2, function(x) {min(x, na.rm = TRUE)}),
set = rownames(microarray[2,]),
extra = apply(microarray[1:58], 2, function(x) {median(x)})
)
)
# Minimal Input
create.polygonplot(
filename = paste0(tempdir(),'/Polygon_Minimal_Input.tiff'),
formula = NA ~ x,
data = polygon.data.gene1,
max = polygon.data.gene1$max,
min = polygon.data.gene1$min,
main = 'Minimal input',
xlimits = c(0,58),
ylimits = c (2,5),
description = 'Polygon created by BoutrosLab.plotting.general'
);
# Axes & Labels
create.polygonplot(
filename = paste0(tempdir(),'/Polygon_Axes_Labels.tiff'),
formula = NA ~ x,
data = polygon.data.gene1,
max = polygon.data.gene1$max,
min = polygon.data.gene1$min,
main = 'Axes & labels',
xlimits = c(0,58),
ylimits = c (0,10),
# Axes & Labels
xlab.label = 'Samples',
ylab.label = 'Value',
xaxis.cex = 1,
yaxis.cex = 1,
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xat = seq(0, 58, 5),
yat = seq(0, 10, 2),
description = 'Polygon created by BoutrosLab.plotting.general'
);
# Colour
create.polygonplot(
filename = paste0(tempdir(),'/Polygon_Colour.tiff'),
formula = NA ~ x,
data = polygon.data.gene1,
max = polygon.data.gene1$max,
min = polygon.data.gene1$min,
main = 'Colour',
xlimits = c(0,58),
ylimits = c (0,10),
xlab.label = 'Samples',
ylab.label = 'Value',
xaxis.cex = 1,
yaxis.cex = 1,
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xat = seq(0, 58, 5),
yat = seq(0, 10, 2),
# Colour
col = default.colours(1),
description = 'Polygon created by BoutrosLab.plotting.general'
);
# Add median line and points
create.polygonplot(
filename = paste0(tempdir(),'/Polygon_Median_Points.tiff'),
formula = NA ~ x,
data = polygon.data.gene1,
max = polygon.data.gene1$max,
min = polygon.data.gene1$min,
# Median
median = polygon.data.gene1$median,
add.median = TRUE,
main = 'Plotting character',
xlimits = c(0,58),
ylimits = c (0,10),
xlab.label = 'Samples',
ylab.label = 'Value',
xaxis.cex = 1,
yaxis.cex = 1,
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xat = seq(0, 58, 5),
yat = seq(0, 10, 2),
col = default.colours(1),
# border points
add.xy.border = TRUE,
description = 'Polygon created by BoutrosLab.plotting.general'
);
# Additional Data
create.polygonplot(
filename = paste0(tempdir(),'/Polygon_Extra_Data.tiff'),
formula = NA ~ x,
# divide data
groups = set,
data = polygon.data.two.genes,
max = polygon.data.two.genes$max,
min = polygon.data.two.genes$min,
main = 'Two data sets',
median = polygon.data.two.genes$median,
add.median = TRUE,
xlimits = c(0,58),
ylimits = c (0,15),
xlab.label = 'Samples',
ylab.label = 'Value',
xaxis.cex = 1,
yaxis.cex = 1,
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xat = seq(0, 58, 5),
yat = seq(0, 14, 2),
# Increasing number of colours
col = default.colours(2),
description = 'Polygon created by BoutrosLab.plotting.general'
);
# Legend
create.polygonplot(
filename = paste0(tempdir(),'/Polygon_Legend.tiff'),
formula = NA ~ x,
groups = set,
data = polygon.data.two.genes,
max = polygon.data.two.genes$max,
min = polygon.data.two.genes$min,
main = 'Legend',
median = polygon.data.two.genes$median,
add.median = TRUE,
xlimits = c(0,58),
ylimits = c (0,15),
xlab.label = 'Samples',
ylab.label = 'Value',
xaxis.cex = 1,
yaxis.cex = 1,
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xat = seq(0, 58, 5),
yat = seq(0, 14, 2),
col = default.colours(2),
# Adding legend
key = list(
text = list(
lab = rownames(microarray[1:2,]),
cex = 0.8,
col = 'black'
),
points = list(
pch = 15,
col = default.colours(2),
cex = 2
),
x = 0.04,
y = 0.93,
padding.text = 3,
columns = 1
),
description = 'Polygon created by BoutrosLab.plotting.general'
);
# Panel Organiation
create.polygonplot(
filename = paste0(tempdir(),'/Polygon_Panel.tiff'),
# divide data
formula = NA ~ x | set,
data = polygon.data.two.genes,
max = polygon.data.two.genes$max,
min = polygon.data.two.genes$min,
main = 'Panel',
median = polygon.data.two.genes$median,
add.median = TRUE,
xlimits = c(0,58),
ylimits = c (0,15),
xlab.label = 'Samples',
ylab.label = 'Value',
xaxis.cex = 1,
yaxis.cex = 1,
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xat = seq(0, 58, 5),
yat = seq(0, 14, 2),
col = default.colours(1),
description = 'Polygon created by BoutrosLab.plotting.general'
);
# Extra Points
create.polygonplot(
filename = paste0(tempdir(),'/Polygon_Extra_Points.tiff'),
formula = NA ~ x,
groups = set,
data = polygon.data.two.genes,
max = polygon.data.two.genes$max,
min = polygon.data.two.genes$min,
main = 'Extra points',
median = polygon.data.two.genes$median,
add.median = TRUE,
xlimits = c(0,58),
ylimits = c (0,15),
xlab.label = 'Samples',
ylab.label = 'Value',
xaxis.cex = 1,
yaxis.cex = 1,
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xat = seq(0, 58, 5),
yat = seq(0, 14, 2),
col = default.colours(2),
# Add to legend
key = list(
text = list(
lab = c(rownames(microarray[1:2,]), 'All genes'),
cex = 0.8,
col = 'black'
),
points = list(
pch = c(15, 15, 3),
col = c(default.colours(2), 'red'),
cex = c(2, 2, 0.7)
),
x = 0.04,
y = 0.93,
padding.text = 3,
columns = 1
),
# Extra points
extra.points = list(
x = polygon.data.two.genes$x,
y = polygon.data.two.genes$extra
),
extra.points.col = 'red',
extra.points.pch = 3,
extra.points.type = c('p', 'l'),
extra.points.cex = 0.7,
description = 'Polygon created by BoutrosLab.plotting.general'
);
# Nature style
create.polygonplot(
filename = paste0(tempdir(),'/Polygon_Nature_style.tiff'),
formula = NA ~ x,
groups = set,
data = polygon.data.two.genes,
max = polygon.data.two.genes$max,
min = polygon.data.two.genes$min,
main = 'Nature style',
median = polygon.data.two.genes$median,
add.median = TRUE,
xlimits = c(0,58),
ylimits = c (0,15),
xaxis.cex = 1,
yaxis.cex = 1,
xlab.cex = 1.5,
ylab.cex = 1.5,
xaxis.fontface = 1,
yaxis.fontface = 1,
xat = seq(0, 58, 5),
yat = seq(0, 14, 2),
col = default.colours(2),
# Adding legend
key = list(
text = list(
lab = rownames(microarray[1:2,]),
cex = 0.8,
col = 'black'
),
points = list(
pch = 15,
col = default.colours(2),
cex = 2
),
x = 0.04,
y = 0.93,
padding.text = 3,
columns = 1
),
# 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 = 'Polygon created by BoutrosLab.plotting.general'
);
# }
Run the code above in your browser using DataLab