Mercurial > repos > jasonxu > matrixeqtl
comparison MatrixEQTL/man/modelLINEAR.Rd @ 3:ae74f8fb3aef draft
Uploaded
author | jasonxu |
---|---|
date | Fri, 12 Mar 2021 08:20:57 +0000 |
parents | cd4c8e4a4b5b |
children |
comparison
equal
deleted
inserted
replaced
2:5fafba5359eb | 3:ae74f8fb3aef |
---|---|
1 \name{modelLINEAR} | |
2 \alias{modelLINEAR} | |
3 \docType{data} | |
4 \title{ | |
5 Constant for \code{\link{Matrix_eQTL_engine}}. | |
6 } | |
7 \description{ | |
8 Set parameter \code{useModel = modelLINEAR} in the call of \code{\link{Matrix_eQTL_main}} to indicate that the effect of genotype on expression should be assumed to be additive linear. | |
9 } | |
10 | |
11 \examples{ | |
12 library('MatrixEQTL') | |
13 | |
14 # Number of columns (samples) | |
15 n = 100; | |
16 | |
17 # Number of covariates | |
18 nc = 10; | |
19 | |
20 # Generate the standard deviation of the noise | |
21 noise.std = 0.1 + rnorm(n)^2; | |
22 | |
23 # Generate the covariates | |
24 cvrt.mat = 2 + matrix(rnorm(n*nc), ncol = nc); | |
25 | |
26 # Generate the vectors with genotype and expression variables | |
27 snps.mat = cvrt.mat \%*\% rnorm(nc) + rnorm(n); | |
28 gene.mat = cvrt.mat \%*\% rnorm(nc) + rnorm(n) * noise.std + 0.5 * snps.mat + 1; | |
29 | |
30 # Create 3 SlicedData objects for the analysis | |
31 snps1 = SlicedData$new( matrix( snps.mat, nrow = 1 ) ); | |
32 gene1 = SlicedData$new( matrix( gene.mat, nrow = 1 ) ); | |
33 cvrt1 = SlicedData$new( t(cvrt.mat) ); | |
34 | |
35 # name of temporary output file | |
36 filename = tempfile(); | |
37 | |
38 # Call the main analysis function | |
39 me = Matrix_eQTL_main( | |
40 snps = snps1, | |
41 gene = gene1, | |
42 cvrt = cvrt1, | |
43 output_file_name = filename, | |
44 pvOutputThreshold = 1, | |
45 useModel = modelLINEAR, | |
46 errorCovariance = diag(noise.std^2), | |
47 verbose = TRUE, | |
48 pvalue.hist = FALSE ); | |
49 # remove the output file | |
50 unlink( filename ); | |
51 | |
52 # Pull Matrix eQTL results - t-statistic and p-value | |
53 beta = me$all$eqtls$beta; | |
54 tstat = me$all$eqtls$statistic; | |
55 pvalue = me$all$eqtls$pvalue; | |
56 rez = c(beta = beta, tstat = tstat, pvalue = pvalue) | |
57 # And compare to those from the linear regression in R | |
58 { | |
59 cat('\n\n Matrix eQTL: \n'); | |
60 print(rez); | |
61 cat('\n R summary(lm()) output: \n'); | |
62 lmodel = lm( gene.mat ~ snps.mat + cvrt.mat, weights = 1/noise.std^2 ); | |
63 lmout = summary( lmodel )$coefficients[2, c(1,3,4)]; | |
64 print( lmout ) | |
65 } | |
66 | |
67 # Results from Matrix eQTL and 'lm' must agree | |
68 stopifnot(all.equal(lmout, rez, check.attributes=FALSE)) | |
69 } | |
70 \references{ | |
71 The package website: \url{http://www.bios.unc.edu/research/genomic_software/Matrix_eQTL/} | |
72 } | |
73 \seealso{ | |
74 See \code{\link{Matrix_eQTL_engine}} for reference and sample code. | |
75 } |