12
12
# ' output:
13
13
# ' - mat_qc: '`sm cfg.getProcessedResultsDir() +
14
14
# ' "/mae/{dataset}/dna_rna_qc_matrix.Rds"`'
15
- # ' threads: 20
15
+ # ' threads: 30
16
16
# ' type: script
17
17
# '---
18
18
@@ -51,12 +51,20 @@ N <- length(vcf_files)
51
51
52
52
lp <- bplapply(1 : N , function (i ){
53
53
54
+ gr_res <- copy(gr_test )
55
+
54
56
# Read sample vcf file
55
-
56
57
sample <- dna_samples [i ] %> % as.character()
57
-
58
- param <- ScanVcfParam(fixed = NA , info = ' NT' , geno = ' GT' , samples = sample , trimEmpty = TRUE )
59
- vcf_sample <- readVcf(vcf_files [i ], param = param , row.names = FALSE )
58
+ vcf_file <- vcf_files [i ]
59
+
60
+ # # Read only the positions to perform the matching from the DNA vcf file
61
+ # # First, find out the chr style
62
+ chrs <- row.names(scanVcfHeader(vcf_file )@ header $ contig )
63
+ seqlevelsStyle(gr_res ) <- seqlevelsStyle(chrs )[1 ]
64
+ gr_res <- keepSeqlevels(gr_res , chrs , pruning.mode = ' coarse' )
65
+ param <- ScanVcfParam(samples = sample , fixed = NA , info = ' NT' , geno = ' GT' ,
66
+ trimEmpty = TRUE , which = gr_res )
67
+ vcf_sample <- readVcf(vcf_file , param = param , row.names = FALSE )
60
68
# Get GRanges and add Genotype
61
69
gr_sample <- granges(vcf_sample )
62
70
@@ -71,13 +79,11 @@ lp <- bplapply(1:N, function(i){
71
79
gt <- gsub(' ref' , ' 0/0' , gt )
72
80
gt <- gsub(' het' , ' 0/1' , gt )
73
81
gt <- gsub(' hom' , ' 1/1' , gt )
74
- }
82
+ }
75
83
76
84
mcols(gr_sample )$ GT <- gt
77
85
78
86
# Find overlaps between test and sample
79
- gr_res <- copy(gr_test )
80
- seqlevelsStyle(gr_res ) <- seqlevelsStyle(seqlevelsInUse(gr_sample ))[1 ]
81
87
ov <- findOverlaps(gr_res , gr_sample , type = ' equal' )
82
88
mcols(gr_res )[from(ov ),]$ GT <- mcols(gr_sample )[to(ov ),]$ GT
83
89
@@ -101,5 +107,4 @@ mat <- mat[unique(sa[rows_in_group, DNA_ID]),
101
107
unique(sa [rows_in_group , RNA_ID ]),
102
108
drop = FALSE ]
103
109
104
- saveRDS(mat , snakemake @ output $ mat_qc )
105
-
110
+ saveRDS(mat , snakemake @ output $ mat_qc )
0 commit comments