-
Notifications
You must be signed in to change notification settings - Fork 2
/
Plot_SampSizeByLocus.GCL.R
44 lines (36 loc) · 1.85 KB
/
Plot_SampSizeByLocus.GCL.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
plot_SampSizeByLocus <- function(SampSizeByLocus){
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This function takes the output from SampSizeByLocus.GCL() and creates a plotly heatmap of the proportion of fish with scores for each locus and silly
#
# Inputs~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# SampSizeByLocus - a tibble of sample sizes by locus produced by SampSizeByLocus.GCL().
#
# Outputs~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# A plotly heatmap of the proportion of fish with scores for each locus and silly
#
# Examples~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# CreateLocusControl.GCL(markersuite = "Sockeye2011_96SNPs", username = "awbarclay", password = password)
# sillyvec = c("SMCDO03", "SNEVA13")
# password = "************"
# LOKI2R.GCL(sillyvec = sillyvec, username = "awbarclay", password = password)
# RemoveIndMissLoci.GCL(sillyvec = sillyvec)
#
# Output <- SampSizeByLocus.GCL(sillyvec = sillyvec, loci = LocusControl$locusnames)
# plot_SampSizeByLocus(SampSizeByLocus = Output)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(!require("pacman")) install.packages("pacman"); library(pacman); pacman::p_load(tidyverse, plotly) # Install packages, if not in library and then load them.
sillyvec <- SampSizeByLocus$silly
silly_n <- silly_n.GCL(sillyvec)
plotly::ggplotly(
SampSizeByLocus %>%
tidyr::pivot_longer(-silly, names_to = "locus", values_to = "count") %>%
dplyr::full_join(silly_n, by = "silly") %>%
dplyr::mutate(proportion = count/n) %>%
ggplot2::ggplot(aes(x = silly, y = locus, fill = proportion))+
ggplot2::geom_tile() +
ggplot2::scale_fill_gradient(low = "white", high = "blue4", limits = c(0, 1)) +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90))
)
}