Gene expression summary for Porites evermanni sRNA-seq data.

  • trimmed reads generated in deep-dive project

  • Reads aligned to Porites evermanni transcriptome, details here

0.0.1 Install and load packages

library(tidyverse)
library(ggplot2)
library(reshape2)
library(pheatmap)
library(RColorBrewer)
library(DESeq2)

1 sRNA

1.1 Load count data

Load in the sRNA count matrix generated using ShortStack 4.1.0. Keep in mind this data includes counts of all sRNAs, not just miRNAs. Also note, while we have 5 samples from which RNA was sequenced, only 3 of those were sequenced for sRNA in P. evermanni.

# Read in sRNA counts data
Peve_counts_sRNA_data_OG <- read_delim("../output/05-Peve-sRNA-ShortStack_4.1.0/ShortStack_out/Counts.txt", delim="\t") 
head(Peve_counts_sRNA_data_OG)
# A tibble: 6 × 6
  Coords               Name  MIRNA POR-73-S1-TP2-fastp-…¹ POR-79-S1-TP2-fastp-…²
  <chr>                <chr> <chr>                  <dbl>                  <dbl>
1 Porites_evermani_sc… Clus… N                          0                      1
2 Porites_evermani_sc… Clus… N                          0                     71
3 Porites_evermani_sc… Clus… N                         12                     12
4 Porites_evermani_sc… Clus… N                        172                     49
5 Porites_evermani_sc… Clus… N                        119                     45
6 Porites_evermani_sc… Clus… N                          5                     35
# ℹ abbreviated names:
#   ¹​`POR-73-S1-TP2-fastp-adapters-polyG-31bp-merged_condensed`,
#   ²​`POR-79-S1-TP2-fastp-adapters-polyG-31bp-merged_condensed`
# ℹ 1 more variable:
#   `POR-82-S1-TP2-fastp-adapters-polyG-31bp-merged_condensed` <dbl>

1.2 Count data munging

Peve_counts_sRNA <- Peve_counts_sRNA_data_OG

# Remove excess portions of sample column names to just "sample###"
colnames(Peve_counts_sRNA) <- sub("-S1-TP2-fastp-adapters-polyG-31bp-merged_condensed", "", colnames(Peve_counts_sRNA))
colnames(Peve_counts_sRNA) <- sub("POR-", "sample", colnames(Peve_counts_sRNA))

# Keep just the counts and cluster names
Peve_counts_sRNA <- Peve_counts_sRNA %>% select("sample73", "sample79", "sample82", "Name")

# I'm not going to be doing any removal of low-count sRNAs for now

# Make the cluster names our new row names
Peve_counts_sRNA <- Peve_counts_sRNA %>% column_to_rownames(var = "Name")

write.table(Peve_counts_sRNA, file = "../output/03.1-Peve-sRNA-summary/Peve_sRNA_ShortStack_counts_formatted.txt", sep = "\t", row.names = TRUE, col.names = TRUE, quote = FALSE)

head(Peve_counts_sRNA)
          sample73 sample79 sample82
Cluster_1        0        1       60
Cluster_2        0       71       17
Cluster_3       12       12       26
Cluster_4      172       49       30
Cluster_5      119       45       26
Cluster_6        5       35      129

1.3 Expression levels

Plot histograms of the expression levels in each sample

# Melt the count matrix into long format
Peve_counts_sRNA_melted <- melt(Peve_counts_sRNA, variable.name = "sample", value.name = "counts")

# Plot the expression level histograms for each sample
ggplot(Peve_counts_sRNA_melted, aes(x = counts)) +
  geom_histogram(binwidth = 1, fill = "#1E2761", color = "black") +
  scale_x_log10() +  # Optional: Log-transform the x-axis for better visualization
  facet_wrap(~sample, scales = "free_y") +
  labs(title = "Gene Expression Level Histogram for Each Sample",
       x = "Expression Level (Counts)",
       y = "Frequency") +
  theme_minimal()

1.4 Transcript counts

First let’s check the total number of transcripts in each sample – keep in mind this expression data has not been normalized yet, so there may be different totals for each sample

# Calculate the total number of transcripts for each sample
total_transcripts <- colSums(Peve_counts_sRNA)

# Create a data frame for plotting
total_transcripts_df <- data.frame(sample = names(total_transcripts),
                                   totals = total_transcripts)

# Plot the total number of transcripts for each sample
ggplot(total_transcripts_df, aes(x = sample, y = totals)) +
  geom_bar(stat = "identity", fill = "#1E2761", color = "black") +
  geom_text(aes(label = totals), vjust = -0.3, size = 3.5) + 
  labs(title = "Total Number of Transcripts per Sample",
       x = "Sample",
       y = "Total Transcripts") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for readability

Now let’s check the number of unique transcripts in each sample – that is, how many unique sRNAs are expressed in each sample? This should be pretty much the same across samples, even without normalization.

# Calculate the number of unique transcripts (non-zero counts) for each sample
unique_transcripts <- colSums(Peve_counts_sRNA > 0)

# Create a data frame for plotting
unique_transcripts_df <- data.frame(sample = names(unique_transcripts),
                                    uniques = unique_transcripts)

# Plot the total number of unique transcripts for each sample
ggplot(unique_transcripts_df, aes(x = sample, y = uniques)) +
  geom_bar(stat = "identity", fill = "#1E2761", color = "black") +
  geom_text(aes(label = uniques), vjust = -0.3, size = 3.5) + 
  labs(title = "Total Number of Unique Expressed Transcripts per Sample",
       x = "Sample",
       y = "Unique Transcripts") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for readability

2 miRNA

2.1 Load miRNA metadata

The ShortStack output Results.txt includes all clusters of sRNA reads, including those not annotated as valid miRNAs. Now that we’ve looked at all the sRNAs a bit, let’s focus in on those classified as miRNAs.

## This code needs miRNA names first ##
# # Join with full metadata sheet, which only contains valid miRNAs
# Peve_metadata_miRNA <- read_csv("../../../deep-dive/DEF-cross-species/output/10-shortRNA-ShortStack-comparison/Peve_results_mature_named.csv") 
# 
# Peve_counts_sRNA <- rownames_to_column(Peve_counts_sRNA, var = "Name")
# 
# Peve_counts_miRNA <- left_join(Peve_metadata_miRNA, Peve_counts_sRNA, by = c("Name" = "Name"))
# 
# # Keep just the counts and given miRNA names (e.g., based on match to previously described miRNA)
# Peve_counts_miRNA <- Peve_counts_miRNA %>% select("sample73", "sample79", "sample82", "given_miRNA_name")
# 
# # Make the miRNA names our new row names
# Peve_counts_miRNA <- Peve_counts_miRNA %>% column_to_rownames(var = "given_miRNA_name")
# 
# head(Peve_counts_miRNA)

## This code can be used until we have miRNA names ##
Peve_counts_miRNA <- Peve_counts_sRNA_data_OG

# Remove excess portions of sample column names to just "sample###"
colnames(Peve_counts_miRNA) <- sub("-S1-TP2-fastp-adapters-polyG-31bp-merged_condensed", "", colnames(Peve_counts_miRNA))
colnames(Peve_counts_miRNA) <- sub("POR-", "sample", colnames(Peve_counts_miRNA))

# Keep only the sRNAs ID'd as valid miRNAs
Peve_counts_miRNA <- Peve_counts_miRNA %>% filter(MIRNA == "Y")

# Keep just the counts and cluster names
Peve_counts_miRNA <- Peve_counts_miRNA %>% select("sample73", "sample79", "sample82", "Name")

# Make the cluster names our new row names
Peve_counts_miRNA <- Peve_counts_miRNA %>% column_to_rownames(var = "Name")

write.table(Peve_counts_miRNA, file = "../output/03.1-Peve-sRNA-summary/Peve_miRNA_ShortStack_counts_formatted.txt", sep = "\t", row.names = TRUE, col.names = TRUE, quote = FALSE)

head(Peve_counts_miRNA)
             sample73 sample79 sample82
Cluster_29       2822     3434     3318
Cluster_589      1885     1158     1017
Cluster_796     20505    23687    49156
Cluster_1140     1339      888      834
Cluster_1167    86625    64520   116691
Cluster_2787     1173      887     1284

2.2 Expression levels

Plot histograms of the expression levels in each sample

# Melt the count matrix into long format
Peve_counts_miRNA_melted <- melt(Peve_counts_miRNA, variable.name = "sample", value.name = "counts")

# Plot the expression level histograms for each sample
ggplot(Peve_counts_miRNA_melted, aes(x = counts)) +
  geom_histogram(binwidth = 1, fill = "#1E2761", color = "black") +
  scale_x_log10() +  # Optional: Log-transform the x-axis for better visualization
  facet_wrap(~sample, scales = "free_y") +
  labs(title = "miRNA Expression Level Histogram for Each Sample",
       x = "Expression Level (Counts)",
       y = "Frequency") +
  theme_minimal()

2.3 miRNA counts

First let’s check the total number of miRNAs in each sample – keep in mind this expression data has not been normalized yet, so there may be different totals for each sample

# Calculate the total number of transcripts for each sample
total_miRNA <- colSums(Peve_counts_miRNA)

# Create a data frame for plotting
total_miRNA_df <- data.frame(sample = names(total_miRNA),
                                   totals = total_miRNA)

# Plot the total number of transcripts for each sample
ggplot(total_miRNA_df, aes(x = sample, y = totals)) +
  geom_bar(stat = "identity", fill = "#1E2761", color = "black") +
  geom_text(aes(label = totals), vjust = -0.3, size = 3.5) + 
  labs(title = "Total Number of miRNAs per Sample",
       x = "Sample",
       y = "Total miRNAs") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for readability

Now let’s check the number of unique miRNAs in each sample – This should be pretty much the same across samples, even without normalization.

# Calculate the number of unique transcripts (non-zero counts) for each sample
unique_miRNA <- colSums(Peve_counts_miRNA > 0)

# Create a data frame for plotting
unique_miRNA_df <- data.frame(sample = names(unique_miRNA),
                                    uniques = unique_miRNA)

# Plot the total number of unique transcripts for each sample
ggplot(unique_miRNA_df, aes(x = sample, y = uniques)) +
  geom_bar(stat = "identity", fill = "#1E2761", color = "black") +
  geom_text(aes(label = uniques), vjust = -0.3, size = 3.5) + 
  labs(title = "Total Number of Unique Expressed miRNAs per Sample",
       x = "Sample",
       y = "Unique miRNA") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for readability

2.4 Heatmap

pheatmap(Peve_counts_miRNA,
         cluster_rows = TRUE,
         cluster_cols = TRUE,
         show_rownames = TRUE,
         show_colnames = TRUE,
         color = colorRampPalette(c("blue", "white", "red"))(50),
         fontsize_row = 8,
         fontsize_col = 8)

Well… there’s like 2 miRNAs with much higher expression than the others, which is making visualizing relative differences difficult. Let’s redo the heatmap, normalizing each row to view relative difference in expression between samples (scale='row')

pheatmap(Peve_counts_miRNA,
         cluster_rows = TRUE,
         cluster_cols = TRUE,
         show_rownames = TRUE,
         show_colnames = TRUE,
         scale = 'row',
         color = colorRampPalette(c("blue", "white", "red"))(50),
         fontsize_row = 8,
         fontsize_col = 8)

3 siRNA

ShortStack’s primary purpose is to identify miRNAs from sRNA-seq data, but it also automatically annotates siRNA loci! Since siRNA potentially play an important role in transposon silencing in invertebrates, we should generate count matrices for siRNAs as well.

We can see clusters annotated as siRNAs in the Results.gff3 output file of ShortStack (sRNA ID shown in the 3rd column)

Peve_Resultsgff <- read.table("../output/05-Peve-sRNA-ShortStack_4.1.0/ShortStack_out/Results.gff3")
# Separate last column info into multiple columns for filtering
Peve_Resultsgff <- Peve_Resultsgff %>%
  separate(V9, into = c("Name", "DicerCall", "MIRNA"), sep = ";") %>%
  mutate(Name = sub("ID=", "", Name),
         DicerCall = sub("DicerCall=", "", DicerCall),
         MIRNA = sub("MIRNA=", "", MIRNA))
head(Peve_Resultsgff)
                           V1         V2                 V3     V4     V5  V6
1 Porites_evermani_scaffold_1 ShortStack Unknown_sRNA_locus   1671   2096  61
2 Porites_evermani_scaffold_1 ShortStack Unknown_sRNA_locus  45711  46131  88
3 Porites_evermani_scaffold_1 ShortStack Unknown_sRNA_locus 313446 313846  50
4 Porites_evermani_scaffold_1 ShortStack Unknown_sRNA_locus 406133 406734 251
5 Porites_evermani_scaffold_1 ShortStack Unknown_sRNA_locus 409836 410269 190
6 Porites_evermani_scaffold_1 ShortStack Unknown_sRNA_locus 465244 465668 169
  V7 V8      Name DicerCall MIRNA
1  +  . Cluster_1         N     N
2  +  . Cluster_2         N     N
3  -  . Cluster_3         N     N
4  -  . Cluster_4         N     N
5  -  . Cluster_5         N     N
6  -  . Cluster_6         N     N
# keep just the sRNA category column (V3), and the cluster names (Name)
# filter to only keep clusters ID'd as siRNAs
Peve_siRNA_clusters <- Peve_Resultsgff %>%
  select(V3, Name) %>%
  filter(str_detect(V3, regex("siRNA")))
head(Peve_siRNA_clusters)
             V3        Name
1 siRNA21_locus  Cluster_24
2 siRNA21_locus  Cluster_40
3 siRNA22_locus  Cluster_49
4 siRNA23_locus  Cluster_58
5 siRNA23_locus  Cluster_82
6 siRNA23_locus Cluster_205
# Now use this list of clusters ID'd as siRNAs to filter our sRNA count matrix
# keep only the sample counts and cluster names
Peve_counts_sRNA <- rownames_to_column(Peve_counts_sRNA, var = "Name")
Peve_counts_siRNA <- left_join(Peve_siRNA_clusters, Peve_counts_sRNA, by = c("Name" = "Name")) %>%
  select(-V3)

# convert the column of cluster names into the df row names
Peve_counts_sRNA <- Peve_counts_sRNA %>% column_to_rownames(var="Name")
Peve_counts_siRNA <- Peve_counts_siRNA %>% column_to_rownames(var="Name")

head(Peve_counts_siRNA)
            sample73 sample79 sample82
Cluster_24         0        0       98
Cluster_40         1       30        7
Cluster_49        55        1        4
Cluster_58       217      248      100
Cluster_82      1792      891     1118
Cluster_205       46        4       43
write.table(Peve_counts_siRNA, file = "../output/03.1-Peve-sRNA-summary/Peve_siRNA_ShortStack_counts_formatted.txt", sep = "\t", row.names = TRUE, col.names = TRUE, quote = FALSE)

3.1 Expression levels

Plot histograms of the expression levels in each sample

# Melt the count matrix into long format
Peve_counts_siRNA_melted <- melt(Peve_counts_siRNA, variable.name = "sample", value.name = "counts")

# Plot the expression level histograms for each sample
ggplot(Peve_counts_siRNA_melted, aes(x = counts)) +
  geom_histogram(binwidth = 1, fill = "#1E2761", color = "black") +
  scale_x_log10() +  # Optional: Log-transform the x-axis for better visualization
  facet_wrap(~sample, scales = "free_y") +
  labs(title = "siRNA Expression Level Histogram for Each Sample",
       x = "Expression Level (Counts)",
       y = "Frequency") +
  theme_minimal()

3.2 siRNA counts

First let’s check the total number of siRNAs in each sample – keep in mind this expression data has not been normalized yet, so there may be different totals for each sample

# Calculate the total number of transcripts for each sample
total_siRNA <- colSums(Peve_counts_siRNA)

# Create a data frame for plotting
total_siRNA_df <- data.frame(sample = names(total_siRNA),
                                   totals = total_siRNA)

# Plot the total number of transcripts for each sample
ggplot(total_siRNA_df, aes(x = sample, y = totals)) +
  geom_bar(stat = "identity", fill = "#1E2761", color = "black") +
  geom_text(aes(label = totals), vjust = -0.3, size = 3.5) + 
  labs(title = "Total Number of siRNAs per Sample",
       x = "Sample",
       y = "Total siRNAs") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for readability

Now let’s check the number of unique siRNAs in each sample – This should be pretty much the same across samples, even without normalization.

# Calculate the number of unique transcripts (non-zero counts) for each sample
unique_siRNA <- colSums(Peve_counts_siRNA > 0)

# Create a data frame for plotting
unique_siRNA_df <- data.frame(sample = names(unique_siRNA),
                                    uniques = unique_siRNA)

# Plot the total number of unique transcripts for each sample
ggplot(unique_siRNA_df, aes(x = sample, y = uniques)) +
  geom_bar(stat = "identity", fill = "#1E2761", color = "black") +
  geom_text(aes(label = uniques), vjust = -0.3, size = 3.5) + 
  labs(title = "Total Number of Unique Expressed siRNAs per Sample",
       x = "Sample",
       y = "Unique siRNA") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for readability

3.3 Heatmap

pheatmap(Peve_counts_siRNA,
         cluster_rows = TRUE,
         cluster_cols = TRUE,
         show_rownames = TRUE,
         show_colnames = TRUE,
         color = colorRampPalette(c("blue", "white", "red"))(50),
         fontsize_row = 8,
         fontsize_col = 8)

pheatmap(Peve_counts_siRNA,
         cluster_rows = TRUE,
         cluster_cols = TRUE,
         show_rownames = TRUE,
         show_colnames = TRUE,
         scale = 'row',
         color = colorRampPalette(c("blue", "white", "red"))(50),
         fontsize_row = 8,
         fontsize_col = 8)

4 ………..

5 Normalized sRNA counts

5.1 Normalize counts with DESeq2

5.1.1 Plot unnormalized sRNA data

Peve_counts_sRNA %>% 
#  select(-Name) %>%
  pivot_longer( cols = everything(), names_to = "sample", values_to = "count") %>%
  ggplot(., aes(x = sample, y = count)) +
  geom_violin() + 
  geom_point(alpha = 0.2) +
  theme_minimal() +
  labs(title = "Unnormalized sRNA counts",
       x = "Sample",
       y = "count")

5.1.2 Metadata

DESeq2 requires a metadata data frame as input. I don’t have sample metadata though so, since we’re just doing DESeq2 for normalization purposes (not analysis purposes), I’m just going to create a dummy sheet

Peve_sample_names <- Peve_counts_sRNA %>%
#  select(-Name) %>%
  colnames()

Peve_metadata_sRNA <- data.frame(Sample = Peve_sample_names,
                            Species = rep("P.evermanni", 3))
rownames(Peve_metadata_sRNA) <- Peve_sample_names

head(Peve_metadata_sRNA)
           Sample     Species
sample73 sample73 P.evermanni
sample79 sample79 P.evermanni
sample82 sample82 P.evermanni

5.1.3 DESeq object

# Calculate DESeq object
Peve_counts_sRNA_rowNames <- Peve_counts_sRNA 
#%>% column_to_rownames(var = "Name")

dds_Peve_sRNA <- DESeqDataSetFromMatrix(countData = Peve_counts_sRNA_rowNames,
                              colData = Peve_metadata_sRNA,
                              design = ~ 1) 

# Run differential expression analysis 
# (Note that this DESeq() function runs all necessary steps, including data normalization, 
# estimating size factors, estimating dispersions, gene-wise dispersion estimates, mean-dispersion 
# relationship, final dispersion estimates, fitting model, and testing)
# Using design = ~1 because we don't have treatment groups

dds_Peve_sRNA <- DESeq(dds_Peve_sRNA)

It’s worth noting here that I’m actually going to be doing two different types of transformation on the counts data, which serve different purposes.

  • First is normalizing the transcript counts, which adjusts for differences in library size or sequencing depth, but retains count-like properties. Normalized counts are most useful for things like visualizing expression levels and differential expression analysis.

  • Second is variance stabilizing the counts data, which aims to make the variance of the transformed data approximately independent of the mean, reducing heteroscedasticity (the relationship between variance and mean) and “smoothing” out the variance at low counts. Notably, the transformed data is no longer on the original count scale. The transformation makes the variance roughly constant across the range of counts, which makes it easier to interpret patterns in the data visually. Variance stabilized data is most useful for exploratory data analysis, like PCA, clustering, and heatmaps, and is also the transformation we’ll want to use before WGCNA.

# extract normalized counts
# (normalization is automatically performed by deseq2)
Peve_counts_sRNA_norm <- counts(dds_Peve_sRNA, normalized=TRUE) %>% data.frame()

write.table(Peve_counts_sRNA_norm, file = "../output/03.1-Peve-sRNA-summary/Peve_counts_sRNA_normalized.txt", sep = "\t", row.names = TRUE, col.names = TRUE, quote = FALSE)


# variance stabilized data
vsd_Peve_sRNA <- varianceStabilizingTransformation(dds_Peve_sRNA, blind=TRUE)
wpn_vsd_Peve_sRNA <- getVarianceStabilizedData(dds_Peve_sRNA)
rv_wpn_Peve_sRNA <- rowVars(wpn_vsd_Peve_sRNA, useNames=TRUE)

Peve_counts_sRNA_vsd <- data.frame(wpn_vsd_Peve_sRNA)
write.table(Peve_counts_sRNA_vsd, file = "../output/03.1-Peve-sRNA-summary/Peve_counts_sRNA_variancestabilized.txt", sep = "\t", row.names = TRUE, col.names = TRUE,quote = FALSE)

q75_wpn_Peve_sRNA <- quantile(rowVars(wpn_vsd_Peve_sRNA, useNames=TRUE), .75)  # 75th quantile variability
Peve_counts_sRNA_vsd_q75 <- wpn_vsd_Peve_sRNA[ rv_wpn_Peve_sRNA > q75_wpn_Peve_sRNA, ] %>% data.frame # filter to retain only the most variable genes
write.table(Peve_counts_sRNA_vsd_q75, file = "../output/03.1-Peve-sRNA-summary/Peve_counts_sRNA_variancestabilized_q75.txt", sep = "\t", row.names = TRUE, col.names = TRUE,quote = FALSE)

q95_wpn_Peve_sRNA <- quantile(rowVars(wpn_vsd_Peve_sRNA, useNames=TRUE), .95)  # 95th quantile variability
Peve_counts_sRNA_vsd_q95 <- wpn_vsd_Peve_sRNA[ rv_wpn_Peve_sRNA > q95_wpn_Peve_sRNA, ] %>% data.frame # filter to retain only the most variable genes
write.table(Peve_counts_sRNA_vsd_q95, file = "../output/03.1-Peve-sRNA-summary/Peve_counts_sRNA_variancestabilized_q95.txt", sep = "\t", row.names = TRUE, col.names = TRUE,quote = FALSE)

5.2 Plot normalized data

Peve_counts_sRNA_norm_long <- Peve_counts_sRNA_norm %>%
  mutate(
    Gene_id = row.names(Peve_counts_sRNA_norm)
  ) %>%
  pivot_longer(-Gene_id)

Peve_counts_sRNA_norm_long %>%
  ggplot(., aes(x = name, y = value)) +
  geom_violin() +
  geom_point() +
  theme_bw() +
  theme(
    axis.text.x = element_text( angle = 90)
  ) +
  ylim(0, NA) +
  labs(
    title = "Normalized Expression",
    x = "Sample",
    y = "Normalized counts"
  )

5.3 Plot variance stabilized data

Peve_counts_sRNA_vsd_long <- Peve_counts_sRNA_vsd %>%
  mutate(
    Gene_id = row.names(Peve_counts_sRNA_vsd)
  ) %>%
  pivot_longer(-Gene_id)

Peve_counts_sRNA_vsd_long %>%
  ggplot(., aes(x = name, y = value)) +
  geom_violin() +
  geom_point() +
  theme_bw() +
  theme(
    axis.text.x = element_text( angle = 90)
  ) +
  ylim(0, NA) +
  labs(
    title = "Variance Stabilized Expression",
    x = "Sample",
    y = "Variance stabilized data"
  )

5.4 Normalized expression levels

Plot histograms of the normalized expression levels in each sample

# Melt the count matrix into long format
Peve_counts_norm_melted <- melt(Peve_counts_sRNA_norm, variable.name = "sample", value.name = "counts")

# Plot the expression level histograms for each sample
ggplot(Peve_counts_norm_melted, aes(x = counts)) +
  geom_histogram(binwidth = 1, fill = "#1E2761", color = "black") +
  scale_x_log10() +  # Optional: Log-transform the x-axis for better visualization
  facet_wrap(~sample, scales = "free_y") +
  labs(title = "Gene Expression Level Histogram for Each Sample",
       x = "Expression Level (Counts)",
       y = "Frequency") +
  theme_minimal()

5.5 Normalized transcript counts

Check the total number of transcripts in each sample – now that we’ve normalized the data these totals should be similar

# Calculate the total number of transcripts for each sample
total_transcripts_norm <- colSums(Peve_counts_sRNA_norm)

# Create a data frame for plotting
total_transcripts_norm_df <- data.frame(sample = names(total_transcripts_norm),
                                   totals = total_transcripts_norm)

# Plot the total number of transcripts for each sample
ggplot(total_transcripts_norm_df, aes(x = sample, y = totals)) +
  geom_bar(stat = "identity", fill = "#1E2761", color = "black") +
  geom_text(aes(label = totals), vjust = -0.3, size = 3.5) +
  labs(title = "Total Number of Transcripts per Sample",
       x = "Sample",
       y = "Total Transcripts") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for readability

5.6 PCA of variance stabilized data

plotPCA(vsd_Peve_sRNA, intgroup="Sample")

5.7 Sample clustering

sample_dists <- dist(t(assay(vsd_Peve_sRNA)))
pheatmap(as.matrix(sample_dists), clustering_distance_rows = "euclidean", 
         clustering_distance_cols = "euclidean", main="Sample Clustering")

5.8 Heatmaps

Of most variable variance stabilized sRNA transcripts

# 75th quantile
heat_colors <- rev(brewer.pal(12, "RdYlBu"))
pheatmap(Peve_counts_sRNA_vsd_q75, 
         cluster_rows = TRUE,
         cluster_cols = TRUE,
         show_rownames = TRUE,
         show_colnames = TRUE,
         color = heat_colors,
         scale="row")

# 95th quantile
pheatmap(Peve_counts_sRNA_vsd_q95, 
         cluster_rows = TRUE,
         cluster_cols = TRUE,
         show_rownames = TRUE,
         show_colnames = TRUE,
         color = heat_colors,
         scale="row")

6 Normalized miRNA counts

6.1 Isolate normalized/vsd miRNA

## Also written to use given miRNA names ##
# Peve_counts_sRNA_norm$Name <- rownames(Peve_counts_sRNA_norm)
# Peve_counts_miRNA_norm <- left_join(Peve_metadata_miRNA, Peve_counts_sRNA_norm, by = c("Name" = "Name")) %>%
#   column_to_rownames(var="given_miRNA_name") %>%
#   select(starts_with("sample"))
# write.table(Peve_counts_miRNA_norm, file = "../output/03.1-Peve-sRNA-summary/Peve_counts_miRNA_normalized.txt", sep = "\t", row.names = TRUE, col.names = TRUE,quote = FALSE)
# 
# Peve_counts_sRNA_vsd$Name <- rownames(Peve_counts_sRNA_vsd)
# Peve_counts_miRNA_vsd <- left_join(Peve_metadata_miRNA, Peve_counts_sRNA_vsd, by = c("Name" = "Name")) %>%
#   column_to_rownames(var="given_miRNA_name") %>%
#   select(starts_with("sample"))
# write.table(Peve_counts_miRNA_vsd, file = "../output/03.1-Peve-sRNA-summary/Peve_counts_miRNA_variancestabilized.txt", sep = "\t", row.names = TRUE, col.names = TRUE,quote = FALSE)

## Use below until you have miRNA names ##
Peve_counts_sRNA_norm$Name <- rownames(Peve_counts_sRNA_norm)
Peve_counts_sRNA_vsd$Name <- rownames(Peve_counts_sRNA_vsd)

Peve_counts_miRNA_namesdf <- data.frame(Name = rownames(Peve_counts_miRNA)) 

Peve_counts_miRNA_norm <- left_join(Peve_counts_miRNA_namesdf, Peve_counts_sRNA_norm, by = c("Name" = "Name")) %>%
  column_to_rownames(var = "Name")
write.table(Peve_counts_miRNA_norm, file = "../output/03.1-Peve-sRNA-summary/Peve_counts_miRNA_normalized.txt", sep = "\t", row.names = TRUE, col.names = TRUE,quote = FALSE)

Peve_counts_miRNA_vsd <- left_join(Peve_counts_miRNA_namesdf, Peve_counts_sRNA_vsd, by = c("Name" = "Name")) %>%
  column_to_rownames(var = "Name")
write.table(Peve_counts_miRNA_vsd, file = "../output/03.1-Peve-sRNA-summary/Peve_counts_miRNA_variancestabilized.txt", sep = "\t", row.names = TRUE, col.names = TRUE,quote = FALSE)

6.2 Normalized expression levels

Plot histograms of the normalized expression levels in each sample

# Melt the count matrix into long format
Peve_counts_miRNA_norm_melted <- melt(Peve_counts_miRNA_norm, variable.name = "sample", value.name = "counts")

# Plot the expression level histograms for each sample
ggplot(Peve_counts_miRNA_norm_melted, aes(x = counts)) +
  geom_histogram(binwidth = 1, fill = "#1E2761", color = "black") +
  scale_x_log10() +  # Optional: Log-transform the x-axis for better visualization
  facet_wrap(~sample, scales = "free_y") +
  labs(title = "Gene Expression Level Histogram for Each Sample",
       x = "Expression Level (Counts)",
       y = "Frequency") +
  theme_minimal()

6.3 Normalized transcript counts

Check the total number of transcripts in each sample – now that we’ve normalized the data these totals should be similar

# Calculate the total number of transcripts for each sample
total_transcripts_miRNA_norm <- colSums(Peve_counts_miRNA_norm)

# Create a data frame for plotting
total_transcripts_miRNA_norm_df <- data.frame(sample = names(total_transcripts_miRNA_norm),
                                   totals = total_transcripts_miRNA_norm)

# Plot the total number of transcripts for each sample
ggplot(total_transcripts_miRNA_norm_df, aes(x = sample, y = totals)) +
  geom_bar(stat = "identity", fill = "#1E2761", color = "black") +
  geom_text(aes(label = totals), vjust = -0.3, size = 3.5) +
  labs(title = "Total Number of miRNA Transcripts per Sample",
       x = "Sample",
       y = "Total Transcripts") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for readability

6.4 Heatmap

Of all miRNAs

heat_colors <- rev(brewer.pal(12, "RdYlBu"))
pheatmap(as.matrix(Peve_counts_miRNA_vsd[apply(Peve_counts_miRNA_vsd, 1, var) > 0, ]), 
         cluster_rows = TRUE,
         cluster_cols = TRUE,
         show_rownames = TRUE,
         show_colnames = TRUE,
         color = heat_colors,
         scale="row")

7 Normalized siRNA counts

7.1 Isolate normalized/vsd siRNA

Peve_counts_sRNA_norm$Name <- rownames(Peve_counts_sRNA_norm)
Peve_counts_sRNA_vsd$Name <- rownames(Peve_counts_sRNA_vsd)

Peve_counts_siRNA_namesdf <- data.frame(Name = rownames(Peve_counts_siRNA)) 

Peve_counts_siRNA_norm <- left_join(Peve_counts_siRNA_namesdf, Peve_counts_sRNA_norm, by = c("Name" = "Name")) %>%
  column_to_rownames(var = "Name")
write.table(Peve_counts_siRNA_norm, file = "../output/03.1-Peve-sRNA-summary/Peve_counts_siRNA_normalized.txt", sep = "\t", row.names = TRUE, col.names = TRUE,quote = FALSE)

Peve_counts_siRNA_vsd <- left_join(Peve_counts_siRNA_namesdf, Peve_counts_sRNA_vsd, by = c("Name" = "Name")) %>%
  column_to_rownames(var = "Name")
write.table(Peve_counts_siRNA_vsd, file = "../output/03.1-Peve-sRNA-summary/Peve_counts_siRNA_variancestabilized.txt", sep = "\t", row.names = TRUE, col.names = TRUE,quote = FALSE)

7.2 Normalized expression levels

Plot histograms of the normalized expression levels in each sample

# Melt the count matrix into long format
Peve_counts_siRNA_norm_melted <- melt(Peve_counts_siRNA_norm, variable.name = "sample", value.name = "counts")

# Plot the expression level histograms for each sample
ggplot(Peve_counts_siRNA_norm_melted, aes(x = counts)) +
  geom_histogram(binwidth = 1, fill = "#1E2761", color = "black") +
  scale_x_log10() +  # Optional: Log-transform the x-axis for better visualization
  facet_wrap(~sample, scales = "free_y") +
  labs(title = "Gene Expression Level Histogram for Each Sample",
       x = "Expression Level (Counts)",
       y = "Frequency") +
  theme_minimal()

7.3 Normalized transcript counts

Check the total number of transcripts in each sample – now that we’ve normalized the data these totals should be similar

# Calculate the total number of transcripts for each sample
total_transcripts_siRNA_norm <- colSums(Peve_counts_siRNA_norm)

# Create a data frame for plotting
total_transcripts_siRNA_norm_df <- data.frame(sample = names(total_transcripts_siRNA_norm),
                                   totals = total_transcripts_siRNA_norm)

# Plot the total number of transcripts for each sample
ggplot(total_transcripts_siRNA_norm_df, aes(x = sample, y = totals)) +
  geom_bar(stat = "identity", fill = "#1E2761", color = "black") +
  geom_text(aes(label = totals), vjust = -0.3, size = 3.5) +
  labs(title = "Total Number of siRNA Transcripts per Sample",
       x = "Sample",
       y = "Total Transcripts") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for readability

7.4 Heatmap

Of all siRNAs

heat_colors <- rev(brewer.pal(12, "RdYlBu"))
pheatmap(as.matrix(Peve_counts_siRNA_vsd[apply(Peve_counts_siRNA_vsd, 1, var) > 0, ]), 
         cluster_rows = TRUE,
         cluster_cols = TRUE,
         show_rownames = TRUE,
         show_colnames = TRUE,
         color = heat_colors,
         scale="row")

LS0tCnRpdGxlOiAiMDMuMS1QZXZlLXNSTkEtc3VtbWFyeSIKYXV0aG9yOiAiS2F0aGxlZW4gRHVya2luIgpkYXRlOiAiMjAyNC0wOS0wNSIKYWx3YXlzX2FsbG93X2h0bWw6IHRydWUKb3V0cHV0OiAKICBib29rZG93bjo6aHRtbF9kb2N1bWVudDI6CiAgICB0aGVtZTogY29zbW8KICAgIHRvYzogdHJ1ZQogICAgdG9jX2Zsb2F0OiB0cnVlCiAgICBudW1iZXJfc2VjdGlvbnM6IHRydWUKICAgIGNvZGVfZm9sZGluZzogc2hvdwogICAgY29kZV9kb3dubG9hZDogdHJ1ZQogIGdpdGh1Yl9kb2N1bWVudDoKICAgIHRvYzogdHJ1ZQogICAgdG9jX2RlcHRoOiAzCiAgICBudW1iZXJfc2VjdGlvbnM6IHRydWUKICAgIGh0bWxfcHJldmlldzogdHJ1ZSAKLS0tCgpgYGB7ciBzZXR1cCwgaW5jbHVkZT1GQUxTRX0KbGlicmFyeShrbml0cikKa25pdHI6Om9wdHNfY2h1bmskc2V0KAogIGVjaG8gPSBUUlVFLCAgICAgICAgICMgRGlzcGxheSBjb2RlIGNodW5rcwogIGV2YWwgPSBUUlVFLCAgICAgICAgICMgRXZhbHVhdGUgY29kZSBjaHVua3MKICB3YXJuaW5nID0gRkFMU0UsICAgICAjIEhpZGUgd2FybmluZ3MKICBtZXNzYWdlID0gRkFMU0UsICAgICAjIEhpZGUgbWVzc2FnZXMKICBjb21tZ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