Load libraries

list.of.packages <- c("tidyverse") #add new libraries here 
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)

# Load all libraries 
lapply(list.of.packages, FUN = function(X) {
  do.call("require", list(X)) 
})
sessionInfo()

Where are differentially methylated loci located?

DML <- read_delim(here::here("analyses","20191120-DML-annotated.txt"), delim = '\t', 
                        col_names = c("contig.dml", "start.dml", "end.dml", "score.dml", "unknown", "contig.feat", "source", "feature", "start.feat", "end.feat", "score.feat", "strand", "frame", "attribute")) %>% as_tibble() %>% 
  mutate(ID=str_extract(attribute, "ID=(.*?);"), 
         Parent=str_extract(attribute, "Parent=(.*?);"),
         Name=str_extract(attribute, "Name=(.*?);"),
         Alias=str_extract(attribute, "Alias=(.*?);"),
         AED=str_extract(attribute, "AED=(.*?);"),
         eAED=str_extract(attribute, "eAED=(.*?);"),
         Note=str_extract(attribute, "Note=(.*?);"),
         Ontology_term=str_extract(attribute, "Ontology_term=(.*?);"),
         Dbxref=str_extract(attribute, "Dbxref=(.*?);"),
         ) %>%
  mutate_at("feature", as.factor)
## Parsed with column specification:
## cols(
##   contig.dml = col_character(),
##   start.dml = col_double(),
##   end.dml = col_double(),
##   score.dml = col_double(),
##   unknown = col_double(),
##   contig.feat = col_character(),
##   source = col_character(),
##   feature = col_character(),
##   start.feat = col_double(),
##   end.feat = col_double(),
##   score.feat = col_character(),
##   strand = col_character(),
##   frame = col_character(),
##   attribute = col_character()
## )
## Warning: 3 parsing failures.
## row col   expected    actual                                                                                         file
##   9  -- 14 columns 8 columns '/Users/laura/Documents/roberts-lab/paper-oly-mbdbs-gen/analyses/20191120-DML-annotated.txt'
##  10  -- 14 columns 8 columns '/Users/laura/Documents/roberts-lab/paper-oly-mbdbs-gen/analyses/20191120-DML-annotated.txt'
##  13  -- 14 columns 8 columns '/Users/laura/Documents/roberts-lab/paper-oly-mbdbs-gen/analyses/20191120-DML-annotated.txt'
par(mar=c(2,4,4,2))
barplot(table(DML$feature)[c("CDS", "exon", "gene", "mRNA", "3'UTR")], 
        main="Locations of DMLs between Hood Canal and South Sound Olys\n(10x cov. in any smpl)", 
        ylab="No. of loci", cex.main=1, cex.axis = .8)

Where are loci located where methylation is associated with oyster shell length?

Loci with 10x coverage across all samples

macau.all <- read_delim(here::here("analyses","macau","20191120-MACAU-10xall-features.txt"), delim = '\t', 
                        col_names = c("contig.locus", "start.locus", "end.locus", "unknown.column", "contig.feat", "source", "feature", "start.feat", "end.feat", "score", "strand", "frame", "attribute")) %>% as_tibble() %>%
  mutate(ID=str_extract(attribute, "ID=(.*?);"), 
         Parent=str_extract(attribute, "Parent=(.*?);"),
         Name=str_extract(attribute, "Name=(.*?);"),
         Alias=str_extract(attribute, "Alias=(.*?);"),
         AED=str_extract(attribute, "AED=(.*?);"),
         eAED=str_extract(attribute, "eAED=(.*?);"),
         Note=str_extract(attribute, "Note=(.*?);"),
         Ontology_term=str_extract(attribute, "Ontology_term=(.*?);"),
         Dbxref=str_extract(attribute, "Dbxref=(.*?);")) %>%
  mutate_at("feature", as.factor)
## Parsed with column specification:
## cols(
##   contig.locus = col_character(),
##   start.locus = col_double(),
##   end.locus = col_double(),
##   unknown.column = col_double(),
##   contig.feat = col_character(),
##   source = col_character(),
##   feature = col_character(),
##   start.feat = col_double(),
##   end.feat = col_double(),
##   score = col_character(),
##   strand = col_character(),
##   frame = col_character(),
##   attribute = col_character()
## )
## Warning: 1 parsing failure.
## row col   expected    actual                                                                                                       file
##  36  -- 13 columns 7 columns '/Users/laura/Documents/roberts-lab/paper-oly-mbdbs-gen/analyses/macau/20191120-MACAU-10xall-features.txt'
par(mar=c(2,2,4,2))
barplot(table(macau.all$feature)[c("CDS", "exon", "gene", "mRNA", "3'UTR")], 
        main="Locations of MACAU-identified loci (10x cov. in all smpl)", 
        ylab="No. of loci", cex.main=1, cex.axis = 1)

Where are loci located where methylation is associated with oyster shell length?

Loci with 10x coverage across any sample

macau.any <- read_delim(here::here("analyses","macau","20191120-MACAU-10xany-features.txt"), delim = '\t', 
                        col_names = c("contig.locus", "start.locus", "end.locus", "unknown.column", "contig.feat", "source", "feature", "start.feat", "end.feat", "score", "strand", "frame", "attribute")) %>% as_tibble() %>%
  mutate(ID=str_extract(attribute, "ID=(.*?);"), 
         Parent=str_extract(attribute, "Parent=(.*?);"),
         Name=str_extract(attribute, "Name=(.*?);"),
         Alias=str_extract(attribute, "Alias=(.*?);"),
         AED=str_extract(attribute, "AED=(.*?);"),
         eAED=str_extract(attribute, "eAED=(.*?);"),
         Note=str_extract(attribute, "Note=(.*?);"),
         Ontology_term=str_extract(attribute, "Ontology_term=(.*?);"),
         Dbxref=str_extract(attribute, "Dbxref=(.*?);"),
         ) %>%
  mutate_at("feature", as.factor)
## Parsed with column specification:
## cols(
##   contig.locus = col_character(),
##   start.locus = col_double(),
##   end.locus = col_double(),
##   unknown.column = col_double(),
##   contig.feat = col_character(),
##   source = col_character(),
##   feature = col_character(),
##   start.feat = col_double(),
##   end.feat = col_double(),
##   score = col_character(),
##   strand = col_character(),
##   frame = col_character(),
##   attribute = col_character()
## )
## Warning: 15 parsing failures.
## row col   expected    actual                                                                                                       file
##   5  -- 13 columns 7 columns '/Users/laura/Documents/roberts-lab/paper-oly-mbdbs-gen/analyses/macau/20191120-MACAU-10xany-features.txt'
##  32  -- 13 columns 7 columns '/Users/laura/Documents/roberts-lab/paper-oly-mbdbs-gen/analyses/macau/20191120-MACAU-10xany-features.txt'
##  58  -- 13 columns 7 columns '/Users/laura/Documents/roberts-lab/paper-oly-mbdbs-gen/analyses/macau/20191120-MACAU-10xany-features.txt'
##  69  -- 13 columns 7 columns '/Users/laura/Documents/roberts-lab/paper-oly-mbdbs-gen/analyses/macau/20191120-MACAU-10xany-features.txt'
## 105  -- 13 columns 7 columns '/Users/laura/Documents/roberts-lab/paper-oly-mbdbs-gen/analyses/macau/20191120-MACAU-10xany-features.txt'
## ... ... .......... ......... ..........................................................................................................
## See problems(...) for more details.
par(mar=c(2,2,4,2))
barplot(table(macau.any$feature)[c("CDS", "exon", "gene", "mRNA", "3'UTR")], 
        main="Locations of MACAU-identified loci (10x cov. in any smpl)", 
        ylab="No. of loci", cex.main=1, cex.axis = 1)