doKMerPCA: k-mer PCA+tSNE

Description Usage Arguments Value Examples

Description

Performs PCA+tSNE of a k-mer frequency matrix. First, the k-mer matrix is scaled, then PCA (prcomp) is performed, then the number of significant PCs is determined, then tSNE is performed using the significant PCs.

Usage

1
doKMerPCA(x, nPCs = "jackstraw", scale = T)

Arguments

x

A matrix of k-mer frequencies, kmers (rows) by samples (columns), as would be produced by inputKMerFreqs.

nPCs

Method for identifying significant PCs, or the number of PCs to use. Either one of ("jackstraw", or "permutation"), or an integer number of PCs. defaults to "jackstraw"

scale

scale the data? defaults to True.

Value

Returns a PCA object (as created by prcomp), also including $nPCs (the number of significant PCs), $nPCMethod (the method used to get the number of PCs), $tSNE, the tsne object (as created by tsne), and $tSNEProj, the projection of the samples onto the two tSNE components.

Examples

1
2
3
4
5
kmerMat = inputKMerFreqs(sprintf("kMerFiles/%s.freq.gz",sampleDesc$id), IDs = sampleDesc$id)
myPCA = doKMerPCA(kmerMat, nPCs = "jackstraw")
p = ggplot(pcs$tSNEProj, aes(tSNE1, tSNE2)) + geom_point(); print(p) # plot tSNE projection
pcs$tSNEProj = merge(pcs$tSNEProj,sampleDesc, by.x="ID",by.y="goodID") # add sample information to tSNE projection
p = ggplot(pcs$tSNEProj, aes(tSNE1, tSNE2, colour=celltype)) + geom_point() + theme_classic(); print(p)

Carldeboer/BrockmanR documentation built on May 31, 2019, 2:19 p.m.