The function runs k-nearest neighbors analysis on a subset of the synthetic data set. The function uses the 'knn' package.

computeKNNRefSyn(listEigenvector, pRAIDS)

Arguments

listEigenvector

a list with 3 entries: 'sample.id', 'eigenvector.ref' and 'eigenvector'. The list represents the PCA done on the 1KG reference profiles and the synthetic profiles projected onto it.

pRAIDS

a RAIDSparam an object with all the RAIDS parameters

Value

a list containing 4 entries:

sample.id

a vector of character strings representing the identifiers of the synthetic profiles analysed.

sample1Kg

a vector of character strings representing the identifiers of the 1KG reference profiles used to generate the synthetic profiles.

sp

a vector of character strings representing the known super population ancestry of the 1KG reference profiles used to generate the synthetic profiles.

matKNN

a data.frame containing the super population inference for each synthetic profiles for different values of PCA dimensions D and k-neighbors values K. The fourth column title corresponds to the fieldPopInfAnc parameter. The data.frame contains 4 columns:

sample.id

a character string representing the identifier of the synthetic profile analysed.

D

a numeric strings representing the value of the PCA dimension used to infer the super population.

K

a numeric strings representing the value of the k-neighbors used to infer the super population.

fieldPopInfAnc value

a character string representing the inferred ancestry.

Author

Pascal Belleau, Astrid Deschênes and Alexander Krasnitz

Examples



## Load the demo PCA on the synthetic profiles projected on the
## demo 1KG reference PCA
data(demoPCASyntheticProfiles)

## Load the known ancestry for the demo 1KG reference profiles
data(demoKnownSuperPop1KG)

## Path to the demo Profile GDS file is located in this package
dataDir <- system.file("extdata/demoKNNSynthetic", package="RAIDS")


# The name of the synthetic study
studyID <- "MYDATA.Synthetic"

studyDF <- data.frame(study.id=studyID,
                             study.desc=studyID,
                             study.platform="NotDef",
                             stringsAsFactors=FALSE)
pathProfileGDS <- file.path(dataDir) # , "ex1.gds"
fileReferenceGDS <- system.file("extdata/tests/ex1_good_small_1KG.gds", package="RAIDS")
pedStudy <- data.frame(Name.ID=c("ex1"),
                             Case.ID=c("ex1"),
                             Sample.Type=c("type"),
                             Diagnosis="NotDef",
                             Source=c("NotDef"),
                             stringsAsFactors=FALSE)
     row.names(pedStudy) <- pedStudy$Name.ID

pRAIDS <- RAIDSparam(studyDF=studyDF,
                      pedStudy=pedStudy,
                      pathProfileGDS=pathProfileGDS,
                      fileReferenceGDS=fileReferenceGDS)
## Projects synthetic profiles on 1KG PCA
results <- computeKNNRefSyn(listEigenvector=demoPCASyntheticProfiles,
    pRAIDS=pRAIDS)

## The inferred ancestry for the synthetic profiles for different values
## of D and K
head(results$matKNN)
#>         sample.id D K superPop
#> 1 1.ex1.HG00246.1 2 2      SAS
#> 2 1.ex1.HG00325.1 2 2      EAS
#> 3 1.ex1.HG00611.1 2 2      SAS
#> 4 1.ex1.HG01173.1 2 2      EAS
#> 5 1.ex1.HG02165.1 2 2      EAS
#> 6 1.ex1.HG01112.1 2 2      AMR