-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphenotype_generation_1.R
More file actions
34 lines (24 loc) · 1.03 KB
/
phenotype_generation_1.R
File metadata and controls
34 lines (24 loc) · 1.03 KB
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
# Null Phenotype generation
library(data.table, quietly = TRUE)
library(argparser, quietly = TRUE)
p <- arg_parser('Generate a null phenotype')
p <- add_argument(p, '--fam', help = 'fam file')
p <- add_argument(p, '--n_phenotypes', help = 'number of phenotypes to generate')
p <- add_argument(p, '--out', help = 'output file prefix')
args <- parse_args(p)
#test
# args = NULL
# args$fam = '/home/parkej95/LinearRegression/ps2_admixture.pruned.fam'
# args$out = '/home/parkej95/LinearRegression/test_pheno'
# Generate a null phenotype
fam = fread(args$fam)
n = nrow(fam)
for (i in 1: args$n_phenotypes) {
set.seed(i)
pheno = data.table(IID = fam$V1, Y = rnorm(n, sd = 5))
# Write the phenotype to a file
write.table(pheno, file = paste0(args$out, '_set_', i, '.pheno'), quote = FALSE, row.names = FALSE, col.names = TRUE)
}
###temp covar generation
# covar = data.table(IID = fam$V1, PC1 = rnorm(n), PC2 = rnorm(n))
# write.table(covar, file = paste0(args$out, '.covar'), quote = FALSE, row.names = FALSE, col.names = TRUE)