getwd()
## [1] "/Users/laurenblake/Desktop/Regulatory_Evol/ashlar-trial/analysis"
# import sample labels
samples <- read.delim("../../../Reg_Evo_Primates/data/Sample_info_RNAseq_RIN.txt")
RIN <- samples$RIN
# expression
exprs <- read.table("../../../Reg_Evo_Primates/data/human_chimp_orth_exp_methyl_7725_hum.txt", sep="")
# methylation data
methyl <- read.csv("../../../Reg_Evo_Primates/data/chimp_human_orth_7725_avg_methyl_per_ts_gene.txt", sep="")
# Normalized gene expression data
cpm.voom.cyclic <- readRDS("../../../Reg_Evo_Primates/data/human_chimp_orth_cpm_voom_cyclic.rds")
# Load libraries
library("edgeR")
## Loading required package: limma
library("limma")
library("plyr")
library("ashr")
library("cowplot")
## Warning: package 'cowplot' was built under R version 3.4.4
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.4.4
##
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggplot2':
##
## ggsave
library("vashr")
## Loading required package: SQUAREM
## Loading required package: qvalue
library("devtools")
## Warning: package 'devtools' was built under R version 3.4.4
#devtools::install_github("jhsiao999/mediation/pkg")
library("medinome")
Set FDR level/svalue
FDR_level <- 0.05
FDR_add <- 0.10
Human heart-kidney
# Check parameters
human_chimp_heart <- c(17, 20, 21, 24, 25, 28, 29)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- rownames(exprs)
rownames(methyl) <- rownames(exprs)
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7603 122
Human heart versus kidney- DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.134471
Human heart versus kidney- conserved DE genes
# Species no DE
species_no_DE <- c(1, 2, 5, 6, 9, 10, 13, 14)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 971 192
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1650903
# Species no DE
species_no_DE <- c(1, 2, 5, 6, 9, 10, 13, 14)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 294 8
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.02649007
Human heart versus kidney- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Human heart-liver
# Check parameters
human_chimp_heart <- c(18, 20, 22, 24, 26, 28, 30)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- rownames(exprs)
rownames(methyl) <- rownames(exprs)
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7562 163
Human heart versus liver DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1703801
Human heart versus liver- conserved DE genes
# Species no DE
species_no_DE <- c(1, 3, 5, 7, 9, 11, 13, 15)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 1076 258
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1934033
# Species no DE
species_no_DE <- c(1, 3, 5, 7, 9, 11, 13, 15)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 186 6
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.03125
Human heart versus liver- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.0003226327
Human heart-lung
# Check parameters
human_chimp_heart <- c(19, 20, 23, 24, 27, 28, 31)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- rownames(exprs)
rownames(methyl) <- rownames(exprs)
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7637 88
Human heart versus lung DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1143466
Human heart versus lung- conserved DE genes
# Species no DE
species_no_DE <- c(1, 4, 5, 8, 9, 12, 13, 16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 961 156
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1396598
# Species no DE
species_no_DE <- c(1, 4, 5, 8, 9, 12, 13, 16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 282 9
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.03092784
Human heart versus liver- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Human kidney-liver
# Check parameters
human_chimp_heart <- c(17, 18, 21, 22, 25, 26, 29, 30)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- exprs[,1]
rownames(methyl) <- exprs[,1]
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7614 111
Human kidney liver DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.09890777
Human kidney liver- conserved DE genes
# Species no DE
species_no_DE <- c(2, 3, 6, 7, 10, 11, 14,15)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 1146 165
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1258581
# Species no DE
species_no_DE <- c(2, 3, 6, 7, 10, 11, 14,15)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 336 1
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.002967359
Human heart versus liver- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Human kidney-lung
# Check parameters
human_chimp_heart <- c(17, 19, 21, 23, 25, 27, 29, 31)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- exprs[,1]
rownames(methyl) <- exprs[,1]
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7665 60
Human kidney lung DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1664581
Human kidney lung- conserved DE genes
# Species no DE
species_no_DE <- c(2, 4, 6, 8, 10, 12, 14,16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 563 128
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1852388
# Species no DE
species_no_DE <- c(2, 4, 6, 8, 10, 12, 14,16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 101 7
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.06481481
Human kidney lung- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Human liver-lung
# Check parameters
human_chimp_heart <- c(18, 19, 22, 23, 26, 27, 30, 31)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- exprs[,1]
rownames(methyl) <- exprs[,1]
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7649 76
Human liver lung DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.118798
Human liver lung- conserved DE genes
# Species no DE
species_no_DE <- c(3, 4, 7, 8, 11, 12, 15,16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 1062 158
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1295082
# Species no DE
species_no_DE <- c(3, 4, 7, 8, 11, 12, 15,16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 199 12
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.05687204
Human liver lung- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Difference of proportions
prop.test(c(12, 158), c(199+12, 1062+158))
##
## 2-sample test for equality of proportions with continuity
## correction
##
## data: c(12, 158) out of c(199 + 12, 1062 + 158)
## X-squared = 8.3856, df = 1, p-value = 0.003782
## alternative hypothesis: two.sided
## 95 percent confidence interval:
## -0.11190539 -0.03336693
## sample estimates:
## prop 1 prop 2
## 0.05687204 0.12950820
prop.test(c(128, 7), c(128+563, 7+101))
##
## 2-sample test for equality of proportions with continuity
## correction
##
## data: c(128, 7) out of c(128 + 563, 7 + 101)
## X-squared = 8.808, df = 1, p-value = 0.002999
## alternative hypothesis: two.sided
## 95 percent confidence interval:
## 0.06034403 0.18050391
## sample estimates:
## prop 1 prop 2
## 0.18523878 0.06481481
Set FDR level/svalue
FDR_level <- 0.1
Human heart-kidney
# Check parameters
human_chimp_heart <- c(17, 20, 21, 24, 25, 28, 29)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- rownames(exprs)
rownames(methyl) <- rownames(exprs)
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7603 122
Human heart versus kidney- DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1013449
Human heart versus kidney- conserved DE genes
# Species no DE
species_no_DE <- c(1, 2, 5, 6, 9, 10, 13, 14)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 1434 212
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1287971
# Species no DE
species_no_DE <- c(1, 2, 5, 6, 9, 10, 13, 14)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 432 4
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.009174312
Human heart versus kidney- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Human heart-liver
# Check parameters
human_chimp_heart <- c(18, 20, 22, 24, 26, 28, 30)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- rownames(exprs)
rownames(methyl) <- rownames(exprs)
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7562 163
Human heart versus liver DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1260732
Human heart versus liver- conserved DE genes
# Species no DE
species_no_DE <- c(1, 3, 5, 7, 9, 11, 13, 15)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 1601 285
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1511135
# Species no DE
species_no_DE <- c(1, 3, 5, 7, 9, 11, 13, 15)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 324 3
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.009174312
Human heart versus liver- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.0001814224
Human heart-lung
# Check parameters
human_chimp_heart <- c(19, 20, 23, 24, 27, 28, 31)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- rownames(exprs)
rownames(methyl) <- rownames(exprs)
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7637 88
Human heart versus lung DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.08619001
Human heart versus lung- conserved DE genes
# Species no DE
species_no_DE <- c(1, 4, 5, 8, 9, 12, 13, 16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 1405 178
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1124447
# Species no DE
species_no_DE <- c(1, 4, 5, 8, 9, 12, 13, 16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 452 7
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.01525054
Human heart versus liver- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Human kidney-liver
# Check parameters
human_chimp_heart <- c(17, 18, 21, 22, 25, 26, 29, 30)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- exprs[,1]
rownames(methyl) <- exprs[,1]
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7614 111
Human kidney liver DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.07413793
Human kidney liver- conserved DE genes
# Species no DE
species_no_DE <- c(2, 3, 6, 7, 10, 11, 14,15)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 1657 179
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.09749455
# Species no DE
species_no_DE <- c(2, 3, 6, 7, 10, 11, 14,15)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE
## logical 484
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Human heart versus liver- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Human kidney-lung
# Check parameters
human_chimp_heart <- c(17, 19, 21, 23, 25, 27, 29, 31)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- exprs[,1]
rownames(methyl) <- exprs[,1]
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7665 60
Human kidney lung DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1155015
Human kidney lung- conserved DE genes
# Species no DE
species_no_DE <- c(2, 4, 6, 8, 10, 12, 14,16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 1006 152
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1312608
# Species no DE
species_no_DE <- c(2, 4, 6, 8, 10, 12, 14,16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE
## logical 158
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Human kidney lung- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Human liver-lung
# Check parameters
human_chimp_heart <- c(18, 19, 22, 23, 26, 27, 30, 31)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- exprs[,1]
rownames(methyl) <- exprs[,1]
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7649 76
Human liver lung DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.09275911
Human liver lung- conserved DE genes
# Species no DE
species_no_DE <- c(3, 4, 7, 8, 11, 12, 15,16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 1659 186
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.100813
# Species no DE
species_no_DE <- c(3, 4, 7, 8, 11, 12, 15,16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 259 9
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.03358209
Human liver lung- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Set FDR level/svalue
FDR_level <- 0.01
Human heart-kidney
# Check parameters
human_chimp_heart <- c(17, 20, 21, 24, 25, 28, 29)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- rownames(exprs)
rownames(methyl) <- rownames(exprs)
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7603 122
Human heart versus kidney- DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.2504013
Human heart versus kidney- conserved DE genes
# Species no DE
species_no_DE <- c(1, 2, 5, 6, 9, 10, 13, 14)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 378 149
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.2827324
# Species no DE
species_no_DE <- c(1, 2, 5, 6, 9, 10, 13, 14)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 89 7
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.07291667
Human heart versus kidney- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.0002816108
Human heart-liver
# Check parameters
human_chimp_heart <- c(18, 20, 22, 24, 26, 28, 30)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- rownames(exprs)
rownames(methyl) <- rownames(exprs)
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7562 163
Human heart versus liver DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.3487603
Human heart versus liver- conserved DE genes
# Species no DE
species_no_DE <- c(1, 3, 5, 7, 9, 11, 13, 15)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 354 193
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.3528336
# Species no DE
species_no_DE <- c(1, 3, 5, 7, 9, 11, 13, 15)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 40 18
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.3103448
Human heart versus liver- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.0008426966
Human heart-lung
# Check parameters
human_chimp_heart <- c(19, 20, 23, 24, 27, 28, 31)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- rownames(exprs)
rownames(methyl) <- rownames(exprs)
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7637 88
Human heart versus lung DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1923077
Human heart versus lung- conserved DE genes
# Species no DE
species_no_DE <- c(1, 4, 5, 8, 9, 12, 13, 16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 398 104
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.2071713
# Species no DE
species_no_DE <- c(1, 4, 5, 8, 9, 12, 13, 16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 108 14
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1147541
Human heart versus liver- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:7]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=5, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.0001408252
Human kidney-liver
# Check parameters
human_chimp_heart <- c(17, 18, 21, 22, 25, 26, 29, 30)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- exprs[,1]
rownames(methyl) <- exprs[,1]
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7614 111
Human kidney liver DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.1916558
Human kidney liver- conserved DE genes
# Species no DE
species_no_DE <- c(2, 3, 6, 7, 10, 11, 14,15)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 471 138
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.226601
# Species no DE
species_no_DE <- c(2, 3, 6, 7, 10, 11, 14,15)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 152 6
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.03797468
Human heart versus liver- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0
Human kidney-lung
# Check parameters
human_chimp_heart <- c(17, 19, 21, 23, 25, 27, 29, 31)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- exprs[,1]
rownames(methyl) <- exprs[,1]
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7665 60
Human kidney lung DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.4461538
Human kidney lung- conserved DE genes
# Species no DE
species_no_DE <- c(2, 4, 6, 8, 10, 12, 14,16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 62 51
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.4513274
# Species no DE
species_no_DE <- c(2, 4, 6, 8, 10, 12, 14,16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 13 4
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.2352941
Human kidney lung- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.0005266623
Human liver-lung
# Check parameters
human_chimp_heart <- c(18, 19, 22, 23, 26, 27, 30, 31)
# Methylation
hc_exprs <- exprs[,2:48]
exprs_methyl <- exprs[,49:79]
# HC heart only
hc_exprs_heart <- hc_exprs[,human_chimp_heart]
methyl <- exprs_methyl[,human_chimp_heart]
rownames(hc_exprs_heart) <- exprs[,1]
rownames(methyl) <- exprs[,1]
Y <- hc_exprs_heart
two_species <- samples$Tissue[human_chimp_heart]
X <- droplevels.factor(two_species)
M <- methyl
RIN_subset <- RIN[human_chimp_heart]
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash_normal <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash_normal$result$svalue < 0.05)
## Mode FALSE TRUE
## logical 7649 76
Human liver lung DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.28125
Human liver lung- conserved DE genes
# Species no DE
species_no_DE <- c(3, 4, 7, 8, 11, 12, 15,16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] < FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 276 111
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.2868217
# Species no DE
species_no_DE <- c(3, 4, 7, 8, 11, 12, 15,16)
species_no_DE_exprs <- hc_exprs[,species_no_DE]
species_no_DE_methyl <- exprs_methyl[,species_no_DE]
two_species <- samples$Tissue[species_no_DE]
no_DE_tissue <- droplevels.factor(two_species)
no_DE_RIN <- RIN[species_no_DE]
design <- model.matrix(~ as.factor(no_DE_tissue) + no_DE_RIN)
fit_species_no_DE <- lmFit(cpm.voom.cyclic[,species_no_DE], design)
fit_species_no_DE <- eBayes(fit_species_no_DE)
HvC_Heart_fit_species_no_DE = topTable(fit_species_no_DE, coef=2, adjust="BH", number=Inf,
sort.by="none")
# Species DE
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_species_no_DE = cbind(HvC_Heart_fit_species_no_DE, HvC_Heart_fit_all)
HvC_Heart_fit_all_5perc <- HvC_Heart_fit_species_no_DE[which(HvC_Heart_fit_species_no_DE[,6] > FDR_level & HvC_Heart_fit_species_no_DE[,13] < FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
summary(fit_ash$result$svalue < FDR_level)
## Mode FALSE TRUE
## logical 47 14
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.2295082
Human liver lung- non DE genes
# Run the linear model in limma
design_1 <- model.matrix(~ X + RIN_subset)
fit_all <- lmFit(cpm.voom.cyclic[,human_chimp_heart], design_1)
fit_all <- eBayes(fit_all)
# Get results
HvC_Heart_fit_all = topTable(fit_all, coef=2, adjust="BH", number=Inf, sort.by="none")
HvC_Heart_fit_all_5perc <-
HvC_Heart_fit_all[which(HvC_Heart_fit_all$adj.P.Val > FDR_level), ]
human_chimp_heart1 <- rownames(methyl) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(methyl, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
M <- counts_human_chimp_heart_subset
human_chimp_heart1 <- rownames(hc_exprs_heart) %in% rownames( HvC_Heart_fit_all_5perc)
human_chimp_heart1 <- as.data.frame(human_chimp_heart1)
counts_genes_in <- cbind(hc_exprs_heart, human_chimp_heart1)
counts_genes_in_cutoff <- subset(counts_genes_in, human_chimp_heart1 == "TRUE")
counts_human_chimp_heart_subset <- counts_genes_in_cutoff[,1:8]
Y <- counts_human_chimp_heart_subset
check_values <- mediate.test.regressing(Y, X, M, RIN_subset)
fit <- vash(check_values$d_se,df=6, singlecomp = T, unimodal = "auto")
fit_ash <- ash(as.vector(check_values$d), fit$sd.post, mode = 0, mixcompdist = "normal")
## Due to absence of package REBayes, switching to EM algorithm
calc <- as.array(summary(fit_ash$result$svalue < FDR_level))
calc2 <- as.numeric(calc[[2]])
(nrow(Y)-calc2)/nrow(Y)
## [1] 0.0001374193