-
Notifications
You must be signed in to change notification settings - Fork 1
/
feather_scan1.Rmd
136 lines (102 loc) · 2.32 KB
/
feather_scan1.Rmd
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
---
title: "Feather scan1"
author: "Brian S. Yandell"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Use feather_genoprob with scan1}
%\VignetteEngine{knitr::rmarkdown}
\usepackage[utf8]{inputenc}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.width = 7, fig.height = 5)
```
The goal is to use `feather_genoprob` object with `scan1` and other tools in `R/qtl2`.
```{r}
suppressPackageStartupMessages({
library(qtl2)
library(qtl2feather)
})
```
```{r}
DOex <-
read_cross2(
file.path("https://raw.githubusercontent.com/rqtl",
"qtl2data/master/DOex",
"DOex.zip"))
```
Calculate genotype probabilities and convert to allele probabilities
```{r}
pr <- calc_genoprob(DOex, error_prob=0.002)
apr <- genoprob_to_alleleprob(pr)
```
Write feather database of pr.
```{r}
tmpdir <- tempdir()
```
```{r}
fpr <- feather_genoprob(pr, "pr", tmpdir)
fapr <- feather_genoprob(apr, "apr", tmpdir)
```
## Genome scan
```{r}
scan_apr <- scan1(fapr, DOex$pheno)
```
```{r}
find_peaks(scan_apr, DOex$pmap)
```
```{r}
plot(scan_apr, DOex$pmap)
```
```{r}
coefs <- scan1coef(apr, DOex$pheno)
```
```{r}
plot(coefs, DOex$pmap)
```
Plot allele effects over LOD scan.
```{r}
plot(coefs, DOex$pmap, scan1_output = scan_apr)
```
## SNP probabilities
Since SNPs are in RDS, need to first download file, then read it.
This file only has `snpinfo` for chr 2.
```{r}
file <- file.path("https://raw.githubusercontent.com/rqtl",
"qtl2data/master/DOex",
"c2_snpinfo.rds")
tmpfile <- tempfile()
download.file(file, tmpfile, quiet=TRUE)
snpinfo <- readRDS(tmpfile)
unlink(tmpfile)
```
Create index to non-equivalent set of SNPs.
```{r}
snpinfo <- index_snps(DOex$pmap, snpinfo)
```
Convert to snp probabilities using feather database.
Need to pick a chromosome, or first one is chosen.
```{r}
snppr <- genoprob_to_snpprob(subset(fapr, chr = "2"), snpinfo)
```
```{r}
object.size(snppr)
```
## Kinship calculation
```{r}
kinship <- calc_kinship(apr, "loco")
```
```{r}
fkinship <- calc_kinship(fapr, "loco")
```
```{r}
summary(c(kinship[["2"]] - fkinship[["2"]]))
```
Perform SNP association analysis.
```{r}
scan_snppr <- scan1(snppr, DOex$pheno, fkinship["2"])
```
Plot results
```{r}
plot(scan_snppr, snpinfo, drop_hilit = 1.5)
```