cal.pc.projection: Calculate linear principal component analysis (PCA) with a...

Description Usage Arguments Value See Also Examples

View source: R/principal.component.R

Description

In order to perform the projection method, disease status for all individuals are required. First, PCA is performed only in control group, then project the scores from control group into case group.

Usage

1
2
3
4
5
6
7
8
cal.pc.projection(
  X,
  status,
  individual_id = NULL,
  labels = NULL,
  no.pc = NA,
  data.type = "linear"
)

Arguments

X

A data matrix which rows represent samples and columns represent features.

status

A vector of numbers that contains disease status for all individuals. For control group, the status is "1", and "2" for case group. Individuals with unknown status (other numbers) are ignored and excluded from the result.

individual_id

A vector of charactors that contains individuals IDs

labels

A vector of charactors that contains labels for all lindividuals

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".

Value

The returned value is a list with 4 objects, $PC, $id, $label,and $status. Individuals with unknown status are excluded.

See Also

cal.pc.linear

Examples

 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
data(example_SNP)

#Create a random list of disease status, 1 = Control and 2 = Case

ind_status <- sample(c(1,2), size = length(sample_labels), replace = TRUE)

PCs <- cal.pc.projection(simsnp$snp, status = ind_status,
labels = sample_labels)
summary(PCs)

#Preview $PC
print(PCs$PC[1:5,1:3])

#Preview $status
print(PCs$status[1:3])

plot3views(PCs$PC[,1:3], PCs$label)

#Calculate the top 3 PCs

PCs <- cal.pc.projection(simsnp$snp, status = ind_status,
labels = sample_labels, no.pc = 3)
summary(PCs)

#Preview $PC
print(PCs$PC[1:5,1:3])

plot3views(PCs$PC[,1:3], PCs$label)

KRIS documentation built on Jan. 21, 2021, 5:08 p.m.