Learn R Programming

KRIS (version 1.1.6)

cal.pc.projection: Calculate linear principal component analysis (PCA) with a projection method for Single-nucleotide polymorphism (SNP) dataset.

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

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.

  • $PC is a PC matrix which rows represent samples and columns represent PCs.

  • $individual_id is a vector of charactors that contains individuals IDs.

  • $label is a vector of charactors that contains labels for all lindividuals.

  • $status is a vector of numbers that contains disease status for all. individuals.

See Also

cal.pc.linear

Examples

Run this code
# NOT RUN {
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)


# }

Run the code above in your browser using DataLab