annotate MatrixEQTL/demo/p.hist.r @ 4:cf4e9238644c draft default tip

Uploaded
author jasonxu
date Fri, 12 Mar 2021 08:23:32 +0000
parents cd4c8e4a4b5b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
1 library("MatrixEQTL")
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
2
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
3 # Number of samples
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
4 n = 100;
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
5
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
6 # Number of variables
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
7 ngs = 2000;
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
8
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
9 # Common signal in all variables (population stratification)
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
10 pop = 0.2 * rnorm(n);
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
11
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
12 # data matrices
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
13 snps.mat = matrix(rnorm(n*ngs), ncol = ngs) + pop;
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
14 gene.mat = matrix(rnorm(n*ngs), ncol = ngs) + pop + snps.mat*((1:ngs)/ngs)^9/2;
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
15
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
16 # data objects for Matrix eQTL engine
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
17 snps1 = SlicedData$new( t( snps.mat ) );
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
18 gene1 = SlicedData$new( t( gene.mat ) );
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
19 cvrt1 = SlicedData$new();
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
20 rm(snps.mat, gene.mat);
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
21
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
22 # Slice data in blocks of 500 variables
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
23 snps1$ResliceCombined(500);
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
24 gene1$ResliceCombined(500);
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
25
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
26 # Produce no output files
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
27 filename = NULL; # tempfile()
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
28
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
29 # Perform analysis recording information for a histogram
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
30 me = Matrix_eQTL_main(
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
31 snps = snps1,
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
32 gene = gene1,
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
33 cvrt = cvrt1,
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
34 output_file_name = filename,
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
35 pvOutputThreshold = 1e-100,
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
36 useModel = modelLINEAR,
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
37 errorCovariance = numeric(),
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
38 verbose = TRUE,
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
39 pvalue.hist = 100);
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
40
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
41 # png(filename = "histogram.png", width = 650, height = 650);
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
42 plot(me, col="grey");
cd4c8e4a4b5b Uploaded
jasonxu
parents:
diff changeset
43 # dev.off();