R/Rcpp_interface.R

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393


# == title
# Distance by closeness
#
# == param
# -mat a numeric matrix where the distance is calculated by rows
#
# == details
# For two rows in the matrix, assume x_1, x_2, ..., x_n1 are the column index of none-zero values in row 1
# and y_1, y_2, ... y_n2 are the column index for non-zero values in row 2, 
# the distance between the two rows based on the closeness is calculated as:
#
# d_closeness = sum_i sum_j(|x_i - y_j|) / (n_1*n_2)
#
# == value
# A `stats::dist` object
#
# == author
# Zuguang Gu <z.gu@dkfz.de>
#
# == example
# x1 = c(0, 0, 0, 0, 1, 1, 1, 0, 0, 0)
# x2 = c(0, 0, 0, 1, 1, 1, 0, 0, 0, 0)
# x3 = c(1, 0, 0, 0, 1, 1, 0, 0, 0, 0)
# m = rbind(x1, x2, x3)
# dist(m)
# dist_by_closeness(m)
#
dist_by_closeness = function(mat) {
    as.dist(.Call("_EnrichedHeatmap_dist_by_closeness", mat))
}
eilslabs/EnrichedHeatmap documentation built on May 16, 2019, 1:22 a.m.