This function write with P-matrix
prepPMatrix(anchor, snpId, matGr = NULL, pRAIDS)a vector of character representing the
ancestral group for each profile from the reference
where sample.ref == 1. If the admixture proportion is higher than
the threshold for one ancestral group, the value is the name
of the ancestral group; else "-".
a vector of character representing the list
of snp.id from gdsReference to keep.
a matrix containing the sample identifiers and where
each column is the name of a subcontinental population. The number of
row corresponds to the number of samples for each subcontinental population.
a RAIDSparam an object with all the RAIDS
parameters.
a list containing one entry per ancestral group:
ancestral groupa list contenains 2 entries:
fa list contenains number of rows in
matGr + 1 entries:
vectorthe first is frequency for all the anchor of each snpId
vectorthe other is frequency for all the anchor minus one row of matGr of each snpId
indexa vector contenains 2 entriescontenains
number of rows in matGr entries. Each value is the index of the row
for which the f of this index corresponds.
## Required library
library(SNPRelate)
data(demoKnownSuperPop1KG)
## 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")
matGr <- getMatrixPopSynthetic(pRAIDS=pRAIDS)
fileGDSProfile <- file.path(pathProfileGDS(pRAIDS),
paste0(pedStudy(pRAIDS)$Name.ID[1], ".gds"))
gdsProfile <- snpgdsOpen(fileGDSProfile)
pruned <- read.gdsn(index.gdsn(gdsProfile, "pruned.study"))
snpgdsClose(gdsProfile)
gdsReference <- snpgdsOpen(fileReferenceGDS(pRAIDS))
admixDesc <- read.gdsn(index.gdsn(gdsReference, "admixture.desc"))
pos <- admixDesc[admixDesc$id == anchorId(pRAIDS), "id.seq"]
anchor <- read.gdsn(index.gdsn(gdsReference, "anchor.ref"),
start=c(1, pos), count=c(-1,1))
snpgdsClose(gdsReference)
rowF <- prepPMatrix( anchor=anchor, snpId = pruned, matGr=matGr, pRAIDS=pRAIDS)
#> Genotype matrix: 28 samples X 61 SNPs
#> Genotype matrix: 27 samples X 61 SNPs
#> Genotype matrix: 5 samples X 61 SNPs
#> Genotype matrix: 33 samples X 61 SNPs
#> Genotype matrix: 10 samples X 61 SNPs
names(rowF)
#> [1] "agEUR" "agEAS" "agAMR" "agAFR" "agSAS"