Skip to content

calcPCBrainAge documentation and imputation bug #2

@DanielEWeeks

Description

@DanielEWeeks

Here are two issues:

(1) The documentation states that DNAm should be a matrix, but this is not correct - you are actually assuming/requiring that it be a data.frame, as this line does not work if DNAm is a matrix instead of a data.frame:

DNAm[, missingCpGs] <- NA

(2) There is an error here in the imputation code because datMeth is in the parent environment, and so has not been expanded to include the missingCpGs columns. Thus, this dies at this line:

datMeth[, missingCpGs[i]] <- imputeMissingBrainCpGs[missingCpGs[i]]

because it is trying to insert the mean CpG values in for the missingCpGs[i] that does not exist in the original datMeth.

Instead, the line should be

DNAm[, missingCpGs[i]] <- imputeMissingBrainCpGs[missingCpGs[i]]

So I think all mentions of datMeth should be replaced with DNAm instead. Here's a portion of the code:

    DNAm[, missingCpGs] <- NA
    if (!is.na(missingCpGs[1])) {
        if (is.null(CpGImputation)) {
            data("imputeMissingBrainCpGs")
            for (i in 1:length(missingCpGs)) {
                datMeth[, missingCpGs[i]] <- imputeMissingBrainCpGs[missingCpGs[i]]
            }
        }
        else {
            for (i in 1:length(missingCpGs)) {
                datMeth[, missingCpGs[i]] <- CpGImputation[missingCpGs[i]]
            }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions