-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_example.R
75 lines (58 loc) · 2.55 KB
/
test_example.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# For more information about the workflow please refer to the ABEMUS wiki page:
# https://github.com/cibiobcg/abemus/wiki/Usage
#
# Data available at: https://github.com/cibiobcg/abemus_models#test-dataset
library( devtools )
devtools::install_github("cibiobcg/abemus", build_vignettes = T)
library( abemus )
library( data.table )
library( parallel )
outdir <- "~/test_dataset_abemus/"
sample.info.file <- "~/test_dataset_abemus/test_sif.tsv"
targetbed <- "~/test_dataset_abemus/regions.bed"
pacbamfolder <- "~/test_dataset_abemus/pacbam_data/"
pacbamfolder_bychrom <- "~/test_dataset_abemus/pacbam_data_bychrom/"
setwd(outdir)
# split pacbam outputs by chrom
split_pacbam_bychrom(targetbed = targetbed,
pacbamfolder = pacbamfolder,
pacbamfolder_bychrom = pacbamfolder_bychrom)
targetbp_list <- bed2positions(targetbed = targetbed,get_only_chromosomes = TRUE)
# compute per-base error model
outpbem <- compute_pbem(sample.info.file = sample.info.file,
targetbed = targetbed,
outdir=outdir,
pacbamfolder_bychrom=pacbamfolder_bychrom)
# outs
head( outpbem$pbem_tab )
outpbem$bperr_summary
outpbem$bgpbem
outpbem$mean_pbem
# compute coverage-based and not-coverage-based allelic fraction thresholds
outafth <- compute_afthreshold(outdir = outdir,
pbem_dir = file.path(outdir,"BaseErrorModel"))
# outs
head( outafth$th_results )
head( outafth$th_results_bin )
head( outafth$datacount_bin )
# call snvs in case samples
calls <- callsnvs(sample.info.file = sample.info.file,
controls_dir = file.path(outdir,"Controls"),
pbem_dir = file.path(outdir,"BaseErrorModel"),
detection.specificity = 0.995,
replicas = 10,
outdir=outdir,
outdir.calls.name = "Results",
targetbed = targetbed,
pacbamfolder_bychrom=pacbamfolder_bychrom)
head( calls$tabsnvs_index )
tabindex <- calls$tabsnvs_index
# compute mean coverage
tabindex <- get_case_mean_coverage(tabindex = tabindex,
pacbamfolder_bychrom = pacbamfolder_bychrom)
target_size <- get_target_size(targetbed=targetbed, Mbp = TRUE)
# apply pbem scaling factor to calls
calls$tabsnvs_index_scalfact <- apply_scaling_factor(tabindex = tabindex,
target_size = target_size,
use.optimal.R = TRUE)
head( calls$tabsnvs_index_scalfact )