Functions for plots useful in HTS data analysis, using ggplot2 R package
- PCA from a matrix or a DESeq2 object
- Density plot from a data frame or a matrix
- Hierarchical clustering from a matrix or a DESeq2 object
- Dotplot for counts / gene from a matrix or a DESeq2 object
- Heatmap from a matrix or a DESeq2 object
source("functions/pca.R")
data: compulsory; object of class matrix OR DESeqTransform OR DESeqDataSet: each column is a sample.
title: optional; will be used to construct the main title of the plot and the name of the file; defaults to time stamp.
first_pc, second_pc; optional: which components do you want to plot. first will go to the x axis, second will go to the y axis; defaults to 1 and 2, respectively.
groups: optional; vector that contains the name of the experimental groups (same order as in the columns of data).
samples: optional; vector that contains the name of the samples for labeling the points; defaults to the column names of data.
dat <- matrix(rnorm(1200), ncol=6)
colnames(dat) <- paste0("sample", 1:6)
pca_ggplot(dat, first_pc=1, second_pc=3,
samples=1:6, groups=c(rep("one", 3), rep("two", 3)),
title="my first PCA")
source("functions/density.R")
data: compulsory; object of class data.frame or matrix: each column is a sample
title: optional; will be used to construct the main title of the plot and the name of the file; defaults to time stamp.
df <- data.frame(sample1=rnorm(1000),
sample2=rnorm(1000),
sample3=rnorm(1000))
density_ggplot(df,
title="test")
source("functions/dendrogram.R")
data: compulsory; object of class matrix OR DESeqTransform OR DESeqDataSet: each column is a sample.
title: optional; will be used to construct the main title of the plot and the name of the file; defaults to time stamp.
groups: optional; vector that contains the name of the experimental groups (same order as in the columns of data).
samples: optional; vector that contains the name of the samples for labeling the points; defaults to the column names of data.
dat <- matrix(rnorm(120000), ncol=60)
colnames(dat) <- paste0("sample", 1:60)
dendro_ggplot(dat,
title="my first Dendrogram",
groups=c(rep("one", 15), rep("two", 20), rep("three", 25)))
source("functions/dotplot_genes_counts.R")
data: compulsory; object of class matrix OR DESeqTransform OR DESeqDataSet: each column is a sample. Row names should be gene names!
genes: compulsory; vector of gene names (should be found in row names of data).
title: optional; defaults to time stamp.
groups: optional; vector that contains the name of the experimental groups (same order as in the columns of data).
samples: optional; vector that contains the name of the samples for labeling the points; defaults to the column names of data.
dat <- matrix(rnorm(120000), ncol=20,
dimnames=list(paste0("gene", 1:6000), paste0("sample", 1:20)))
dotplot_genes_ggplot(dat,
genes=c("gene2030", "gene140", "gene850"),
title="my first dot plot",
groups=c(rep("one", 6), rep("two", 7), rep("three", 7)))