cosine_pairs: Calculate pairs of cosine similarities between replicates

Description Usage Arguments Value Examples

Description

Given a list, with an element per compound, cols are the elements of the vector with which to calculate the cosine similarity. cosine_pairs will calculate the theta value between all replicates for each possible pairing of compounds and return the result in a long-format dataframe.

Usage

1
cosine_pairs(x, cols)

Arguments

x

list, each element being a separate compound

cols

integer, column indices that match numeric data (e.g principal comonents)

Value

dataframe of compound combinations across replicates with a column of cosine similarity values

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
cmpds <- c(rep('compound_1', 100),
           rep('compound_2', 100),
           rep('compound_3', 100))
replicate <- rep(1:100, 3)
PC1 <- rnorm(300)
PC2 <- rnorm(300)
df <- data.frame(cmpds, replicate, PC1, PC2)
df_split <- split(df, df$cmpds)
# works with unequal replicate sizes
df_split$a <- df_split$a[-c(1:10), ]
cosine_pairs(df_split, 3:4)

Swarchal/TCCS documentation built on May 9, 2019, 3:24 p.m.