da2DT: Convert a 'lda' object to a long-format 'data.table'

View source: R/da2DT.R

da2DTR Documentation

Convert a lda object to a long-format data.table

Description

Convert a lda object to a long-format data.table

Usage

da2DT(daObj, sampVec, obsPops)

Arguments

daObj

Lda: An object produced by lda.

sampVec

Character: The sample IDs, which need to match the sample order in predict(daObj)$x.

obsPops

Character/Factor: The observed population IDs, which need to match sample order in predict(daObj)$x.

Value

Returns a wide-format data.table with columns $POP, the population IDs, $SAMPLE, the sample IDs, $LD[x], the individual LD axes, with [x] denoting the axis number.

Examples

library(genomalicious)

data(data_Genos)

PCA <- pca_genos(data_Genos, popCol='POP')
DA <- lda(PCA$pops ~ PCA$x[,1:3])

da2DT(DA, sampVec=rownames(PCA$x), obsPops=PCA$pops)


j-a-thia/genomalicious documentation built on Oct. 19, 2024, 7:51 p.m.