.Rhistory 17.7 KB
Newer Older
1
2
3
print(tab)
}
tab2 <- mark_prop(tab2,cross="F2",homo=0.1,hetero=0.1)
mariefbourdon's avatar
mariefbourdon committed
4
5
mark_prop <- function(tab,cross,homo=NA,hetero=NA,pval=NA,na=0.5){
#calculate total number of individuals genotyped for each marker
mariefbourdon's avatar
mariefbourdon committed
6
tab <- tab %>% mutate(n_geno = (n_HM1 + n_HM2 + n_HT))
7
8
9
#stock colnames to join
names <- colnames(tab)
print(names)
mariefbourdon's avatar
mariefbourdon committed
10
11
12
13
14
15
16
17
18
#stop if cross != "F2" or "N2"
if(!cross %in% c("F2","N2")){
stop("Cross must be F2 or N2")
}
#stop of homo&hetero or pval not specified
if((is.na(homo)==TRUE | is.na(hetero)==TRUE) & is.na(pval)==TRUE){
stop("Arguments homo and hetero or argument pval must be specified")
}
#stop with prop of na
19
20
#calculate proportion
tab <- tab %>% mutate(p_NA = n_NA/(n_geno+n_NA))
mariefbourdon's avatar
mariefbourdon committed
21
22
23
tab <- tab %>%
mutate(exclude_prop=case_when(p_NA > na ~ 1,
T ~ 0))
24
#exclude with prop of homo/hetero
mariefbourdon's avatar
mariefbourdon committed
25
if(is.na(pval)==TRUE){
26
27
28
29
#calculate proportion of each genotype
tab <- tab %>% mutate(p_HM1 = n_HM1/n_geno)
tab <- tab %>% mutate(p_HM2 = n_HM2/n_geno)
tab <- tab %>% mutate(p_HT = n_HT/n_geno)
mariefbourdon's avatar
mariefbourdon committed
30
31
32
33
34
35
36
tab <- tab %>%
mutate(exclude_prop=case_when(p_NA > na ~ 1,
cross=="F2" & (p_HM1 < homo | p_HM2 < homo | p_HT < hetero) ~ 1,
cross=="N2" & (p_HM1 < homo | p_HT < hetero) ~ 1,
T ~ exclude_prop
))
}
37
38
#exclude with pval chisq.test
## NEED TO ADD THIS FILTER IF CROSS = N2
mariefbourdon's avatar
mariefbourdon committed
39
if(is.na(pval)==FALSE){
mariefbourdon's avatar
mariefbourdon committed
40
41
42
tab <- tab %>% filter(p_NA != 1) %>% rowwise() %>%
mutate(.,chi_pval = tibble(n_HM1,n_HM2,n_HT) %>%
chisq.test(p=c(0.25,0.25,0.5)) %>% .$p.value) %>%
43
full_join(.,tab,by=all_of(names))
mariefbourdon's avatar
mariefbourdon committed
44
45
tab <- tab %>% mutate(exclude_prop=case_when(chi_pval < pval ~ 1,
T ~ exclude_prop))
mariefbourdon's avatar
mariefbourdon committed
46
}
47
48
49
50
51
print(tab)
tab <- tab %>% select(all_of(names),exclude_prop)
print(tab)
}
tab2 <- mark_prop(tab2,cross="F2",homo=0.1,hetero=0.1)
mariefbourdon's avatar
mariefbourdon committed
52
mark_prop <- function(tab,cross,homo=NA,hetero=NA,pval=NA,na=0.5){
53
54
55
#stock colnames to join
names <- colnames(tab)
print(names)
mariefbourdon's avatar
mariefbourdon committed
56
#calculate total number of individuals genotyped for each marker
mariefbourdon's avatar
mariefbourdon committed
57
tab <- tab %>% mutate(n_geno = (n_HM1 + n_HM2 + n_HT))
mariefbourdon's avatar
mariefbourdon committed
58
59
60
61
62
63
64
65
66
#stop if cross != "F2" or "N2"
if(!cross %in% c("F2","N2")){
stop("Cross must be F2 or N2")
}
#stop of homo&hetero or pval not specified
if((is.na(homo)==TRUE | is.na(hetero)==TRUE) & is.na(pval)==TRUE){
stop("Arguments homo and hetero or argument pval must be specified")
}
#stop with prop of na
67
68
#calculate proportion
tab <- tab %>% mutate(p_NA = n_NA/(n_geno+n_NA))
mariefbourdon's avatar
mariefbourdon committed
69
70
71
tab <- tab %>%
mutate(exclude_prop=case_when(p_NA > na ~ 1,
T ~ 0))
72
#exclude with prop of homo/hetero
mariefbourdon's avatar
mariefbourdon committed
73
if(is.na(pval)==TRUE){
74
75
76
77
#calculate proportion of each genotype
tab <- tab %>% mutate(p_HM1 = n_HM1/n_geno)
tab <- tab %>% mutate(p_HM2 = n_HM2/n_geno)
tab <- tab %>% mutate(p_HT = n_HT/n_geno)
mariefbourdon's avatar
mariefbourdon committed
78
79
80
81
82
83
84
tab <- tab %>%
mutate(exclude_prop=case_when(p_NA > na ~ 1,
cross=="F2" & (p_HM1 < homo | p_HM2 < homo | p_HT < hetero) ~ 1,
cross=="N2" & (p_HM1 < homo | p_HT < hetero) ~ 1,
T ~ exclude_prop
))
}
85
86
#exclude with pval chisq.test
## NEED TO ADD THIS FILTER IF CROSS = N2
mariefbourdon's avatar
mariefbourdon committed
87
if(is.na(pval)==FALSE){
mariefbourdon's avatar
mariefbourdon committed
88
89
90
tab <- tab %>% filter(p_NA != 1) %>% rowwise() %>%
mutate(.,chi_pval = tibble(n_HM1,n_HM2,n_HT) %>%
chisq.test(p=c(0.25,0.25,0.5)) %>% .$p.value) %>%
91
full_join(.,tab,by=all_of(names))
mariefbourdon's avatar
mariefbourdon committed
92
93
tab <- tab %>% mutate(exclude_prop=case_when(chi_pval < pval ~ 1,
T ~ exclude_prop))
mariefbourdon's avatar
mariefbourdon committed
94
}
95
96
97
98
99
100
101
102
print(tab)
tab <- tab %>% select(all_of(names),exclude_prop)
print(tab)
}
tab2 <- mark_match(stuart_tab,ref=strains)
tab2 %>% filter(exclude_match==1)
tab2 <- mark_poly(tab2)
head(tab2)
mariefbourdon's avatar
mariefbourdon committed
103
mark_prop <- function(tab,cross,homo=NA,hetero=NA,pval=NA,na=0.5){
104
105
106
#stock colnames to join
names <- colnames(tab)
print(names)
mariefbourdon's avatar
mariefbourdon committed
107
#calculate total number of individuals genotyped for each marker
mariefbourdon's avatar
mariefbourdon committed
108
tab <- tab %>% mutate(n_geno = (n_HM1 + n_HM2 + n_HT))
mariefbourdon's avatar
mariefbourdon committed
109
110
111
112
113
114
115
116
117
#stop if cross != "F2" or "N2"
if(!cross %in% c("F2","N2")){
stop("Cross must be F2 or N2")
}
#stop of homo&hetero or pval not specified
if((is.na(homo)==TRUE | is.na(hetero)==TRUE) & is.na(pval)==TRUE){
stop("Arguments homo and hetero or argument pval must be specified")
}
#stop with prop of na
118
119
#calculate proportion
tab <- tab %>% mutate(p_NA = n_NA/(n_geno+n_NA))
mariefbourdon's avatar
mariefbourdon committed
120
121
122
tab <- tab %>%
mutate(exclude_prop=case_when(p_NA > na ~ 1,
T ~ 0))
123
#exclude with prop of homo/hetero
mariefbourdon's avatar
mariefbourdon committed
124
if(is.na(pval)==TRUE){
125
126
127
128
#calculate proportion of each genotype
tab <- tab %>% mutate(p_HM1 = n_HM1/n_geno)
tab <- tab %>% mutate(p_HM2 = n_HM2/n_geno)
tab <- tab %>% mutate(p_HT = n_HT/n_geno)
mariefbourdon's avatar
mariefbourdon committed
129
130
131
132
133
134
135
tab <- tab %>%
mutate(exclude_prop=case_when(p_NA > na ~ 1,
cross=="F2" & (p_HM1 < homo | p_HM2 < homo | p_HT < hetero) ~ 1,
cross=="N2" & (p_HM1 < homo | p_HT < hetero) ~ 1,
T ~ exclude_prop
))
}
136
137
#exclude with pval chisq.test
## NEED TO ADD THIS FILTER IF CROSS = N2
mariefbourdon's avatar
mariefbourdon committed
138
if(is.na(pval)==FALSE){
mariefbourdon's avatar
mariefbourdon committed
139
140
141
tab <- tab %>% filter(p_NA != 1) %>% rowwise() %>%
mutate(.,chi_pval = tibble(n_HM1,n_HM2,n_HT) %>%
chisq.test(p=c(0.25,0.25,0.5)) %>% .$p.value) %>%
142
full_join(.,tab,by=all_of(names))
mariefbourdon's avatar
mariefbourdon committed
143
144
145
tab <- tab %>% mutate(exclude_prop=case_when(chi_pval < pval ~ 1,
T ~ exclude_prop))
}
146
147
148
print(tab)
tab <- tab %>% select(all_of(names),exclude_prop)
print(tab)
mariefbourdon's avatar
mariefbourdon committed
149
}
150
151
tab2 <- mark_prop(tab2,cross="F2",homo=0.1,hetero=0.1)
devtools::build(path=".",vignettes=FALSE)
mariefbourdon's avatar
mariefbourdon committed
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
library(dplyr)
library(stuart)
annot_mini <- read.csv(url("https://raw.githubusercontent.com/kbroman/MUGAarrays/master/UWisc/mini_uwisc_v2.csv"))
data(genos)
summary(genos)
data(phenos)
summary(phenos)
strains <- geno_strains(ref=annot_mini,geno=genos,par1=c("StrainsA_1","StrainsA_2"),par2=c("StrainsB_1","StrainsB_2"),name1="parent1",name2="parent2")
head(strains)
genos <- genos %>% filter(!Sample.ID %in% c("StrainsA_1", "StrainsA_2", "StrainsB_1","StrainsB_2"))
data(stuart_tab)
summary(stuart_tab)
tab2 <- mark_match(stuart_tab,ref=strains)
tab2 %>% filter(exclude_match==1)
tab2 <- mark_poly(tab2)
head(tab2)
172
173
174
175
176
177
tab2 <- mark_prop(tab2,cross="F2",homo=0.1,hetero=0.1)
head(tab2)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
mariefbourdon's avatar
mariefbourdon committed
178
179
library(dplyr)
library(stuart)
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
annot_mini <- read.csv(url("https://raw.githubusercontent.com/kbroman/MUGAarrays/master/UWisc/mini_uwisc_v2.csv"))
data(genos)
summary(genos)
data(phenos)
summary(phenos)
strains <- geno_strains(ref=annot_mini,geno=genos,par1=c("StrainsA_1","StrainsA_2"),par2=c("StrainsB_1","StrainsB_2"),name1="parent1",name2="parent2")
head(strains)
genos <- genos %>% filter(!Sample.ID %in% c("StrainsA_1", "StrainsA_2", "StrainsB_1","StrainsB_2"))
data(stuart_tab)
summary(stuart_tab)
View(stuart_tab)
tab2 <- mark_match(stuart_tab,ref=strains)
tab2 %>% filter(exclude_match==1)
View(tab2)
tab2 <- mark_poly(tab2)
head(tab2)
View(tab2)
tab2 <- mark_prop(tab2,cross="F2",homo=0.1,hetero=0.1)
View(tab2)
library(stuart)
mariefbourdon's avatar
mariefbourdon committed
200
201
202
203
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
204
205
library(dplyr)
library(stuart)
mariefbourdon's avatar
mariefbourdon committed
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
annot_mini <- read.csv(url("https://raw.githubusercontent.com/kbroman/MUGAarrays/master/UWisc/mini_uwisc_v2.csv"))
data(genos)
summary(genos)
data(phenos)
summary(phenos)
strains <- geno_strains(ref=annot_mini,geno=genos,par1=c("StrainsA_1","StrainsA_2"),par2=c("StrainsB_1","StrainsB_2"),name1="parent1",name2="parent2")
head(strains)
genos <- genos %>% filter(!Sample.ID %in% c("StrainsA_1", "StrainsA_2", "StrainsB_1","StrainsB_2"))
data(stuart_tab)
summary(stuart_tab)
tab2 <- mark_match(stuart_tab,ref=strains)
tab2 %>% filter(exclude_match==1)
tab2 <- mark_poly(tab2)
head(tab2)
tab2 <- mark_prop(tab2,cross="F2",homo=0.1,hetero=0.1)
head(tab2)
222
View(tab2)
mariefbourdon's avatar
mariefbourdon committed
223
224
225
tab2 <- mark_allele(tab=tab2,ref=strains,par1="parent1",par2="parent2")
tab2 %>% arrange(desc(exclude_allele)) %>% head()
strains %>% filter(marker %in% c("gJAX00038569","gJAX00425031","gUNC12245354","gUNC15530876","gUNC21555204","gUNC21596600")) %>% arrange(marker) %>% select(marker,parent1,parent2)
226
227
View(tab2)
strains %>% filter(marker %in% c("gJAX00038569","gJAX00425031","gUNC12245354","gUNC15530876","gUNC21555204","gUNC21596600")) %>% arrange(marker) %>% select(marker,parent1,parent2)
mariefbourdon's avatar
mariefbourdon committed
228
229
230
rqtl_file <- write_rqtl(geno=genos,pheno=phenos,tab=tab2,ref=strains,par1="parent1",par2="parent2",prefix="ind_",pos="cM_cox")
rqtl_file[1:10,1:7]
devtools::build_vignettes()
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
devtools::build_manual()
build_manual
devtools::build_manual
Rd2pdf
tools::texi2pdf
devtools::build_manual()
devtools::build(path=".",vignettes=FALSE,manual=TRUE)
devtools::build_manual()
Rd2pdf()
Rd2pdf
install.packages("RdUtils")
RdUtils
RdUtils()
system("R CMD Rd2pdf stuart")
system("R CMD Rd2pdf stuaRt")
getwd()
cd ..
setwd("~/Documents/stuart_package/stuart")
setwd("~/Documents/stuart_package/stuart")
setwd("~/Documents/stuart_package")
system("R CMD Rd2pdf stuaRt")
system("R CMD Rd2pdf stuart")
system("R CMD Rd2pdf stuart")
setwd("~/Documents/stuart_package/stuart")
devtools::build_manual()
getwd()
devtools::build_manual(path=".")
devtools::build_manual(path=".")
View(genos)
devtools::build(path=".",vignettes=FALSE)
mariefbourdon's avatar
mariefbourdon committed
261
devtools::build_vignettes()
262
263
264
265
266
267
devtools::build_manual(path=".")
devtools::build_manual(path=".")
devtools::build(path=".",vignettes=FALSE)
devtools::build_manual(path=".")
roxygen2::roxygenise()
devtools::build_manual(path=".")
Marie Bourdon's avatar
Marie Bourdon committed
268
269
library(dplyr)
library(stuart)
270
271
272
273
274
275
276
277
278
279
280
test <- tibble(x=c("A","T"),y=c("A","A"),z=c("A","A"))
View(test)
View(test)
View(test)
View(test)
View(rqtl_file)
View(annot_mini)
View(genos)
View(genos)
View(genos)
View(test)
Marie Bourdon's avatar
Marie Bourdon committed
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
library(dplyr)
library(stuart)
test <- tibble(x=c("A","T"),y=c("A","A"),z=c("A","A"))
View(test)
test <- test %>% mutate(geno=x)
View(test)
test %>% mutate(geno = ifelse(geno==y,geno,"N"))
test <- test %>% mutate(geno = ifelse(geno==y,geno,"N"))
test <- test %>% mutate(geno = ifelse(geno==z,geno,"N"))
View(test)
test <- tibble(x=c("A","T"),y=c("A","A"),z=c("A","N"))
test <- tibble(x=c("A","T"),y=c("A","A"),z=c("A","N"))
test <- test %>% mutate(geno=x)
print(test)
test <- test %>% mutate(geno = ifelse(geno==y,geno,"N"))
print(test)
test <- test %>% mutate(geno = ifelse(geno==z,geno,"N"))
print(test)
geno_strains <- function(ref,geno,par1,par2,name1,name2){
#rename df columns
geno <- geno %>% rename("marker"=1,
"id"=2,
"allele_1"=3,
"allele_2"=4)
#recode genotypes from 2 alleles to 1
geno <- geno %>% mutate_all(as.character)
geno <- geno %>% filter(id %in% c(par1,par2))
geno <- geno %>% mutate(Geno=case_when(allele_1 == "-" | allele_2 == "-" ~ "N",
allele_1 == allele_2 ~ allele_1,
allele_1 %in% c("A","T","G","C") & allele_2 %in% c("A","T","G","C") ~ "H"))
geno <- geno %>% select(marker,id,Geno) %>% pivot_wider(names_from = id, values_from = Geno)
#create consensus
geno <- geno %>% mutate(parent1 = !!sym(par1[1]))
if(length(par1)!=1){
for(i in 2:length(par1)){
geno <- geno %>% mutate(parent1 = ifelse(parent1==!!sym(par1[i]),parent1,"N"))
}
}
geno <- geno %>% mutate(parent2 = !!sym(par2[1]))
if(length(par2)!=1){
for(i in 2:length(par2)){
geno <- geno %>% mutate(parent2 = ifelse(parent2==!!sym(par2[i]),parent2,"N"))
}
}
geno <- geno %>% select(marker,parent1,parent2)
colnames(geno) <- c("marker",name1,name2)
#merge with ref file
ref <- full_join(ref,geno,by=c("marker"="marker"))
return(ref)
}
data(genos)
summary(genos)
data(phenos)
summary(phenos)
annot_mini <- read.csv(url("https://raw.githubusercontent.com/kbroman/MUGAarrays/master/UWisc/mini_uwisc_v2.csv"))
data(stuart_tab)
summary(stuart_tab)
View(annot_mini)
ref <- tibble(marker = c("mark1","mark2","mark3","mark4","mark5","mark6"),
chr = c("1","1","2","2","3","X")
)
View(genos)
geno <- tibble(SNP.Name = c("mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6"),
Sample.ID = c("par1a","par1a","par1a","par1a","par1a","par1a",
"par1b","par1b","par1b","par1b","par1b","par1b",
"par1c","par1c","par1c","par1c","par1c","par1c",
"par2a","par2a","par2a","par2a","par2a","par2a",
"par2b","par2b","par2b","par2b","par2b","par2b",
"par2c","par2c","par2c","par2c","par2c","par2c"))
View(geno)
geno <- tibble(SNP.Name = c("mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6"),
Sample.ID = c("par1a","par1a","par1a","par1a","par1a","par1a",
"par1b","par1b","par1b","par1b","par1b","par1b",
"par1c","par1c","par1c","par1c","par1c","par1c",
"par2a","par2a","par2a","par2a","par2a","par2a",
"par2b","par2b","par2b","par2b","par2b","par2b",
"par2c","par2c","par2c","par2c","par2c","par2c"),
Allele1...Forward = c("A","A","A","A","A","A",
"A","A","A","A","T","T",
"A","A","A","N","T","-",
"A","A","A","A","A","A",
"A","A","A","A","T","T",
"A","A","A","N","T","-"),
Allele2...Forward = c("A","A","A","A","A","A",
"A","A","A","A","T","T",
"A","A","A","N","T","-",
"A","A","A","A","A","A",
"A","A","A","A","T","T",
"A","A","A","N","T","-"))
geno_strains(ref=ref,geno=geno,par1=c("par1a","par1b","par1c"),par2=c("par2a","par2b","par2c"),name1="parent1",name2="parent2")
library(dplyr)
library(tidyr)
geno_strains(ref=ref,geno=geno,par1=c("par1a","par1b","par1c"),par2=c("par2a","par2b","par2c"),name1="parent1",name2="parent2")
geno <- tibble(SNP.Name = c("mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6",
"mark1","mark2","mark3","mark4","mark5","mark6"),
Sample.ID = c("par1a","par1a","par1a","par1a","par1a","par1a",
"par1b","par1b","par1b","par1b","par1b","par1b",
"par1c","par1c","par1c","par1c","par1c","par1c",
"par2a","par2a","par2a","par2a","par2a","par2a",
"par2b","par2b","par2b","par2b","par2b","par2b",
"par2c","par2c","par2c","par2c","par2c","par2c"),
Allele1...Forward = c("A","A","A","A","A","A",
"A","A","A","A","T","T",
"A","A","A","-","T","-",
"A","A","A","A","A","A",
"A","A","A","A","T","T",
"A","A","A","-","T","-"),
Allele2...Forward = c("A","A","A","A","A","A",
"A","A","A","A","T","T",
"A","A","A","-","T","-",
"A","A","A","A","A","A",
"A","A","A","A","T","T",
"A","A","A","-","T","-"))
geno_strains(ref=ref,geno=geno,par1=c("par1a","par1b","par1c"),par2=c("par2a","par2b","par2c"),name1="parent1",name2="parent2")
devtools::build(path=".",vignettes=FAKSE)
rlang::last_error()
devtools::build(path=".",vignettes=FAKSE)
devtools::build(path=".",vignettes=FALSE)
View(genos)
genos %>% filter(SNP.Name %in% c("S3J010123784","SAH010136363","S2H010137098")) %>% filter(Sample.ID %in% c("StrainsA_1","StrainsA_2","StrainsB_1","StrainsB_2"))
genos %>% filter(Sample.ID %in% c("StrainsA_1","StrainsA_2","StrainsB_1","StrainsB_2")) %>% filter(SNP.Name %in% c("S3J010123784","SAH010136363","S2H010137098"))
geno_strains <- function(ref,geno,par1,par2,name1,name2){
#rename df columns
geno <- geno %>% rename("marker"=1,
"id"=2,
"allele_1"=3,
"allele_2"=4)
#recode genotypes from 2 alleles to 1
geno <- geno %>% mutate_all(as.character)
geno <- geno %>% filter(id %in% c(par1,par2))
geno <- geno %>% mutate(Geno=case_when(allele_1 == "-" | allele_2 == "-" ~ "N",
allele_1 == allele_2 ~ allele_1,
allele_1 %in% c("A","T","G","C") & allele_2 %in% c("A","T","G","C") ~ "H"))
geno <- geno %>% select(marker,id,Geno) %>% pivot_wider(names_from = id, values_from = Geno)
#create consensus
geno <- geno %>% mutate(parent1 = !!sym(par1[1]))
if(length(par1)!=1){
for(i in 2:length(par1)){
geno <- geno %>% mutate(parent1 = ifelse(parent1==!!sym(par1[i]),parent1,"N"))
}
}
geno <- geno %>% mutate(parent2 = !!sym(par2[1]))
if(length(par2)!=1){
for(i in 2:length(par2)){
geno <- geno %>% mutate(parent2 = ifelse(parent2==!!sym(par2[i]),parent2,"N"))
}
}
print(geno)
geno <- geno %>% select(marker,parent1,parent2)
colnames(geno) <- c("marker",name1,name2)
#merge with ref file
ref <- full_join(ref,geno,by=c("marker"="marker"))
return(ref)
}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
library(dplyr)
library(stuart)
annot_mini <- read.csv(url("https://raw.githubusercontent.com/kbroman/MUGAarrays/master/UWisc/mini_uwisc_v2.csv"))
data(genos)
summary(genos)
data(phenos)
summary(phenos)
strains <- geno_strains(ref=annot_mini,geno=genos,par1=c("StrainsA_1","StrainsA_2"),par2=c("StrainsB_1","StrainsB_2"),name1="parent1",name2="parent2")
devtools::build(path=".",vignettes=FALSE)
devtools::build_vignettes()
devtools::build_manual(path=".")
devtools::build(path=".",vignettes=FALSE)
devtools::build_vignettes()
devtools::build_manual(path=".")
devtools::build(path=".",vignettes=FALSE)
install.packages("KableExtra")
install.packages("kableExtra")
install.packages("kableExtra")
library(dplyr)
library(stuart)
print.data.frame(tab2 %>% filter(exclude_match==1))
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
library(dplyr)
library(stuart)
annot_mini <- read.csv(url("https://raw.githubusercontent.com/kbroman/MUGAarrays/master/UWisc/mini_uwisc_v2.csv"))
data(genos)
summary(genos)
data(phenos)
summary(phenos)
strains <- geno_strains(ref=annot_mini,geno=genos,par1=c("StrainsA_1","StrainsA_2"),par2=c("StrainsB_1","StrainsB_2"),name1="parent1",name2="parent2")
print.data.frame(head(strains))
genos <- genos %>% filter(!Sample.ID %in% c("StrainsA_1", "StrainsA_2", "StrainsB_1","StrainsB_2"))
data(stuart_tab)
summary(stuart_tab)
tab2 <- mark_match(stuart_tab,ref=strains)
print.data.frame(tab2 %>% filter(exclude_match==1))
tab2 <- mark_poly(tab2)
head(tab2)
tab2 <- mark_prop(tab2,cross="F2",homo=0.1,hetero=0.1)
print.data.frame(head(tab2))
tab2 %>% arrange(desc(exclude_allele)) %>% head() %>% print.data.frame()
tab2 <- mark_allele(tab=tab2,ref=strains,par1="parent1",par2="parent2")
tab2 %>% arrange(desc(exclude_allele)) %>% head() %>% print.data.frame()
head(tab2) %>% print.data.frame()
head(tab2) %>% print.data.frame()
rqtl_file[1:10,1:9] %>% print.data.frame()
devtools::build(path=".",vignettes=FALSE)
devtools::build_vignettes()
devtools::build_manual(path=".")
remove.packages("stuart")
devtools::install_gitlab(repo="mouselab/stuart",host="gitlab.pasteur.fr")
library(stuart)
View(annot_mini)
annot_mini %>% filter(is.na(chr)==FALSE) %>% filter(is.na(cM_cox)==TRUE)
devtools::build(path=".",vignettes=FALSE)
library(stuart)
write_rqtl