stat.getDirSim {CTD}R Documentation

DirSim: The Jaccard distance with directionality incorporated.

Description

DirSim: The Jaccard distance with directionality incorporated.

Usage

stat.getDirSim(ptID, ptID2, kmx, data_mx)

Arguments

ptID

- The identifier associated with patient 1's sample.

ptID2

- The identifier associated with patient 2's sample.

kmx

- The number of top perturbations to consider in distance calculation.

data_mx

- The matrix that gives the perturbation strength (z-scores) for all variables (columns) for each patient (rows).

Value

dirSim - a distance matrix, where row and columns are patient identifiers.

Examples

# Get patient distances for the first 2 patients in the Miller 2015 dataset.
data("Miller2015")
data_mx = Miller2015[-c(1,grep("x - ", rownames(Miller2015))),
                        grep("IEM",colnames(Miller2015))]
data_mx = apply(data_mx[,c(1,2)], c(1,2), as.numeric)
# Look at the top 5 metabolites for each patient. 
kmx=5
# Build your results ("res") list object to store patient distances at
# different size k's.
res = list()
t = list(dir=matrix(NA, nrow=ncol(data_mx), ncol=ncol(data_mx)))
rownames(t$dir) = colnames(data_mx)
colnames(t$dir) = colnames(data_mx)
for (i in seq_len(kmx)) { res[[i]] = t }
for (pt in seq_len(ncol(data_mx))) {
    print(pt)
    ptID=colnames(data_mx)[pt]
    for (pt2 in pt:ncol(data_mx)) {
        ptID2=colnames(data_mx)[pt2]
        tmp=stat.getDirSim(ptID,ptID2,kmx,data_mx)
        for (k in seq_len(kmx)) {
            res[[k]]$dir[ptID, ptID2]=tmp[k]
            res[[k]]$dir[ptID2, ptID]=tmp[k]
        }
    }
}

[Package CTD version 1.0.0 Index]