-
Notifications
You must be signed in to change notification settings - Fork 17
/
STAARpipelineSummary_Known_Loci_Individual_Analysis_Pruning.r
75 lines (60 loc) · 2.29 KB
/
STAARpipelineSummary_Known_Loci_Individual_Analysis_Pruning.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
###########################################################
# Independent variants selection from a list of variants
# Xihao Li, Zilin Li
# Initiate date: 11/04/2021
# Current date: 03/10/2022
###########################################################
rm(list=ls())
gc()
## load required packages
library(gdsfmt)
library(SeqArray)
library(SeqVarTools)
library(STAAR)
library(STAARpipeline)
###########################################################
# User Input
###########################################################
## aGDS directory
agds_dir <- get(load("/path_to_the_file/agds_dir.Rdata"))
## Info of known variants
known_loci_info <- read.csv("/path_to_the_file/TOPMed_F5_LDL_Known_Loci_info.csv")
Individual_sig <- get(load("/path_to_the_file/results_individual_analysis_sig.Rdata"))
known_loci_info <- rbind(known_loci_info,Individual_sig[,1:4])
## Null model
obj_nullmodel <- get(load("/path_to_the_file/obj_nullmodel.Rdata"))
## output path
output_path <- "/path_to_the_output_file/"
## output file name
output_file_name <- "TOPMed_F5_LDL_known_loci_individual_analysis_genome_LD_pruning"
## QC_label
QC_label <- "annotation/filter"
## variant_type
variant_type <- "variant"
## geno_missing_imputation
geno_missing_imputation <- "mean"
## method_cond
method_cond <- "optimal"
## maf_cutoff
samplesize <- length(obj_nullmodel$id_include)
maf_cutoff <- 20.5/samplesize
## Variant list
known_loci_info <- known_loci_info[!is.na(known_loci_info[,1]),]
variants_list <- known_loci_info
samplesize <- length(obj_nullmodel$id_include)
## input chr number from batch file
chr <- as.numeric(commandArgs(TRUE)[1])
print(chr)
###########################################################
# Main Function
###########################################################
## aGDS file
agds.path <- agds_dir[chr]
genofile <- seqOpen(agds.path)
known_loci_chr <- c()
known_loci <- LD_pruning(chr=chr,genofile=genofile,obj_nullmodel=obj_nullmodel,variants_list=variants_list,maf_cutoff=maf_cutoff,
method_cond=method_cond,QC_label=QC_label,
variant_type=variant_type,geno_missing_imputation=geno_missing_imputation)
known_loci_chr <- rbind(known_loci_chr,known_loci)
seqClose(genofile)
save(known_loci_chr,file=paste0(output_path,output_file_name,"_chr",chr,".Rdata"))