--- title: "07.2-DML-adult-comparison-low-cov" author: "Kathleen Durkin" date: "2025-06-10" always_allow_html: true output: github_document: toc: true toc_depth: 3 number_sections: true html_preview: true bookdown::html_document2: theme: cosmo toc: true toc_float: true number_sections: true code_folding: show code_download: true --- In `06.2-diff-methyl-split-lifestage-low-cov` I identified loci in the larval samples that are differentially methylated based on parental OA treatment. I now want to see whether any of those DMLs were also present in the adults Note: I'm first checking the adult DML tables, but I may also want to look a the methylomes of both the larvae and the larvae's parents in more detail, since not all adult oysters whose gametes were sequenced in Venkatamaran et al. 2024 were used for fertilization crosses. ```{r} library(tidyverse) ``` # Adult comparison Download adult DMLs (both female (eggs) and male (sperm)) ```{r, engine='bash', eval=FALSE} curl -L https://github.com/sr320/ceabigr/raw/refs/heads/main/data/female_dml.bed -o ../data/adult_female_dml.bed curl -L https://github.com/sr320/ceabigr/raw/refs/heads/main/data/male_dml.bed -o ../data/adult_male_dml.bed ``` ## Combo ```{r, engine='bash'} echo "Combo DMLs that are also differentially methylated in female parents" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/combo_diff25_DML.bed -b ../data/adult_female_dml.bed /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/combo_diff25_DML.bed -b ../data/adult_female_dml.bed > ../output/07.2-DML-adult-comparison-low-cov/combo_diff25_DML_female-parent.bed echo "" echo "Combo DMLs that are also differentially methylated in male parents" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/combo_diff25_DML.bed -b ../data/adult_male_dml.bed /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/combo_diff25_DML.bed -b ../data/adult_male_dml.bed > ../output/07.2-DML-adult-comparison-low-cov/combo_diff25_DML_male-parent.bed echo"" echo "Total Combo DMLs:" cat ../output/06.2-diff-methyl-split-lifestage-low-cov/combo_diff25_DML.bed | wc -l echo "Shared with female parent:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/combo_diff25_DML.bed -b ../data/adult_female_dml.bed | wc -l echo "Shared with male parent:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/combo_diff25_DML.bed -b ../data/adult_male_dml.bed | wc -l ``` 7 Combo DMLs present in the male parents (8.64%) ## Zygote ```{r, engine='bash'} echo "Zygote DMLs that are also differentially methylated in female parents" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/zygote_diff25_DML.bed -b ../data/adult_female_dml.bed /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/zygote_diff25_DML.bed -b ../data/adult_female_dml.bed > ../output/07.2-DML-adult-comparison-low-cov/zygote_diff25_DML_female-parent.bed echo "" echo "Zygote DMLs that are also differentially methylated in male parents" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/zygote_diff25_DML.bed -b ../data/adult_male_dml.bed /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/zygote_diff25_DML.bed -b ../data/adult_male_dml.bed > ../output/07.2-DML-adult-comparison-low-cov/zygote_diff25_DML_male-parent.bed echo"" echo "Total Zygote DMLs:" cat ../output/06.2-diff-methyl-split-lifestage-low-cov/zygote_diff25_DML.bed | wc -l echo "Shared with female parent:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/zygote_diff25_DML.bed -b ../data/adult_female_dml.bed | wc -l echo "Shared with male parent:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/zygote_diff25_DML.bed -b ../data/adult_male_dml.bed | wc -l ``` 15 Zygote DMLs present in the male parents (2.75%) ## Larvae ```{r, engine='bash'} echo "Larval DMLs that are also differentially methylated in female parents" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/larvae_diff25_DML.bed -b ../data/adult_female_dml.bed /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/larvae_diff25_DML.bed -b ../data/adult_female_dml.bed > ../output/07.2-DML-adult-comparison-low-cov/larvae_diff25_DML_female-parent.bed echo "" echo "Larval DMLs that are also differentially methylated in male parents" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/larvae_diff25_DML.bed -b ../data/adult_male_dml.bed /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/larvae_diff25_DML.bed -b ../data/adult_male_dml.bed > ../output/07.2-DML-adult-comparison-low-cov/larvae_diff25_DML_male-parent.bed echo"" echo "Total Larvae DMLs:" cat ../output/06.2-diff-methyl-split-lifestage-low-cov/larvae_diff25_DML.bed | wc -l echo "Shared with female parent:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/larvae_diff25_DML.bed -b ../data/adult_female_dml.bed | wc -l echo "Shared with male parent:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/larvae_diff25_DML.bed -b ../data/adult_male_dml.bed | wc -l ``` 31 Larvae DMLs present in male parents (2.92%) 2 Larvae DMLs present in female parents (0.19%) (though both the DMLs shared with female parents have nearly insignificant methylation differences) ## Plot ```{r} samples <- c("combo_diff25_DML", "zygote_diff25_DML", "larvae_diff25_DML") # Build df dml_counts_df <- map_dfr(samples, function(samp) { # Read in files all_feats <- read_tsv(paste0("../output/06.2-diff-methyl-split-lifestage-low-cov/", samp, ".bed"), col_names = FALSE, show_col_types = FALSE) maternal_feats <- read_tsv(paste0("../output/07.2-DML-adult-comparison-low-cov/", samp, "_female-parent.bed"), col_names = FALSE, show_col_types = FALSE) paternal_feats <- read_tsv(paste0("../output/07.2-DML-adult-comparison-low-cov/", samp, "_male-parent.bed"), col_names = FALSE, show_col_types = FALSE) # Compute counts n_all <- nrow(all_feats) n_maternal <- nrow(maternal_feats) n_paternal <- nrow(paternal_feats) # Return long-format counts for plotting tibble( Sample = samp, Category = c("All DMLs", "Maternal", "Paternal"), Count = c(n_all, n_maternal, n_paternal) ) }) ``` ```{r} ggplot(dml_counts_df, aes(x = Sample, y = Count, fill = Category)) + geom_col(position = "dodge") + labs(title = "DMLs per Group and Parent Origin", y = "Number of DMLs", x = "Group") + scale_fill_manual(values = c("All DMLs" = "#636363", "Maternal" = "#ff7f0e", "Paternal" = "#1f77b4")) + theme_minimal() ``` # Genomic features We can also compare to different genomic features Download tracks ```{r, engine='bash', eval=FALSE} curl -L http://eagle.fish.washington.edu/Cvirg_tracks/C_virginica-3.0_Gnomon_exon.bed -o ../data/C_virginica-3.0_Gnomon_exon.bed curl -L http://eagle.fish.washington.edu/Cvirg_tracks/C_virginica-3.0_intron.bed -o ../data/C_virginica-3.0_intron.bed ``` Note that, by default, `bedtools intersect` outputs a line for each instance of intersection, including if e.g. a DML intersects multiple exons because the exons overlap. To only output a single line to indicate the DML intersects *at least one* feature, use th `-u` option. ## Combo ```{r, engine='bash'} echo "Total Combo DMLs" cat ../output/06.2-diff-methyl-split-lifestage-low-cov/combo_diff25_DML.bed | wc -l echo "Number of Combo DMLs in exons:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/combo_diff25_DML.bed -b ../data/C_virginica-3.0_Gnomon_exon.bed -u | wc -l /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/combo_diff25_DML.bed -b ../data/C_virginica-3.0_Gnomon_exon.bed -u > ../output/07.2-DML-adult-comparison-low-cov/combo_diff25_DML_exon.bed echo "Number of Combo DMLs in introns:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/combo_diff25_DML.bed -b ../data/C_virginica-3.0_intron.bed -u | wc -l /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/combo_diff25_DML.bed -b ../data/C_virginica-3.0_intron.bed -u > ../output/07.2-DML-adult-comparison-low-cov/combo_diff25_DML_intron.bed ``` ## Zygote ```{r, engine='bash'} echo "Total Zygote DMLs" cat ../output/06.2-diff-methyl-split-lifestage-low-cov/zygote_diff25_DML.bed | wc -l echo "Number of Zygote DMLs in exons:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/zygote_diff25_DML.bed -b ../data/C_virginica-3.0_Gnomon_exon.bed -u | wc -l /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/zygote_diff25_DML.bed -b ../data/C_virginica-3.0_Gnomon_exon.bed -u > ../output/07.2-DML-adult-comparison-low-cov/zygote_diff25_DML_exon.bed echo "Number of Zygote DMLs in introns:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/zygote_diff25_DML.bed -b ../data/C_virginica-3.0_intron.bed -u | wc -l /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/zygote_diff25_DML.bed -b ../data/C_virginica-3.0_intron.bed -u > ../output/07.2-DML-adult-comparison-low-cov/zygote_diff25_DML_intron.bed ``` ## Larve ```{r, engine='bash'} echo "Total Larvae DMLs" cat ../output/06.2-diff-methyl-split-lifestage-low-cov/larvae_diff25_DML.bed | wc -l echo "Number of Larvae DMLs in exons:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/larvae_diff25_DML.bed -b ../data/C_virginica-3.0_Gnomon_exon.bed -u | wc -l /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/larvae_diff25_DML.bed -b ../data/C_virginica-3.0_Gnomon_exon.bed -u > ../output/07.2-DML-adult-comparison-low-cov/larvae_diff25_DML_exon.bed echo "Number of Larvae DMLs in introns:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/larvae_diff25_DML.bed -b ../data/C_virginica-3.0_intron.bed -u | wc -l /home/shared/bedtools2/bin/bedtools intersect -a ../output/06.2-diff-methyl-split-lifestage-low-cov/larvae_diff25_DML.bed -b ../data/C_virginica-3.0_intron.bed -u > ../output/07.2-DML-adult-comparison-low-cov/larvae_diff25_DML_intron.bed ``` ## Plot ```{r} samples <- c("combo_diff25_DML", "zygote_diff25_DML", "larvae_diff25_DML") # Build df counts_df <- map_dfr(samples, function(samp) { # Read in files all_feats <- read_tsv(paste0("../output/06.2-diff-methyl-split-lifestage-low-cov/", samp, ".bed"), col_names = FALSE, show_col_types = FALSE) intron_feats <- read_tsv(paste0("../output/07.2-DML-adult-comparison-low-cov/", samp, "_intron.bed"), col_names = FALSE, show_col_types = FALSE) exon_feats <- read_tsv(paste0("../output/07.2-DML-adult-comparison-low-cov/", samp, "_exon.bed"), col_names = FALSE, show_col_types = FALSE) # Compute counts n_all <- nrow(all_feats) n_introns <- nrow(intron_feats) n_exons <- nrow(exon_feats) n_other <- n_all - n_introns - n_exons # optional # Return long-format counts for plotting tibble( Sample = samp, Region = c("Intronic", "Exonic", "Other"), Count = c(n_introns, n_exons, n_other) ) }) ``` ```{r} ggplot(counts_df, aes(x = Sample, y = Count, fill = Region)) + geom_bar(stat = "identity") + labs(title = "Feature Counts by Region Type", x = "Sample", y = "Number of Features") + scale_fill_manual(values = c("Intronic" = "#1f77b4", "Exonic" = "#ff7f0e", "Other" = "#2ca02c")) + theme_minimal() ``` # Genomic features of features shared with parents ## Combo ```{r, engine='bash'} echo "Female Parents:" echo "Total Combo DMLs shared with female parents" cat ../output/07.2-DML-adult-comparison-low-cov/combo_diff25_DML_female-parent.bed | wc -l echo "" echo "Male Parents:" echo "Total Combo DMLs shared with male parents" cat ../output/07.2-DML-adult-comparison-low-cov/combo_diff25_DML_male-parent.bed | wc -l echo "Number of shared Combo DMLs in exons:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/07.2-DML-adult-comparison-low-cov/combo_diff25_DML_male-parent.bed -b ../data/C_virginica-3.0_Gnomon_exon.bed -u | wc -l echo "Number of shared Combo DMLs in introns:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/07.2-DML-adult-comparison-low-cov/combo_diff25_DML_male-parent.bed -b ../data/C_virginica-3.0_intron.bed -u | wc -l ``` ## Zygote ```{r, engine='bash'} echo "Female Parents:" echo "Total Zygote DMLs shared with female parents" cat ../output/07.2-DML-adult-comparison-low-cov/zygote_diff25_DML_female-parent.bed | wc -l echo "" echo "Male Parents:" echo "Total Zygote DMLs shared with male parents" cat ../output/07.2-DML-adult-comparison-low-cov/zygote_diff25_DML_male-parent.bed | wc -l echo "Number of shared Zygote DMLs in exons:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/07.2-DML-adult-comparison-low-cov/zygote_diff25_DML_male-parent.bed -b ../data/C_virginica-3.0_Gnomon_exon.bed -u | wc -l echo "Number of shared Zygote DMLs in introns:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/07.2-DML-adult-comparison-low-cov/zygote_diff25_DML_male-parent.bed -b ../data/C_virginica-3.0_intron.bed -u | wc -l ``` ## Larvae ```{r, engine='bash'} echo "Female Parents:" echo "Total Larvae DMLs shared with female parents" cat ../output/07.2-DML-adult-comparison-low-cov/larvae_diff25_DML_female-parent.bed | wc -l echo "Number of shared Larvae DMLs in exons:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/07.2-DML-adult-comparison-low-cov/larvae_diff25_DML_female-parent.bed -b ../data/C_virginica-3.0_Gnomon_exon.bed -u | wc -l echo "Number of shared Larvae DMLs in introns:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/07.2-DML-adult-comparison-low-cov/larvae_diff25_DML_female-parent.bed -b ../data/C_virginica-3.0_intron.bed -u | wc -l echo "" echo "Male Parents:" echo "Total Larvae DMLs shared with male parents" cat ../output/07.2-DML-adult-comparison-low-cov/larvae_diff25_DML_male-parent.bed | wc -l echo "Number of shared Larvae DMLs in exons:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/07.2-DML-adult-comparison-low-cov/larvae_diff25_DML_male-parent.bed -b ../data/C_virginica-3.0_Gnomon_exon.bed -u | wc -l echo "Number of shared Larvae DMLs in introns:" /home/shared/bedtools2/bin/bedtools intersect -a ../output/07.2-DML-adult-comparison-low-cov/larvae_diff25_DML_male-parent.bed -b ../data/C_virginica-3.0_intron.bed -u | wc -l ``` # Note on intron/exon annotation quality While working with these tracks I noticed some potential overlap between the intron and exon tracks (which should be biologically impossible, since they are mutually exclusive by definition) ```{r, engine='bash'} echo "Number of introns" cat ../data/C_virginica-3.0_intron.bed | wc -l echo "Number of exons" cat ../data/C_virginica-3.0_Gnomon_exon.bed | wc -l echo "Number of intron/exon overlaps" /home/shared/bedtools2/bin/bedtools intersect -a ../data/C_virginica-3.0_Gnomon_exon.bed -b ../data/C_virginica-3.0_intron.bed | wc -l echo "" /home/shared/bedtools2/bin/bedtools intersect -a ../data/C_virginica-3.0_Gnomon_exon.bed -b ../data/C_virginica-3.0_intron.bed | head -10 ``` After looking manually at the overlaps, and checking some examples in IGV, the problem seems to be slightly messy annotation. All the overlaps are only a single nucleotide long, and they represent places where the end of an intron and start of an exon (or vice versa) were annotated as overlapping by 1. Weirdly, only a portion of intron/exon interfaces are overlapping like this. The others appear to have a single nucleotide *separating* them, i.e. a nucleotide that is not annotated as intronic *or* exonic sitting between the two regions. These 1-nt errors (overlaps and gaps) probably represent **improper handling of gtf/gff and bed files**, since the two use different annotation systems. # Summary For all groups considered (Combo/grouped, Zygote only, and Larvae only), a small subset of offspring DMLs were also differentially methylated based on exposure in the parents. Shared DMLs were almost exclusively found in the male parents. This is consistent with methylation work in vertebrates that shows only the **paternal** contribution is stably inherited! Offspring DMLs are mostly found in gene bodies, and are roughly equally distributed between introns and exons. This observation holds for offspring DMLs that were also differentially methylated in parents.