Skip to content

Latest commit

 

History

History
192 lines (154 loc) · 7.08 KB

160325.md

File metadata and controls

192 lines (154 loc) · 7.08 KB


------[p. 168] -----------------------------------------------------
Data handling with the GWASTools package

R version 3.2.2 (2015-08-14) で動かず

R version 3.2.3 なら動く


-------[p.173]-------------------------------------------------------

Manipulating other GWAS data formats

> library(GenABEL)
Error in library(GenABEL) : 
   ‘GenABEL’ という名前のパッケージはありません 
> 
> install.packages("GenABEL")
Installing package into ‘C:/Users/ekaminuma/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
also installing the dependency ‘GenABEL.data’

trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/GenABEL.data_1.0.0.zip'
Content type 'application/zip' length 2419647 bytes (2.3 MB)
downloaded 2.3 MB

trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/GenABEL_1.8-0.zip'
Content type 'application/zip' length 3665588 bytes (3.5 MB)
downloaded 3.5 MB

package ‘GenABEL.data’ successfully unpacked and MD5 sums checked
package ‘GenABEL’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\ekaminuma\AppData\Local\Temp\RtmpAhIVZs\downloaded_packages
> library(GenABEL)
 要求されたパッケージ MASS をロード中です 
 要求されたパッケージ GenABEL.data をロード中です 
Warning messages:
1:  パッケージ ‘GenABEL’ はバージョン 3.2.4 の R の下で造られました  
2:  パッケージ ‘GenABEL.data’ はバージョン 3.2.3 の R の下で造られました  
> 
> 

padin.18の中身がmyPed.pedと同じ(illumina形式でなかった)
> convert.snp.illumina(infile = "pedin.18", out = "myraw.raw", strand = "+")
Reading genotypes from file 'pedin.18' ...
Error in convert.snp.illumina(infile = "pedin.18", out = "myraw.raw",  : 
  illegal genotype (three alleles) for SNP '1' (line 2)!


 
> convert.snp.ped("myPed.ped", mapfile = "map.18", out = "myRaw.raw")
Reading map from file 'map.18' ...
... done.  Read positions of 214 markers from file 'map.18'
Reading genotypes from file 'myPed.ped' ...
...done.  Read information for 90 people from file 'myPed.ped'
Analysing marker information ...
Writing to file 'myRaw.raw' ...
... done.
> 



> source("http://bioconductor.org/biocLite.R")
Bioconductor version 3.1 (BiocInstaller 1.18.5), ?biocLite for help
A newer version of Bioconductor is available for this version of R,
  ?BiocUpgrade for help
> biocLite("trio")
BioC_mirror: http://bioconductor.org
Using Bioconductor version 3.1 (BiocInstaller 1.18.5), R version 3.2.2.
Installing package(s) ‘trio’
trying URL 'http://bioconductor.org/packages/3.1/bioc/bin/windows/contrib/3.2/trio_3.6.0.zip'
Content type 'application/zip' length 1970901 bytes (1.9 MB)
downloaded 1.9 MB

package ‘trio’ successfully unpacked and MD5 sums checked


> library(trio)
> 
> 
> mySNP <- read.pedfile(file = "myPed.ped")
NOTE: first.row has not been specified. Since the first row does not seem
to contain the rs-IDs, first.row is set to TRUE.

> 
> 
> head(mySNP)
  famid     pid fatid motid sex affected SNP1.1 SNP1.2 SNP2.1 SNP2.2
1     1 NA06985     0     0   2        2      1      2      1      1
2     1 NA06991     0     0   2        1      2      2      1      1
3     1 NA06993     0     0   2        1      2      2      1      1
4     1 NA06994     0     0   1        2      1      1      1      1
5     1 NA07000     0     0   2        1      2      2      1      1
6     1 NA07019     0     0   2        2      1      2      1      1
  SNP3.1 SNP3.2 SNP4.1 SNP4.2 SNP5.1 SNP5.2 SNP6.1 SNP6.2 SNP7.1 SNP7.2
1      1      1      1      1      1      2      2      2      1      2
2      1      1      1      1      1      1      2      2      2      2
3      1      1      1      1      1      1      2      2      2      2
4      1      1      1      1      2      2      2      2      1      1
5      1      1      1      1      1      1      2      2      2      2
6      1      1      1      1      2      2      2      2      1      1
 

> colnames(mySNP)
  [1] "famid"    "pid"      "fatid"    "motid"    "sex"      "affected"
  [7] "SNP1.1"   "SNP1.2"   "SNP2.1"   "SNP2.2"   "SNP3.1"   "SNP3.2"  
 [13] "SNP4.1"   "SNP4.2"   "SNP5.1"   "SNP5.2"   "SNP6.1"   "SNP6.2"  
 [19] "SNP7.1"   "SNP7.2"   "SNP8.1"   "SNP8.2"   "SNP9.1"   "SNP9.2"  
 [25] "SNP10.1"  "SNP10.2"  "SNP11.1"  "SNP11.2"  "SNP12.1"  "SNP12.2" 
 [31] "SNP13.1"  "SNP13.2"  "SNP14.1"  "SNP14.2"  "SNP15.1"  "SNP15.2"
:

> allsnps <- unlist(strsplit(colnames(mySNP)[7:ncol(mySNP)], "[.]"))[seq(1,68,2)]  
> 
> allsnps
 [1] "SNP1"  "SNP1"  "SNP2"  "SNP2"  "SNP3"  "SNP3"  "SNP4"  "SNP4" 
 [9] "SNP5"  "SNP5"  "SNP6"  "SNP6"  "SNP7"  "SNP7"  "SNP8"  "SNP8" 
[17] "SNP9"  "SNP9"  "SNP10" "SNP10" "SNP11" "SNP11" "SNP12" "SNP12"
[25] "SNP13" "SNP13" "SNP14" "SNP14" "SNP15" "SNP15" "SNP16" "SNP16"
[33] "SNP17" "SNP17"


> 

> onlysnp <- mySNP[, -c(1:6)] 
> 
> dim(onlysnp)
[1]  90 428
> 
> 
> odds <- seq(1, ncol(onlysnp),2) 
> 
> odds
  [1]   1   3   5   7   9  11  13  15  17  19  21  23  25  27  29  31  33
 [18]  35  37  39  41  43  45  47  49  51  53  55  57  59  61  63  65  67
 [35]  69  71  73  75  77  79  81  83  85  87  89  91  93  95  97  99 101
 [52] 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135
 [69] 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169
 [86] 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199 201 203
[103] 205 207 209 211 213 215 217 219 221 223 225 227 229 231 233 235 237
[120] 239 241 243 245 247 249 251 253 255 257 259 261 263 265 267 269 271
[137] 273 275 277 279 281 283 285 287 289 291 293 295 297 299 301 303 305
[154] 307 309 311 313 315 317 319 321 323 325 327 329 331 333 335 337 339
[171] 341 343 345 347 349 351 353 355 357 359 361 363 365 367 369 371 373
[188] 375 377 379 381 383 385 387 389 391 393 395 397 399 401 403 405 407
[205] 409 411 413 415 417 419 421 423 425 427
> 
> 


> 

 

> allsnps <- allsnps[odds]))
> x  <- matrix(0, nrow(onlysnp), length(allsnps))
> 
> x <- data.frame(x)
> 
> colnames(x)<- allsnps 
> 

> for (i in 1:length(odds)){ 
+ p=as.factor(paste(onlysnp[, odds[i]], onlysnp[, evens[i]], sep =""))
+ x[,i]=p
+ }
> 
> mySNP=data.frame(mySNP[, c(1:6)],x)
> 
> head(mySNP)
  famid     pid fatid motid sex affected SNP1 SNP2 SNP3 SNP4 SNP5 SNP6
1     1 NA06985     0     0   2        2   12   11   11   11   12   22
2     1 NA06991     0     0   2        1   22   11   11   11   11   22
3     1 NA06993     0     0   2        1   22   11   11   11   11   22
4     1 NA06994     0     0   1        2   11   11   11   11   22   22
5     1 NA07000     0     0   2        1   22   11   11   11   11   22
6     1 NA07019     0     0   2        2   12   11   11   11   22   22
  SNP7 SNP8 SNP9 SNP10 SNP11 SNP12 SNP13 SNP14 SNP15 SNP16 SNP17 NA.
1   12   12   22    11    11    11    11    11    12    11    22  12
2   22   11   22    11    11    11    11    11    11    12    22  12
3   22   11   22    11    11    11    11    11    12    12    22  12
4   11   22   22    11    11    11    11    11    22    22    11  22
5   22   11   22    11    11    11    11    11    12    12    12  22
6   11   22   22    11    11    11    11    11    12    12    12  12