getJaccard: Calculate Jaccard Index for Two Binary Vectors

Description Usage Arguments Details Value Author(s) References Examples

View source: R/getJaccard.R

Description

Calculate Jaccard index for two binary vectors.

Usage

1
getJaccard(cl1, cl2)

Arguments

cl1

n by 1 binary vector of classification 1 for the n subjects

cl2

n by 1 binary vector of classification 2 for the n subjects

Details

Jaccard Index is defined as the ratio

d/(b+c+d

, where d is the number of subjects who were classified to group 1 by both classification rules, b is the number of subjects who were classified to group 1 by classification rule 1 and were classified to group 0 by classification rule 2, c is the number of subjects who were classified to group 0 by classification rule 1 and were classified to group 1 by classification rule 2.

Value

The Jaccard Index

Author(s)

Zeyu Zhang, Danyang Yu, Minseok Seo, Craig P. Hersh, Scott T. Weiss, Weiliang Qiu

References

Zhang Z, Yu D, Seo M, Hersh CP, Weiss ST, Qiu W. Novel Data Transformations for RNA-seq Differential Expression Analysis. (2019) 9:4820 https://rdcu.be/brDe5

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  n = 10
  set.seed(1234567)

  # generate two random binary vector of size n
  cl1 = sample(c(1,0), size = n, prob = c(0.5, 0.5), replace = TRUE)
  cl2 = sample(c(1,0), size = n, prob = c(0.5, 0.5), replace = TRUE)
  cat("\n2x2 contingency table >>\n")
  print(table(cl1, cl2))

  JI = getJaccard(cl1, cl2)
  cat("Jaccard index = ", JI, "\n")

countTransformers documentation built on May 1, 2019, 7:59 p.m.