The function select the optimal K and D parameters for a specific profile. The results on the synthetic data are used for the parameter selection. Once the optimal parameters are selected, the ancestry is inferred for the specific profile.

computeAncestryFromSynthetic2(
  syntheticKNN,
  pedSyn,
  spRef,
  listCatPop = c("EAS", "EUR", "AFR", "AMR", "SAS"),
  pRAIDS = pRAIDS
)

Arguments

syntheticKNN

a vector of character strings representing the name of files that contain the results of ancestry inference done on the synthetic profiles for multiple values of D and K. The files must exist.

pedSyn

a data.frame containing the columns extracted from the GDS Sample 'study.annot' node with a extra column named as the 'popName' parameter that has been extracted from the 1KG GDS 'sample.annot' node.

spRef

a vector of character strings representing the known super population ancestry for the 1KG profiles. The 1KG profile identifiers are used as names for the vector.

listCatPop

a vector of character string representing the list of possible ancestry assignations. Default: ("EAS", "EUR", "AFR", "AMR", "SAS").

pRAIDS

a RAIDSparam an object with all the RAIDS parameters

Value

a list containing 4 entries:

pcaSample

a list containing the information related to the eigenvectors. The list contains those 3 entries:

sample.id

a character string representing the unique identifier of the current profile.

eigenvector.ref

a matrix of numeric containing the eigenvectors for the reference profiles.

eigenvector

a matrix of numeric containing the eigenvectors for the current profile projected on the PCA from the reference profiles.

paraSample

a list containing the results with different D and K values that lead to optimal parameter selection. The list contains those entries:

dfPCA

a data.frame containing statistical results on all combined synthetic results done with a fixed value of D (the number of dimensions). The data.frame contains those columns:

D

a numeric representing the value of D (the number of dimensions).

median

a numeric representing the median of the minimum AUROC obtained (within super populations) for all combination of the fixed D value and all tested K values.

mad

a numeric representing the MAD of the minimum AUROC obtained (within super populations) for all combination of the fixed D value and all tested K values.

upQuartile

a numeric representing the upper quartile of the minimum AUROC obtained (within super populations) for all combination of the fixed D value and all tested K values.

k

a numeric representing the optimal K value (the number of neighbors) for a fixed D value.

dfPop

a data.frame containing statistical results on all combined synthetic results done with different values of D (the number of dimensions) and K (the number of neighbors). The data.frame contains those columns:

D

a numeric representing the value of D (the number of dimensions).

K

a numeric representing the value of K (the number of neighbors).

AUROC.min

a numeric representing the minimum accuracy obtained by grouping all the synthetic results by super-populations, for the specified values of D and K.

AUROC

a numeric representing the accuracy obtained by grouping all the synthetic results for the specified values of D and K.

Accu.CM

a numeric representing the value of accuracy of the confusion matrix obtained by grouping all the synthetic results for the specified values of D and K.

dfAUROC

a data.frame the summary of the results by super-population. The data.frame contains those columns:

D

a numeric representing the value of D (the number of dimensions).

K

a numeric representing the value of K (the number of neighbors).

Call

a character string representing the super-population.

L

a numeric representing the lower value of the 95% confidence interval for the AUROC obtained for the fixed values of super-population, D and K.

AUROC

a numeric representing the AUROC obtained for the fixed values of super-population, D and K.

H

a numeric representing the higher value of the 95% confidence interval for the AUROC obtained for the fixed values of super-population, D and K.

D

a numeric representing the optimal D value (the number of dimensions) for the specific profile.

K

a numeric representing the optimal K value (the number of neighbors) for the specific profile.

listD

a numeric representing the optimal D values (the number of dimensions) for the specific profile. More than one D is possible.

KNNSample

a list containing the inferred ancestry using different D and K values. The list contains those entries:

sample.id

a character string representing the unique identifier of the current profile.

matKNN

a data.frame containing the inferred ancestry for different values of K and D. The data.frame contains those columns:

sample.id

a character string representing the unique identifier of the current profile.

D

a numeric representing the value of D (the number of dimensions) used to infer the ancestry.

K

a numeric representing the value of K (the number of neighbors) used to infer the ancestry.

SuperPop

a character string representing the inferred ancestry for the specified D and K values.

Ancestry

a data.frame containing the inferred ancestry for the current profile. The data.frame contains those columns:

sample.id

a character string representing the unique identifier of the current profile.

D

a numeric representing the value of D (the number of dimensions) used to infer the ancestry.

K

a numeric representing the value of K (the number of neighbors) used to infer the ancestry.

SuperPop

a character string representing the inferred ancestry.

References

Galinsky KJ, Bhatia G, Loh PR, Georgiev S, Mukherjee S, Patterson NJ, Price AL. Fast Principal-Component Analysis Reveals Convergent Evolution of ADH1B in Europe and East Asia. Am J Hum Genet. 2016 Mar 3;98(3):456-72. doi: 10.1016/j.ajhg.2015.12.022. Epub 2016 Feb 25.

Author

Pascal Belleau, Astrid Deschênes and Alexander Krasnitz

Examples


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

## The Reference GDS file
path1KG <- system.file("extdata/tests", package="RAIDS")

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

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

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,
                      fieldPopInfAnc="SuperPop")

pedSyn <- RAIDS:::prepPedSyntheticRef(pRAIDS)
spRef <- getRefSuperPop2(pRAIDS)
syntheticKNN <- readRDS(file.path(dataDir, "ex1", "KNN.synt.ex1.2.rds"))
resCall <- computeAncestryFromSynthetic2(syntheticKNN=syntheticKNN,
                      pedSyn=pedSyn,
                      spRef=spRef,
                      listCatPop=c("EAS", "EUR", "AFR", "AMR", "SAS"),
                      pRAIDS=pRAIDS)
#> Warning: A K smaller than 3 could not give robust results.
#> Warning: ci.auc() of a ROC curve with AUC == 1 is always 1-1 and can be misleading.

resCall$Ancestry
#>    sample.id D  K SuperPop
#> 80       ex1 7 11      EAS