Skip to content

Commit 8b66e5f

Browse files
committed
remove redundant vcf format conversion function
1 parent 2a54800 commit 8b66e5f

File tree

1 file changed

+0
-34
lines changed

1 file changed

+0
-34
lines changed

tests/testthat/helper-test-utils.R

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,3 @@
1-
# function that converts test data in long format into wide format
2-
3-
convert.long.vcf.to.wide.vcf <- function(long.vcf) {
4-
long.vcf <- as.data.frame(long.vcf);
5-
fixed.colnames <- c('CHROM', 'POS', 'ID', 'REF', 'ALT');
6-
fixed.data <- long.vcf[, fixed.colnames];
7-
fixed.data$variant.id <- paste0(fixed.data$CHROM, ':', fixed.data$POS);
8-
fixed.data <- unique(fixed.data); # remove duplicates
9-
# convert to data.table
10-
fixed.data <- data.table::as.data.table(fixed.data);
11-
#fixed.data$allele.matrix.row.index <- seq_len(nrow(fixed.data));
12-
13-
variant.id <- paste0(long.vcf$CHROM, ':', long.vcf$POS);
14-
allele.matrix <- as.matrix(get.variant.by.sample.matrix(
15-
long.data = long.vcf,
16-
row.id.cols = c('CHROM', 'POS'),
17-
value.col = 'gt_GT_alleles'
18-
));
19-
20-
# sort allele matrix in order of corresponding fixed data variant id
21-
allele.matrix <- allele.matrix[match(fixed.data$variant.id, rownames(allele.matrix)), ];
22-
23-
# save allele matrix row indices in fixed data
24-
fixed.data$allele.matrix.row.index <- seq_len(nrow(allele.matrix));
25-
26-
# format output according to import.vcf standards
27-
output <- list(
28-
genotyped.alleles = allele.matrix,
29-
vcf.fixed.fields = fixed.data
30-
);
31-
32-
return(output);
33-
34-
}
351

362
initialize.defaults <- function() {
373
phenotype.data <- NULL

0 commit comments

Comments
 (0)