R/synthetic2.R
syntheticGeno2.RdThe functions uses one cancer profile in combination with one 1KG reference profile to generate an synthetic profile that is saved in the Profile GDS file.
When more than one 1KG reference profiles are specified, the function recursively generates synthetic profiles for each cancer profile + 1KG reference profile combination.
The number of synthetic profiles generated by combination is specified by the number of simulation requested.
syntheticGeno2(pRAIDS)The integer OL when the function is successful.
## Required library
library(gdsfmt)
## Path to the demo 1KG GDS file is located in this package
dataDir <- system.file("extdata/tests", package="RAIDS")
## Profile GDS file (temporary)
pathProfileGDS <- tempdir()
fileNameGDS <- file.path(pathProfileGDS, "ex1.gds")
## Copy the Profile GDS file demo that has been pruned and annotated
file.copy(file.path(dataDir, "ex1_demo_with_pruning_and_1KG_annot.gds"),
fileNameGDS)
#> [1] TRUE
studyDF <- data.frame(study.id = "MYDATA",
study.desc = "Description",
study.platform = "PLATFORM",
stringsAsFactors = FALSE)
samplePED <- data.frame(Name.ID = c("ex1", "ex2"),
Case.ID = c("Patient_h11", "Patient_h12"),
Diagnosis = rep("Cancer", 2),
Sample.Type = rep("Primary Tumor", 2),
Source = rep("Databank B", 2), stringsAsFactors = FALSE)
rownames(samplePED) <- samplePED$Name.ID
pRAIDS <- RAIDSparam(profileFile=file.path(dataDir, "ex1.txt.gz"),
genoSource="snp-pileup",
studyDF=studyDF,
pedStudy=samplePED,
prefix="synthTest",
pathProfileGDS=pathProfileGDS,
fileReferenceGDS=file.path(dataDir,
"ex1_good_small_1KG.gds"),
fileReferenceAnnotGDS=file.path(dataDir,
"ex1_good_small_1KG_Annot.gds")
)
syntheticRefDF(pRAIDS) <- selectForSynthetic(pRAIDS = pRAIDS,
nbProfiles=30L)
## Generate the synthetic profiles and add them into the Profile GDS
syntheticGeno2(pRAIDS)
#> [1] 0
profileGDS <- openfn.gds(fileNameGDS)
tail(read.gdsn(index.gdsn(profileGDS, "sample.id")))
#> [1] "synthTest.ex1.NA20910.1" "synthTest.ex1.NA20847.1"
#> [3] "synthTest.ex1.NA20908.1" "synthTest.ex1.NA20872.1"
#> [5] "synthTest.ex1.NA20906.1" "synthTest.ex1.NA20875.1"
## Close GDS files (important)
closefn.gds(profileGDS)
## Remove Profile GDS file (created for demo purpose)
unlink(fileNameGDS, force=TRUE)