forked from perishky/meffil
/
lin-karnani-reference.r
55 lines (50 loc) · 2.24 KB
/
lin-karnani-reference.r
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
## Cord Tissue referenc data generated by Xinyi Lin and Neerja Karnani
## paper:
## 'Cell type-specific DNA methylation in neonatal cord tissue and cord blood: a 850K-reference panel and comparison of cell types'
## https://doi.org/10.1080/15592294.2018.1522929
## Download page https://karnanilab.com/Tools/FlowSorted.CordTissueAndBlood.EPIC/
## direct: https://karnanilab.com/Tools/FlowSorted.CordTissueAndBlood.EPIC/FlowSorted.CordTissueAndBlood.EPIC_1.0.1.tar.gz
## install with devtools::install_local("FlowSorted.CordTissueAndBlood.EPIC_1.0.1.tar.gz")
## Neerja Karnani <neerja_karnani@sics.a-star.edu.sg>
create.lin.karnani.reference <- function(verbose=T) {
# source("http://bioconductor.org/biocLite.R")
# if (!require("minfi"))
# biocLite("minfi")
require("minfi")
require("meffil")
require("FlowSorted.CordTissueAndBlood.EPIC")
FlowSorted.CordTissueAndBlood.EPIC <- updateObject(FlowSorted.CordTissueAndBlood.EPIC)
# data("FlowSorted.CordTissueAndBlood.EPIC")
## code from minfi::preprocessFunnorm
## (could not just use that function because Meth/Unmeth
## signals not retained and we need them here to create the cell type
## reference)
reference <- preprocessNoob(FlowSorted.CordTissueAndBlood.EPIC)
reference <- mapToGenome(reference)
extracted.data <- minfi:::.extractFromRGSet450k(FlowSorted.CordTissueAndBlood.EPIC)
samplesheet <- colData(FlowSorted.CordTissueAndBlood.EPIC) ## pData(phenoData(FlowSorted.CordBlood.450k))
colnms <- colnames(samplesheet)
colnms[4] <- "Sex"
colnames(samplesheet) <- colnms
sex <- sign(samplesheet$Sex == "F") + 1
reference <- minfi:::.normalizeFunnorm450k(
object=reference, extractedData=extracted.data,
sex=sex, nPCs=10, verbose=F
)
M <- getMeth(reference)
U <- getUnmeth(reference)
# cell.types <- c("Bcell", "CD4T", "CD8T", "Gran", "Mono", "NK")
cell.types <- unique(samplesheet$CellType)
selected <- samplesheet$CellType %in% cell.types
# use common probes
features <- meffil.featureset("common")
common <- features$name[features$name %in% unique(c(rownames(M),rownames(U)))]
meffil.add.cell.type.reference(
"lin and karani cord tissue",
M[common,selected], U[common,selected],
cell.types=samplesheet$CellType[selected],
chip="epic",
featureset="epic",
verbose=verbose
)
}