article_figures.Rmd 13.8 KB
Newer Older
Marie Bourdon's avatar
Marie Bourdon committed
1
2
3
---
title: "article_figures.Rmd"
author: "Marie Bourdon"
mariefbourdon's avatar
mariefbourdon committed
4
date: "June 2022"
Marie Bourdon's avatar
Marie Bourdon committed
5
6
7
output: html_document
---

Marie Bourdon's avatar
Marie Bourdon committed
8
# Goal and raw data
Marie Bourdon's avatar
Marie Bourdon committed
9
10
11

The goal of this script is to produce figure for the stuart package manuscript.

Marie Bourdon's avatar
Marie Bourdon committed
12
This scripts uses data from the package, and other files found in the "files" directory.
Marie Bourdon's avatar
Marie Bourdon committed
13
14
15
16
17
18
19
20
21
22
23
24

This script uses the qtl_plot() ggplot based function to plot QTL mapping results. This function is in the script "QTL_plot.R".

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(magrittr)
library(qtl)
library(cowplot)
library(grid)
library(gridExtra)
library(gridGraphics)
mariefbourdon's avatar
mariefbourdon committed
25
library(scales)
Marie Bourdon's avatar
Marie Bourdon committed
26
27
28
29

library(stuart)

source("files/QTL_plot.R")
mariefbourdon's avatar
mariefbourdon committed
30
source("files/find_linked_markers.R")
Marie Bourdon's avatar
Marie Bourdon committed
31
32
```

mariefbourdon's avatar
mariefbourdon committed
33
# Load R objects from datasets
Marie Bourdon's avatar
Marie Bourdon committed
34

mariefbourdon's avatar
mariefbourdon committed
35
36
37
38
```{r}
load("data1/data1.rda")
load("data2/data2.rda")
load("data3/data3.rda")
Marie Bourdon's avatar
Marie Bourdon committed
39
annot_mini <- read.csv(url("https://raw.githubusercontent.com/kbroman/MUGAarrays/master/UWisc/mini_uwisc_v2.csv"))
Marie Bourdon's avatar
Marie Bourdon committed
40
41
```

Marie Bourdon's avatar
Marie Bourdon committed
42

Marie Bourdon's avatar
Marie Bourdon committed
43
44
45
46
47
48
49
# Graphs

## Grid mark_prop

### Graph missing genotypes

```{r graph_NA}
mariefbourdon's avatar
mariefbourdon committed
50
na_plot <- tab2 %>% mutate(prop_NA=n_NA/176) %>% ggplot(aes(x=prop_NA)) +
Marie Bourdon's avatar
Marie Bourdon committed
51
  geom_histogram() +
mariefbourdon's avatar
mariefbourdon committed
52
53
  scale_y_log10(expand = c(.01, .01)) +
  scale_x_continuous(expand = c(.005, .005)) +
mariefbourdon's avatar
mariefbourdon committed
54
  theme_classic() +
mariefbourdon's avatar
mariefbourdon committed
55
  labs(title="Proportion of missing genotypes",
Marie Bourdon's avatar
Marie Bourdon committed
56
57
58
       x="Proportion of NA",y="Number of markers") +
  theme(
    aspect.ratio=0.8,
mariefbourdon's avatar
mariefbourdon committed
59
    plot.title = element_text(hjust = 0.4,size=14))
Marie Bourdon's avatar
Marie Bourdon committed
60
61
62
63

na_plot
```

mariefbourdon's avatar
mariefbourdon committed
64
65
Proportions of markers with more than 75% of missing genotypes:
```{r prop_missing}
mariefbourdon's avatar
mariefbourdon committed
66
tab2 %>% mutate(prop_NA=n_NA/176) %>% filter(prop_NA > 0.50) %>% summarise(p=n()/count(tab2)%>%pull())
mariefbourdon's avatar
mariefbourdon committed
67
68
69
```


Marie Bourdon's avatar
Marie Bourdon committed
70
71
72
### Graph proportion of genotypes

```{r graph_prop}
mariefbourdon's avatar
mariefbourdon committed
73
prop_plot <- tab2 %>% filter(n_NA<88) %>% filter(!chr %in% c("M","X","Y")) %>%
mariefbourdon's avatar
mariefbourdon committed
74
  ggplot(aes(x=n_HM1/(n_HM1+n_HM2+n_HT),y=n_HM2/(n_HM1+n_HM2+n_HT),color=as.factor(exclude_prop))) +
Marie Bourdon's avatar
Marie Bourdon committed
75
  geom_point() +
mariefbourdon's avatar
mariefbourdon committed
76
  scale_color_manual(values=c("#66bd63","#b2182b"),labels = c("Retained", "Excluded")) +
mariefbourdon's avatar
mariefbourdon committed
77
78
79
  geom_hline(yintercept = 0.1,linetype="dashed",size=.3) +
  geom_vline(xintercept = 0.1,linetype="dashed",size=.3) +
  geom_abline(intercept = 0.9, slope=-1,linetype="dashed",size=.3) +
mariefbourdon's avatar
mariefbourdon committed
80
81
  scale_x_continuous(expand = c(.005, .005)) +
  scale_y_continuous(expand = c(.005, .005)) +
mariefbourdon's avatar
mariefbourdon committed
82
  labs(title="Exclusion of markers by mark_prop()",
mariefbourdon's avatar
mariefbourdon committed
83
84
       x="Proportion of A/A individuals",
       y="Proportion of B/B individuals",
Marie Bourdon's avatar
Marie Bourdon committed
85
86
       color="Exclusion") +
  theme_classic() +
mariefbourdon's avatar
mariefbourdon committed
87
88
89
  theme(aspect.ratio=0.8,
        legend.position=c(0.8,0.8),
        legend.title = element_blank()) +
mariefbourdon's avatar
mariefbourdon committed
90
  theme(plot.title = element_text(hjust = 0.4,size=14)) +
mariefbourdon's avatar
mariefbourdon committed
91
  geom_segment(x = 0.2, y = 0.78,
mariefbourdon's avatar
mariefbourdon committed
92
93
               xend = 0.25, yend = 0.72,
               color = "#1d91c0",
mariefbourdon's avatar
mariefbourdon committed
94
95
               arrow = arrow(type="closed",length=unit(4,"points"))) +
  geom_segment(x = 0.39, y = 0.58,
mariefbourdon's avatar
mariefbourdon committed
96
97
               xend = 0.44, yend = 0.52,
               color = "#1d91c0",
mariefbourdon's avatar
mariefbourdon committed
98
               arrow = arrow(type="closed",length=unit(4,"points")))
Marie Bourdon's avatar
Marie Bourdon committed
99
100
prop_plot
```
mariefbourdon's avatar
mariefbourdon committed
101

Marie Bourdon's avatar
Marie Bourdon committed
102
103
104
105
106
107
### Grid

Figure with graphs proportion of NA and exclusion depending on genotype proportions


```{r grid_na_prop}
mariefbourdon's avatar
mariefbourdon committed
108
gridnaprop <- plot_grid(na_plot,prop_plot,
Marie Bourdon's avatar
Marie Bourdon committed
109
110
111
112
113
114
                  ncol=1,
                  labels = c('A', 'B'), 
                  label_size = 20,
                  byrow = TRUE
                  )

mariefbourdon's avatar
mariefbourdon committed
115
gridnaprop
Marie Bourdon's avatar
Marie Bourdon committed
116

mariefbourdon's avatar
mariefbourdon committed
117
ggsave("figures/fig2.pdf",gridnaprop,width=5,height=8)
mariefbourdon's avatar
mariefbourdon committed
118
119
ggsave("figures/fig2.png",gridnaprop,width=5,height=8)

Marie Bourdon's avatar
Marie Bourdon committed
120
121
122
123
124
125
126

rm(na_plot,prop_plot)
```

## Graph before after


mariefbourdon's avatar
mariefbourdon committed
127
### Grid before
Marie Bourdon's avatar
Marie Bourdon committed
128
129


mariefbourdon's avatar
mariefbourdon committed
130

mariefbourdon's avatar
mariefbourdon committed
131
```{r grid_before}
mariefbourdon's avatar
mariefbourdon committed
132
grid_before <- plot_grid(as_grob(plotmap_before),rec_ratios_before,pheno_before_annot,pheno_before_zoom,ncol=2,labels=c("A","B","C","D"),label_size=20)
mariefbourdon's avatar
mariefbourdon committed
133
grid_before
mariefbourdon's avatar
mariefbourdon committed
134
ggsave("figures/fig1prev.pdf",grid_before,width=14,height = 10)
Marie Bourdon's avatar
Marie Bourdon committed
135
136
137
```


mariefbourdon's avatar
mariefbourdon committed
138
### Grid after
Marie Bourdon's avatar
Marie Bourdon committed
139

mariefbourdon's avatar
mariefbourdon committed
140

Marie Bourdon's avatar
Marie Bourdon committed
141

mariefbourdon's avatar
mariefbourdon committed
142
```{r grid fig3, fig.height = 7, fig.width = 13, fig.align = "center"}
mariefbourdon's avatar
mariefbourdon committed
143
grid_after <- plot_grid(as_grob(plotmap_after),rec_ratios_after,pheno_after_plot,pheno_after_zoom,ncol=2,labels=c("A","B","C","D"),label_size=20)
mariefbourdon's avatar
mariefbourdon committed
144
145
grid_after
ggsave("figures/fig3prev.pdf",grid_after,width=14,height = 10)
Marie Bourdon's avatar
Marie Bourdon committed
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
```

# Differences between real and reference genotypes for parental strains

```{r dif_number}
dif <- full_join(strains,strns_ref,by=c("marker","chr","cM_cox")) %>% 
  mutate(dif=case_when((!parent1.x%in%c("N","H") & 
                          !parent1.y%in%c("N","H") & 
                          parent1.x!=parent1.y) ~ 1,
                       (!parent2.x%in%c("N","H") &
                          !parent2.y%in%c("N","H") & 
                          parent2.x!=parent2.y) ~ 1, 
                       T~0))

dif %>% filter(dif==1) %>% count()
mariefbourdon's avatar
mariefbourdon committed
161
162

rm(dif)
Marie Bourdon's avatar
Marie Bourdon committed
163
164
```

mariefbourdon's avatar
mariefbourdon committed
165
166
167
168
169
170
171
## Table alleles different between parental strains and F2s

```{r allele}
#investigation of the role of mark_allele function
#prove that some marker with non corresponding alleles between parents and F2

#keep only markers that are exlcuded with mark_allele
mariefbourdon's avatar
mariefbourdon committed
172
allele <- tab2 %>% 
mariefbourdon's avatar
mariefbourdon committed
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
  filter(exclude_allele==1&exclude_poly==0&exclude_prop==0&exclude_na==0&exclude_estmap==0)
strains_allele <- strains %>% filter(marker %in% allele$marker)

#number of markers not excluded by other functoins
tab2 %>% 
  filter(exclude_poly==0&exclude_prop==0&exclude_na==0&exclude_estmap==0) %>% nrow()

#join with strains genotypes to have parental strains
allele <- left_join(allele,strains_allele,by=c("marker"="marker"))


#most of markers excluded with mark_allele that were not excluded with other functions have N/H as genotype for parents
#keep only those with non missing/heterozygous genotypes
allele %<>% filter(parent1 != "N" & parent2 != "N")
allele %<>% select(marker,parent1,parent2,allele_1,allele_2)


print(allele)

print(xtable::xtable(allele, type = "latex"), file = "tables/tab_alleles.tex",include.rownames=FALSE)
rm(allele,strains_allele)
```

mariefbourdon's avatar
mariefbourdon committed
196
## Differences between real and reference genotypes for parental strains
mariefbourdon's avatar
mariefbourdon committed
197

mariefbourdon's avatar
mariefbourdon committed
198
199
200
201
202
203
204
205
206
```{r dif_table}
dif <- full_join(strains,strns_ref,by=c("marker","chr","cM_cox")) %>% 
  mutate(dif=case_when((!parent1.x%in%c("N","H") & 
                          !parent1.y%in%c("N","H") & 
                          parent1.x!=parent1.y) ~ 1,
                       (!parent2.x%in%c("N","H") &
                          !parent2.y%in%c("N","H") & 
                          parent2.x!=parent2.y) ~ 1, 
                       T~0))
mariefbourdon's avatar
mariefbourdon committed
207

mariefbourdon's avatar
mariefbourdon committed
208
dif %>% filter(dif==1) %>% count()
mariefbourdon's avatar
mariefbourdon committed
209
210
```

mariefbourdon's avatar
mariefbourdon committed
211
212
## Pheno data format

mariefbourdon's avatar
mariefbourdon committed
213
214
```{r pheno}
format_pheno <- phenos[1:6,]
mariefbourdon's avatar
mariefbourdon committed
215
write_csv(format_pheno,file="figures/tableS1.csv")
mariefbourdon's avatar
mariefbourdon committed
216
217
218
print(xtable::xtable(format_pheno, type = "latex"), file = "tables/tab_alleles.tex",include.rownames=FALSE)
```

mariefbourdon's avatar
mariefbourdon committed
219

mariefbourdon's avatar
mariefbourdon committed
220
## Markers with unmatching alleles that lead to distortion of genetic map
mariefbourdon's avatar
mariefbourdon committed
221
222
223
224

```{r}
tab2 %>% filter(exclude_allele==1 & exclude_prop==0) %>% select(marker:n_NA) %>% left_join(.,strains) %>% filter(!parent1 %in% c("N","H") & !parent2 %in% c("N","H"))

mariefbourdon's avatar
mariefbourdon committed
225
226
allele_rec <- tab2 %>% filter(marker %in% c("gJAX00038569","mUNC21540855","gUNC21555204","gUNC21596600")) %>% 
  select(marker:n_NA) %>% left_join(.,strains,by = c("marker", "chr", "cM_cox"))
mariefbourdon's avatar
mariefbourdon committed
227
228

# gJAX00038569
mariefbourdon's avatar
mariefbourdon committed
229
230
map_1 <- newmap_before[["12"]][c("gUNC21523346","gJAX00038569","gUNCHS034222")] #50cM on each side
pos_1 <- cross_before[["geno"]][["12"]][["map"]][c("gUNC21523346","gJAX00038569","gUNCHS034222")]
mariefbourdon's avatar
mariefbourdon committed
231
232

# mUNC21540855
mariefbourdon's avatar
mariefbourdon committed
233
234
map_2 <- newmap_before[["12"]][c("gUNCHS034222","mUNC21540855","SFJ123443466")] #50cM on each side
pos_2 <- cross_before[["geno"]][["12"]][["map"]][c("gUNCHS034222","mUNC21540855","SFJ123443466")]
mariefbourdon's avatar
mariefbourdon committed
235
236

# gUNC21555204
mariefbourdon's avatar
mariefbourdon committed
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
map_3 <- newmap_before[["12"]][c("SFJ123443466","gUNC21555204","gJAX00340618")] #30-60cM on each side
pos_3 <- cross_before[["geno"]][["12"]][["map"]][c("SFJ123443466","gUNC21555204","gJAX00340618")]

# gUNC21596600
map_4 <- newmap_before[["12"]][c("JAX00341204","gUNC21596600","UNC21601697")] #30-60cM on each side
pos_4 <- cross_before[["geno"]][["12"]][["map"]][c("JAX00341204","gUNC21596600","UNC21601697")]


df <- tibble(gJAX00038569 = c(map_1,pos_1),
       mUNC21540855 = c(map_2,pos_2),
       gUNC21555204 = c(map_3,pos_3),
       gUNC21596600 = c(map_4,pos_4))
df <- as_tibble(cbind(nms = names(df), t(df))) %>% rename(marker = nms,
                                                          rec_before = V2,
                                                          rec = V3,
                                                          rec_after = V4,
                                                          pos_before = V5,
                                                          pos = V6,
                                                          pos_after = V7)

df %<>% mutate(rec_before = as.numeric(rec) - as.numeric(rec_before),
              rec_after = as.numeric(rec_after) - as.numeric(rec),
              pos_before = as.numeric(pos) - as.numeric(pos_before),
              pos_after = as.numeric(pos_after) - as.numeric(pos)) %>%
  select(marker,rec_before,rec_after,pos_before,pos_after)

allele_rec <- full_join(allele_rec,df,by="marker") %>% select(marker:parent2,rec_before,rec_after,pos_before,pos_after)
allele_rec


mariefbourdon's avatar
mariefbourdon committed
267
rm(map_1,map_2,map_3,map_4,pos_1,pos_2,pos_3,pos_4,df,allele_rec)
mariefbourdon's avatar
mariefbourdon committed
268
269
```

mariefbourdon's avatar
mariefbourdon committed
270
271
272
## All 3 datasets

### Phenotype distribution
mariefbourdon's avatar
mariefbourdon committed
273

mariefbourdon's avatar
mariefbourdon committed
274
```{r}
mariefbourdon's avatar
mariefbourdon committed
275
276
grid_pheno <- plot_grid(pheno_data1,pheno_data2,pheno_data3,ncol=2,labels=c("A","B","C","D"),label_size=20)
grid_pheno
mariefbourdon's avatar
mariefbourdon committed
277

mariefbourdon's avatar
mariefbourdon committed
278
279
280
281
282
283
ggsave("figures/figS1.pdf",grid_pheno,width=14,height = 10)
```

### Grid with all 3 data sets

```{r}
mariefbourdon's avatar
mariefbourdon committed
284
285
colnames(peak1_tab) <- c("marker","chr","pos","allele\n1","allele\n2",
                 "n\nHM1","n\nHM2","n\nHT","n\nNA")
mariefbourdon's avatar
mariefbourdon committed
286
colnames(peak3_tab) <- c("marker","chr","pos","allele\n1","allele\n2",
mariefbourdon's avatar
mariefbourdon committed
287
288
289
290
                 "n\nHM1","n\nHM2","n\nHT","n\nNA")


narrow_grid <- ggdraw() +
mariefbourdon's avatar
mariefbourdon committed
291
292
293
294
295
296
297
298
  draw_plot(pheno_before_annot_data2,0,.7,.5,.3) +
  draw_plot(pheno_before_annot_data3,.5,.7,.5,.3) +
  draw_plot(peak1,0,.35,.3,.3) +
  draw_plot(tableGrob(peak1_tab,rows=NULL),.3,.35,.7,.3) +
  draw_plot(peak3,0,0,.3,.3) +
  draw_plot(tableGrob(peak3_tab,rows=NULL),.3,0,.7,.3) +
  draw_plot_label(c("A","B","C","D","E","F"),
                  c(0,.5,0,.3,0,.3),c(1,1,.65,.65,.3,.3))
mariefbourdon's avatar
mariefbourdon committed
299
300

narrow_grid
mariefbourdon's avatar
mariefbourdon committed
301
ggsave(narrow_grid,file="figures/figS3prev.pdf",width=10,height=14)
mariefbourdon's avatar
mariefbourdon committed
302
303
```

mariefbourdon's avatar
mariefbourdon committed
304

mariefbourdon's avatar
mariefbourdon committed
305
306
307
## Dataset sup

### Map before and rec ratio distrib
mariefbourdon's avatar
mariefbourdon committed
308

mariefbourdon's avatar
mariefbourdon committed
309
```{r}
mariefbourdon's avatar
mariefbourdon committed
310
grid_mapbef <- plot_grid(plotmap_before_data2,plotmap_before_data3,rec_ratios_before_data2,rec_ratios_before_data3,ncol=2,labels=c("A","B","C","D"),label_size=20)
mariefbourdon's avatar
mariefbourdon committed
311

mariefbourdon's avatar
mariefbourdon committed
312
grid_mapbef
mariefbourdon's avatar
mariefbourdon committed
313
ggsave("figures/figS2prev.pdf",grid_mapbef ,width=14,height = 10)
mariefbourdon's avatar
mariefbourdon committed
314
315
316
317
318
```

### Map after and rec ratio distrib

```{r}
mariefbourdon's avatar
mariefbourdon committed
319
grid_mapaf <- plot_grid(plotmap_after_data2,plotmap_after_data3,rec_ratios_after_data2,rec_ratios_after_data3,ncol=2,labels=c("A","B","C","D"),label_size=20)
mariefbourdon's avatar
mariefbourdon committed
320

mariefbourdon's avatar
mariefbourdon committed
321
ggsave("figures/figS4prev.pdf",grid_mapaf,width=14,height = 10)
mariefbourdon's avatar
mariefbourdon committed
322
323
```

mariefbourdon's avatar
mariefbourdon committed
324
### Scans
mariefbourdon's avatar
mariefbourdon committed
325
326

```{r}
mariefbourdon's avatar
mariefbourdon committed
327
328
329
grid_scans <- plot_grid(pheno_after_plot_data2,pheno_after_plot_data3,ncol=2,labels=c("A","B"),label_size=20)

ggsave("figures/figS5.pdf",grid_scans,width=14,height = 5)
mariefbourdon's avatar
mariefbourdon committed
330
331
```

mariefbourdon's avatar
mariefbourdon committed
332

mariefbourdon's avatar
mariefbourdon committed
333
334
335
## Comparision of non mendelian/wrong alleles markers between the 4 datasets


mariefbourdon's avatar
mariefbourdon committed
336
```{r}
mariefbourdon's avatar
mariefbourdon committed
337
338
339
colnames(tab2_data2) <- c(colnames(tab2_data2)[1:3],paste0(colnames(tab2_data2)[4:ncol(tab2_data2)],".2"))
colnames(tab2_data3) <- c(colnames(tab2_data3)[1:3],paste0(colnames(tab2_data3)[4:ncol(tab2_data3)],".3"))

mariefbourdon's avatar
mariefbourdon committed
340
tab_alldata <- full_join(tab2,tab2_data2) %>% full_join(.,tab2_data3)
mariefbourdon's avatar
mariefbourdon committed
341
342

#keep all markers with non mendelian prop in at least 1 dataset
mariefbourdon's avatar
mariefbourdon committed
343
344
345
prop_rem <- tab_alldata %>% filter((exclude_poly==0&exclude_prop==1) | (exclude_poly==0&exclude_allele==1) |
                       (exclude_poly.2==0&exclude_prop.2==1) | (exclude_poly.2==0&exclude_allele.2==1) |
                       (exclude_poly.3==0&exclude_prop.3==1) | (exclude_poly.3==0&exclude_allele.3==1))
mariefbourdon's avatar
mariefbourdon committed
346
347
348
349
350
351
352

nrow(prop_rem)

#make sure marker is prop excluded in at least 1 dataset
prop_rem %<>% mutate(exclpr_data1=case_when(exclude_poly==0&exclude_prop==1 ~ 1, T ~ 0)) %>%
              mutate(exclpr_data2=case_when(exclude_poly.2==0&exclude_prop.2==1 ~ 1, T ~ 0)) %>%
              mutate(exclpr_data3=case_when(exclude_poly.3==0&exclude_prop.3==1 ~ 1, T ~ 0)) %>%
mariefbourdon's avatar
mariefbourdon committed
353
  mutate(sompr=exclpr_data1+exclpr_data2+exclpr_data3) 
mariefbourdon's avatar
mariefbourdon committed
354
355
356
357
358

#note if marker retained in a data set
prop_rem %<>% mutate(excl_data1=case_when((exclude_match+exclude_poly+exclude_na+exclude_prop+exclude_allele+exclude_estmap)==0 ~ 0, T ~ 1)) %>%
             mutate(excl_data2=case_when((exclude_match.2+exclude_poly.2+exclude_na.2+exclude_prop.2+exclude_allele.2+exclude_estmap.2)==0 ~ 0, T ~ 1)) %>%
             mutate(excl_data3=case_when((exclude_match.3+exclude_poly.3+exclude_na.3+exclude_prop.3+exclude_allele.3+exclude_estmap.3)==0 ~ 0, T ~ 1)) %>%
mariefbourdon's avatar
mariefbourdon committed
359
  mutate(som=excl_data1+excl_data2+excl_data3) 
mariefbourdon's avatar
mariefbourdon committed
360
361

#number of markers ok in a least 1 dataset
mariefbourdon's avatar
mariefbourdon committed
362
prop_rem %>% filter(som<3) %>% nrow()
mariefbourdon's avatar
mariefbourdon committed
363
364

#number of markers always removed
mariefbourdon's avatar
mariefbourdon committed
365
366
367
368
369
370
prop_rem %<>% mutate(notpoly=case_when(som==3 & (exclude_poly+exclude_poly.2+exclude_poly.3==2) ~ 0,
                                       som==3 & is.na(exclude_poly.2)==TRUE & (exclude_poly+exclude_poly.3==1) ~ 0,
                                       som==3 & (exclude_poly+exclude_poly.2+exclude_poly.3==0) ~ 2,
                                       som==3 & is.na(exclude_poly.2)==TRUE & (exclude_poly+exclude_poly.3==0) ~ 2,
                                       som==3 & (exclude_poly+exclude_poly.2+exclude_poly.3<2) & (exclude_poly+exclude_poly.2+exclude_poly.3>0) ~ 1,
                                       som==3 & is.na(exclude_poly.2)==TRUE &  (exclude_poly+exclude_poly.3<1) & (exclude_poly+exclude_poly.3>0) ~ 1))
mariefbourdon's avatar
mariefbourdon committed
371
372

prop_rem %>% group_by(notpoly) %>% summarise(n=n())
mariefbourdon's avatar
mariefbourdon committed
373
374
```

mariefbourdon's avatar
mariefbourdon committed
375
376
377
378
379
380
## Are markers excluded by mark_estmap okay in other crosses ? 

```{r}
#keep all markers with non mendelian prop in at least 1 dataset
map_rem <- tab_alldata %>% filter(exclude_estmap==1 |
                       exclude_estmap.2==1 |
mariefbourdon's avatar
mariefbourdon committed
381
                       exclude_estmap.3==1)
mariefbourdon's avatar
mariefbourdon committed
382

mariefbourdon's avatar
mariefbourdon committed
383
384
385
map_rem %<>% mutate(som=case_when(exclude_match+exclude_poly+exclude_na+exclude_prop+exclude_allele+exclude_estmap==0 ~ 0,
                                 exclude_match.2+exclude_poly.2+exclude_na.2+exclude_prop.2+exclude_allele.2+exclude_estmap.2==0 ~ 0,
                                 exclude_match.3+exclude_poly.3+exclude_na.3+exclude_prop.3+exclude_allele.3+exclude_estmap.3==0 ~ 0,))
mariefbourdon's avatar
mariefbourdon committed
386
387
```

mariefbourdon's avatar
mariefbourdon committed
388
5/9 are okay in another cross.
mariefbourdon's avatar
mariefbourdon committed
389
390


mariefbourdon's avatar
mariefbourdon committed
391