Update to parse the plink output for LD blocks.
... | ... |
@@ -9,7 +9,7 @@ Description: This package implements specialized algorithms that enable |
9 | 9 |
following publication: Belleau, P et al. Genetic Ancestry Inference from |
10 | 10 |
Cancer-Derived Molecular Data across Genomic and Transcriptomic |
11 | 11 |
Platforms. Cancer Res 1 January 2023; 83 (1): 49–58. |
12 |
-Version: 1.3.1 |
|
12 |
+Version: 1.3.2 |
|
13 | 13 |
Authors@R: c(person("Pascal", "Belleau", email="[email protected]", |
14 | 14 |
role=c("cre", "aut"), comment = c(ORCID = "0000-0002-0802-1071")), |
15 | 15 |
person("Astrid", "Deschênes", email="[email protected]", |
... | ... |
@@ -1335,3 +1335,107 @@ appendGDSSampleOnly <- function(gds, listSamples) { |
1335 | 1335 |
|
1336 | 1336 |
return(0L) |
1337 | 1337 |
} |
1338 |
+ |
|
1339 |
+#' @title Append information associated to ld blocks, as indexes, into the |
|
1340 |
+#' Population Reference SNV Annotation GDS file |
|
1341 |
+#' |
|
1342 |
+#' @description The function appends the information about the ld blocks into |
|
1343 |
+#' the Population Reference SNV Annotation GDS file. The information is |
|
1344 |
+#' extracted from the parameter listBlock. |
|
1345 |
+#' |
|
1346 |
+#' @param gds an object of class \link[gdsfmt]{gds.class} |
|
1347 |
+#' (GDS file), an opened Reference Annotation GDS file. |
|
1348 |
+#' |
|
1349 |
+#' @param listBlock a \code{array} of integer |
|
1350 |
+#' representing the linkage disequilibrium block for |
|
1351 |
+#' each SNV in the in the same order than the variant |
|
1352 |
+#' in Population reference dataset. |
|
1353 |
+#' |
|
1354 |
+#' @param blockName a \code{character} string representing the id of the block. |
|
1355 |
+#' The blockName should not exist in \'gdsRefAnnotFile\'. |
|
1356 |
+#' |
|
1357 |
+#' @param blockDesc a \code{character} string representing the description of |
|
1358 |
+#' the block. |
|
1359 |
+#' |
|
1360 |
+#' @return The integer \code{0L} when successful. |
|
1361 |
+#' |
|
1362 |
+#' @examples |
|
1363 |
+#' |
|
1364 |
+#' ## Required library for GDS |
|
1365 |
+#' library(gdsfmt) |
|
1366 |
+#' ## Path to the demo pedigree file is located in this package |
|
1367 |
+#' dataDir <- system.file("extdata", package="RAIDS") |
|
1368 |
+#' |
|
1369 |
+# ## Temporary file |
|
1370 |
+#' fileAnnotGDS <- file.path(tempdir(), "ex1_good_small_1KG_Ann_GDS.gds") |
|
1371 |
+#' |
|
1372 |
+#' |
|
1373 |
+#' file.copy(file.path(dataDir, "tests", |
|
1374 |
+#' "ex1_NoBlockGene.1KG_Annot_GDS.gds"), fileAnnotGDS) |
|
1375 |
+#' |
|
1376 |
+#' |
|
1377 |
+#' fileReferenceGDS <- file.path(dataDir, "tests", |
|
1378 |
+#' "ex1_good_small_1KG.gds") |
|
1379 |
+#' \donttest{ |
|
1380 |
+#' gdsRef <- openfn.gds(fileReferenceGDS) |
|
1381 |
+#' listBlock <- read.gdsn(index.gdsn(gdsRef, "snp.position")) |
|
1382 |
+#' listBlock <- rep(-1, length(listBlock)) |
|
1383 |
+#' closefn.gds(gdsRef) |
|
1384 |
+#' gdsAnnot1KG <- openfn.gds(fileAnnotGDS, readonly=FALSE) |
|
1385 |
+#' ## Append information associated to blocks |
|
1386 |
+#' RAIDS:::addGDS1KGLDBlock(gds=gdsAnnot1KG, |
|
1387 |
+#' listBlock=listBlock, |
|
1388 |
+#' blockName="blockEmpty", |
|
1389 |
+#' blockDesc="Example") |
|
1390 |
+#'. closefn.gds(gdsAnnot1KG) |
|
1391 |
+#' |
|
1392 |
+#' gdsAnnot1KG <- openfn.gds(fileAnnotGDS) |
|
1393 |
+#' print(gdsAnnot1KG) |
|
1394 |
+#' |
|
1395 |
+#' closefn.gds(gdsAnnot1KG) |
|
1396 |
+#' } |
|
1397 |
+#' |
|
1398 |
+#' ## Remove temporary file |
|
1399 |
+#' unlink(fileAnnotGDS, force=TRUE) |
|
1400 |
+#' |
|
1401 |
+#' @author Pascal Belleau, Astrid Deschênes and Alexander Krasnitz |
|
1402 |
+#' @importFrom gdsfmt add.gdsn index.gdsn ls.gdsn compression.gdsn |
|
1403 |
+#' @importFrom gdsfmt append.gdsn sync.gds |
|
1404 |
+#' @encoding UTF-8 |
|
1405 |
+#' @keywords internal |
|
1406 |
+addGDS1KGLDBlock <- function(gds, listBlock, blockName, blockDesc) { |
|
1407 |
+ |
|
1408 |
+ blockAnnot <- data.frame(block.id=blockName, |
|
1409 |
+ block.desc=blockDesc, |
|
1410 |
+ stringsAsFactors=FALSE) |
|
1411 |
+ |
|
1412 |
+ if(! ("block.annot" %in% ls.gdsn(gds))) { |
|
1413 |
+ varBlockAnnot <- add.gdsn(gds, "block.annot", blockAnnot) |
|
1414 |
+ }else { |
|
1415 |
+ curAnnot <- index.gdsn(gds, "block.annot/block.id") |
|
1416 |
+ append.gdsn(curAnnot,blockAnnot$block.id) |
|
1417 |
+ curAnnot <- index.gdsn(gds, "block.annot/block.desc") |
|
1418 |
+ append.gdsn(curAnnot, blockAnnot$block.desc) |
|
1419 |
+ } |
|
1420 |
+ |
|
1421 |
+ varBlock <- NULL |
|
1422 |
+ if(! ("block" %in% ls.gdsn(gds))){ |
|
1423 |
+ varBlock <- add.gdsn(gds, "block", |
|
1424 |
+ valdim=c(length(listBlock), 1), |
|
1425 |
+ listBlock, storage="int32", |
|
1426 |
+ compress = "LZ4_RA") |
|
1427 |
+ readmode.gdsn(varBlock) |
|
1428 |
+ |
|
1429 |
+ }else { |
|
1430 |
+ if(is.null(varBlock)) { |
|
1431 |
+ varBlock <- index.gdsn(gds, "block") |
|
1432 |
+ varBlock <- compression.gdsn(varBlock, "") |
|
1433 |
+ } |
|
1434 |
+ append.gdsn(varBlock, listBlock) |
|
1435 |
+ varBlock <- compression.gdsn(varBlock, "LZ4_RA") |
|
1436 |
+ } |
|
1437 |
+ |
|
1438 |
+ sync.gds(gds) |
|
1439 |
+ |
|
1440 |
+ return(0L) |
|
1441 |
+} |
... | ... |
@@ -1020,6 +1020,183 @@ getRefSuperPop <- function(fileReferenceGDS) { |
1020 | 1020 |
return(df) |
1021 | 1021 |
} |
1022 | 1022 |
|
1023 |
+#' @title Append information associated to ld blocks, as indexes, into the |
|
1024 |
+#' Population Reference SNV Annotation GDS file |
|
1025 |
+#' |
|
1026 |
+#' @description The function appends the information about the ld blocks into |
|
1027 |
+#' the Population Reference SNV Annotation GDS file. The information is |
|
1028 |
+#' extracted from the Population Reference GDS file and files \'.det\'. |
|
1029 |
+#' |
|
1030 |
+#' @param fileReferenceGDS a \code{character} string representing the file |
|
1031 |
+#' name of the Reference GDS file. The file must exist. |
|
1032 |
+#' |
|
1033 |
+#' @param gdsRefAnnotFile a \code{character} string representing the |
|
1034 |
+#' file name corresponding the Reference SNV |
|
1035 |
+#' Annotation GDS file. The function will |
|
1036 |
+#' open it in write mode and close it after. The file must exist. |
|
1037 |
+#' |
|
1038 |
+#' @param pathBlock a \code{character} string representing the directory |
|
1039 |
+#' where all the output file det from the plink block command are located. |
|
1040 |
+#' The directory must not include other file with the extension \'.det\'. |
|
1041 |
+#' The name of the \'.det\' must include the super-population between \'.\' |
|
1042 |
+#' and the chromosome in the form \'chrNumber.\' \( \'chr1.\'\). |
|
1043 |
+#' |
|
1044 |
+#' @param superPop a \code{character} string representing the super population. |
|
1045 |
+#' |
|
1046 |
+#' @param blockName a \code{character} string representing the id of the block. |
|
1047 |
+#' The blockName should not exist in \'gdsRefAnnotFile\'. |
|
1048 |
+#' Default: \code{"ldBlock"}. |
|
1049 |
+#' |
|
1050 |
+#' @param blockDesc a \code{character} string representing the description of |
|
1051 |
+#' the block. |
|
1052 |
+#' Default: \code{"Not Define"} |
|
1053 |
+#' |
|
1054 |
+#' @param verbose a \code{logical} indicating if message information should be |
|
1055 |
+#' printed. Default: \code{FALSE}. |
|
1056 |
+#' |
|
1057 |
+#' @return \code{OL} when the function is successful. |
|
1058 |
+#' |
|
1059 |
+#' @details |
|
1060 |
+#' |
|
1061 |
+#' More information about GDS file format can be found at the Bioconductor |
|
1062 |
+#' gdsfmt website: |
|
1063 |
+#' https://bioconductor.org/packages/gdsfmt/ |
|
1064 |
+#' |
|
1065 |
+#' @examples |
|
1066 |
+#' |
|
1067 |
+#' ## Path to the demo pedigree file is located in this package |
|
1068 |
+#' dataDir <- system.file("extdata", package="RAIDS") |
|
1069 |
+#' |
|
1070 |
+# ## Temporary file |
|
1071 |
+#' fileAnnotGDS <- file.path(tempdir(), "ex1_good_small_1KG_Ann_GDS.gds") |
|
1072 |
+#' |
|
1073 |
+#' ## Demo of of output file det from the plink block |
|
1074 |
+#' ## command for chromosome 1 |
|
1075 |
+#' fileLdBlock <- file.path(dirname(fileAnnotGDS), "block.sp.EUR.Ex.chr1.blocks.det") |
|
1076 |
+#' |
|
1077 |
+#' |
|
1078 |
+#' file.copy(file.path(dataDir, "tests", |
|
1079 |
+#' "ex1_NoBlockGene.1KG_Annot_GDS.gds"), fileAnnotGDS) |
|
1080 |
+#' file.copy(file.path(dataDir, "block.sp.EUR.Ex.chr1.blocks.det"), |
|
1081 |
+#' fileLdBlock) |
|
1082 |
+#' |
|
1083 |
+#' |
|
1084 |
+#' |
|
1085 |
+#' ## GDS Reference file |
|
1086 |
+#' fileReferenceGDS <- file.path(dataDir, "tests", |
|
1087 |
+#' "ex1_good_small_1KG.gds") |
|
1088 |
+#' |
|
1089 |
+#' \donttest{ |
|
1090 |
+#' |
|
1091 |
+#' |
|
1092 |
+#' ## Append information associated to blocks |
|
1093 |
+#' addBlockFromDetFile(fileReferenceGDS=fileReferenceGDS, |
|
1094 |
+#' gdsRefAnnotFile=fileAnnotGDS, |
|
1095 |
+#' pathBlock=dirname(fileAnnotGDS), |
|
1096 |
+#' superPop="EUR") |
|
1097 |
+#' |
|
1098 |
+#' gdsAnnot1KG <- openfn.gds(fileAnnotGDS) |
|
1099 |
+#' print(gdsAnnot1KG) |
|
1100 |
+#' |
|
1101 |
+#' closefn.gds(gdsAnnot1KG) |
|
1102 |
+#' } |
|
1103 |
+#' |
|
1104 |
+#' ## Remove temporary file |
|
1105 |
+#' unlink(fileAnnotGDS, force=TRUE) |
|
1106 |
+#' unlink(fileLdBlock, force=TRUE) |
|
1107 |
+#' |
|
1108 |
+#' @author Pascal Belleau, Astrid Deschênes and Alexander Krasnitz |
|
1109 |
+#' |
|
1110 |
+#' @importFrom gdsfmt openfn.gds closefn.gds read.gdsn index.gdsn ls.gdsn |
|
1111 |
+#' @importFrom SNPRelate snpgdsOpen |
|
1112 |
+#' @encoding UTF-8 |
|
1113 |
+#' @export |
|
1114 |
+addBlockFromDetFile <- function(fileReferenceGDS, gdsRefAnnotFile, pathBlock, |
|
1115 |
+ superPop, blockName="ldBlock", |
|
1116 |
+ blockDesc="Not Define", verbose=FALSE) { |
|
1117 |
+ if (!(is.character(fileReferenceGDS) && (file.exists(fileReferenceGDS)))) { |
|
1118 |
+ stop("The \'fileReferenceGDS\' must be a character string ", |
|
1119 |
+ "representing the Reference GDS file. The file must exist.") |
|
1120 |
+ } |
|
1121 |
+ if(!(is.character(blockName))){ |
|
1122 |
+ stop("The \'blockName\' must be a character string ", |
|
1123 |
+ "representing the name of the block.") |
|
1124 |
+ } |
|
1125 |
+ |
|
1126 |
+ if(blockName == "ldBlock"){ |
|
1127 |
+ blockName <- paste0(blockName, ".", superPop) |
|
1128 |
+ } |
|
1129 |
+ |
|
1130 |
+ gdsRefAnnot <- openfn.gds(gdsRefAnnotFile) |
|
1131 |
+ |
|
1132 |
+ if(("block.annot" %in% ls.gdsn(gdsRefAnnot))) { |
|
1133 |
+ listAnno <- read.gdsn(index.gdsn(gdsRefAnnot, "block.annot")) |
|
1134 |
+ if(length(which(gdsRefAnnot$block.id == blockName)) > 0){ |
|
1135 |
+ stop("The \'blockName\' already exist in \'gdsRefAnnotFile\'.") |
|
1136 |
+ } |
|
1137 |
+ } |
|
1138 |
+ closefn.gds(gdsRefAnnot) |
|
1139 |
+ |
|
1140 |
+ gdsReference <- snpgdsOpen(filename=fileReferenceGDS) |
|
1141 |
+ |
|
1142 |
+ |
|
1143 |
+ |
|
1144 |
+ ## The verbose must be a logical |
|
1145 |
+ validateLogical(verbose, "verbose") |
|
1146 |
+ |
|
1147 |
+ ## Extract the SNP chromosomes and positions |
|
1148 |
+ snpChromosome <- read.gdsn(index.gdsn(gdsReference, "snp.chromosome")) |
|
1149 |
+ #snpPosition <- read.gdsn(index.gdsn(gdsReference, "snp.position")) |
|
1150 |
+ closefn.gds(gdsReference) |
|
1151 |
+ |
|
1152 |
+ listFileBlock <- dir(pathBlock, ".det") |
|
1153 |
+ listFileBlock <- listFileBlock[grep(paste0("\\.", superPop, "\\."), listFileBlock)] |
|
1154 |
+ |
|
1155 |
+ listChr <- unique(snpChromosome) |
|
1156 |
+ |
|
1157 |
+ #listChr <- listChr[order(listChr)] |
|
1158 |
+ #listChr <- seq_len(22) |
|
1159 |
+ listBlock <- list() |
|
1160 |
+ |
|
1161 |
+ for(chr in seq_len(length(listChr))) { |
|
1162 |
+ if(verbose) { message("chr", listChr[chr], " ",Sys.time()) } |
|
1163 |
+ listChrCur <- listFileBlock[grep(paste0("chr",listChr[chr],"\\."), listFileBlock)] |
|
1164 |
+ if(length(listChrCur) == 1){ |
|
1165 |
+ tmp <- processBlockChr(fileReferenceGDS, file.path(pathBlock, listChrCur)) |
|
1166 |
+ listBlock[[chr]] <- tmp$block.snp |
|
1167 |
+ if(chr > 1) { |
|
1168 |
+ vMax <- max(listBlock[[chr-1]]) |
|
1169 |
+ vMin <- min(listBlock[[chr-1]]) |
|
1170 |
+ listBlock[[chr]][listBlock[[chr]] > 0] <- |
|
1171 |
+ listBlock[[chr]][listBlock[[chr]] > 0] + vMax |
|
1172 |
+ if(vMin < 0) { |
|
1173 |
+ listBlock[[chr]][listBlock[[chr]] < 0] <- |
|
1174 |
+ listBlock[[chr]][listBlock[[chr]] < 0] + vMin |
|
1175 |
+ } |
|
1176 |
+ } |
|
1177 |
+ }else{ |
|
1178 |
+ |
|
1179 |
+ listBlock[[chr]] <- rep(-1, length(which(snpChromosome == listChr[chr]))) |
|
1180 |
+ vMin <- 0 |
|
1181 |
+ if(chr > 1){ |
|
1182 |
+ vMin <- min(listBlock[[chr-1]]) |
|
1183 |
+ } |
|
1184 |
+ if(vMin < 0){ |
|
1185 |
+ listBlock[[chr]] <- listBlock[[chr]] + vMin |
|
1186 |
+ } |
|
1187 |
+ } |
|
1188 |
+ |
|
1189 |
+ } |
|
1190 |
+ listBlock <- do.call(c, listBlock) |
|
1191 |
+ |
|
1192 |
+ gdsRefAnnot <- openfn.gds(gdsRefAnnotFile, readonly = FALSE) |
|
1193 |
+ |
|
1194 |
+ ## Save the information into the GDS file |
|
1195 |
+ addGDS1KGLDBlock(gdsRefAnnot, listBlock, blockName, blockDesc) |
|
1196 |
+ closefn.gds(gdsRefAnnot) |
|
1197 |
+ ## Success |
|
1198 |
+ return(0L) |
|
1199 |
+} |
|
1023 | 1200 |
|
1024 | 1201 |
#' @title Append information associated to blocks, as indexes, into the |
1025 | 1202 |
#' Population Reference SNV Annotation GDS file |
... | ... |
@@ -2351,7 +2351,9 @@ inferAncestry <- function(profileFile, pathProfileGDS, |
2351 | 2351 |
|
2352 | 2352 |
genoSource <- arg_match(genoSource) |
2353 | 2353 |
|
2354 |
- |
|
2354 |
+ if(genoSource == "bam"){ |
|
2355 |
+ stop("The bam is not release yet look to get a \'Devel\' version or contact us") |
|
2356 |
+ } |
|
2355 | 2357 |
profileName <- gsub("\\.gz$", "", profileBaseName, ignore.case = TRUE) |
2356 | 2358 |
for(extCur in c( "\\.vcf$", "\\.txt$", "\\.bam", "\\.tsv", "\\.csv")){ |
2357 | 2359 |
profileName <- gsub(extCur, "", profileName, ignore.case = TRUE) |
... | ... |
@@ -2776,6 +2778,9 @@ inferAncestryGeneAware <- function(profileFile, pathProfileGDS, |
2776 | 2778 |
|
2777 | 2779 |
genoSource <- arg_match(genoSource) |
2778 | 2780 |
|
2781 |
+ if(genoSource == "bam"){ |
|
2782 |
+ stop("The bam is not release yet look to get a \'Devel\' version or contact us") |
|
2783 |
+ } |
|
2779 | 2784 |
|
2780 | 2785 |
profileName <- gsub("\\.gz$", "", profileBaseName, ignore.case = TRUE) |
2781 | 2786 |
for(extCur in c( "\\.vcf$", "\\.txt$", "\\.bam", "\\.tsv", "\\.csv")){ |
... | ... |
@@ -458,7 +458,7 @@ readSNVVCF <- function(fileName, |
458 | 458 |
#' \item{\code{chr}}{ a \code{integer} representing a the chromosome from |
459 | 459 |
#' fileBlock. |
460 | 460 |
#' } |
461 |
-#' \item{\code{block.snp}}{ the a \code{array} of integer |
|
461 |
+#' \item{\code{block.snp}}{ a \code{array} of integer |
|
462 | 462 |
#' representing the linkage disequilibrium block for |
463 | 463 |
#' each SNV in the in the same order than the variant |
464 | 464 |
#' in Population reference dataset. |
... | ... |
@@ -506,43 +506,46 @@ processBlockChr <- function(fileReferenceGDS, fileBlock) { |
506 | 506 |
listChr <- as.integer(gsub("chr", "", listChr)) |
507 | 507 |
listSNVChr <- read.gdsn(index.gdsn(gdsReference, "snp.chromosome")) |
508 | 508 |
listSNVChr <- which(listSNVChr == listChr) |
509 |
- snp.keep <- read.gdsn(index.gdsn(gdsReference, "snp.position"))[listSNVChr] |
|
509 |
+ snpKeep <- read.gdsn(index.gdsn(gdsReference, "snp.position"))[listSNVChr] |
|
510 | 510 |
closefn.gds(gdsReference) |
511 |
- z <- cbind(c(blockChr$BP1, snp.keep, blockChr$BP2+1), |
|
511 |
+ z <- cbind(c(blockChr$BP1, snpKeep, blockChr$BP2+1), |
|
512 | 512 |
c(seq_len(nrow(blockChr)), |
513 |
- rep(0, length(snp.keep)), -1*seq_len(nrow(blockChr)))) |
|
513 |
+ rep(0, length(snpKeep)), -1*seq_len(nrow(blockChr)))) |
|
514 | 514 |
|
515 | 515 |
z <- z[order(z[,1]),] |
516 |
- block.snp <- cumsum(z[,2])[z[,2] == 0] |
|
516 |
+ blockSnp <- cumsum(z[,2])[z[,2] == 0] |
|
517 | 517 |
|
518 | 518 |
curStart <- 0 |
519 | 519 |
activeBlock <- 0 |
520 | 520 |
blockState <- 0 |
521 |
- block.inter <- rep(0, length(which(block.snp == 0))) |
|
521 |
+ blockInter <- rep(0, length(which(blockSnp == 0))) |
|
522 | 522 |
k <- 1 |
523 |
- for(i in seq_len(length(block.snp))){ |
|
524 |
- if(block.snp[i] == 0){ |
|
523 |
+ for(i in seq_len(length(blockSnp))){ |
|
524 |
+ if(blockSnp[i] == 0){ |
|
525 | 525 |
if(activeBlock == 1){ |
526 |
- if(snp.keep[i] - curStart >= 10000) { |
|
526 |
+ if(snpKeep[i] - curStart >= 10000) { |
|
527 | 527 |
blockState <- blockState - 1 |
528 | 528 |
|
529 |
- curStart <- snp.keep[i] |
|
529 |
+ curStart <- snpKeep[i] |
|
530 | 530 |
} |
531 | 531 |
} else{ |
532 | 532 |
blockState <- blockState - 1 |
533 |
- curStart <- snp.keep[i] |
|
534 |
- curStart <- snp.keep[i] |
|
533 |
+ curStart <- snpKeep[i] |
|
535 | 534 |
activeBlock <- 1 |
536 | 535 |
} |
537 |
- block.inter[k] <- blockState |
|
536 |
+ if(blockState == 0){ |
|
537 |
+ blockState <- -1 |
|
538 |
+ } |
|
539 |
+ blockInter[k] <- blockState |
|
538 | 540 |
k <- k + 1 |
539 | 541 |
}else{ |
540 | 542 |
activeBlock <- 0 |
541 | 543 |
} |
542 | 544 |
} |
543 |
- block.snp[block.snp == 0] <- block.inter |
|
545 |
+ |
|
546 |
+ blockSnp[blockSnp == 0] <- blockInter |
|
544 | 547 |
res <- list(chr=listChr, |
545 |
- block.snp=block.snp) |
|
548 |
+ block.snp=blockSnp) |
|
546 | 549 |
return(res) |
547 | 550 |
} |
548 | 551 |
|
... | ... |
@@ -1,3 +1,10 @@ |
1 |
+CHANGES IN VERSION 1.3.2 |
|
2 |
+------------------------ |
|
3 |
+ |
|
4 |
+SIGNIFICANT USER-VISIBLE CHANGES |
|
5 |
+ |
|
6 |
+ o New functions inferAncestry(), inferAncestryGeneAware() and getRefSuperPop() to simplify ancestry inference |
|
7 |
+ |
|
1 | 8 |
CHANGES IN VERSION 1.3.1 |
2 | 9 |
------------------------ |
3 | 10 |
|
4 | 11 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,105 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/process1KG.R |
|
3 |
+\encoding{UTF-8} |
|
4 |
+\name{addBlockFromDetFile} |
|
5 |
+\alias{addBlockFromDetFile} |
|
6 |
+\title{Append information associated to ld blocks, as indexes, into the |
|
7 |
+Population Reference SNV Annotation GDS file} |
|
8 |
+\usage{ |
|
9 |
+addBlockFromDetFile( |
|
10 |
+ fileReferenceGDS, |
|
11 |
+ gdsRefAnnotFile, |
|
12 |
+ pathBlock, |
|
13 |
+ superPop, |
|
14 |
+ blockName = "ldBlock", |
|
15 |
+ blockDesc = "Not Define", |
|
16 |
+ verbose = FALSE |
|
17 |
+) |
|
18 |
+} |
|
19 |
+\arguments{ |
|
20 |
+\item{fileReferenceGDS}{a \code{character} string representing the file |
|
21 |
+name of the Reference GDS file. The file must exist.} |
|
22 |
+ |
|
23 |
+\item{gdsRefAnnotFile}{a \code{character} string representing the |
|
24 |
+file name corresponding the Reference SNV |
|
25 |
+Annotation GDS file. The function will |
|
26 |
+open it in write mode and close it after. The file must exist.} |
|
27 |
+ |
|
28 |
+\item{pathBlock}{a \code{character} string representing the directory |
|
29 |
+where all the output file det from the plink block command are located. |
|
30 |
+The directory must not include other file with the extension \'.det\'. |
|
31 |
+The name of the \'.det\' must include the super-population between \'.\' |
|
32 |
+and the chromosome in the form \'chrNumber.\' \( \'chr1.\'\).} |
|
33 |
+ |
|
34 |
+\item{superPop}{a \code{character} string representing the super population.} |
|
35 |
+ |
|
36 |
+\item{blockName}{a \code{character} string representing the id of the block. |
|
37 |
+The blockName should not exist in \'gdsRefAnnotFile\'. |
|
38 |
+Default: \code{"ldBlock"}.} |
|
39 |
+ |
|
40 |
+\item{blockDesc}{a \code{character} string representing the description of |
|
41 |
+the block. |
|
42 |
+Default: \code{"Not Define"}} |
|
43 |
+ |
|
44 |
+\item{verbose}{a \code{logical} indicating if message information should be |
|
45 |
+printed. Default: \code{FALSE}.} |
|
46 |
+} |
|
47 |
+\value{ |
|
48 |
+\code{OL} when the function is successful. |
|
49 |
+} |
|
50 |
+\description{ |
|
51 |
+The function appends the information about the ld blocks into |
|
52 |
+the Population Reference SNV Annotation GDS file. The information is |
|
53 |
+extracted from the Population Reference GDS file and files \'.det\'. |
|
54 |
+} |
|
55 |
+\details{ |
|
56 |
+More information about GDS file format can be found at the Bioconductor |
|
57 |
+gdsfmt website: |
|
58 |
+https://bioconductor.org/packages/gdsfmt/ |
|
59 |
+} |
|
60 |
+\examples{ |
|
61 |
+ |
|
62 |
+## Path to the demo pedigree file is located in this package |
|
63 |
+dataDir <- system.file("extdata", package="RAIDS") |
|
64 |
+ |
|
65 |
+fileAnnotGDS <- file.path(tempdir(), "ex1_good_small_1KG_Ann_GDS.gds") |
|
66 |
+ |
|
67 |
+## Demo of of output file det from the plink block |
|
68 |
+## command for chromosome 1 |
|
69 |
+fileLdBlock <- file.path(dirname(fileAnnotGDS), "block.sp.EUR.Ex.chr1.blocks.det") |
|
70 |
+ |
|
71 |
+ |
|
72 |
+file.copy(file.path(dataDir, "tests", |
|
73 |
+ "ex1_NoBlockGene.1KG_Annot_GDS.gds"), fileAnnotGDS) |
|
74 |
+file.copy(file.path(dataDir, "block.sp.EUR.Ex.chr1.blocks.det"), |
|
75 |
+ fileLdBlock) |
|
76 |
+ |
|
77 |
+ |
|
78 |
+ |
|
79 |
+## GDS Reference file |
|
80 |
+fileReferenceGDS <- file.path(dataDir, "tests", |
|
81 |
+ "ex1_good_small_1KG.gds") |
|
82 |
+ |
|
83 |
+ \donttest{ |
|
84 |
+ |
|
85 |
+ |
|
86 |
+ ## Append information associated to blocks |
|
87 |
+ addBlockFromDetFile(fileReferenceGDS=fileReferenceGDS, |
|
88 |
+ gdsRefAnnotFile=fileAnnotGDS, |
|
89 |
+ pathBlock=dirname(fileAnnotGDS), |
|
90 |
+ superPop="EUR") |
|
91 |
+ |
|
92 |
+ gdsAnnot1KG <- openfn.gds(fileAnnotGDS) |
|
93 |
+ print(gdsAnnot1KG) |
|
94 |
+ |
|
95 |
+ closefn.gds(gdsAnnot1KG) |
|
96 |
+} |
|
97 |
+ |
|
98 |
+## Remove temporary file |
|
99 |
+unlink(fileAnnotGDS, force=TRUE) |
|
100 |
+unlink(fileLdBlock, force=TRUE) |
|
101 |
+ |
|
102 |
+} |
|
103 |
+\author{ |
|
104 |
+Pascal Belleau, Astrid Deschênes and Alexander Krasnitz |
|
105 |
+} |
0 | 106 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,76 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/gdsWrapper_internal.R |
|
3 |
+\encoding{UTF-8} |
|
4 |
+\name{addGDS1KGLDBlock} |
|
5 |
+\alias{addGDS1KGLDBlock} |
|
6 |
+\title{Append information associated to ld blocks, as indexes, into the |
|
7 |
+Population Reference SNV Annotation GDS file} |
|
8 |
+\usage{ |
|
9 |
+addGDS1KGLDBlock(gds, listBlock, blockName, blockDesc) |
|
10 |
+} |
|
11 |
+\arguments{ |
|
12 |
+\item{gds}{an object of class \link[gdsfmt]{gds.class} |
|
13 |
+(GDS file), an opened Reference Annotation GDS file.} |
|
14 |
+ |
|
15 |
+\item{listBlock}{a \code{array} of integer |
|
16 |
+representing the linkage disequilibrium block for |
|
17 |
+each SNV in the in the same order than the variant |
|
18 |
+in Population reference dataset.} |
|
19 |
+ |
|
20 |
+\item{blockName}{a \code{character} string representing the id of the block. |
|
21 |
+The blockName should not exist in \'gdsRefAnnotFile\'.} |
|
22 |
+ |
|
23 |
+\item{blockDesc}{a \code{character} string representing the description of |
|
24 |
+the block.} |
|
25 |
+} |
|
26 |
+\value{ |
|
27 |
+The integer \code{0L} when successful. |
|
28 |
+} |
|
29 |
+\description{ |
|
30 |
+The function appends the information about the ld blocks into |
|
31 |
+the Population Reference SNV Annotation GDS file. The information is |
|
32 |
+extracted from the parameter listBlock. |
|
33 |
+} |
|
34 |
+\examples{ |
|
35 |
+ |
|
36 |
+## Required library for GDS |
|
37 |
+library(gdsfmt) |
|
38 |
+## Path to the demo pedigree file is located in this package |
|
39 |
+dataDir <- system.file("extdata", package="RAIDS") |
|
40 |
+ |
|
41 |
+fileAnnotGDS <- file.path(tempdir(), "ex1_good_small_1KG_Ann_GDS.gds") |
|
42 |
+ |
|
43 |
+ |
|
44 |
+file.copy(file.path(dataDir, "tests", |
|
45 |
+ "ex1_NoBlockGene.1KG_Annot_GDS.gds"), fileAnnotGDS) |
|
46 |
+ |
|
47 |
+ |
|
48 |
+fileReferenceGDS <- file.path(dataDir, "tests", |
|
49 |
+ "ex1_good_small_1KG.gds") |
|
50 |
+ \donttest{ |
|
51 |
+ gdsRef <- openfn.gds(fileReferenceGDS) |
|
52 |
+ listBlock <- read.gdsn(index.gdsn(gdsRef, "snp.position")) |
|
53 |
+ listBlock <- rep(-1, length(listBlock)) |
|
54 |
+ closefn.gds(gdsRef) |
|
55 |
+ gdsAnnot1KG <- openfn.gds(fileAnnotGDS, readonly=FALSE) |
|
56 |
+ ## Append information associated to blocks |
|
57 |
+ RAIDS:::addGDS1KGLDBlock(gds=gdsAnnot1KG, |
|
58 |
+ listBlock=listBlock, |
|
59 |
+ blockName="blockEmpty", |
|
60 |
+ blockDesc="Example") |
|
61 |
+. closefn.gds(gdsAnnot1KG) |
|
62 |
+ |
|
63 |
+ gdsAnnot1KG <- openfn.gds(fileAnnotGDS) |
|
64 |
+ print(gdsAnnot1KG) |
|
65 |
+ |
|
66 |
+ closefn.gds(gdsAnnot1KG) |
|
67 |
+} |
|
68 |
+ |
|
69 |
+## Remove temporary file |
|
70 |
+unlink(fileAnnotGDS, force=TRUE) |
|
71 |
+ |
|
72 |
+} |
|
73 |
+\author{ |
|
74 |
+Pascal Belleau, Astrid Deschênes and Alexander Krasnitz |
|
75 |
+} |
|
76 |
+\keyword{internal} |
... | ... |
@@ -22,7 +22,7 @@ a \code{list} containing 2 entries: |
22 | 22 |
\item{\code{chr}}{ a \code{integer} representing a the chromosome from |
23 | 23 |
fileBlock. |
24 | 24 |
} |
25 |
-\item{\code{block.snp}}{ the a \code{array} of integer |
|
25 |
+\item{\code{block.snp}}{ a \code{array} of integer |
|
26 | 26 |
representing the linkage disequilibrium block for |
27 | 27 |
each SNV in the in the same order than the variant |
28 | 28 |
in Population reference dataset. |