R/ancestryAnalysis.R
pruningProfile2.RdThis function computes the list of pruned SNVs for a
specific profile. When
a group of SNVs are in linkage disequilibrium, only one SNV from that group
is retained. The linkage disequilibrium is calculated with the
snpgdsLDpruning() function. The initial list of
SNVs that are passed to the snpgdsLDpruning()
function can be specified by the user.
pruningProfile2(pRAIDS)The function returns a RAIDSparam an object with all the RAIDS
parameters updated.
## Path to the demo Reference 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: "study.id", "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)
## The data.frame containing the information about the samples
## The entries should be strings, not factors (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
## Temporary Profile GDS file
pathProfileGDS <- tempdir()
profileFile <- file.path(pathProfileGDS, "ex1.gds")
pRAIDS <- RAIDSparam( studyDF=studyDF,
profileFile=file.path(dataDir, "ex1.txt.gz"),
genoSource = "snp-pileup",
pedStudy=samplePED,
pathProfileGDS=pathProfileGDS,
fileReferenceGDS=fileGDS)
## Copy the Profile GDS file demo that has not been pruned yet
file.copy(file.path(dataDir, "ex1_demo.gds"), profileFile)
#> [1] TRUE
## Compute the list of pruned SNVs for a specific profile 'ex1'
## and save it in the Profile GDS file 'ex1.gds'
pRAIDS <- pruningProfile2(pRAIDS)
## Check content of Profile GDS file
## The 'pruned.study' entry should be present
content <- openfn.gds(profileFile)
content
#> File: /tmp/Rtmp46wk9V/ex1.gds (4.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 40, 379B }
## Close the Profile GDS file (important)
closefn.gds(content)
## Remove Profile GDS file (created for demo purpose)
unlink(profileFile, force=TRUE)