R/processStudy.R
add1KG2SampleGDS.Rd
The function extracts the information about the pruned SNVs from the 1KG GDS file and adds entries related to the pruned SNVs in the Profile GDS file. The nodes are added to the Profile GDS file: 'sample.id', 'snp.id', 'snp.chromosome', 'snp.position', 'snp.index', 'genotype' and 'lap'.
add1KG2SampleGDS(gdsReference, fileProfileGDS, currentProfile, studyID)
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 Profile GDS file. The Profile GDS file must exist.
a character
string corresponding to the sample
identifier associated to the current list of pruned SNVs.
a character
string corresponding to the study
identifier associated to the current list of pruned SNVs.
The function returns 0L
when successful.
## Required library for GDS
library(SNPRelate)
## Path to the demo 1KG GDS file is located in this package
dataDir <- system.file("extdata/tests", package="RAIDS")
fileGDS <- file.path(dataDir, "ex1_good_small_1KG.gds")
## The data.frame containing the information about the study
## The 3 mandatory columns: "studyID", "study.desc", "study.platform"
## The entries should be strings, not factors (stringsAsFactors=FALSE)
studyDF <- data.frame(study.id="MYDATA",
study.desc="Description",
study.platform="PLATFORM",
stringsAsFactors=FALSE)
## Temporary Profile file
fileProfile <- file.path(tempdir(), "ex2.gds")
## Copy required file
file.copy(file.path(dataDir, "ex1_demo_with_pruning.gds"),
fileProfile)
#> [1] TRUE
## Open 1KG file
gds1KG <- snpgdsOpen(fileGDS)
## Compute the list of pruned SNVs for a specific profile 'ex1'
## and save it in the Profile GDS file 'ex2.gds'
add1KG2SampleGDS(gdsReference=gds1KG,
fileProfileGDS=fileProfile,
currentProfile=c("ex1"),
studyID=studyDF$study.id)
#> [1] 0
## Close the 1KG GDS file (important)
closefn.gds(gds1KG)
## Check content of Profile GDS file
## The 'pruned.study' entry should be present
content <- openfn.gds(fileProfile)
content
#> File: /tmp/Rtmps2Gf87/ex2.gds (10.4K)
#> + [ ]
#> |--+ Ref.count { SparseInt16 11000x1, 568B }
#> |--+ Alt.count { SparseInt16 11000x1, 74B }
#> |--+ Total.count { SparseInt16 11000x1, 580B }
#> |--+ study.list [ data.frame ] *
#> | |--+ study.id { Str8 1, 7B }
#> | |--+ study.desc { Str8 1, 12B }
#> | \--+ study.platform { Str8 1, 9B }
#> |--+ study.annot [ data.frame ] *
#> | |--+ data.id { Str8 1, 4B }
#> | |--+ case.id { Str8 1, 12B }
#> | |--+ sample.type { Str8 1, 14B }
#> | |--+ diagnosis { Str8 1, 7B }
#> | |--+ source { Str8 1, 11B }
#> | \--+ study.id { Str8 1, 7B }
#> |--+ geno.ref { Bit2 11000x1 LZMA_ra(10.7%), 301B }
#> |--+ pruned.study { Str8 61, 578B }
#> |--+ sample.id { Str8 157, 1.2K }
#> |--+ snp.id { Str8 61, 578B }
#> |--+ snp.chromosome { Int32 61, 244B }
#> |--+ snp.position { Int32 61, 244B }
#> |--+ snp.index { Int32 61, 244B }
#> |--+ genotype { Bit2 61x157, 2.3K }
#> \--+ lap { PackedReal8 61, 61B }
## Close the Profile GDS file (important)
closefn.gds(content)
## Remove Profile GDS file (created for demo purpose)
unlink(fileProfile, force=TRUE)