getHannum: Get sample age estimates using Hannum CpG Methylation Clock...

Description Usage Arguments Author(s) References Examples

View source: R/getHannum.R

Description

Uses methylation and coefficients at specified CpGs to estimate sample age as described in Hannum et al 2013.

Usage

1
getHannum(df, keepcpgs.hannum=TRUE, showStatusHannum=TRUE)

Arguments

df

Beta-value data frame, with samples as columns and markers as rows.

keepcpgs.hannum

Wether to retain list of CpGs used (model CpGs available in provided df).

showStatusHannum

Whether to display detailed status of age estimate calculations.

Author(s)

Sean Maden

References

Hannum et al. "Genome-wide Methylation Profiles Reveal Quantitative Views of Human Aging Rates." Molecular Cell, 2014.

Examples

 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
## The function is currently defined as
function (df, keepcpgs.hannum=TRUE, showStatusHannum=TRUE) 
{
    message("Initializing Hannum Clock age estimates...")
    hcgs <- hannumModel$marker
    int.hcgs <- rownames(df[rownames(df) 
    vector.df <- as.data.frame(matrix(nrow = ncol(df), ncol = (length(int.hcgs) + 
        1)))
    colnames(vector.df) <- c(int.hcgs, "Est.Age")
    rownames(vector.df) <- colnames(df)
    for (i in 1:nrow(vector.df)) {
        for (j in 1:(ncol(vector.df) - 1)) {
            cgi <- colnames(vector.df)[j]
            hcgs.weighti <- hannumModel[hannumModel$marker == 
                cgi, ]$coefficient
            vector.df[i, j] <- df[cgi, i] * hcgs.weighti
        }
        vector.df$Est.Age[i] <- sum(vector.df[i, 1:(ncol(vector.df) - 
            3)])
        if (showStatusHannum) {
 #           message("Hannum Age Est. Status: Finished sample ",i," or ",round(100*(i/nrow(vector.df)),3),"%")
        }
    }
    dfhan <- data.frame(Hannum.Est = vector.df$Est.Age)
    return.list <- list(dfhan)
    names(return.list) <- "Hannum.Clock.Est"
    if (keepcpgs.hannum) {
        return.list <- append(return.list, list(rownames(df[rownames(df) 
            hcgs, ])))
        names(return.list)[[length(return.list)]] <- "Hannum.CpGs.Used"
    }
    return(return.list)
}

metamaden/cgageR documentation built on May 20, 2019, 5:07 p.m.