cog_cv_ra: Cog Core/Variable and Relative Abundance

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

This function classifies each cog into "core" or "variable" categories.

Usage

1

Arguments

df

the input is a data-frame with the column names participants and the row names cogs.

Details

"Core" is defined as any cog that is in 100 percent of participants. "Variable" is defined as any cog that is in less than 100 percent of participants.

Value

The output is a data frame with three columns. The first column is the cog name, the second column classifies the cog by "core" or "variable" and the

Author(s)

atomczik

References

http://www.ncbi.nlm.nih.gov/pubmed/19043404

See Also

see also cog.path.ref

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
34
35
36
37
38
39
40
41
42
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (df) 
{
    df <- normalize_counts(df)
    n <- length(row.names(df))
    m <- length(df)
    k <- m + 1
    for (i in 1:n) {
        df[i, ] <- as.numeric(df[i, ])
    }
    df$core_variable <- "blank"
    for (i in 1:n) {
        df$core_variable[i] <- ((sum((df[i, ]) >= 1e-07)) - 1)
    }
    for (i in 1:n) {
        if (df[i, ]$core_variable >= m) {
            df[i, ]$core_variable <- "core"
        }
        else {
            df[i, ]$core_variable <- "variable"
        }
    }
    df$RA_mean <- "blank"
    for (i in 1:n) {
        df$RA_mean[i] <- mean(as.numeric(df[i, 1:m]))
    }
    df$RA_sd <- "blank"
    for (i in 1:n) {
        df$RA_sd[i] <- sd(as.numeric(df[i, 1:m]))
    }
    cog.cv.ra <- as.data.frame(cbind(row.names(df), df$core_variable, 
        df$RA_mean, df$RA_sd))
    names(cog.cv.ra) <- c("cog.name", "core_variable", "RA_mean", 
        "RA_sd")
    cog.cv.ra$RA_mean <- as.numeric(cog.cv.ra$RA_mean)
    cog.cv.ra$RA_sd <- as.numeric(cog.cv.ra$RA_sd)
    return(cog.cv.ra)
  }

dlemas/microbes documentation built on May 15, 2019, 9:15 a.m.