library(compositions)
library(ggplot2)
library(reshape2)
library(tibble)
path="041918BEillcus515F-pr.fasta.otus.fa.OTU.clean.txt"
data <- read.table(path, header=T, sep="\t")
data2 <-data[,6:13]
#Create a count compositional dataset and perform a clr transformation
dc = ccomp(t(data2))
comp = clr(dc)
names(comp)<-data[,1]
compdf<-as.data.frame(comp)
compdf$tissue<-c("Fat Body","Ovary","Spermatheca","Egg","Fat Body","Ovary","Spermatheca","Egg")
compdf$spotted<-c(TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE)
longcomp<- melt(compdf, value.name="clr")
Using tissue, spotted as id variables
ggplot(longcomp[longcomp$variable=="OTU_6",], aes(x=tissue, y=clr, fill=spotted)) + geom_bar(stat="identity", position="dodge") + ggtitle("Presence of Nosema maddoxi OTU in Nezara viridula") + ylab("Centered Log Ratio") + xlab("Tissue")
ggplot(data = longcomp[longcomp$variable=="OTU_6",], aes(x = spotted, y = clr, group = tissue)) + geom_boxplot(width=0.3, aes(group=spotted), fill='#A4A4A4') +
geom_line(aes(color = tissue), size = 1) +
geom_point(aes(color = tissue), size = 2) +
ylab("Centered Log Ratio") + xlab("Spotted") + ggtitle("Presence of Nosema maddoxi OTU in Nezara viridula") +
guides(color=guide_legend("Tissue"))
longcomp[longcomp$variable=="OTU_6",]
t(data[6,])
6
otu.name "OTU_6"
Taxonomy "___af327408.1__gi:33340569_ ;k__fungi;p__microsporidia;c__microsporidia;o__microsporidia;f__burenellidae;g__vairimorpha;s__vairimorpha cheracis;superkingdom__eukaryota;suborder__pansporoblastina"
Percent.Homology "96.26168"
evalue "6.11e-94"
bitscore "347.533"
X1.Nezara.viridula.Infected.Fat.Body "4014"
X2.Nezara.viridula.Infected.Ovary "4692"
X3.Nezara.viridula.Infected.Spermatheca "199"
X4.Nezara.viridula.Infected.Egg "132"
X5.Nezara.viridula.Clean.Fat.Body "22"
X6.Nezara.viridula.Clean.Ovary "24"
X7.Nezara.viridula.Clean.Spermatheca "20"
X8.Nezara.viridula.Clean.Egg "13"
tempdf <-as.data.frame(t(compdf[,1:392]))
tempdf$taxa <-data$Taxonomy
write.table(tempdf, file="clrOTU.txt", sep="\t")