plotQC: A set of function for data QC plot

Description Usage Arguments Value Examples

View source: R/plotQC.R

Description

The 'panel' parameter allows different type of visualisation for output object from PhosR. 'panel = 0' is used to create a 2*2 panel of plots including the following. 'panel = 1' is used to visualise percentage of quantification after imputataion. 'panel = 2' is used to visualise dendrogram (hierarchical clustering) of the input matrix. 'panel = 3' is used to visualise abundance level of samples from the input matrix. 'panel = 4' is used to show PCA plot

Usage

1
plotQC(mat, cols, labels, panel, ...)

Arguments

mat

A p by n matrix, where p is the number of phosphosites and n is the number of samples.

cols

A vector of colours to be used in the plot. The length should be equal to the columns of the mat.

labels

A vector of sample names. Used the label points in PCA plot (panel=4)

panel

A numeric value (0-4) to choose the plot type. See description for details.

...

Plotting parameters for base plots

Value

A graphical plot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Imputation
data('phospho.cells.Ins.sample')
grps = gsub('_[0-9]{1}', '', colnames(phospho.cells.Ins))
phospho.cells.Ins.filtered <- selectGrps(phospho.cells.Ins, grps, 0.5, n=1)

set.seed(123)
phospho.cells.Ins.impute <-
    scImpute(
    phospho.cells.Ins.filtered,
    0.5,
    grps)[,colnames(phospho.cells.Ins.filtered)]

set.seed(123)
phospho.cells.Ins.impute[,1:5] <- ptImpute(phospho.cells.Ins.impute[,6:10],
phospho.cells.Ins.impute[,1:5], percent1 = 0.6, percent2 = 0, paired = FALSE)

phospho.cells.Ins.ms <- medianScaling(phospho.cells.Ins.impute,
                                    scale = FALSE)

cols <- rep(c('#ED4024', '#7FBF42', '#3F61AD', '#9B822F'), each=6)
par(mfrow=c(1,2))
plotQC(phospho.cells.Ins.filtered,
        labels=colnames(phospho.cells.Ins.filtered),
        panel = 1, cols = cols)
plotQC(phospho.cells.Ins.ms,
        labels=colnames(phospho.cells.Ins.ms),
        panel = 1, cols = cols)

# Batch correction
data('phospho_L6_ratio')
data('SPSs')

grps = gsub('_.+', '', colnames(phospho.L6.ratio))

# Cleaning phosphosite label
phospho.site.names = rownames(phospho.L6.ratio)
L6.sites = gsub(' ', '', sapply(strsplit(rownames(phospho.L6.ratio), '~'),
                                function(x){paste(toupper(x[2]), x[3], '',
                                                sep=';')}))
phospho.L6.ratio = t(sapply(split(data.frame(phospho.L6.ratio), L6.sites),
                            colMeans))
phospho.site.names = split(phospho.site.names, L6.sites)

# Construct a design matrix by condition
design = model.matrix(~ grps - 1)

# phosphoproteomics data normalisation using RUV
ctl = which(rownames(phospho.L6.ratio) %in% SPSs)
phospho.L6.ratio.RUV = RUVphospho(phospho.L6.ratio, M = design, k = 3,
                                ctl = ctl)

cs = rainbow(length(unique(grps)))
colorCodes = sapply(grps, switch, AICAR=cs[1], Ins=cs[2], AICARIns=cs[3])

# plot after batch correction
par(mfrow=c(1,2))
plotQC(phospho.L6.ratio, panel = 2, cols=colorCodes)
plotQC(phospho.L6.ratio.RUV, cols=colorCodes,
        labels = colnames(phospho.L6.ratio),
        panel=2, ylim=c(-20, 20), xlim=c(-30, 30))

par(mfrow=c(1,2))
plotQC(phospho.L6.ratio, panel = 4, cols=colorCodes,
        labels = colnames(phospho.L6.ratio),
        main='Before Batch correction')
plotQC(phospho.L6.ratio.RUV, cols=colorCodes,
        labels = colnames(phospho.L6.ratio),
        panel=4, ylim=c(-20, 20), xlim=c(-30, 30),
        main='After Batch correction')

PengyiYang/PhosR documentation built on June 21, 2020, 8:37 a.m.