-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDifferent size pedigrees and missing mums.R
48 lines (34 loc) · 1.52 KB
/
Different size pedigrees and missing mums.R
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
require(krsp)
require(tidyverse)
con = krsp_connect(group = "krsp-aws")
ped=tbl(con, "pedigree") %>% collect() %>%
select(animal=squirrel_id, sire=sire_id, dam=dam_id) %>%
filter(!(is.na(animal)))
pedf=tbl(con, "flastall") %>% collect() %>%
select(animal=squirrel_id, sire=sire_id, dam=dam_id) %>%
filter(!(is.na(animal)))
nrow(ped)
nrow(pedf) #so this one is twice as large
#Yet its not down to duplicated entries:
pedf %>% count(animal) %>% filter(n > 1)
ped %>% count(animal) %>% filter(n > 1)
#Identifying missing mums
miss.mums.ped = ped %>% filter(!is.na(dam), !(dam %in% animal)) %>%
select(animal=dam) %>% mutate(sire=NA, dam=NA) %>%
group_by(animal) %>% sample_n(1)
#None, so that is good
miss.mums.flall = pedf %>% filter(!is.na(dam), !(dam %in% animal)) %>%
select(animal=dam) %>% mutate(sire=NA, dam=NA) %>%
group_by(animal) %>% sample_n(1)
#19 here
#Do same for dads
miss.dads.ped = ped %>% filter(!is.na(sire), !(sire %in% animal)) %>%
select(animal=sire) %>% mutate(sire=NA, dam=NA) %>%
group_by(animal) %>% sample_n(1)
#None, so that is good
miss.dads.flall = pedf %>% filter(!is.na(sire), !(sire %in% animal)) %>%
select(animal=sire) %>% mutate(sire=NA, dam=NA) %>%
group_by(animal) %>% sample_n(1)
#1 individual
#These could be row bound to the pedigree:
pedf.all = bind_rows(pedf, miss.mums.flall, miss.dads.flall)