Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/CNV.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ getGLADProfiles<-function(rnb.set,refbased=TRUE){

annot <- annotation(rnb.set)
target <- rnb.set@target
if(target %in% c("probes27","probes450","probesEPIC", "probesEPICv2")){
if(target %in% c("probes27","probes450","probesEPIC", "probesEPICv2", "probesMSA")){
target <- "probes450"
}
cnv.reference.data<-rnb.get.cnv.annotations(target)
Expand Down
2 changes: 2 additions & 0 deletions R/RnBSet-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,8 @@ setMethod("mergeSamples", signature(object = "RnBSet"),
platform<-"EPIC"
}else if (object@target=="probesEPICv2"){
platform<-"EPICv2"
}else if (object@target=="probesMSA"){
platform<-"MSA"
}else if (object@target=="probes450"){
platform<-"450k"
}else if(object@target=="probes27"){
Expand Down
32 changes: 27 additions & 5 deletions R/RnBeadRawSet-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ RnBeadRawSet<-function(
beta.offset=100,
summarize.bead.counts=TRUE,
summarize.regions=TRUE,
region.types = rnb.region.types.for.analysis(ifelse(platform=="MMBC", "mm10", ifelse(target=="probesEPICv2", "hg38", rnb.getOption("assembly")))), ## TODO: Implement assembly selection
region.types = rnb.region.types.for.analysis(ifelse(platform=="MMBC", "mm10",
ifelse(target=="probesEPICv2"|| target=="probesMSA", "hg38", rnb.getOption("assembly")))), ## TODO: Implement assembly selection
useff=rnb.getOption("disk.dump.big.matrices"),
ffcleanup=FALSE){

Expand Down Expand Up @@ -252,6 +253,9 @@ RnBeadRawSet<-function(
}else if (platform =="EPICv2") {
target <- "probesEPICv2"
assembly <- "hg38"
}else if (platform =="MSA") {
target <- "probesMSA"
assembly <- "hg38"
}else if (platform =="450k") {
target <- "probes450"
assembly <- ifelse(genome.assembly == "hg19", "hg19", "hg38")
Expand Down Expand Up @@ -422,6 +426,8 @@ setAs("MethyLumiSet", "RnBeadRawSet",
platform="EPIC"
}else if(annotation(from)=="IlluminaMethylationEPICv2"){
platform="EPICv2"
}else if(annotation(from)=="IlluminaMethylationScreeningArray"){
platform="MSA"
}else if(annotation(from)=="IlluminaHumanMethylation450k"){
platform="450k"
}else if(annotation(from)=="IlluminaHumanMethylation27k"){
Expand Down Expand Up @@ -507,6 +513,9 @@ setAs("RnBeadRawSet","MethyLumiSet",
}else if(from@target == "probesEPICv2"){
probeIDs<-rnb.get.annotation("controlsEPICv2", assembly = "hg38")[,"Target"]
probeIDs<-paste(probeIDs, unlist(sapply(table(probeIDs)[unique(probeIDs)], seq, from=1 )), sep=".")
}else if(from@target == "probesMSA"){
probeIDs<-rnb.get.annotation("controlsMSA", assembly = "hg38")[,"Target"]
probeIDs<-paste(probeIDs, unlist(sapply(table(probeIDs)[unique(probeIDs)], seq, from=1 )), sep=".")
}else if(from@target == "probes450"){
probeIDs<-rnb.get.annotation("controls450")[,"Target"]
probeIDs<-paste(probeIDs, unlist(sapply(table(probeIDs)[unique(probeIDs)], seq, from=1 )), sep=".")
Expand All @@ -521,6 +530,8 @@ setAs("RnBeadRawSet","MethyLumiSet",
annotation(mset@QC) <- "IlluminaMethylationEPIC"
}else if(from@target == "probesEPICv2"){
annotation(mset@QC) <- "IlluminaMethylationEPICv2"
}else if(from@target == "probesMSA"){
annotation(mset@QC) <- "IlluminaMethylationScreeningArray"
}else if(from@target == "probes450"){
annotation(mset@QC) <- "IlluminaHumanMethylation450k"
}else if(from@target == "probes27"){
Expand All @@ -532,6 +543,8 @@ setAs("RnBeadRawSet","MethyLumiSet",
annotation(mset) <- "IlluminaMethylationEPIC"
}else if(from@target == "probesEPICv2"){
annotation(mset) <- "IlluminaMethylationEPICv2"
}else if(from@target == "probesMSA"){
annotation(mset) <- "IlluminaMethylationScreeningArray"
}else if(from@target == "probes450"){
annotation(mset) <- "IlluminaHumanMethylation450k"
}else if(from@target == "probes27"){
Expand All @@ -558,7 +571,10 @@ setAs("RGChannelSet", "RnBeadRawSet", function(from, to) {
} else if (assay.name == "IlluminaHumanMethylationEPICv2") {
assay.name <- "probesEPICv2"
platform.name <- "EPICv2"
} else if (assay.name == "IlluminaHumanMethylation450k") {
} else if (assay.name == "IlluminaHumanMethylationScreeningArray") {
assay.name <- "probesMSA"
platform.name <- "MSA"
} else if (assay.name == "IlluminaHumanMethylation450k") {
assay.name <- "probes450"
platform.name <- "450k"
} else if (assay.name == "IlluminaHumanMethylation27k") {
Expand All @@ -569,15 +585,16 @@ setAs("RGChannelSet", "RnBeadRawSet", function(from, to) {
}

## Use RnBeads' mapping from probe IDs to addresses
probes.all <- rnb.get.annotation(assay.name, ifelse(assay.name=="probesEPICv2", "hg38", rnb.getOption("assembly"))) ## TODO: Impove genome build selection
is.EPICv2.or.MSA <- ifelse(assay.name == "probesEPICv2" || assay.name == "probesMSA", TRUE, FALSE)
probes.all <- rnb.get.annotation(assay.name, ifelse(is.EPICv2.or.MSA, "hg38", rnb.getOption("assembly"))) ## TODO: Impove genome build selection
probes.all <- lapply(probes.all, function(x) {
result <- as.data.frame(mcols(x)[, c("Design", "Color", "AddressA", "AddressB")])
rownames(result) <- names(x)
result
}
)
probes.all <- do.call(rbind, unname(probes.all))
controls.all <- rnb.get.annotation(sub("^probes", "controls", assay.name), ifelse(assay.name=="probesEPICv2", "hg38", rnb.getOption("assembly"))) ## TODO: Impove genome build selection
controls.all <- rnb.get.annotation(sub("^probes", "controls", assay.name), ifelse(is.EPICv2.or.MSA, "hg38", rnb.getOption("assembly"))) ## TODO: Impove genome build selection
controls.all <- controls.all[, "ID"]

## Extract data on signals
Expand Down Expand Up @@ -674,7 +691,8 @@ setAs("RnBeadRawSet", "RGChannelSet", function(from, to){
# probes.all <- do.call(rbind, unname(probes.all))
probes.all <- annotation(from)[,c("Design", "Color", "AddressA", "AddressB")]
genome.assembly<-rnb.getOption("assembly")
controls.all <- rnb.get.annotation(sub("^probes", "controls", assay.name), ifelse(assay.name=="probesEPICv2", "hg38", genome.assembly))
is.EPICv2.or.MSA<-ifelse(assay.name == "probesEPICv2" || assay.name == "probesMSA", TRUE, FALSE)
controls.all <- rnb.get.annotation(sub("^probes", "controls", assay.name), ifelse(is.EPICv2.or.MSA, "hg38", genome.assembly))
controls.all <- controls.all[, "ID"]

# Obtain methylated and unmethylated intensities
Expand Down Expand Up @@ -747,6 +765,8 @@ setAs("RnBeadRawSet", "RGChannelSet", function(from, to){
anno <- "IlluminaHumanMethylationEPIC"
}else if(assay.name %in% "probesEPICv2"){
anno <- "IlluminaHumanMethylationEPICv2"
}else if(assay.name %in% "probesMSA"){
anno <- "IlluminaHumanMethylationScreeningArray"
}else if(assay.name %in% "probes450"){
anno <- "IlluminaHumanMethylation450k"
}else if(assay.name %in% "probes27"){
Expand Down Expand Up @@ -1305,6 +1325,8 @@ intensities.by.color<-function(raw.set,
if (add.controls) {
if (raw.set@target == "probesEPICv2") {
ncd <- rnb.get.annotation("controlsEPICv2", assembly = "hg38")
} else if (raw.set@target == "probesMSA") {
ncd <- rnb.get.annotation("controlsMSA", assembly = "hg38")
} else {
ncd <- rnb.get.annotation(ifelse(raw.set@target == "probesEPIC", "controlsEPIC", "controls450"))
}
Expand Down
6 changes: 5 additions & 1 deletion R/RnBeadSet-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,15 @@ setMethod("initialize", "RnBeadSet",
.Object@qc<-qc

genome.assembly<-rnb.getOption("assembly")
is.EPICv2.or.MSA<-ifelse(target == "probesEPICv2" || target == "probesMSA", TRUE, FALSE)

callNextMethod(.Object,
pheno=pheno,
sites=sites,
meth.sites=meth.sites,
covg.sites=covg.sites,
status=status,
assembly=ifelse(target=="probesMMBC", "mm10", ifelse(target=="probesEPICv2", "hg38", genome.assembly)),
assembly=ifelse(target=="probesMMBC", "mm10", ifelse(is.EPICv2.or.MSA, "hg38", genome.assembly)),
target=target
)

Expand Down Expand Up @@ -246,6 +247,9 @@ RnBeadSet<-function(
} else if (platform == "EPICv2") {
target <- "probesEPICv2"
assembly <- "hg38"
} else if (platform == "MSA") {
target <- "probesMSA"
assembly <- "hg38"
} else if (platform == "450k") {
target <- "probes450"
assembly <- ifelse(genome.assembly == "hg19", "hg19", "hg38")
Expand Down
25 changes: 22 additions & 3 deletions R/annotations.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,24 @@ EPIC.CONTROL.TARGETS <- c(
"staining" = "STAINING",
"target removal" = "TARGET REMOVAL")

EPICv2.CONTROL.TARGETS <- c( ## TODO: Not validated for EPIC v2 (Most likely it's compatible)
EPICv2.CONTROL.TARGETS <- c(
"bisulfite conversion I" = "BISULFITE CONVERSION I",
"bisulfite conversion II" = "BISULFITE CONVERSION II",
"extension" = "EXTENSION",
"hybridization" = "HYBRIDIZATION",
"negative control" = "NEGATIVE",
"non-polymorphic" = "NON-POLYMORPHIC",
"norm A" = "NORM_A",
"norm C" = "NORM_C",
"norm G" = "NORM_G",
"norm T" = "NORM_T",
"restoration" = "RESTORATION",
"specificity I" = "SPECIFICITY I",
"specificity II" = "SPECIFICITY II",
"staining" = "STAINING",
"target removal" = "TARGET REMOVAL")

MSA.CONTROL.TARGETS <- c( ## TODO: Not validated for MSA (Most likely it's compatible)
"bisulfite conversion I" = "BISULFITE CONVERSION I",
"bisulfite conversion II" = "BISULFITE CONVERSION II",
"extension" = "EXTENSION",
Expand Down Expand Up @@ -766,7 +783,7 @@ rnb.get.assemblies <- function() {
#' rnb.get.annotation("promoters")
#' }
rnb.get.annotation <- function(type = "CpG", assembly = "hg19") {
if (type == "probesEPICv2" || type == "controlsEPICv2") {
if (type == "probesEPICv2" || type == "controlsEPICv2" || type == "probesMSA" || type == "controlsMSA") {
assembly = "hg38"
}

Expand Down Expand Up @@ -1364,7 +1381,7 @@ rnb.get.chromosomes <- function(assembly = "hg19") {
#' Extracts all control probe types in the HumanMethylation450 assay.
#'
#' @param target A singleton of type \code{character}, specifying the microarray platform.
#' \code{"probesEPICv2"},\code{"probesEPIC"},\code{"probes450"} and \code{"probes27"} correspond to MethylationEPICv2,
#' \code{"probesEPICv2"},\code{"probesMSA"},\code{"probesEPIC"},\code{"probes450"} and \code{"probes27"} correspond to MethylationEPICv2,
#' Methylation EPIC, HumanMethylation450, and HumanMethylation27 microarrays respectively.
#'
#' @return \code{character} vector of control targets.
Expand All @@ -1380,6 +1397,8 @@ rnb.infinium.control.targets <- function(target="probes450") {
return(EPIC.CONTROL.TARGETS)
}else if(target=="probesEPICv2"){
return(EPICv2.CONTROL.TARGETS)
}else if(target=="probesMSA"){
return(MSA.CONTROL.TARGETS)
}else if(target=="probes450"){
return(HM450.CONTROL.TARGETS)
}else if(target=="probes27"){
Expand Down
1 change: 0 additions & 1 deletion R/batch.R
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,6 @@ rnb.section.dreduction.internal <- function(report, pcoordinates, sample.phenoty
} else {
report <- rnb.add.section(report, "Low-dimensional Representation", stext)
}

## Mention that only some sites and/or regions are selected
if (!is.null(attr(pcoordinates, "selected"))) {
selected <- attr(pcoordinates, "selected")
Expand Down
5 changes: 5 additions & 0 deletions R/batch.quality.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ rnb.execute.batch.qc <- function(rnb.set, pcoordinates, permutations = NULL) {
id.col<-"ID"
type.col<-"Target"
ctrls<-"controlsEPICv2"
} else if(rnb.set@target=="probesMSA"){
CONTROL.TYPES <- rnb.infinium.control.targets("probesMSA")[c(1:4, 6, 11:14)]
id.col<-"ID"
type.col<-"Target"
ctrls<-"controlsMSA"
} else if(rnb.set@target=="probes450"){
CONTROL.TYPES <- rnb.infinium.control.targets("probes450")[c(1:4, 6, 11:14)]
id.col<-"ID"
Expand Down
3 changes: 2 additions & 1 deletion R/combining.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ rnb.combine.pheno <- function(dataset1, dataset2) {
#' @author Yassen Assenov
#' @export
rnb.combine.arrays <- function(dataset1, dataset2, type="common") {
## TODO: Update for MSA
if (!inherits(dataset1, "RnBeadSet")) {
stop("Invalid value for dataset1")
}
Expand All @@ -132,7 +133,7 @@ rnb.combine.arrays <- function(dataset1, dataset2, type="common") {
stop("Incompatible assemblies")
}
i <- c(dataset1@target, dataset2@target)
common.platform <- c("probesEPICv2" = "EPICv2", "probesEPIC" = "EPIC", "probes450" = "450k", "probes27" = "27k") ## TODO: Validate for EPICv2 (on EPICv1 ?)
common.platform <- c("probesEPICv2" = "EPICv2", "probesEPIC" = "EPIC", "probes450" = "450k", "probes27" = "27k")
if (!(i[1] %in% names(common.platform))) {
stop("Unsupported platform for dataset1")
}
Expand Down
30 changes: 17 additions & 13 deletions R/controlPlots.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ rnb.plot.control.boxplot <- function(
meta <- rnb.get.annotation("controlsEPIC", assembly = "hg19")
}else if(rnb.set@target=="probesEPICv2"){
meta <- rnb.get.annotation("controlsEPICv2", assembly = "hg38")
}else if(rnb.set@target=="probesMSA"){
meta <- rnb.get.annotation("controlsMSA", assembly = "hg38")
}else if(rnb.set@target=="probes450"){
meta <- rnb.get.annotation("controls450", assembly = "hg19")
}else if(rnb.set@target=="probes27"){
Expand All @@ -73,6 +75,8 @@ rnb.plot.control.boxplot <- function(
types<-rnb.infinium.control.targets(rnb.set@target)[c(14,4,3,15,1:2,12:13,6,11)]
}else if(rnb.set@target=="probesEPICv2"){
types<-rnb.infinium.control.targets(rnb.set@target)[c(14,4,3,15,1:2,12:13,6,11)]
}else if(rnb.set@target=="probesMSA"){
types<-rnb.infinium.control.targets(rnb.set@target)[c(14,4,3,15,1:2,12:13,6,11)]
}else if(rnb.set@target=="probes450"){
types<-rnb.infinium.control.targets(rnb.set@target)[c(13,4,3,14,1:2,11:12,6)]
}else if(rnb.set@target=="probes27"){
Expand All @@ -85,12 +89,12 @@ rnb.plot.control.boxplot <- function(
warning("Unoptimized probe type, plotting performance may be decreased")
}

if(rnb.set@target=="probes450" || rnb.set@target=="probesEPIC" || rnb.set@target=="probesMMBC" || rnb.set@target=="probesEPICv2"){
if(rnb.set@target=="probes450" || rnb.set@target=="probesEPIC" || rnb.set@target=="probesMMBC" || rnb.set@target=="probesEPICv2" || rnb.set@target=="probesMSA"){
rownames(meta)<-meta[["ID"]]
### TODO: Remove the following passage
### for testing purposes only!
if(rnb.set@target=="probesEPIC" || rnb.set@target=="probesEPICv2"){
meta<-rnb.update.controlsEPIC.enrich(meta) ## TODO: Not validated for EPICv2
if(rnb.set@target=="probesEPIC" || rnb.set@target=="probesEPICv2" || rnb.set@target=="probesMSA"){
meta<-rnb.update.controlsEPIC.enrich(meta) ## TODO: Not validated for EPICv2 & MSA
}
meta <- meta[type == meta[["Target"]], ]
ids<-as.character(meta[["ID"]])
Expand Down Expand Up @@ -125,7 +129,7 @@ rnb.plot.control.boxplot <- function(

scales<-lapply(qc(rnb.set), get.unified.scale)

if(rnb.set@target=="probes450" || rnb.set@target=="probesEPIC" || rnb.set@target=="probesMMBC" || rnb.set@target=="probesEPICv2"){
if(rnb.set@target=="probes450" || rnb.set@target=="probesEPIC" || rnb.set@target=="probesMMBC" || rnb.set@target=="probesEPICv2" || rnb.set@target=="probesMSA"){
## Shorten the words describing probe's expected intensity
INTENSITIES <- c("Background" = "Bgnd", "High" = "High", "Low" = "Low", "Medium" = "Med")
levels(meta[, "Expected Intensity"]) <- INTENSITIES[levels(meta[, "Expected Intensity"])]
Expand Down Expand Up @@ -220,14 +224,14 @@ rnb.plot.negative.boxplot<- function(
...) {


if(rnb.set@target=="probesEPIC" || rnb.set@target=="probesEPICv2" || rnb.set@target=="probesMMBC" ){
if(rnb.set@target=="probesEPIC" || rnb.set@target=="probesEPICv2" || rnb.set@target=="probesMMBC" || rnb.set@target=="probesMSA"){
genome.assembly<-rnb.getOption("assembly")
meta <- rnb.get.annotation(gsub("probes", "controls", rnb.set@target), assembly=c("probesEPIC"=genome.assembly, "probesMMBC"="mm10", "probesEPICv2"="hg38")[rnb.set@target])
meta <- rnb.get.annotation(gsub("probes", "controls", rnb.set@target), assembly=c("probesEPIC"=genome.assembly, "probesMMBC"="mm10", "probesEPICv2"="hg38", "probesMSA"="hg38")[rnb.set@target])
## Extract intensities of the control probes
### TODO: Remove the following passage
### for testing purposes only!
if(rnb.set@target=="probesEPIC" || rnb.set@target=="probesEPICv2"){
meta<-rnb.update.controlsEPIC.enrich(meta) ## TODO: Not validated for EPICv2 (duplicate)
if(rnb.set@target=="probesEPIC" || rnb.set@target=="probesEPICv2" || rnb.set@target=="probesMSA"){
meta<-rnb.update.controlsEPIC.enrich(meta) ## TODO: Not validated for EPICv2 & MSA (duplicate)
}
meta <- meta["NEGATIVE" == meta[["Target"]], ]
ids<-as.character(meta[["ID"]])
Expand Down Expand Up @@ -367,9 +371,9 @@ rnb.plot.control.barplot<-function(
{


if(rnb.set@target=="probesEPIC" || rnb.set@target=="probesEPICv2" || rnb.set@target=="probesMMBC"){
if(rnb.set@target=="probesEPIC" || rnb.set@target=="probesEPICv2" || rnb.set@target=="probesMMBC" || rnb.set@target=="probesMSA"){
genome.assembly<-rnb.getOption("assembly") ## TODO: Improve genome build selection
control.meta.data <- rnb.get.annotation(gsub("probes", "controls", rnb.set@target), assembly=c("probesEPIC"=genome.assembly, "probesEPICv2"="hg38", "probesMMBC"="mm10")[rnb.set@target])
control.meta.data <- rnb.get.annotation(gsub("probes", "controls", rnb.set@target), assembly=c("probesEPIC"=genome.assembly, "probesEPICv2"="hg38", "probesMSA"="hg38", "probesMMBC"="mm10")[rnb.set@target])
### TODO: Remove the following passage
### for testing purposes only!
#if(rnb.set@target=="probesEPIC"){
Expand Down Expand Up @@ -438,7 +442,7 @@ rnb.plot.control.barplot<-function(

## get meta information

if(rnb.set@target=="probes450" || rnb.set@target=="probesEPIC" || rnb.set@target=="probesMMBC" || rnb.set@target=="probesEPICv2"){
if(rnb.set@target=="probes450" || rnb.set@target=="probesEPIC" || rnb.set@target=="probesMMBC" || rnb.set@target=="probesEPICv2" || rnb.set@target=="probesMSA"){
meta<-subset(control.meta.data, ID==id)
}else if(rnb.set@target=="probes27"){
meta<-subset(control.meta.data, Address==id)
Expand All @@ -465,7 +469,7 @@ rnb.plot.control.barplot<-function(

### plot green channel

if(rnb.set@target=="probes450" || rnb.set@target=="probesEPIC" || rnb.set@target=="probesMMBC" || rnb.set@target=="probesEPICv2"){
if(rnb.set@target=="probes450" || rnb.set@target=="probesEPIC" || rnb.set@target=="probesMMBC" || rnb.set@target=="probesEPICv2" || rnb.set@target=="probesMSA"){
main_txt_grn<-paste(probe, meta[,"Description"], "green channel", if(meta[, "Evaluate Green"]=="+") meta[, "Expected Intensity"] else "Background", sep=": ")
main_txt_red<-paste(probe, meta[,"Description"], "red channel",if(meta[, "Evaluate Red"]=="+") meta[, "Expected Intensity"] else "Background", sep=": ")
}else{
Expand Down Expand Up @@ -531,7 +535,7 @@ rnb.plot.control.barplot<-function(
#' @author Yassen Assenov
#' @noRd
rnb.get.snp.matrix <- function(dataset, threshold.nas = 1) {
if (dataset@target %in% c("probes450", "probesEPIC", "probesMMBC", "probesEPICv2")) {
if (dataset@target %in% c("probes450", "probesEPIC", "probesMMBC", "probesEPICv2", "probesMSA")) {
result <- meth(dataset, row.names=TRUE)
result <- result[grep("^rs", rownames(result)), , drop = FALSE]
} else if (dataset@target == "probes27") {
Expand Down
Loading