centre_control: Shift co-ordinates to centre on a compounds centroid

Description Usage Arguments Value Examples

Description

Idea is to shift co-ordinates so that the centroid of the negative control is always centered on 0,0. Useful for PCA biplots where the 0,0 denotes the centroid of the entire data, and not necessarily the negative control. If given a dataframe and specified columns for the x and y co-ordinates, this function will shift the co-ordinates to be centered on the centroid of a specified compound. The difference between centre_control and centre_controls_m is that centre_control_m can centre a range or columns, whereas centre_control is limited to 2 named columns.

Usage

1
centre_control(df, cols, cmpd_col, cmpd)

Arguments

df

dataframe

cols

column indicies or names

cmpd_col

column containing names to subset with cmpd

cmpd

name of compound to subset cmpd_col with

Value

dataframe of 'df' shifted so that cmpd is centered on 0,0

Examples

1
2
3
4
5
6
7
8
# artifical example using iris
pca <- prcomp(iris[,1:4])$x[,1:3]
df <- data.frame(pca, name = iris[,5])
pca_shift <- centre_control(df, 1:3,  cmpd_col = 'name', cmpd = 'setosa')

par(mfrow = c(2,1))
plot(df$PC1, df$PC2, col = df$name, pch = 20)
plot(pca_shift$PC1, pca_shift$PC2, col = pca_shift$name, pch = 20)

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