R/consensusFingerprint.R

Defines functions consensusFingerprint

Documented in consensusFingerprint

consensusFingerprint <-
function(fingerprintframe, threshold)
# Produce a consensus fingerprint. For each pathway, the consesnsus 
# fingerprint is
# 1 if either the mean of the fingerprints exceed a certain threshold,
# -1 if they fall below -threshold,
# 0 otherwise
{
    if (threshold < 0) stop("threshold must be positive")

    mean.frame <- apply(fingerprintframe, 1, mean) # create mean fingerprint
    consensus <- rep(0, nrow(fingerprintframe)) # initiate consenssu vector

    if (!(length(consensus) == length(mean.frame))) stop("Error")

    names(consensus) <- names(mean.frame)
    consensus[mean.frame > threshold] <- 1# fill with pathways passing threshold
    consensus[mean.frame < (-threshold)] <- (-1)

    return (consensus)
}

Try the pathprint package in your browser

Any scripts or data that you put into this service are public.

pathprint documentation built on April 28, 2020, 7:54 p.m.