Main figures
Figure 2. Pedigree genomics
Crossing homozygotic male, with heterozygotic female (5) F1 male (0/0) x female (0/1) original Rmd: ~/Documents/GitHub/varroa-linkage-map/R_scripts/explore_vcf_F1_F2.Rmd
# define a list to put all the data frames in
obs <- list()
for (fam in family) {
obs[[fam]] <- table %>%
dplyr::select(starts_with(fam)) %>%
dplyr::filter_at(vars(matches("_fnd")), all_vars(. == "0/0")) %>% # force F0 female to be homo, like her son
dplyr::filter_at(vars(matches("_son")), all_vars(. == "0/0")) %>%
dplyr::filter_at(vars(matches("_dat")), all_vars(. == "0/1")) %>%
dplyr::select(contains("grn")) %>%
tidyr::pivot_longer(everything()) %>%
dplyr::rename(sample = name, gt = value) %>%
dplyr::count(sample, gt, .drop = FALSE) %>%
dplyr::filter(gt %in% c("0/0", "1/1", "0/1")) %>%
mutate(n = as.numeric(n)) %>%
group_by(sample) %>%
mutate(total = as.numeric(sum(n))) %>%
mutate(sex = case_when(
grepl("son", sample) ~ "Male",
grepl("dat", sample) ~ "Female"))
}
# bind all families together, to a final data frame containing all observed counts
observed <- do.call("rbind", obs) %>% mutate(sample = as.character(sample))
samples <- data.frame(sample = rep(unique(observed$sample), each =3), gt = rep(c("0/0", "0/1", "1/1")))
# define the group of abnormal males
abnorm_males = tibble(sample = c( "400_401a_grnson","412_413a_grnson", "426_427b_grnson", "458_459a_grnson", "46_47d_grnson"), sex = "Male", normality = "abnormal")
samples_obs <- left_join(samples, observed, by=c("sample","gt")) %>% mutate(sex = case_when(
grepl("son", sample) ~ "Male",
grepl("dat", sample) ~ "Female")) %>%
group_by(sample) %>%
replace(is.na(.), 0) %>%
mutate(total = as.numeric(sum(n))) %>%
dplyr::mutate(prop = n/total) %>%
left_join(abnorm_males, by = "sample") %>%
dplyr::select(-sex.y) %>%
replace(is.na(.), "normal") %>%
dplyr::rename(sex = sex.x) %>%
unite("type", sex,normality, remove = FALSE)
# make a table with the expected proportions for the different modes of reproduction:
Haploid = data.frame(mode = "Haploid", gt = c("0/0", "0/1", "1/1"),prop = c(0.5, 0, 0.5))
Automixis = data.frame(mode = "Automixis", gt = c("0/0", "0/1", "1/1"),prop = c(0, 1, 0))
Sexual = data.frame(mode = "Sexual",gt = c("0/0", "0/1", "1/1"),prop = c(0.5, 0.5, 0))
modes = rbind(Haploid,Automixis,Sexual)
Pooled sites
samples_obs_forPlot = samples_obs %>%
dplyr::filter(total>=10) %>%
mutate(class = "Observed") %>%
dplyr::filter(normality == "normal") %>%
select(c("sample","gt", "total", "sex","prop","class")) %>%
rename(type = sex)
modes_forPlot = modes %>%
mutate(class = "Expected") %>%
rename(type = mode)
pooled_obs_count = samples_obs %>%
dplyr::filter(total>=10) %>%
dplyr::filter(normality == "normal") %>%
filter(gt =="0/0") %>%
group_by(sex) %>%
mutate(sites = sum(total)) %>%
select(c(sex,sites)) %>%
unique()
pooled_obs_count
## # A tibble: 2 × 2
## # Groups: sex [2]
## sex sites
## <chr> <dbl>
## 1 Male 5747
## 2 Female 5243
df = rbind(samples_obs_forPlot, modes_forPlot)
plot
# (1)
# order the x axis text
df$type <- factor(df$type, level=c("Haploid" ,"Sexual","Automixis","Female","Male"))
# change the labales
my_strip_labels <- as_labeller(c(
"Expected" = "A. Expected proportions,
different inheritance modes",
"Observed" = "B. Observed proportions,
pooled sites"))
# (2) or reverse plot:
# order the x axis text
df$type <- factor(df$type, level=c("Female","Male","Sexual","Automixis", "Haploid"))
df$class <- factor(df$class, level=c("Observed","Expected"))
# change the labales
my_strip_labels <- as_labeller(c(
"Observed" = "A. Observed proportions,
pooled sites",
"Expected" = "B. Expected proportions,
hypothesized inheritance modes"))
df %>% ggplot(aes(fill=gt, y=prop, x=type)) +
geom_bar(position="fill", stat="identity", ) +
ylab("Genotype proportion") +
# labs(title = "Offspring genotype, crossing (0/0) male x (0/1) female") +
labs(fill = "Genotype") +
theme_classic() +
theme(axis.title.x = element_blank(),
axis.text.x = element_text(size=12),
axis.text.y = element_text(size=12),
strip.text.x = element_text(size = 12)) +
scale_fill_manual(values=c("#ffbf00", "#66b032","#1982c4"))+
scale_x_discrete(labels=c("Female" = "19 females
5,243 sites", "Male" = "14 males
5,747 sites",
"Haploid" = "Haploid
parthenogenesis",
"Sexual" = "Sexual
reproduction","Automixis" = "Diploid
parthenogenesis
(Automixis)")) + # change the x axis text to be more informative:
theme(legend.position = "right",
strip.text.x = element_text(angle = 0, hjust = 0)) +
facet_grid(.~class, scales = 'free',space = 'free',drop = F,
labeller = my_strip_labels) # add labels
Figure 3. Pedigree genomics
Crossing homozygotic male, with heterozygotic female (7) F1 male (0/1) x female (0/0) original Rmd: ~/Documents/GitHub/varroa-linkage-map/R_scripts/explore_vcf_F1_F2.Rmd
# define a list to put all the data frames in
obs <- list()
for (fam in family) {
obs[[fam]] <- table %>%
dplyr::select(starts_with(fam)) %>%
dplyr::filter_at(vars(matches("_fnd")), all_vars(. == "0/1")) %>% # force F0 female to be homo, like her son
dplyr::filter_at(vars(matches("_son")), all_vars(. == "0/1")) %>%
dplyr::filter_at(vars(matches("_dat")), all_vars(. == "0/0")) %>%
dplyr::select(contains("grn")) %>%
tidyr::pivot_longer(everything()) %>%
dplyr::rename(sample = name, gt = value) %>%
dplyr::count(sample, gt, .drop = FALSE) %>%
dplyr::filter(gt %in% c("0/0", "1/1", "0/1")) %>%
mutate(n = as.numeric(n)) %>%
group_by(sample) %>%
mutate(total = as.numeric(sum(n))) %>%
mutate(sex = case_when(
grepl("son", sample) ~ "Male",
grepl("dat", sample) ~ "Female"))
}
# bind all families together, to a final data frame containing all observed counts
observed <- do.call("rbind", obs) %>% mutate(sample = as.character(sample))
samples <- data.frame(sample = rep(unique(observed$sample), each =3), gt = rep(c("0/0", "0/1", "1/1")))
# define the group of abnormal males
abnorm_males = tibble(sample = c("240_241c_grnson", "400_401a_grnson","412_413a_grnson", "426_427b_grnson", "458_459a_grnson", "46_47d_grnson", "478_479-1a_grnson"), sex = "Male", normality = "abnormal")
samples_obs <- left_join(samples, observed, by=c("sample","gt")) %>% mutate(sex = case_when(
grepl("son", sample) ~ "Male",
grepl("dat", sample) ~ "Female")) %>%
group_by(sample) %>%
replace(is.na(.), 0) %>%
mutate(total = as.numeric(sum(n))) %>%
dplyr::mutate(prop = n/total) %>%
left_join(abnorm_males, by = "sample") %>%
dplyr::select(-sex.y) %>%
replace(is.na(.), "normal") %>%
dplyr::rename(sex = sex.x) %>%
unite("type", sex,normality, remove = FALSE)
# make a table with the expected proportions for the different modes of reproduction:
Haploid = data.frame(mode = "Haploid", gt = c("0/0", "0/1", "1/1"),prop = c(1, 0, 0))
Automixis = data.frame(mode = "Automixis", gt = c("0/0", "0/1", "1/1"),prop = c(1, 0, 0))
Sexual = data.frame(mode = "Sexual",gt = c("0/0", "0/1", "1/1"),prop = c(0.5, 0.5, 0))
modes = rbind(Haploid,Automixis,Sexual)
Pooled sites
samples_obs_forPlot = samples_obs %>%
dplyr::filter(total>=10) %>%
mutate(class = "Observed") %>%
dplyr::filter(normality == "normal") %>%
select(c("sample","gt", "total", "sex","prop","class")) %>%
rename(type = sex)
modes_forPlot = modes %>%
mutate(class = "Expected") %>%
rename(type = mode)
pooled_obs_count = samples_obs %>%
dplyr::filter(total>=10) %>%
dplyr::filter(normality == "normal") %>%
filter(gt =="0/0") %>%
group_by(sex) %>%
mutate(count = sum(total)) %>%
select(c(sex,count)) %>%
unique()
df = rbind(samples_obs_forPlot, modes_forPlot)
# order the x axis text
df$type <- factor(df$type, level=c("Haploid" ,"Sexual","Automixis","Female","Male"))
df$class <- factor(df$class, level=c("Observed","Expected"))
# change the labales
my_strip_labels <- as_labeller(c(
"Observed" = "A. Observed proportions,
pooled sites",
"Expected" = "B. Expected proportions,
hypothesized inheritance modes"))
df %>% ggplot(aes(fill=gt, y=prop, x=type)) +
geom_bar(position="fill", stat="identity", ) +
ylab("Genotype proportion") +
# labs(title = "Offspring genotype, crossing (0/0) male x (0/1) female") +
labs(fill = "Genotype") +
theme_classic() +
theme(axis.title.x = element_blank(),
axis.text.x = element_text(size=12),
axis.text.y = element_text(size=12),
strip.text.x = element_text(size = 12)) +
scale_fill_manual(values=c("#ffbf00", "#66b032","#1982c4"))+
scale_x_discrete(labels=c("Haploid" = "Haploid
parthenogenesis",
"Sexual" = "Sexual
reproduction","Automixis" = "Diploid
parthenogenesis
(Automixis)", "Female" = "19 females
2,811 sites", "Male" = "14 males
2,105 sites")) + # change the x axis text to be more informative:
theme(legend.position = "right",
strip.text.x = element_text(angle = 0, hjust = 0)) +
facet_grid(.~class, scales = 'free',space = 'free',drop = F,
labeller = my_strip_labels) # add labels
Figure 4A. Flow-cytometry
original Rmd: ~/Documents/GitHub/varroa_ploidy/R_scripts/varroa-ploidy.Rmd
data <- read.csv("/Users/nuriteliash/Documents/GitHub/varroa_ploidy/data/ploidy.csv") %>%
dplyr::mutate(Family = as.character(Family)) %>%
dplyr::mutate(stage_mature = case_when(
grepl("adult", Stage) ~ "Mature",
!grepl("adult", Stage) ~ "Imature"))
# change the labales
my_strip_labels <- as_labeller(c(
"Imature" = "Imature mites
n = 37",
"Mature" = "Mature mites
n = 38"))
# histogram plot:
p_ploidy_hist = data %>% dplyr::filter(body.part == "Body") %>%
ggplot(aes(x=Ploidy, color = Sex, fill = Sex)) +
geom_histogram(position="dodge") +
geom_density(alpha=.2) +
ylab("Count") +
theme_classic2() +
theme(legend.position = "none") +
ggtitle("Varroa mite ploidy count
Flow-cytometry") +
facet_grid(.~stage_mature, space = 'free',drop = F,
labeller = my_strip_labels) # add labels
# density plot:
p_ploidy_dens = data %>% dplyr::filter(body.part == "Body") %>%
ggplot(aes(x=Ploidy, color = Sex, fill = Sex)) +
# geom_histogram(position="dodge") +
geom_density(alpha=.2) +
ylab("Density") +
theme_classic2() +
theme(legend.position = "none") +
ggtitle("Varroa mite ploidy
Flow-cytometry") +
facet_grid(.~stage_mature, space = 'free',drop = F,
labeller = my_strip_labels) # add labels
#density plot with rug
p_ploidy_dens_rug = data %>% dplyr::filter(body.part == "Body") %>%
ggplot(aes(x=Ploidy, color = Sex, fill = Sex)) +
geom_density(alpha=.2) +
geom_rug(aes(x=Ploidy,color = Sex), alpha=0.9, size=1.5,length = unit(0.05, "npc"))+
ylab("Density") +
theme_classic2() +
theme(legend.position = "none") +
ggtitle("Varroa mite ploidy
Flow-cytometry") +
facet_grid(.~stage_mature, space = 'free',drop = F,
labeller = my_strip_labels) # add labels
Figure 4B. Karyotyping
original Rmd: ~/Documents/GitHub/varroa-karyotyping/varroa karyotyping.Rmd
dat <- read.csv("/Users/nuriteliash/Documents/GitHub/varroa-karyotyping/karyo_varroa.csv")
summary(dat)
## ID Sex stage cell_count
## Min. :30.00 Length:357 Length:357 Min. : 0.000
## 1st Qu.:63.00 Class :character Class :character 1st Qu.: 0.000
## Median :79.00 Mode :character Mode :character Median : 0.000
## Mean :70.29 Mean : 1.454
## 3rd Qu.:89.00 3rd Qu.: 2.000
## Max. :96.00 Max. :25.000
## cell_perc chromo_number
## Min. : 0.000 Min. : 4
## 1st Qu.: 0.000 1st Qu.: 9
## Median : 0.000 Median :14
## Mean : 4.762 Mean :14
## 3rd Qu.: 6.452 3rd Qu.:19
## Max. :58.824 Max. :24
# how many males and females?
mite_counts = tibble(males = n_distinct(filter(dat, Sex=="male")$ID),
females = n_distinct(filter(dat, Sex=="female")$ID))
mite_counts
## # A tibble: 1 × 2
## males females
## <int> <int>
## 1 8 9
dat_karyo = dat %>%
dplyr::mutate(chromo_number = as.numeric(chromo_number)) %>%
expandRows("cell_count", drop = FALSE) %>%
dplyr::mutate(Indx = row_number(cell_count)) %>%
group_by(ID) %>%
dplyr::mutate(median_count = median(chromo_number)) %>%
dplyr::mutate(stage_mature = "Imature mites
n = 17")
# change the labales
#my_strip_labels <- as_labeller("Imature" = "Imature mites
#n = 17")
p_kar_dens = dat_karyo %>%
ggplot(aes(x=chromo_number, color = Sex, fill = Sex)) +
# geom_histogram(position="dodge") +
geom_density(alpha=.2) +
ylab("Density") +
xlab("Chromosome count") +
theme_classic2() +
theme(legend.position = "none") +
ggtitle("Varroa mite chromosome count
Karyotyping") +
facet_grid(.~stage_mature, space = 'free',drop = F)
#density plot with rug
p_karyo_dens_rug = dat_karyo %>%
ggplot(aes(x=chromo_number, color = Sex, fill = Sex)) +
geom_rug(aes(x=chromo_number,color = Sex), alpha=0.9, size=1.5, length = unit(0.05, "npc"))+
geom_density(alpha=.2) +
ylab("Density") +
xlab("Chromosome count") +
theme_classic2() +
theme(legend.position = "none") +
ggtitle("Varroa mite chromosome count
Karyotyping") +
facet_grid(.~stage_mature, space = 'free',drop = F)
# or histogram:
p_karyo_hist = dat_karyo %>%
ggplot(aes(x=chromo_number, color = Sex, fill = Sex)) +
geom_density(alpha=.2) +
geom_histogram(position="dodge", binwidth = 1) +
ylab("Count") +
xlab("Chromosome count") +
theme_classic2() +
theme(legend.position = "none") +
ggtitle("Varroa mite chromosome count
Karyotyping")
old Karyotyping plot
plot Karyotyping and flow cytometry together
ggarrange(p_ploidy_dens, p_kar_dens, labels = c("A", "B"),
common.legend = TRUE, legend = "bottom")
ggarrange(p_ploidy_hist, p_karyo_hist, labels = c("A", "B"),
common.legend = TRUE, legend = "bottom")
ggarrange(p_ploidy_dens_rug, p_karyo_dens_rug, labels = c("A", "B"),
common.legend = TRUE, legend = "bottom", widths = c(1, 0.65))