Description Usage Arguments Value See Also Examples
View source: R/principal.component.R
Available for two types of data; numeric data and Single-nucleotide polymorphism (SNP) dataset in additive coding (0, 1, and 2).
1 | cal.pc.linear(X, PCscore = TRUE, no.pc = NA, data.type = "linear", XXT = TRUE)
|
X |
A data matrix which rows represent samples and columns represent features. |
PCscore |
To specify whether scaled PCs will be calculated or not. If FALSE, eigenvectors are returned instead. Default = TRUE. |
no.pc |
A number of PCs to be calculated. If no.pc is set, PCs are patially calculated. Otherwise all PCs are obtained after calculation. Default = NA. |
data.type |
To specify a type of data matrix X. It can be set to "linear" and "snp". Default = "linear". |
XXT |
To specify how pricipal components (PCs) are calculated. If TRUE, PCs are calculated from X.t(X), otherwise X is used directly. XXT is useful option especially an input matrix X contains many columns. Enabling this option, it helps to reduce computation complexity. Regardless the option XXT is enable or not, optained PCs are the same. Default = TRUE. |
The returned value is a list with 2 objects, $PC
,
$evalue
:
$PC
is a PC matrix which rows represent samples and columns
represent PCs.
$evalue
is a vector of eigen values.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #Load simulated dataset
data(example_SNP)
#Using default parameters
PCs <- cal.pc.linear(simsnp$snp)
summary(PCs)
#Preview $PC
print(PCs$PC[1:5,1:3])
#Preview $evalue
print(PCs$evalue[1:3])
plot3views(PCs$PC[,1:3], sample_labels)
#Calculate PCs without PC scores
PCs <- cal.pc.linear(simsnp$snp, PCscore = FALSE)
summary(PCs)
#Preview $PC
print(PCs$PC[1:5,1:3])
#Preview $evalue
print(PCs$evalue[1:3])
plot3views(PCs$PC[,1:3], sample_labels)
#Calculate the top 3 PCs
PCs <- cal.pc.linear(simsnp$snp, no.pc = 3)
summary(PCs)
#Preview $PC
print(PCs$PC[1:5,1:3])
#Preview $evalue
print(PCs$evalue[1:3])
plot3views(PCs$PC[,1:3], sample_labels)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.