--- title: "11-byssal_thread_by_sample" output: html_document date: "2024-12-12" --- ### Load libraries ```{r} library(tidyverse) library(ggplot2) library(readr) ``` ### Load in gene count matrix and gene loc/gene ID key ```{r} gene_count_matrix_clean <- read_csv("/home/shared/8TB_HDD_02/graceleuchtenberger/Github/byssus-exp-analysis/output/gene_count_matrix_clean.csv") loc_go_blast <- read_delim("/home/shared/8TB_HDD_02/graceleuchtenberger/Github/byssus-exp-analysis/output/LOC_GO_list.txt",delim = "\t") colnames(loc_go_blast)[colnames(loc_go_blast) == "gene"] ="loc_id" ``` ```{r} gene_count_matrix_clean <- gene_count_matrix_clean %>% mutate(loc_id = sub(".*\\|", "", ...1)) %>% # Extract part after the pipe select(loc_id, everything()) # View the updated data frame print(df) ``` ```{r} annot_GCM <- left_join(gene_count_matrix_clean, loc_go_blast[,c("loc_id", "Protein.names", "uniprot_accession.y", "Gene.Names", "Organism")], by= "loc_id") annot_GCM <- annot_GCM %>% select(loc_id, Protein.names, uniprot_accession.y, Gene.Names, Organism, everything()) ``` ```{r} foot_GCM <- annot_GCM %>% filter(grepl("foot", Protein.names, ignore.case = TRUE)) byss_GCM <- annot_GCM %>% filter(grepl("byss", Protein.names, ignore.case = TRUE)) foot_GCM <- foot_GCM %>% distinct(uniprot_accession.y, .keep_all = TRUE) byss_GCM <- byss_GCM %>% distinct(uniprot_accession.y, .keep_all = TRUE) foot_byss_GCM <- rbind(foot_GCM, byss_GCM) write.csv(foot_byss_GCM , file = "/home/shared/8TB_HDD_02/graceleuchtenberger/Github/byssus-exp-analysis/output/foot_byss_GCM.csv") ``` ```{r} foot_GCM_1 <- foot_byss_GCM %>% pivot_longer(!1:6, names_to = "sample", values_to = "count") colnames(treatmentinfo.2)[colnames(treatmentinfo.2) == "sample.1"] ="sample" foot_byss_GCM_2 <- left_join(foot_GCM_1, treatmentinfo.2, by = "sample") write.csv(foot_byss_GCM_2, file = "/home/shared/8TB_HDD_02/graceleuchtenberger/Github/byssus-exp-analysis/output/foot_byss_GCM.csv") ``` ```{r} foot_byss_GCM_2 <- read_csv("/home/shared/8TB_HDD_02/graceleuchtenberger/Github/byssus-exp-analysis/output/foot_byss_GCM.csv") ``` ```{r} foot_byss_gene_plot <- foot_byss_GCM_2 %>% filter(tissue == "F") %>% ggplot(aes(x=Protein.names, y=log(count), fill=treatment))+ geom_boxplot()+ theme_classic()+ theme(axis.text.x = element_text(angle = 45, hjust = 1))+ theme(plot.margin = unit(c(0.5, 0.5, 0.5, 1), "inches")) foot_byss_gene_plot ggsave(foot_byss_gene_plot, file = "output/foot_byss_gene_plot.pdf") ``` ```{r} gill_byss_gene_plot<- foot_byss_GCM_2 %>% filter(tissue == "G") %>% ggplot(aes(x=Protein.names, y=log(count), fill=treatment))+ geom_boxplot()+ theme_classic()+ theme(axis.text.x = element_text(angle = 45, hjust = 1))+ theme(plot.margin = unit(c(0.5, 0.5, 0.5, 1), "inches"))+ ylim(1,10) gill_byss_gene_plot ggsave(gill_byss_gene_plot, file = "output/gill_byss_gene_plot.pdf") ```