# convert to relative abundance
ps1 <- microbiome::transform(ps1, "compositional")
#remove taxa that are not present in the spiked samples
ps1 <- prune_taxa(taxa_sums(ps1) > 0, ps1)
print(ps1)
ps1 <- filter_taxa(ps1, function(x) sum(x > 0.0125) > (0.005*length(x)), TRUE)
tax_table(ps1) <- cbind(tax_table(ps1),
rownames(tax_table(ps1)))
colnames(tax_table(ps1)) <-
c("Domain", "Phylum", "Class", "Order", "Family", "Genus", "OTUID")
getPalette = colorRampPalette(brewer.pal(10, "Paired"))
#barplot with single OTU
p <- plot_bar(ps1, fill = "OTUID")
p <- p + facet_wrap(~Day_of_study_factor, scales = "free_x", nrow = 1)
p <- p + theme(text = element_text(size = 20), panel.background = element_rect(fill = "white",
colour = "lightgrey",
size = 0.5, linetype = "solid"),)
p <- p + scale_fill_manual(values = getPalette(10))
p
pdf(file = "./figures/Barplot_EcN_presence_in_spiked_samples.pdf", height = 10, width = 10)
p
dev.off() #Resulting figure can be found under Supplementary Figure S2 of the manuscript
ps1.1OTU <- readRDS("./phyobjects/ps1.1OTU.rds")
ps1.1OTU@sam_data$Day_of_study_factor <- factor(ps1.1OTU@sam_data$Day_of_study_factor, levels = c("Day_4", "Day_8", "Day_14", "Day_26", "Day_27", "Day_35", "Day_43", "Day_44", "Day_59", "Day_69", "Day_70"))
ps1.1OTU <- subset_samples(ps1.1OTU, Unique %in% c("yes"))
ps1.1OTU <- subset_samples(ps1.1OTU, Origin %in% c("faeces"))
#subset to exclusively contain pre-weaning faecal samples, as post-weaning faecal samples do not contain the EcN-specific ASV:
ps1.1OTU <- subset_samples(ps1.1OTU, Day_of_study_factor %in% c("Day_4", "Day_8", "Day_14", "Day_26"))
ps1.1OTU <- subset_samples(ps1.1OTU, Treatment %in% c("EcN"))
getPalette = colorRampPalette(brewer.pal(24, "Paired"))
#barplot with single OTU
p <- plot_bar(ps1.1OTU, x="Ear_tag", fill = "Ear_tag")
p <- p + facet_wrap(~Day_of_study_factor, scales = "free_x", nrow = 1)
p <- p + theme(text = element_text(size = 20), panel.background = element_rect(fill = "white",
colour = "lightgrey",
size = 0.5, linetype = "solid"),)
p <- p + scale_fill_manual(values = getPalette(24))
p
pdf(file = "./figures/Barplot_EcN_presence_over_time_in_faeces_pre-weaning_ear_tag.pdf", height = 15, width = 25)
p
dev.off() #Resulting figure can be found under Figure 2 of the manuscript
ps1.1OTU <- readRDS("./phyobjects/ps1.1OTU.rds")
ps1.1OTU@sam_data$Origin_Day <- factor(ps1.1OTU@sam_data$Origin_Day, levels = c("faeces_Day_4", "faeces_Day_8", "faeces_Day_14", "faeces_Day_26", "faeces_Day_35", "faeces_Day_43", "faeces_Day_59", "faeces_Day_69", "jejunum_digesta_Day_27", "ileum_digesta_Day_27", "caecum_digesta_Day_27", "jejunum_digesta_Day_44", "ileum_digesta_Day_44", "caecum_digesta_Day_44", "jejunum_digesta_Day_70", "ileum_digesta_Day_70", "caecum_digesta_Day_70"))
ps1.1OTU <- subset_samples(ps1.1OTU, Unique %in% c("yes"))
ps1.1OTU <- subset_samples(ps1.1OTU, Origin %in% c("jejunum_digesta", "ileum_digesta", "caecum_digesta"))
#subset to exclusively contain pre-weaning faecal samples, as post-weaning faecal samples do not contain the EcN-specific ASV:
ps1.1OTU <- subset_samples(ps1.1OTU, Treatment %in% c("EcN"))
getPalette = colorRampPalette(brewer.pal(24, "Paired"))
#barplot with single OTU
p <- plot_bar(ps1.1OTU, x="Ear_tag", fill = "Origin_Day")
p <- p + facet_wrap(~Origin_Day, scales = "free_x", nrow = 1)
p <- p + theme(text = element_text(size = 20), panel.background = element_rect(fill = "white",
colour = "lightgrey",
size = 0.5, linetype = "solid"),)
p <- p + scale_fill_manual(values = getPalette(24))
p
pdf(file = "./figures/Barplot_EcN_presence_over_time_in_digesta_ear_tag.pdf", height = 15, width = 25)
p
dev.off() #Resulting figure can be found under Supplementary Figure S6 of the manuscript
ps1.1genus <- readRDS("./phyobjects/ps1.EcN.rds")
# convert to relative abundance
ps1.1genus <- microbiome::transform(ps1.1genus, "compositional")
ps1.1genus@sam_data$Day_of_study_factor <- factor(ps1.1genus@sam_data$Day_of_study_factor, levels = c("Day_4", "Day_8", "Day_14", "Day_26", "Day_27", "Day_35", "Day_43", "Day_44", "Day_59", "Day_69", "Day_70"))
colnames(tax_table(ps1.1genus))
tax_table(ps1.1genus) <- cbind(tax_table(ps1.1genus),
rownames(tax_table(ps1.1genus)))
colnames(tax_table(ps1.1genus)) <-
c("Domain", "Phylum", "Class", "Order", "Family", "Genus", "OTUID")
ps1.1genus <- subset_taxa(ps1.1genus, Genus == "Treponema_2")
ps1.1genus <- subset_samples(ps1.1genus, Unique %in% c("yes"))
ps1.1genus <- subset_samples(ps1.1genus, Origin %in% c("faeces"))
ps1.1genus <- prune_taxa(taxa_sums(otu_table(ps1.1genus))>0, ps1.1genus)
getPalette = colorRampPalette(brewer.pal(ntaxa(ps1.1genus), "Paired"))
#barplot with single OTU
p <- plot_bar(ps1.1genus, x="Ear_tag", fill = "OTU")
p <- p + facet_wrap(~Day_of_study_factor + Origin + Treatment, scales = "free_x", nrow = 1)
p <- p + theme(text = element_text(size = 20), panel.background = element_rect(fill = "white",
colour = "lightgrey",
size = 0.5, linetype = "solid"),)
p <- p + scale_fill_manual(values = getPalette(ntaxa(ps1.1genus)))
p
pdf(file = "./figures/Barplot_Treponema_2_presence_over_time_in_faeces_fill_OTU.pdf", height = 15, width = 25)
p
dev.off() #Resulting figure can be found under Supplementary Figure S13 of the manuscript
ps1.1genus <- readRDS("./phyobjects/ps1.EcN.rds")
ps1.1genus@sam_data$Day_of_study_factor <- factor(ps1.1genus@sam_data$Day_of_study_factor, levels = c("Day_4", "Day_8", "Day_14", "Day_26", "Day_27", "Day_35", "Day_43", "Day_44", "Day_59", "Day_69", "Day_70"))
colnames(tax_table(ps1.1genus))
tax_table(ps1.1genus) <- cbind(tax_table(ps1.1genus),
rownames(tax_table(ps1.1genus)))
colnames(tax_table(ps1.1genus)) <-
c("Domain", "Phylum", "Class", "Order", "Family", "Genus", "OTUID")
# convert to relative abundance
ps1.1genus <- microbiome::transform(ps1.1genus, "compositional")
# Select a single species within the Treponema genus:
#ps1.1genus <- subset_taxa(ps1.1genus, OTUID == "8138091913") #Treponema Succinifaciens
#ps1.1genus <- subset_taxa(ps1.1genus, OTUID == "8138091950") #Treponema porcinum
#ps1.1genus <- subset_taxa(ps1.1genus, OTUID == "8138091954") #Treponema parvum
#ps1.1genus <- subset_taxa(ps1.1genus, OTUID == "8138092035") #Treponema berlinense
ps1.1genus <- subset_taxa(ps1.1genus, OTUID == "8138091173" | OTUID == "813809349") #Candidatus Treponema suis
ps1.1genus <- subset_samples(ps1.1genus, Unique %in% c("yes"))
ps1.1genus <- subset_samples(ps1.1genus, Origin %in% c("faeces")) #, "caecum_digesta"))
ps1.1genus <- prune_taxa(taxa_sums(otu_table(ps1.1genus))>0, ps1.1genus)
getPalette = colorRampPalette(brewer.pal(ntaxa(ps1.1genus), "Paired"))
#barplot with single OTU
p <- plot_bar(ps1.1genus, x="Ear_tag", fill = "OTU")
p <- p + facet_wrap(~Day_of_study_factor + Origin + Treatment, scales = "free_x", nrow = 1)
p <- p + theme(text = element_text(size = 20), panel.background = element_rect(fill = "white",
colour = "lightgrey",
size = 0.5, linetype = "solid"),)
p <- p + scale_fill_manual(values = getPalette(ntaxa(ps1.1genus)))
p
pdf(file = "./figures/Barplot_candidatus_treponema_suis1_and_2_singleOTU_presence_over_time_fill_OTU_faeces.pdf", height = 15, width = 25)
p
dev.off() #Resulting figure can be found under Supplementary Figure S13 of the manuscript
ps1.1genus <- readRDS("./phyobjects/ps1.EcN.rds")
ps1.1genus@sam_data$Day_of_study_factor <- factor(ps1.1genus@sam_data$Day_of_study_factor, levels = c("Day_4", "Day_8", "Day_14", "Day_26", "Day_27", "Day_35", "Day_43", "Day_44", "Day_59", "Day_69", "Day_70"))
# convert to relative abundance
ps1.1genus <- microbiome::transform(ps1.1genus, "compositional")
ps1.1genus <- subset_taxa(ps1.1genus, Genus == "Holdemanella")
ps1.1genus <- subset_samples(ps1.1genus, Unique %in% c("yes"))
ps1.1genus <- subset_samples(ps1.1genus, Origin %in% c("faeces"))
ps1.1genus <- subset_samples(ps1.1genus, Pre_or_post_weaning %in% c("Pre_weaning"))
ps1.1genus <- prune_taxa(taxa_sums(otu_table(ps1.1genus))>0, ps1.1genus)
getPalette = colorRampPalette(brewer.pal(ntaxa(ps1.1genus), "Paired"))
#barplot with single OTU
p <- plot_bar(ps1.1genus, x="Ear_tag", fill = "OTU")
p <- p + facet_wrap(~Day_of_study_factor + Origin + Treatment, scales = "free_x", nrow = 1)
p <- p + theme(text = element_text(size = 20), panel.background = element_rect(fill = "white",
colour = "lightgrey",
size = 0.5, linetype = "solid"),)
p <- p + scale_fill_manual(values = getPalette(ntaxa(ps1.1genus)))
p
pdf(file = "./figures/Barplot_Holdemanella_presence_over_time_in_faeces_pre-w_fill_OTU.pdf", height = 15, width = 25)
p
dev.off() #This figure was not used in the manuscript, but does contain interesting data.
ps1.1genus <- readRDS("./phyobjects/ps1.EcN.rds")
ps1.1genus@sam_data$Day_of_study_factor <- factor(ps1.1genus@sam_data$Day_of_study_factor, levels = c("Day_4", "Day_8", "Day_14", "Day_26", "Day_27", "Day_35", "Day_43", "Day_44", "Day_59", "Day_69", "Day_70"))
# convert to relative abundance
ps1.1genus <- microbiome::transform(ps1.1genus, "compositional")
ps1.1genus <- subset_taxa(ps1.1genus, Genus == "Ruminococcaceae_UCG−014")
ps1.1genus <- subset_samples(ps1.1genus, Unique %in% c("yes"))
ps1.1genus <- subset_samples(ps1.1genus, Origin %in% c("faeces"))
ps1.1genus <- prune_taxa(taxa_sums(otu_table(ps1.1genus))>0, ps1.1genus)
getPalette = colorRampPalette(brewer.pal(ntaxa(ps1.1genus), "Paired"))
#barplot with single OTU
p <- plot_bar(ps1.1genus, x="Ear_tag", fill = "OTU")
p <- p + facet_wrap(~Day_of_study_factor + Origin + Treatment, scales = "free_x", nrow = 1)
p <- p + theme(text = element_text(size = 20), panel.background = element_rect(fill = "white",
colour = "lightgrey",
size = 0.5, linetype = "solid"),)
p <- p + scale_fill_manual(values = getPalette(ntaxa(ps1.1genus)))
p
pdf(file = "./figures/Barplot_Ruminococcaceae_UCG−014_presence_over_time_in_faeces_fill_OTU.pdf", height = 15, width = 25)
p
dev.off() #This figure was not used in the manuscript, but does contain interesting data.
ps1.1genus <- readRDS("./phyobjects/ps1.EcN.rds")
ps1.1genus@sam_data$Day_of_study_factor <- factor(ps1.1genus@sam_data$Day_of_study_factor, levels = c("Day_4", "Day_8", "Day_14", "Day_26", "Day_27", "Day_35", "Day_43", "Day_44", "Day_59", "Day_69", "Day_70"))
# convert to relative abundance
ps1.1genus <- microbiome::transform(ps1.1genus, "compositional")
ps1.1genus <- subset_taxa(ps1.1genus, Genus == "Terrisporobacter")
ps1.1genus <- subset_samples(ps1.1genus, Unique %in% c("yes"))
ps1.1genus <- subset_samples(ps1.1genus, Origin %in% c("faeces"))
ps1.1genus <- subset_samples(ps1.1genus, Pre_or_post_weaning %in% c("Pre_weaning"))
ps1.1genus <- prune_taxa(taxa_sums(otu_table(ps1.1genus))>0, ps1.1genus)
getPalette = colorRampPalette(brewer.pal(ntaxa(ps1.1genus), "Paired"))
#barplot with single OTU
p <- plot_bar(ps1.1genus, x="Ear_tag", fill = "OTU")
p <- p + facet_wrap(~Day_of_study_factor + Origin + Treatment, scales = "free_x", nrow = 1)
p <- p + theme(text = element_text(size = 20), panel.background = element_rect(fill = "white",
colour = "lightgrey",
size = 0.5, linetype = "solid"),)
p <- p + scale_fill_manual(values = getPalette(ntaxa(ps1.1genus)))
p
pdf(file = "./figures/Barplot_Terrisporobacter_presence_over_time_in_faeces_pre-w_fill_OTU.pdf", height = 15, width = 25)
p
dev.off() #This figure was not used in the manuscript, but does contain interesting data.
ps1 <- readRDS("./phyobjects/ps1.EcN.rds")
ps1.tested <- ps1 <- subset_samples(ps1, fcs_tested_qpcr %in% c("yes"))
ps1.tested
ps1.tested.df <- as.data.frame(sample_data(ps1.tested))
p <- ggplot(ps1.tested.df,
mapping = aes(rel_abund_ecn_ct33, EcN_NGS_relative)) +
geom_point(size = 3, alpha = 0.9, colour = 'darkgreen') + scale_x_log10() + scale_y_log10() +
geom_smooth(method='lm', se = FALSE)
p
pdf(file = "./figures/Compare_EcN_abund_NGS_vs_qPCR_ct33.pdf", height = 10, width = 15)
p
dev.off()
#Calculate r-squared:
x <- c(ps1.tested.df$rel_abund_ecn_ct33)
y <- c(ps1.tested.df$EcN_NGS_relative)
ps1.tested.df.calc_r2_merged <- data.frame(x, y)
summary(lm(x ~ y, data=ps1.tested.df.calc_r2_merged))$r.squared
res <- read.table("./input_data/ileum_data_volcano_plot_for_R_d27_ecn_padj.csv",
header = TRUE,
sep = ",",
stringsAsFactors = FALSE)
head(res)
colnames(res) <- c("Gene","log2FoldChange","pvalue", "padj")
res$padj <- rownames(res)
res$padj <- p.adjust(res[,3], method = "fdr")
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-3.2,2.8), ylim=c(0, 2.4)))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, padj<.5 & abs(log2FoldChange)>0.1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
# The pdf figure should be used to really look at the data, as it has better visibility
pdf(file = "./figures/ileum_data_volcano_plot_for_R_d27_ecn_padj_xy_limits.pdf", height = 10, width = 15)
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-3.2,2.8), ylim=c(0, 2.4)))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, pvalue<1 & abs(log2FoldChange)>1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
dev.off()
res <- read.table("./input_data/ileum_data_volcano_plot_for_R_d44_ecn_padj.csv",
header = TRUE,
sep = ",",
stringsAsFactors = FALSE)
head(res)
colnames(res) <- c("Gene","log2FoldChange","pvalue", "padj")
res$padj <- rownames(res)
res$padj <- p.adjust(res[,3], method = "fdr")
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-3.2,2.8), ylim=c(0, 2.4)))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, padj<.5 & abs(log2FoldChange)>0.1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
# The pdf figure should be used to really look at the data, as it has better visibility
pdf(file = "./figures/ileum_data_volcano_plot_for_R_d44_ecn_padj_xy_limits.pdf", height = 10, width = 15)
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-3.2,2.8), ylim=c(0, 2.4)))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, pvalue<1 & abs(log2FoldChange)>1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
dev.off()
res <- read.table("./input_data/ileum_data_volcano_plot_for_R_d27_vs_d44_ecn_padj.csv",
header = TRUE,
sep = ",",
stringsAsFactors = FALSE)
head(res)
colnames(res) <- c("Gene","log2FoldChange","pvalue", "padj")
res$padj <- rownames(res)
res$padj <- p.adjust(res[,3], method = "fdr")
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot"))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, padj<.05 & abs(log2FoldChange)>0.1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
pdf(file = "./figures/ileum_data_volcano_plot_for_R_d27_vs_d44_ecn_padj_xy_limits.pdf", height = 10, width = 15)
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot"))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, padj<.05 & abs(log2FoldChange)>0.1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
dev.off()
# The pdf figure should be used to really look at the data, as it has better visibility
pdf(file = "./figures/ileum_data_volcano_plot_for_R_d27_vs_d44_ecn_padj_xy_limits_h20_w30.pdf", height = 20, width = 30)
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot"))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, padj<.05 & abs(log2FoldChange)>0.1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
dev.off()
res <- read.table("./input_data/colon_data_volcano_plot_for_R_d27_padj.csv",
header = TRUE,
sep = ",",
stringsAsFactors = FALSE)
head(res)
colnames(res) <- c("Gene","log2FoldChange","pvalue", "padj")
res$padj <- rownames(res)
res$padj <- p.adjust(res[,3], method = "fdr")
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-3.2,2.8), ylim=c(0, 2.4)))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, padj<.5 & abs(log2FoldChange)>0.1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
# The pdf figure should be used to really look at the data, as it has better visibility
pdf(file = "./figures/colon_data_volcano_plot_for_R_d27_padj_xy_limits.pdf", height = 10, width = 15)
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-3.2,2.8), ylim=c(0, 2.4)))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, pvalue<1 & abs(log2FoldChange)>1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
dev.off()
res <- read.table("./input_data/colon_data_volcano_plot_for_R_d44_padj.csv",
header = TRUE,
sep = ",",
stringsAsFactors = FALSE)
head(res)
colnames(res) <- c("Gene","log2FoldChange","pvalue", "padj")
res$padj <- rownames(res)
res$padj <- p.adjust(res[,3], method = "fdr")
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-3.2,2.8), ylim=c(0, 2.4)))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, padj<.5 & abs(log2FoldChange)>0.1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
# The pdf figure should be used to really look at the data, as it has better visibility
pdf(file = "./figures/colon_data_volcano_plot_for_R_d44_padj_xy_limits.pdf", height = 10, width = 15)
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-3.2,2.8), ylim=c(0, 2.4)))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, pvalue<1 & abs(log2FoldChange)>1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
dev.off()
res <- read.table("./input_data/colon_data_volcano_plot_for_R_d27_vs_d44_padj.csv",
header = TRUE,
sep = ",",
stringsAsFactors = FALSE)
head(res)
colnames(res) <- c("Gene","log2FoldChange","pvalue", "padj")
res$padj <- rownames(res)
res$padj <- p.adjust(res[,3], method = "fdr")
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot"))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, padj<.05 & abs(log2FoldChange)>0.1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
with(subset(res, abs(log2FoldChange)>1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
pdf(file = "./figures/colon_data_volcano_plot_for_R_d27_vs_d44_padj_xy_limits.pdf", height = 10, width = 15)
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot"))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, padj<.05 & abs(log2FoldChange)>0.1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
with(subset(res, abs(log2FoldChange)>1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
dev.off()
# The pdf figure should be used to really look at the data, as it has better visibility
pdf(file = "./figures/colon_data_volcano_plot_for_R_d27_vs_d44_padj_xy_limits_h20_w30.pdf", height = 20, width = 30)
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot"))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, padj<.05 & abs(log2FoldChange)>0.1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
with(subset(res, abs(log2FoldChange)>1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
dev.off()
version
sessionInfo()
# Here, the analysis of one of the immunological data files is showcased. All other immunological files that are present within the data repository were run with the same code, although with alternating parameters.
my_data <- read.table("./input_data/Flow_cytometry_NKT_PBMC_Memory_Ki67_EcN.csv",
header = TRUE,
sep = ",",
stringsAsFactors = FALSE)
library(tidyverse)
library(ggpubr)
library(rstatix)
library(datarium)
library(nlme)
library(lme4)
str(my_data)
boxplot(score ~ group*time,
col=c("white","lightgray"),my_data)
fm1 <- lme(score ~ time + group + time * group, data = my_data, method = "REML", random = ~ 1 | department, na.action=na.omit)
anova(fm1)
lme.pre.pd1 <- lme(score ~ time + group + time * group,
data = my_data, method = "REML",
random = ~ 1 | department, na.action=na.omit)
summary(lme.pre.pd1)
lme.pre.pd1
anova(lme.pre.pd1)
?geom_line
# There is no need for temporal autocorrelation (p-value not significant)
lme.pre.pd2 <- lme(score ~ time + group + time * group,
data = my_data, method = "REML",
cor = corAR1(), random = ~ 1 | id | department, na.action=na.omit)
lme.pre.pd2
anova(lme.pre.pd1, lme.pre.pd2)
# Rest of code
aov.pd.ls1 <- anova(lme.pre.pd1)
aov.pd.ls1
res.aov2 <- aov(score ~ group + time, data = my_data)
summary(res.aov2)
res.aov3 <- aov(score ~ group + time + group:time, data = my_data)
summary(res.aov3)
TukeyHSD(res.aov2)
#lmer (lme4)
fit1 <- lmer(score ~ group + time + (1 | department), REML=F, data = my_data)
summary(fit1)
drop1(fit1, test = "Chisq")
fit2 <- lmer(score ~ group + time + (1 + time | id), REML=F, data = my_data)
summary(fit2)
drop1(fit2, test = "Chisq")
# Here, the analysis of one of the immunological data files is showcased. All other immunological files that are present within the data repository were run with the same code, although with alternating parameters.
my_data <- read.table("./input_data/Flow_cytometry_NKT_PBMC_Memory_Ki67_EcN.csv",
header = TRUE,
sep = ",",
stringsAsFactors = FALSE)
str(my_data)
boxplot(score ~ group*time,
col=c("white","lightgray"),my_data)
fm1 <- lme(score ~ time + group + time * group, data = my_data, method = "REML", random = ~ 1 | department, na.action=na.omit)
boxplot(score ~ group*time,
col=c("white","lightgray"),my_data)
fm1 <- lme(score ~ time + group + time * group, data = my_data, method = "REML", random = ~ 1 | department, na.action=na.omit)
anova(fm1)
lme.pre.pd1 <- lme(score ~ time + group + time * group,
data = my_data, method = "REML",
random = ~ 1 | department, na.action=na.omit)
summary(lme.pre.pd1)
lme.pre.pd1
anova(lme.pre.pd1)
lme.pre.pd2 <- lme(score ~ time + group + time * group,
data = my_data, method = "REML",
cor = corAR1(), random = ~ 1 | id | department, na.action=na.omit)
lme.pre.pd2
anova(lme.pre.pd1, lme.pre.pd2)
aov.pd.ls1 <- anova(lme.pre.pd1)
aov.pd.ls1
res.aov2 <- aov(score ~ group + time, data = my_data)
summary(res.aov2)
res.aov3 <- aov(score ~ group + time + group:time, data = my_data)
summary(res.aov3)
TukeyHSD(res.aov2)
fit1 <- lmer(score ~ group + time + (1 | department), REML=F, data = my_data)
summary(fit1)
drop1(fit1, test = "Chisq")
fit2 <- lmer(score ~ group + time + (1 + time | id), REML=F, data = my_data)
summary(fit2)
drop1(fit2, test = "Chisq")
boxplot(score ~ group*time,
col=c("white","lightgray"),my_data)
# Here, the analysis of one of the immunological data files is showcased. All other immunological files that are present within the data repository were run with the same code, although with alternating parameters.
my_data <- read.table("./input_data/Flow_cytometry_NKT_PBMC_Memory_Ki67_EcN.csv",
header = TRUE,
sep = ",",
stringsAsFactors = FALSE)
boxplot(score ~ group*time,
col=c("white","lightgray"),my_data)
fm1 <- lme(score ~ time + group + time * group, data = my_data, method = "REML", random = ~ 1 | department, na.action=na.omit)
anova(fm1)
lme.pre.pd1 <- lme(score ~ time + group + time * group,
data = my_data, method = "REML",
random = ~ 1 | department, na.action=na.omit)
summary(lme.pre.pd1)
lme.pre.pd1
anova(lme.pre.pd1)
# There is no need for temporal autocorrelation (p-value not significant)
lme.pre.pd2 <- lme(score ~ time + group + time * group,
data = my_data, method = "REML",
cor = corAR1(), random = ~ 1 | id | department, na.action=na.omit)
lme.pre.pd2
anova(lme.pre.pd1, lme.pre.pd2)
# Rest of code
aov.pd.ls1 <- anova(lme.pre.pd1)
aov.pd.ls1
res.aov2 <- aov(score ~ group + time, data = my_data)
summary(res.aov2)
res.aov3 <- aov(score ~ group + time + group:time, data = my_data)
summary(res.aov3)
TukeyHSD(res.aov2)
#lmer (lme4)
fit1 <- lmer(score ~ group + time + (1 | department), REML=F, data = my_data)
summary(fit1)
drop1(fit1, test = "Chisq")
fit2 <- lmer(score ~ group + time + (1 + time | id), REML=F, data = my_data)
summary(fit2)
drop1(fit2, test = "Chisq")
