R/processStudy.R
addStudy1Kg.Rd
The information about the samples present in the 1KG GDS file is added into the GDS Sample file. Only the information about the unrelated samples from the 1OOO Genome Study are copied into the GDS Sample file. The information is only added to the GDS Sample file when the 1KG Study is not already present in the GDS Sample file. The sample information for all selected samples is appended to the GDS Sample file "study.annot" node. The study information is appended to the GDS Sample file "study.list" node.
addStudy1Kg(gdsReference, fileProfileGDS, verbose = FALSE)
an object of class gds.class (a GDS file), the opened 1KG GDS file.
a character
string representing the path and
file name of the GDS Sample file. The GDS Sample file must exist.
a logical
indicating if messages should be printed
to show how the different steps in the function. Default: FALSE
.
The integer 0L
when successful.
## Required library for GDS
library(gdsfmt)
## Get the temp folder
tempDir <- tempdir()
## Create a temporary 1KG GDS file and add needed information
fileName1KG <- file.path(tempDir, "GDS_TEMP_addStudy1Kg_1KG.gds")
gds1KG <- createfn.gds(filename=fileName1KG)
add.gdsn(gds1KG, "sample.id", c("HTT101", "HTT102", "HTT103"))
samples <- data.frame(sex=c(1, 1, 2), pop.group=c("GBR", "GIH", "GBR"),
superPop=c("EUR", "SAS", "EUR"), batch=rep(0, 3),
stringsAsFactors = FALSE)
add.gdsn(gds1KG, "sample.annot", samples)
add.gdsn(gds1KG, "sample.ref", c(1,0, 1))
sync.gds(gds1KG)
## Create a temporary Profile GDS file
fileNameProfile <- file.path(tempDir, "GDS_TEMP_addStudy1Kg_Sample.gds")
gdsProfile <- createfn.gds(fileNameProfile)
study.list <- data.frame(study.id=c("HTT Study"),
study.desc=c("Important Study"),
study.platform=c("Panel"), stringsAsFactors=FALSE)
add.gdsn(gdsProfile, "study.list", study.list)
study.annot <- data.frame(data.id=c("TOTO1"), case.id=c("TOTO1"),
sample.type=c("Study"), diagnosis=c("Study"),
source=rep("IGSR"), study.id=c("Study"),
stringsAsFactors=FALSE)
add.gdsn(gdsProfile, "study.annot", study.annot)
sync.gds(gdsProfile)
closefn.gds(gdsProfile)
## Append information about the 1KG samples into the Profile GDS file
## The Profile GDS file will contain 'study.list' and 'study.annot' entries
addStudy1Kg(gdsReference=gds1KG, fileProfileGDS=fileNameProfile,
verbose=TRUE)
#> study.annot DONE 2024-10-22 20:26:50.012342
#> [1] 0
closefn.gds(gds1KG)
unlink(fileNameProfile, recursive=TRUE, force=TRUE)
unlink(fileName1KG, recursive=TRUE, force=TRUE)
unlink(tempDir)