# NOT RUN {
# }
# NOT RUN {
set.seed(12345);
simple.data <- data.frame(
x = runif(20000, 0, 1),
y = 1:20000
);
create.manhattanplot(
filename = paste0(tempdir(),'/Manhattan_Simple.tiff'),
formula = -log10(x) ~ y,
data = simple.data,
main = 'Simple',
description = 'Manhattan plot created using BoutrosLab.plotting.general'
);
# set up chromosome covariate colours to use for chr covariate, below
chr.colours <- force.colour.scheme(microarray$Chr, scheme = 'chromosome');
# make chr covariate and chr labels
chr.n.genes <- vector();
chr.tck <- vector();
chr.pos.genes <- vector();
chr.break <- vector();
chr.break[1] <- 0;
# get a list of chromosomes to loop
chr <- unique(microarray$Chr);
# loop over each chromosome
for ( i in 1:length(chr) ) {
# get the number of genes that belong to one chromosome
n <- sum(microarray$Chr == chr[i]);
# calculate where the labels go
chr.n.genes[i] <- n;
chr.break[i+1] <- n + chr.break[i];
chr.pos.genes[i] <- floor(chr.n.genes[i]/2);
chr.tck[i] <- chr.pos.genes[i] + which(microarray$Chr == chr[i])[1];
}
# add an indicator function for the data-frame
microarray$ind <- 1:nrow(microarray);
# Minimal input
create.manhattanplot(
filename = paste0(tempdir(),'/Manhattan_Minimal_Input.tiff'),
formula = -log10(pval) ~ ind,
data = microarray,
main = 'Minimal input',
description = 'Manhattan plot created using BoutrosLab.plotting.general'
);
# Custom Axes
create.manhattanplot(
filename = paste0(tempdir(),'/Manhattan_Custom_Axes.tiff'),
formula = -log10(pval) ~ ind,
data = microarray,
main = 'Custom axes',
xlab.label = expression('Chromosomes'),
ylab.label = expression('P'['adjusted']),
xat = chr.tck,
xaxis.lab = c(1:22, 'X', 'Y'),
xaxis.tck = 0,
xaxis.cex = 1,
yaxis.cex = 1,
yat = seq(0,5,1),
yaxis.lab = c(
1,
expression(10^-1),
expression(10^-2),
expression(10^-3),
expression(10^-4)
),
description = 'Manhattan plot created using BoutrosLab.plotting.general'
);
# Colour scheme
create.manhattanplot(
filename = paste0(tempdir(),'/Manhattan_Colour_Scheme.tiff'),
formula = -log10(pval) ~ ind,
data = microarray,
main = 'Colour scheme',
xlab.label = expression('Chromosomes'),
ylab.label = expression('P'['adjusted']),
xat = chr.tck,
xaxis.lab = c(1:22, 'X', 'Y'),
xaxis.tck = 0,
xaxis.cex = 1,
yaxis.cex = 1,
yat = seq(0,5,1),
yaxis.lab = c(
1,
expression(10^-1),
expression(10^-2),
expression(10^-3),
expression(10^-4)
),
col = chr.colours,
description = 'Manhattan plot created using BoutrosLab.plotting.general'
);
# Plotting Character
create.manhattanplot(
filename = paste0(tempdir(),'/Manhattan_Plotting_Character.tiff'),
formula = -log10(pval) ~ ind,
data = microarray,
main = 'Plotting character',
xlab.label = expression('Chromosomes'),
ylab.label = expression('P'['adjusted']),
xat = chr.tck,
xaxis.lab = c(1:22, 'X', 'Y'),
xaxis.tck = 0,
xaxis.cex = 1,
yaxis.cex = 1,
yat = seq(0,5,1),
yaxis.lab = c(
1,
expression(10^-1),
expression(10^-2),
expression(10^-3),
expression(10^-4)
),
col = chr.colours,
# Change plotting character and size of plotting character
pch = 18,
cex = 0.75,
description = 'Manhattan plot created using BoutrosLab.plotting.general'
);
# Line
create.manhattanplot(
filename = paste0(tempdir(),'/Manhattan_Added_Line.tiff'),
formula = -log10(pval) ~ ind,
data = microarray,
main = 'Line',
xlab.label = expression('Chromosomes'),
ylab.label = expression('P'['adjusted']),
xat = chr.tck,
xaxis.lab = c(1:22, 'X', 'Y'),
xaxis.tck = 0,
xaxis.cex = 1,
yaxis.cex = 1,
yat = seq(0,5,1),
yaxis.lab = c(
1,
expression(10^-1),
expression(10^-2),
expression(10^-3),
expression(10^-4)
),
col = chr.colours,
pch = 18,
cex = 0.75,
# draw horizontal line
abline.h = 2,
abline.lty = 2,
abline.lwd = 1,
abline.col = 'black',
description = 'Manhattan plot created using BoutrosLab.plotting.general'
);
# Background shading
create.manhattanplot(
filename = paste0(tempdir(),'/Manhattan_BG.tiff'),
formula = -log10(pval) ~ ind,
data = microarray,
main = 'Bg rectangles',
xlab.label = expression('Chromosomes'),
ylab.label = expression('P'['adjusted']),
xat = chr.tck,
xaxis.lab = c(1:22, 'X', 'Y'),
xaxis.tck = 0,
xaxis.cex = 1,
yaxis.cex = 1,
yat = seq(0,5,1),
yaxis.lab = c(
1,
expression(10^-1),
expression(10^-2),
expression(10^-3),
expression(10^-4)
),
col = chr.colours,
pch = 18,
cex = 0.75,
abline.h = 2,
abline.lty = 2,
abline.lwd = 1,
abline.col = 'black',
# Adding rectangles
add.rectangle = TRUE,
xleft.rectangle = chr.break[seq(1, length(chr.break) - 1, 2)],
ybottom.rectangle = 0,
xright.rectangle = chr.break[seq(2, length(chr.break) - 1, 2)],
ytop.rectangle = 4.5,
col.rectangle = 'grey',
alpha.rectangle = 0.5,
description = 'Manhattan plot created using BoutrosLab.plotting.general'
);
# Nature style
create.manhattanplot(
filename = paste0(tempdir(),'/Manhattan_Nature_style.tiff'),
formula = -log10(pval) ~ ind,
data = microarray,
main = 'Nature style',
xat = chr.tck,
xaxis.lab = c(1:22, 'X', 'Y'),
xaxis.tck = 0,
xaxis.cex = 1,
yaxis.cex = 1,
yat = seq(0,5,1),
yaxis.lab = c(
1,
expression(10^-1),
expression(10^-2),
expression(10^-3),
expression(10^-4)
),
col = chr.colours,
pch = 18,
cex = 0.75,
abline.h = 2,
abline.lty = 2,
abline.lwd = 1,
abline.col = 'black',
# Adding rectangles
add.rectangle = TRUE,
xleft.rectangle = chr.break[seq(1, length(chr.break) - 1, 2)],
ybottom.rectangle = 0,
xright.rectangle = chr.break[seq(2, length(chr.break) - 1, 2)],
ytop.rectangle = 4.5,
col.rectangle = 'grey',
alpha.rectangle = 0.5,
# 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 = 'Manhattan plot created using BoutrosLab.plotting.general'
);
# }
Run the code above in your browser using DataLab