Closed samulituominen closed 3 years ago
Hi @samulituominen ,
The error stems from a difference in the cells that you are estimating. In your code you must replace "Neu" for "Gran" for CordBloodCombined. See pages 6 and 7 from the manual . I hope this solves the issue. I will close this issue, but please let me know whether you still have any problems after that.
Hi @lucassalas and thanks for the quick response ! I did that and unfortunately the same error persists:
library(FlowSorted.Blood.EPIC)
library(FlowSorted.CordBloodCombined.450k)
data(IDOLOptimizedCpGsCordBlood)
RGSet <- readRDS('rgset.rds')
countsEPIC <- estimateCellCounts2(RGSet,
compositeCellType = "CordBloodCombined",
processMethod = "preprocessNoob",
probeSelect = "IDOL",
cellTypes = c("CD8T", "CD4T", "NK", "Bcell", "Mono", "Gran", "nRBC"),
referencePlatform = "IlluminaHumanMethylation450k",
referenceset = "FlowSorted.CordBloodCombined.450k",
IDOLOptimizedCpGs = IDOLOptimizedCpGsCordBlood,
returnAll = FALSE)
[convertArray] Casting as IlluminaHumanMethylation450k Loading required package: IlluminaHumanMethylation450kmanifest Loading required package: IlluminaHumanMethylationEPICmanifest Error in h(simpleError(msg, call)) : error in evaluating the argument 'table' in selecting a method for function '%in%': unable to find an inherited method for function ‘colData’ for signature ‘"function"’
Hi,
I want to diagnose the problem as I do not see the line where the function is broken.
My best guess is that one of your colData is either logical or factor and this is breaking the combination by the combineArrays function from minfi.
Please take a look using this:
head(pData(RGset))
If any logical or factor, manually set those to as.character.
Also run this two lines to confirm that colData is being called properly:
`!"CellType" %in% names(colData(FlowSorted.CordBloodCombined.450k))
!"CellType" %in% names(colData(RGSet))
`
What is strange here is that the minfi function combineArrays does not call a match table for RGChannelSet objects. Was this object stored with an old minfi version?
The functions are just these lines:
`setMethod( "combineArrays", signature(object1 = "RGChannelSet", object2 = "RGChannelSet"), function(object1, object2, outType = c("IlluminaHumanMethylation450k", "IlluminaHumanMethylationEPIC"), verbose = TRUE) {
outType <- match.arg(outType)
array1 <- annotation(object1)[["array"]]
array2 <- annotation(object2)[["array"]]
if (array1 == array2) outType <- array1
if (array1 == "IlluminaHumanMethylation27k" ||
array2 == "IlluminaHumanMethylation27k") {
stop("27k arrays cannot be combined at the RGChannelSet level.")
}
object1 <- convertArray(object1, outType = outType, verbose = verbose)
object2 <- convertArray(object2, outType = outType, verbose = verbose)
features1 <- rownames(object1)
features2 <- rownames(object2)
features <- intersect(features1, features2)
object1 <- object1[features, ]
object2 <- object2[features, ]
rgSet <- combine(object1, object2)
rgSet$ArrayTypes <- rep(
x = c(array1, array2),
times = c(ncol(object1), ncol(object2)))
rgSet
}
) setMethod( "convertArray", signature(object = "RGChannelSet"), function(object, outType = c("IlluminaHumanMethylation450k", "IlluminaHumanMethylationEPIC"), verbose = TRUE) {
outType <- match.arg(outType)
array <- annotation(object)[["array"]]
if (array == outType) return(object)
if (verbose) message(sprintf("[convertArray] Casting as %s", outType))
.convertArray_450k_epic(
rgSet = object,
outType = outType,
verbose = verbose)
}
) .convertArray_450k_epic<-function (rgSet, outType = c("IlluminaHumanMethylation450k", "IlluminaHumanMethylationEPIC"), verbose = verbose) { outType <- match.arg(outType) .isRGOrStop(rgSet) stopifnot(.is450k(rgSet) || .isEPIC(rgSet)) array <- annotation(rgSet)["array"] if (array == outType) stop("'rgSet' already in the 'outType' array type.") manifest1 <- getManifest(outType) manifest2 <- getManifest(rgSet) keepAddresses <- list(I = NULL, II = NULL, SnpI = NULL, SnpII = NULL, Control = NULL) probes1 <- getProbeInfo(manifest1, type = "I") probes2 <- getProbeInfo(manifest2, type = "I") commonNames <- intersect(probes1$Name, probes2$Name) probes1 <- probes1[match(commonNames, probes1$Name), ] probes2 <- probes2[match(commonNames, probes2$Name), ] stopifnot(all(probes1$Color == probes2$Color)) stopifnot(all(probes1$ProbeSeqA == probes2$ProbeSeqA)) stopifnot(all(probes1$ProbeSeqB == probes2$ProbeSeqB)) translate <- c(probes1$AddressA, probes1$AddressB) names(translate) <- c(probes2$AddressA, probes2$AddressB) wh <- which(rownames(rgSet) %in% names(translate)) rownames(rgSet)[wh] <- translate[rownames(rgSet)[wh]] keepAddresses$I <- unname(translate) probes1 <- getProbeInfo(manifest1, type = "II") probes2 <- getProbeInfo(manifest2, type = "II") commonNames <- intersect(probes1$Name, probes2$Name) probes1 <- probes1[match(commonNames, probes1$Name), ] probes2 <- probes2[match(commonNames, probes2$Name), ] stopifnot(all(probes1$ProbeSeqA == probes2$ProbeSeqA)) translate <- probes1$AddressA names(translate) <- probes2$AddressA wh <- which(rownames(rgSet) %in% names(translate)) rownames(rgSet)[wh] <- translate[rownames(rgSet)[wh]] keepAddresses$II <- unname(translate) probes1 <- getProbeInfo(manifest1, type = "SnpI") probes2 <- getProbeInfo(manifest2, type = "SnpI") commonNames <- intersect(probes1$Name, probes2$Name) probes1 <- probes1[match(commonNames, probes1$Name), ] probes2 <- probes2[match(commonNames, probes2$Name), ] stopifnot(all(probes1$ProbeSeqA == probes2$ProbeSeqB)) stopifnot(all(probes1$ProbeSeqB == probes2$ProbeSeqA)) translate <- c(probes1$AddressA, probes1$AddressB) names(translate) <- c(probes2$AddressA, probes2$AddressB) wh <- which(rownames(rgSet) %in% names(translate)) rownames(rgSet)[wh] <- translate[rownames(rgSet)[wh]] keepAddresses$SnpI <- unname(translate) probes1 <- getProbeInfo(manifest1, type = "SnpII") probes2 <- getProbeInfo(manifest2, type = "SnpII") commonNames <- intersect(probes1$Name, probes2$Name) probes1 <- probes1[match(commonNames, probes1$Name), ] probes2 <- probes2[match(commonNames, probes2$Name), ] stopifnot(all(probes1$ProbeSeqA == probes2$ProbeSeqA)) translate <- probes1$AddressA names(translate) <- probes2$AddressA wh <- which(rownames(rgSet) %in% names(translate)) rownames(rgSet)[wh] <- translate[rownames(rgSet)[wh]] keepAddresses$SnpII <- unname(translate) probes1 <- getProbeInfo(manifest1, type = "Control") probes2 <- getProbeInfo(manifest2, type = "Control") commonAddress <- intersect(probes1$Address, probes2$Address) probes1 <- probes1[match(commonAddress, probes1$Address), ] probes2 <- probes2[match(commonAddress, probes2$Address), ] keepAddresses$Control <- unname(probes1$Address) keepAddresses <- do.call("c", keepAddresses) keepAddresses <- keepAddresses[keepAddresses %in% rownames(rgSet)] rgSet <- rgSet[keepAddresses, ] annotation(rgSet) <- .getAnnotationFromOutType(outType) rgSet }`
table is not called here (but it is for other combineArrays minfi objects).
Look carefully to your colData, if nothing of the solutions above work, I would try to redo the RGChannelSet (maybe a small subset of 10 samples instead of the 288) and check again the combineArrays. Please let me know if it works.
I ran the script line by line and noticed that this line throws the error. From that and preceding lines I understood that I was missing the reference set (FlowSorted.CordBloodCombined.450k) from my workspace.
The error message was a bit cryptic, but in the end it was my bad. Downloading the reference set fixed the problem, here's the complete working version:
library(FlowSorted.Blood.EPIC)
library(FlowSorted.CordBloodCombined.450k)
data(IDOLOptimizedCpGsCordBlood)
library(ExperimentHub)
hub <- ExperimentHub()
myfiles <- query(hub, "FlowSorted.CordBloodCombined.450k")
FlowSorted.CordBloodCombined.450k <- myfiles[[1]]
RGSet <- readRDS('rgset.rds')
memory.limit(60000)
countsEPIC <- estimateCellCounts2(RGSet,
compositeCellType = "CordBloodCombined",
processMethod = "preprocessNoob",
probeSelect = "IDOL",
cellTypes = c("CD8T", "CD4T", "NK", "Bcell", "Mono", "Gran", "nRBC"),
referencePlatform = "IlluminaHumanMethylation450k",
referenceset = "FlowSorted.CordBloodCombined.450k",
IDOLOptimizedCpGs = IDOLOptimizedCpGsCordBlood,
returnAll = FALSE)
[convertArray] Casting as IlluminaHumanMethylation450k [estimateCellCounts2] Combining user data with reference (flow sorted) data. [estimateCellCounts2] Processing user and reference data together. [estimateCellCounts2] Using IDOL L-DMR probes for composition estimation. [estimateCellCounts2] Estimating composition.
Warning message: In asMethod(object) : NAs introduced by coercion
I'm getting a weird error while running FlowSorted.Blood.EPIC::estimateCellCounts2(). My data are from cord blood measured with the EPIC chip. This is my setup:
Then, I try to run:
which I hope is appropriate given the data. However, I'm getting this error:
Do you have any idea what is causing this ? I also noticed that if I try the same, but with different (inappropriate) arguments, it finishes:
Below is my sessionInfo(). Im using R 4.0.2 with all the packages freshly installed.