ALT_geno <- read.delim(file = c("/efs/home/p418100/Stevia/Xu_real_Allele_calls_raw.hmp.csv"), sep = ",") %>%
clean_names(case = "parsed") # Reading in and cleaning names
ALT_geno$chrom <- as.character(ALT_geno$chrom) # reassigning variable class
ALT_pheno <- read.delim(file = c("/efs/home/p418100/Stevia/24FE_STV_Storage.csv"), sep = ",") %>%
clean_names(case = "parsed") %>%
rename(taxa = Research_ID) %>%
filter(Date %in% "25-Apr-24") %>%
dplyr::select(Alt_1_10, taxa) %>%
mutate(taxa = case_when(str_detect(str_sub(taxa, 1, 1), "2") ~ str_c("X", taxa),
str_detect(str_sub(taxa, 1, 1), "1") ~ str_c("X", taxa),
T ~ taxa)) %>%
mutate(taxa = str_replace_all(taxa, "-", "_")) %>%
mutate(taxa = str_replace_all(taxa, "STVRadScrn", "STV_Rad_Scrn")) %>%
mutate(taxa = str_replace_all(taxa, "STVScrn", "STV_Scrn")) %>%
dplyr::filter(!is.na(Alt_1_10)) %>%
distinct() # pushing some NLP onto taxa names. Only renaming subjects starting with a number value.
ALT_pheno$Alt_1_10 <- as.numeric(ALT_pheno$Alt_1_10) # reclassifying variable
ALT_pheno <- ALT_pheno %>%
filter(!is.na(Alt_1_10)) %>%
reframe(Alt_1_10 = mean(Alt_1_10),
.by = c(taxa)) %>%
mutate(taxa = case_when(str_detect(str_sub(taxa, 1, 1), "2") ~ str_c("X", taxa),
str_detect(str_sub(taxa, 1, 1), "1") ~ str_c("X", taxa),
T ~ taxa)) %>%
mutate(taxa = str_replace_all(taxa, "-", "_")) %>%
mutate(taxa = str_replace_all(taxa, "STVRadScrn", "STV_Rad_Scrn")) %>%
mutate(taxa = str_replace_all(taxa, "STVScrn", "STV_Scrn")) %>%
dplyr::filter(!is.na(Alt_1_10)) %>%
distinct() # NLP on names and summarizing replicates.
# ALT_pheno <-
# bind_rows(
# dplyr::filter(ALT_pheno, taxa %in% ALT_gbs_entries$taxa) %>%
# filter(Alt_1_10 == 1) %>%
# slice_sample(prop = .25) %>% # slicing the filter
# distinct()
# , #bind_rows to phenotype set minus the filterd and sliced subset.
# dplyr::filter(ALT_pheno, taxa %in% ALT_gbs_entries$taxa) %>%
# filter(!Alt_1_10 == 1) %>% #make sure this matches the phenotype filtered and sliced.
# distinct()
# )
ALT_gbs_entries <- ALT_geno[,12:ncol(ALT_geno)] %>%
colnames() %>% as.data.frame() %>% rename(taxa = ".") %>% unique() #list of entries in the GBS file
ALT_geno <- ALT_geno %>%
dplyr::select(c(rs, alleles, chrom, pos, strand, assembly, center, prot_LSID, assay_LSID, panel_LSID, Q_Ccode, contains(ALT_pheno$taxa))) # trimming the GBS file for only those lines with phenotype data
ALT_pheno <- ALT_pheno %>%
dplyr::filter(taxa %in% colnames(ALT_geno[,12:length(ALT_geno)])) # trimming the GBS file for only those lines with phenotype data
ALT_pheno <- ALT_pheno %>%
mutate(Family = str_sub(taxa, start = 1, end = -6))
ALT_pheno %>% group_by()
## # A tibble: 468 × 3
## taxa Alt_1_10 Family
## <chr> <dbl> <chr>
## 1 SCO_1929 4 SCO
## 2 SCO_1973 3 SCO
## 3 SCO_1994 2 SCO
## 4 SCO_2087 4 SCO
## 5 SCO_2101 2 SCO
## 6 SCO_2103_017 3 SCO_210
## 7 SCO_2104_005 3 SCO_210
## 8 SCO_2104_007 2 SCO_210
## 9 SCO_2111_019 1 SCO_211
## 10 SCO_2119_011 4 SCO_211
## # ℹ 458 more rows
#Phenotype Exploration
#scaled stevia FT data
ALT_pheno_scaled <- ALT_pheno %>%
dplyr::filter(!is.na(Alt_1_10)) %>%
mutate(Alt_1_10 = as.numeric(scale(Alt_1_10)))
#Log transformed
ALT_pheno_log <- ALT_pheno %>%
dplyr::filter(!is.na(Alt_1_10)) %>%
mutate(Alt_1_10 = log(Alt_1_10))
ALT_pheno_log2 <- ALT_pheno %>%
dplyr::filter(!is.na(Alt_1_10)) %>%
mutate(Alt_1_10 = log2(Alt_1_10))
ALT_pheno_log10 <- ALT_pheno %>%
dplyr::filter(!is.na(Alt_1_10)) %>%
mutate(Alt_1_10 = log10(Alt_1_10))
hist(ALT_pheno$Alt_1_10)
shapiro.test(ALT_pheno$Alt_1_10)
##
## Shapiro-Wilk normality test
##
## data: ALT_pheno$Alt_1_10
## W = 0.89286, p-value < 2.2e-16
hist(ALT_pheno_scaled$Alt_1_10)
shapiro.test(ALT_pheno_scaled$Alt_1_10)
##
## Shapiro-Wilk normality test
##
## data: ALT_pheno_scaled$Alt_1_10
## W = 0.89286, p-value < 2.2e-16
hist(ALT_pheno_log$Alt_1_10)
shapiro.test(ALT_pheno_log$Alt_1_10)
##
## Shapiro-Wilk normality test
##
## data: ALT_pheno_log$Alt_1_10
## W = 0.90734, p-value = 2.736e-16
hist(ALT_pheno_log2$Alt_1_10)
shapiro.test(ALT_pheno_log2$Alt_1_10)
##
## Shapiro-Wilk normality test
##
## data: ALT_pheno_log2$Alt_1_10
## W = 0.90734, p-value = 2.736e-16
hist(ALT_pheno_log10$Alt_1_10)
shapiro.test(ALT_pheno_log10$Alt_1_10)
##
## Shapiro-Wilk normality test
##
## data: ALT_pheno_log10$Alt_1_10
## W = 0.90734, p-value = 2.736e-16
ALT_pheno %>%
ggplot(aes(strtrim(taxa, 5 ), Alt_1_10, fill = strtrim(taxa, 5))) +
geom_col() +
scale_fill_manual(values = cargill_pallet) +
theme_minimal()
ALT_pheno %>%
ggplot(aes(Alt_1_10, fill = strtrim(taxa, 5))) +
geom_bar() +
scale_fill_manual(values = cargill_pallet) +
theme_minimal() +
theme(legend.position = "right")
ALT_pheno %>%
group_by(Family) %>%
summarise(avg_Alt = round(mean(Alt_1_10, na.rm = T), 2),
sd_avg_Alt = round(sd(Alt_1_10, na.rm = T), 2),
var_avg_Alt = round(var(Alt_1_10, na.rm = T), 2),
n = n()) %>%
ggplot(aes(reorder(str_remove(Family, "X"), -avg_Alt), avg_Alt)) +
geom_bar(stat = "identity", aes(fill = Family), show.legend = F) +
geom_errorbar(aes(ymin=avg_Alt-sd_avg_Alt, ymax=avg_Alt+sd_avg_Alt), width=.2, position = position_dodge(.9)) +
scale_fill_manual(values=cargill_pallet) +
ggtitle("Alt by Family") +
theme_minimal() +
theme(axis.text.x = element_text(size = 7, angle=90)) +
xlab("Famliy")
# If the p value is less than the chosen alpha level 0.05, then the null hypothesis is rejected and there is evidence that the data tested are not normally distributed.
# file processing. Saving the parsed genotype and phenotype file for GAPIT ingestion.
write_delim(ALT_pheno, file = "/efs/home/p418100/Stevia/Stevia_ALT_pheno.txt", delim = "\t")
write_delim(ALT_geno, file = "/efs/home/p418100/Stevia/Stevia_hmp.txt", delim = "\t")
myY <- read.table(file = "/efs/home/p418100/Stevia/Stevia_ALT_pheno.txt", header = T, sep = "\t")
myG <- read.table(file = "/efs/home/p418100/Stevia/Stevia_hmp.txt", header = F, sep = "\t")
# myY <- read.table(file = "~/Husker/GAPIT_Tutorial_Data/mdp_traits.txt")
# myG <- read.table(file = "~/Husker/GAPIT_Tutorial_Data/mdp_genotype_test.hmp.txt", header = F)
# detach("package:plotly", unload=TRUE) # if plolty is loaded before GAPIT, GAPIT produces an incompatibility error about finding a plot element "p". needs to be detached first.
# source("~/Husker/GAPIT.library.R")
# source("~/Husker/gapit_functions.txt")
#
# GAPIT(Y = myY[,c(1,2)],
# G = myG,
# PCA.total = 3,
# # SNP.MAF = 0.123,
# Multiple_analysis = T,
# model = c("GLM", "MLM", "CMLM", "SUPER", "MLMM", "BLINK", "FarmCPU"),
# Random.model = F,
# kinship.cluster = "centroid"
# )
library(plotly)
stevia_pca <- read_csv(file = "~/Stevia/GAPIT.Genotype.PCA.csv") # reading in PCA from GAPIT
## Rows: 469 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): taxa
## dbl (3): PC1, PC2, PC3
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
stevia_clusters <- kmeans(stevia_pca[2:4], centers = 6)$cluster %>% as.factor() # Kmeans on PCAs
ALT_pca_pheno <- dplyr::select(left_join(stevia_pca, ALT_pheno, by = c("taxa")), taxa, PC1, PC2, PC3, Alt_1_10) %>%
bind_cols(cluster = stevia_clusters) # creating a data table with pheno PCAs and clusters
plotly::plot_ly(ALT_pca_pheno,
x = ALT_pca_pheno$PC1 ,
y = ALT_pca_pheno$PC2,
z = ALT_pca_pheno$PC3,
opacity = .8,
text = ALT_pca_pheno$taxa,
mode = "markers",
color = ALT_pca_pheno$cluster,
colors = cargill_pallet[c(1:10)],
marker = list(size = 11)) %>%
plotly::add_markers() %>%
plotly::layout(scene = list(xaxis = list(title = 'PC1'),
yaxis = list(title = 'PC2'),
zaxis = list(title = 'PC3')),
title = "stevia_pca") # 3D plot of PCA and clusters
plotly::plot_ly(ALT_pca_pheno,
x = ALT_pca_pheno$PC1 ,
y = ALT_pca_pheno$PC2,
z = ALT_pca_pheno$PC3,
opacity = .8,
text = ALT_pca_pheno$taxa,
mode = "markers",
color = ALT_pca_pheno$Alt_1_10,
colors = cargill_pallet[c(1:10)],
marker = list(size = 11)) %>%
plotly::add_markers() %>%
plotly::layout(scene = list(xaxis = list(title = 'PC1'),
yaxis = list(title = 'PC2'),
zaxis = list(title = 'PC3')),
title = "stevia_pca") # 3D plot of PCA and clusters
ALT_pca_pheno %>%
ggplot(aes(Alt_1_10, fill = cluster)) +
geom_bar(position = "fill") +
scale_fill_manual(values=cargill_pallet) +
ggtitle("Alt by K-Cluster") +
theme_minimal() +
theme(axis.text.x = element_text(size = 7, angle=0))
## Warning: Removed 1 rows containing non-finite values (`stat_count()`).
ALT_pca_pheno %>%
ggplot(aes(Alt_1_10, fill = cluster)) +
geom_bar() +
scale_fill_manual(values=cargill_pallet) +
ggtitle("Alt by K-Cluster") +
theme_minimal() +
theme(axis.text.x = element_text(size = 7, angle=0))
## Warning: Removed 1 rows containing non-finite values (`stat_count()`).
ALT_pca_pheno_reduced <- ALT_pca_pheno %>%
filter(!between(Alt_1_10, 2, 4))
ALT_pca_geno_reduced <- ALT_geno %>%
dplyr::select(c(rs, alleles, chrom, pos, strand, assembly, center, prot_LSID, assay_LSID, panel_LSID, Q_Ccode, contains(ALT_pca_pheno_reduced$taxa))) # trimming the GBS file for only those lines with phenotype data
# file processing. Saving the parsed genotype and phenotype file for GAPIT ingestion.
# write_delim(ALT_pca_pheno_reduced, file = "/efs/home/p418100/Stevia/Stevia_ALT_pheno_pca.txt", delim = "\t")
# write_delim(ALT_pca_geno_reduced, file = "/efs/home/p418100/Stevia/Stevia_hmp_reduced.txt", delim = "\t")
#
# myY_r <- read.table(file = "/efs/home/p418100/Stevia/Stevia_ALT_pheno_pca.txt", header = T, sep = "\t")
# myG_r <- read.table(file = "/efs/home/p418100/Stevia/Stevia_hmp_reduced.txt", header = F, sep = "\t")
#
# source("~/Husker/GAPIT.library.R")
# source("~/Husker/gapit_functions.txt")
#
# GAPIT(Y = myY_r[,c(1,5)],
# G = myG_r,
# PCA.total = 3,
# SNP.MAF = 0.123,
# Multiple_analysis = T,
# model = c("GLM", "MLM", "CMLM", "SUPER", "MLMM", "BLINK", "FarmCPU"),
# Random.model = F,
# kinship.cluster = "centroid"
# )
stevia_sig_markers <- read_csv(file = "~/Stevia/GAPIT.Association.Filter_GWAS_results.csv")
## New names:
## Rows: 19 Columns: 7
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (2): SNP, traits dbl (5): ...1, Chr, Pos, P.value, MAF
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
stevia_BLINK_effs_markers <- read_csv(file = "~/Stevia/GAPIT.Association.GWAS_Results.BLINK.Alt_1_10.csv")
## Rows: 6289 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): SNP
## dbl (7): Chr, Pos, P.value, MAF, nobs, H&B.P.Value, Effect
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
stevia_MLMM_effs_markers <- read_csv(file = "~/Stevia/GAPIT.Association.GWAS_Results.MLMM.Alt_1_10.csv")
## Rows: 6289 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): SNP
## dbl (7): Chr, Pos, P.value, MAF, nobs, H&B.P.Value, Effect
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
stevia_FarmCPU_effs_markers <- read_csv(file = "~/Stevia/GAPIT.Association.GWAS_Results.FarmCPU.Alt_1_10.csv")
## Rows: 6289 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): SNP
## dbl (7): Chr, Pos, P.value, MAF, nobs, H&B.P.Value, Effect
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
stevia_CMLM_effs_markers <- read_csv(file = "~/Stevia/GAPIT.Association.GWAS_Results.CMLM.Alt_1_10.csv")
## Rows: 6289 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): SNP
## dbl (7): Chr, Pos, P.value, MAF, nobs, H&B.P.Value, Effect
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
stevia_GLM_effs_markers <- read_csv(file = "~/Stevia/GAPIT.Association.GWAS_Results.GLM.Alt_1_10.csv")
## Rows: 6289 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): SNP
## dbl (7): Chr, Pos, P.value, MAF, nobs, H&B.P.Value, Effect
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
stevia_MLM_effs_markers <- read_csv(file = "~/Stevia/GAPIT.Association.GWAS_Results.MLM.Alt_1_10.csv")
## Rows: 6289 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): SNP
## dbl (7): Chr, Pos, P.value, MAF, nobs, H&B.P.Value, Effect
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
stevia_SUPER_effs_markers <- read_csv(file = "~/Stevia/GAPIT.Association.GWAS_Results.SUPER.Alt_1_10.csv")
## Rows: 6289 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): SNP
## dbl (6): Chr, Pos, P.value, MAF, nobs, H&B.P.Value
## lgl (1): Effect
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#pulling in all the model SNP predictions
stevia_effs_markers <- bind_rows(stevia_MLMM_effs_markers,
stevia_FarmCPU_effs_markers,
stevia_BLINK_effs_markers,
stevia_CMLM_effs_markers,
stevia_GLM_effs_markers,
stevia_MLM_effs_markers,
stevia_SUPER_effs_markers,
.id = "traits")
stevia_effs_markers$traits <- str_replace_all(stevia_effs_markers$traits, "1", "MLMM.Alt_1_10")
stevia_effs_markers$traits <- str_replace_all(stevia_effs_markers$traits, "2", "FarmCPU.Alt_1_10")
stevia_effs_markers$traits <- str_replace_all(stevia_effs_markers$traits, "3", "BLINK.Alt_1_10")
stevia_effs_markers$traits <- str_replace_all(stevia_effs_markers$traits, "4", "CMLM.Alt_1_10")
stevia_effs_markers$traits <- str_replace_all(stevia_effs_markers$traits, "5", "GLM.Alt_1_10")
stevia_effs_markers$traits <- str_replace_all(stevia_effs_markers$traits, "6", "MLM.Alt_1_10")
stevia_effs_markers$traits <- str_replace_all(stevia_effs_markers$traits, "7", "SUPER.Alt_1_10")# creating a common data frame for sig snps
stevia_sig_markers <- stevia_sig_markers %>%
left_join(dplyr::select(stevia_effs_markers, SNP, traits, Effect), by = c("SNP", "traits")) # Joining the effect results from model predictions to marker datatable
write_csv(stevia_sig_markers, file = "~/Stevia/Stevia_Alt_1_10_sig_marker_effects_pac240111.csv" )
snps <- dplyr::select(stevia_sig_markers, SNP) %>%
distinct() # list of sig markers to filter with
ALT_geno_sig_snps <- dplyr::filter(ALT_geno, rs %in% snps$SNP) %>%
dplyr::select(rs, SCO_1929:X21SE_STV_Rad_Scrn_0015_0474) %>%
t() %>%
row_to_names(1) %>%
as.data.frame() %>%
rownames_to_column(var = "taxa") # transposing allele calls to join pheno data tables
ALT_pca_pheno_snps <- ALT_pca_pheno %>%
left_join(ALT_geno_sig_snps, by = "taxa") %>%
pivot_longer(cols = contains("Xu"), names_to = "sig_snps", values_to = "allele") # summary data table with pheno and allele calls for sig markers.
ALT_results <- ALT_pca_pheno %>%
left_join(ALT_geno_sig_snps, by = "taxa") %>% write_csv(file = "~/Stevia/Stevia_ALT_results_pac240112.csv" )
stevia_sig_markers %>% reframe(sum_marker_effect = sum(abs(Effect)), .by = traits) # absolute summed marker effects
## # A tibble: 4 × 2
## traits sum_marker_effect
## <chr> <dbl>
## 1 GLM.Alt_1_10 5.03
## 2 SUPER.Alt_1_10 NA
## 3 BLINK.Alt_1_10 0.765
## 4 FarmCPU.Alt_1_10 2.17
plotly::ggplotly(ALT_pca_pheno_snps %>%
# filter(sig_snps %in% "2_120512813_Xu") %>%
# filter(!allele %in% "N") %>%
# filter(!sig_snps %in% "6_89505513_Xu") %>%
ggplot(aes(x = Alt_1_10)) +
geom_histogram(stat = "bin", binwidt = 1, show.legend = T, aes(fill = allele)) + #
ggtitle("Histogram of Native Alternaria for "
) +
scale_fill_manual(values = cargill_pallet) +
# facet_wrap(. ~ sig_snps, ncol = 6) +
theme_minimal()
)
## Warning in geom_histogram(stat = "bin", binwidt = 1, show.legend = T, aes(fill
## = allele)): Ignoring unknown parameters: `binwidt`
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 11 rows containing non-finite values (`stat_bin()`).
ggplotly(ALT_pca_pheno_snps %>%
mutate(allele = case_when(allele %in% "K" ~ "Het",
allele %in% "R" ~ "Het",
allele %in% "Y" ~ "Het",
allele %in% "W" ~ "Het",
allele %in% "M" ~ "Het",
T ~ allele)) %>%
# filter(sig_snps %in% "2_171427417_Xu") %>%
# filter(!allele %in% "N") %>%
# filter(sig_snps %in% "2_129546534_Xu") %>%
ggplot(aes(x = Alt_1_10)) +
geom_histogram(stat = "bin", binwidth = 1, bins = 15, show.legend = F, aes(fill = allele)) + #
ggtitle("Histogram of Average Native Alternaria Infection") +
scale_fill_manual(values = cargill_pallet) +
facet_wrap(. ~ sig_snps, ncol = 4) +
theme_minimal() +
theme(legend.position="right") )
## Warning: Removed 11 rows containing non-finite values (`stat_bin()`).
ggplotly(ALT_pca_pheno_snps %>%
mutate(allele = case_when(allele %in% "K" ~ "Het",
allele %in% "R" ~ "Het",
allele %in% "Y" ~ "Het",
allele %in% "W" ~ "Het",
allele %in% "M" ~ "Het",
T ~ allele)) %>%
# filter(sig_snps %in% "2_171427417_Xu") %>%
# filter(!allele %in% "N") %>%
# filter(sig_snps %in% "2_129546534_Xu") %>%
ggplot(aes(x = Alt_1_10)) +
geom_bar(position = "fill", show.legend = F, aes(fill = allele)) + #
ggtitle("Histogram of Average Native Alternaria Infection") +
scale_fill_manual(values = cargill_pallet) +
facet_wrap(. ~ sig_snps, ncol = 4) +
theme_minimal() +
theme(legend.position="right") )
## Warning: Removed 11 rows containing non-finite values (`stat_count()`).
ALT_pca_pheno_snps %>%
mutate(allele = case_when(allele %in% "K" ~ "Het",
allele %in% "R" ~ "Het",
allele %in% "Y" ~ "Het",
allele %in% "W" ~ "Het",
T ~ allele)) %>%
filter(!allele %in% "N") %>%
filter(!allele %in% "H") %>%
ggplot(aes(x = allele, y = Alt_1_10)) +
geom_boxplot(aes(fill = allele)) +
scale_fill_manual(values = cargill_pallet) +
facet_wrap(. ~ sig_snps, ncol = 3) +
theme_linedraw()
## Warning: Removed 11 rows containing non-finite values (`stat_boxplot()`).
ALT_pheno %>%
group_by(taxa) %>%
summarise(avg_Alt = round(mean(Alt_1_10, na.rm = T), 2),
sd_avg_Alt = round(sd(Alt_1_10, na.rm = T), 2),
var_avg_Alt = round(var(Alt_1_10, na.rm = T), 2),
n = n()) %>%
left_join(ALT_geno_sig_snps) %>%
filter(!`2_129546534_Xu` %in% "N") %>%
filter(!`2_129546534_Xu` %in% "R") %>%
ggplot(aes(reorder(str_remove(taxa, "X"), -avg_Alt), avg_Alt)) +
geom_bar(stat = "identity", aes(fill = `2_129546534_Xu`), show.legend = T) +
geom_errorbar(aes(ymin=avg_Alt-sd_avg_Alt, ymax=avg_Alt+sd_avg_Alt), width=.2, position = position_dodge(.9)) +
scale_fill_manual(values=cargill_pallet[c(1,7, 9, 11)]) +
ggtitle("Alt by taxa") +
theme_minimal() +
theme(axis.text.x = element_text(size = 5, angle=90), legend.position = "right") +
xlab("taxa")
## Joining with `by = join_by(taxa)`
# ALT_pheno %>%
# group_by(taxa) %>%
# summarise(avg_Alt = round(mean(Alt_1_10, na.rm = T), 2),
# sd_avg_Alt = round(sd(Alt_1_10, na.rm = T), 2),
# var_avg_Alt = round(var(Alt_1_10, na.rm = T), 2),
# n = n()) %>%
# left_join(ALT_geno_sig_snps) %>%
# filter(!`6_35400748_Xu` %in% "N") %>%
# filter(!`6_35400748_Xu` %in% "W") %>%
# ggplot(aes(reorder(str_remove(taxa, "X"), -avg_Alt), avg_Alt)) +
# geom_bar(stat = "identity", aes(fill = `6_35400748_Xu`), show.legend = T) +
# geom_errorbar(aes(ymin=avg_Alt-sd_avg_Alt, ymax=avg_Alt+sd_avg_Alt), width=.2, position = position_dodge(.9)) +
# scale_fill_manual(values=cargill_pallet[c(1,5)]) +
# ggtitle("Alt by taxa") +
# theme_minimal() +
# theme(axis.text.x = element_text(size = 5, angle=90), legend.position = "right") +
# xlab("taxa")
ALT_pca_pheno %>%
left_join(ALT_geno_sig_snps) %>%
plotly::plot_ly(.,
x = .$PC1 ,
y = .$PC2,
z = .$PC3,
opacity = .8,
text = .$taxa,
mode = "markers",
color = .$`2_120512813_Xu`,
colors = cargill_pallet[c(1:10)],
marker = list(size = 11)) %>%
plotly::add_markers() %>%
plotly::layout(scene = list(xaxis = list(title = 'PC1'),
yaxis = list(title = 'PC2'),
zaxis = list(title = 'PC3')),
title = "stevia_pca") # 3D plot of PCA and clusters
## Joining with `by = join_by(taxa)`
## Warning: Unknown or uninitialised column: `2_120512813_Xu`.