modelMatrixMeth: Construct Design Matrix for edgeR Analysis of Methylation...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/modelMatrixMeth.R

Description

Construct design matrix (aka model matrix) for edgeR analysis of methylation count data from sample level information.

Usage

1

Arguments

object

a sample-level design matrix or model formula or terms object.

...

any other arguments are passed to model.matrix.

Details

This function computes a design matrix for modeling methylated and unmethylated counts. The resulting design matrix can be input to glmFit when analysing BS-seq methylation data using edgeR.

In BS-seq methylation analysis, each DNA sample generates two counts, a count of methylated reads and a count of unmethylated reads, for each genomic locus for each sample. The function converts sample-level information about the treatment conditions to make an appropriate design matrix with two rows for each sample. Counts are assumed to be ordered as methylated and then unmethylated by sample.

If design.treatments <- model.matrix(object,...) has nsamples rows and p columns, then modelMatrixMeth(object, ...) has 2*nsamples rows and nsamples+p columns. See Chen et al (2017) for more information.

Value

A numeric design matrix. It has 2 rows for each sample and a column for each sample in addition to the columns generated by model.matrix(object, ...).

Author(s)

Gordon Smyth

References

Chen, Y, Pal, B, Visvader, JE, Smyth, GK (2017). Differential methylation analysis of reduced representation bisulfite sequencing experiments using edgeR. F1000Research 6, 2055. https://f1000research.com/articles/6-2055

See Also

model.matrix in the stats package.

Examples

1
2
3
4
5
6
Treatments <- gl(3,2,labels=c("A","B","C"))
modelMatrixMeth(~Treatments)

# Equivalent calling sequence:
design.treatments <- model.matrix(~Treatments)
modelMatrixMeth(design.treatments)

Example output

Loading required package: limma
   Sample1 Sample2 Sample3 Sample4 Sample5 Sample6 (Intercept) TreatmentsB
1        1       0       0       0       0       0           1           0
2        1       0       0       0       0       0           0           0
3        0       1       0       0       0       0           1           0
4        0       1       0       0       0       0           0           0
5        0       0       1       0       0       0           1           1
6        0       0       1       0       0       0           0           0
7        0       0       0       1       0       0           1           1
8        0       0       0       1       0       0           0           0
9        0       0       0       0       1       0           1           0
10       0       0       0       0       1       0           0           0
11       0       0       0       0       0       1           1           0
12       0       0       0       0       0       1           0           0
   TreatmentsC
1            0
2            0
3            0
4            0
5            0
6            0
7            0
8            0
9            1
10           0
11           1
12           0
   Sample1 Sample2 Sample3 Sample4 Sample5 Sample6 (Intercept) TreatmentsB
1        1       0       0       0       0       0           1           0
2        1       0       0       0       0       0           0           0
3        0       1       0       0       0       0           1           0
4        0       1       0       0       0       0           0           0
5        0       0       1       0       0       0           1           1
6        0       0       1       0       0       0           0           0
7        0       0       0       1       0       0           1           1
8        0       0       0       1       0       0           0           0
9        0       0       0       0       1       0           1           0
10       0       0       0       0       1       0           0           0
11       0       0       0       0       0       1           1           0
12       0       0       0       0       0       1           0           0
   TreatmentsC
1            0
2            0
3            0
4            0
5            0
6            0
7            0
8            0
9            1
10           0
11           1
12           0

edgeR documentation built on Jan. 16, 2021, 2:03 a.m.