Skip to content

Instantly share code, notes, and snippets.

@eduardofox2
Created January 21, 2020 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardofox2/8a59213b89da8d64389cc857bdf19675 to your computer and use it in GitHub Desktop.
Save eduardofox2/8a59213b89da8d64389cc857bdf19675 to your computer and use it in GitHub Desktop.
R Script containing raw [numeric] data, statistical analyses, and plotting codes behind the scientific paper 'Fire Ant Venom Alkaloids Inhibit Biofilm Formation'
#Data analysis and plotting of figures for the paper
#Fire Ant Venom Alkaloids Inhibit Biofilm Formation
#available from www.ncbi.nlm.nih.gov/pmc/articles/PMC6669452/ or https://dx.doi.org/10.3390%2Ftoxins11070420
#############################Written by Eduardo G. P. Fox in 2017, Guangzhou, P.R.China########################
#Based on data provided by coauthors, after long negotiation against resistance to scripting & transparency
#Please direct questions/comments to profile at www.researchgate.net/profile/Eduardo_Fox or @ofoxofox (Twitter)
#Loading useful functions
#New Function to regress log10
antilog<-function(lx,base)
{
lbx<-lx/log(exp(1),base=10)
result<-exp(lbx)
result
}
#Loading necessary packages [install.packages if locally missing.]
library(reshape2)
library(ggplot2)
library(ggthemes)
library(plyr)
library(cowplot)
#Data input and formatting from raw data as provided by 1st author Danielle Bruno and responsible postdoc Livia Cardoso
#Surface conditioning vs. Cell adhesion
#Quantification of Biofilm Formation
Poly.sol<-
data.frame(
CTL = c(0, 0, 0, 0),
c100 = c(12.31961, 13.05841, 15.937, 14.954),
c500 = c(42.41197, 33.01553, 32.34423, 27.23132),
c750 = c(51.29201, 44.00102, 56.87009, 42.16636),
c1000 = c(45.61521, 37.07386, 61.28448, 68.62085),
c5000 = c(52.50368, 45.48918, 72.19076, 80.78874)
)
Steel.sol<-
data.frame(
CTL = c(0, 0, 0, 0),
c100 = c(12.47, 13.29, 12.99, 14.58),
c500 = c(41.2, 42.3, 41.5, 40.9),
c750 = c(43.4, 44.2, 42.9, 42.5),
c1000 = c(57.6, 60, 58.5, 55.86),
c5000 = c(57.4, 63.9, 59.1, 55.8)
)
#Antimicrobial activity: halo of inhibition
halo.sol<-
data.frame(
CTL = c(0, 0, 0),
c500 = c(1, 1.5, 2),
c750 = c(8, 8, 7),
c1000 = c(9, 10, 13),
c5000 = c(13, 15, 15)
)
#Surface conditioning vs. Cell viability
Cell.poly.sol<-
data.frame(
CTL = c(2.19, 2.13, 2.01),
c1000 = c(1.27, 1.57, 1.71),
c5000 = c(1.66, 1.53, 1.51)
)
cell.Steel.sol.CTL <-c(2.19, 2.08, 2.28)
#cell.Steel.sol.1000 <-c(, NO GROWTH, )
#cell.Steel.sol.5000 <-c(, NO GROWTH, )
cell.Steel.sol<-data.frame(cell.Steel.sol.CTL)
names(cell.Steel.sol)<-c("CTL")
Cell.poly.sol1 <- lapply(Cell.poly.sol, antilog)
#Inhibition of mature biofilm
Sup.Poly.sol<-
data.frame(
CTL = c(0.00000, 0.00000, 0.00000, 0.00000),
c100 = c(14.67397, 15.12583, 14.67420, 16.12102),
c500 = c(29.27011, 27.62474, 31.21019, 28.92321),
c750 = c(30.12102, 32.26171, 31.12013, 34.21019),
c1000 =c(43.69667, 40.01106, 37.15499, 37.46796),
c5000 =c(56.20852, 44.60165, 47.34607, 47.56630)
)
Sup.Steel.sol<-
data.frame(
CTL = c(0.00, 0.00, 0.00),
c100= c(-7.12, -3.90, -6.25),
c500= c(-10.12, -2.38, -11.03),
c750= c(-11.27, -14.70, -12.90),
c1000=c(-13.27, -18.60, -16.60),
c5000=c(-15.60, -19.43, -12.90)
)
#Preparing sets to be compared in plots as data lists to be melted to long format
Sol.F1<-list(Poly.sol,Steel.sol)
names(Sol.F1)<-c("Poly","Steel")
Sup.Sol.F<-list(Sup.Poly.sol,Sup.Steel.sol)
names(Sup.Sol.F)<-c("Poly","Steel")
#Acquiring descriptive stats
summary.Sol.Steel<-ddply(subset(melt(Sol.F1),L1=="Steel"), c("variable"), summarise, min=min(value, na.rm=T),
max =max(value, na.rm=T),mean=mean(value, na.rm=T), sd=sd(value, na.rm=T), se = sd/sqrt(length(value)))
summary.Sol.Poly<-ddply(subset(melt(Sol.F1),L1=="Poly"), c("variable"), summarise, min=min(value, na.rm=T),
max =max(value, na.rm=T),mean=mean(value, na.rm=T), sd=sd(value, na.rm=T), se = sd/sqrt(length(value)))
summary.halo.sol<-ddply(melt(halo.sol), c("variable"), summarise, min=min(value, na.rm=T),
max =max(value, na.rm=T),mean=mean(value, na.rm=T), sd=sd(value, na.rm=T), se = sd/sqrt(length(value)))
summary.Sup.Sol.Steel<-ddply(subset(melt(Sup.Sol.F),L1=="Steel"), c("variable"), summarise, min=min(value, na.rm=T), max =max(value, na.rm=T),mean=mean(value, na.rm=T), sd=sd(value, na.rm=T), se = sd/sqrt(length(value)))
summary.Sup.Sol.Poly<-ddply(subset(melt(Sup.Sol.F),L1=="Poly"), c("variable"), summarise, min=min(value, na.rm=T), max =max(value, na.rm=T),mean=mean(value, na.rm=T), sd=sd(value, na.rm=T), se = sd/sqrt(length(value)))
#Plotting results
#Inhibition halo formation
ggplot(melt(halo.sol), aes(x = variable, y = value)) +
geom_jitter(width = 0.1, size=2, na.rm = TRUE)+
stat_summary(fun.ymin = function(x) mean(x) - 0, fun.ymax = function(x) mean(x) + sd(x),
geom = "errorbar", size=1, width=0.1, na.rm = TRUE)+
theme(panel.border = element_rect(color="black", size=0.5, linetype="solid"))+
theme(legend.position=c(0.1, 0.8), legend.title = element_text(size=11, face="bold"),
axis.text.x = element_text(face="bold", size=11, angle=45, hjust=.5, vjust=.5), axis.title=element_text(size=15))+
labs(title = "Halo diameter", font="bold", size=16, x="[Solenopsin]", y = "mm" )+
theme_classic()
#Estimating MIC based on transformed linear regression [J. Antimicrob. Chemother. 2008, v. 61, p. 1295–1301].
#loading concentration values
conc_sol_MIC<-c(500, 750, 1000, 5000)
#calculating concentration and halo equivalents to enter linear regression
y_MIC<-c('^'(colMeans(halo.sol[,-1])/2,2))
x_MIC<-log(conc_sol_MIC, 10)
#producing the log linear regression of converted halos
regression<-lm(y_MIC~x_MIC)
plot(x_MIC,y_MIC,col = "blue",main = "MIC calculation", xlim=c(2,4),
abline(lm(y_MIC~x_MIC)),cex = 1.3,pch = 16,xlab = "Log[mg.ul]",ylab = "(halo/2)^2")
#finding y at origin of x
x0<-abs(as.numeric(regression$coeff)[1])/as.numeric(regression$coeff)[2]
#converting back to concentration
MIC = antilog(x0)
#Quantification of Biofilm Formation
ggplot(melt(Sol.F1), aes(x = variable, y = value)) +
geom_point(aes(col=L1), size=1, na.rm = TRUE, position = position_jitterdodge(jitter.width = 0.15, dodge.width = 0.5))+
stat_summary(aes(fill=L1), fun.ymin = function(x) mean(x) - 0, fun.ymax = function(x) mean(x) + sd(x),
geom = "errorbar", position=position_dodge(width=0.5), size=1, width=0.2, na.rm = TRUE)+
scale_y_continuous(name= 'diameter (mm)', limits=c(0,100), breaks=c(0,25,50,75,100))+
theme(panel.border = element_rect(color="black", size=0.5, linetype="solid"))+
theme(legend.position=c(0.1, 0.8), legend.title = element_text(size=11, face="bold"),
axis.text.x = element_text(face="bold", size=11, angle=45, hjust=.5, vjust=.5), axis.title=element_text(size=15))+
labs(title = "Halo diameter", font="bold", size=16)+
theme_classic()
#Viable cells recovered
ggplot(melt(Cell.poly.sol), aes(x = variable, y = value)) +
geom_jitter(width = 0.1, size=2, na.rm = TRUE)+
stat_summary(fun.ymin = function(x) mean(x) - 0, fun.ymax = function(x) mean(x) + sd(x),
geom = "errorbar", size=1, width=0.1, na.rm = TRUE)+
theme(panel.border = element_rect(color="black", size=0.5, linetype="solid"))+
theme(legend.position=c(0.1, 0.8), legend.title = element_text(size=11, face="bold"),
axis.text.x = element_text(face="bold", size=11, angle=45, hjust=.5, vjust=.5), axis.title=element_text(size=15))+
labs(title = "Viable Cells Count", font="bold", size=16, x="[ ]Solenopsins Extract (ug/mL)", y = "Log.CFU/mL" )+
theme_classic()
#Reduction of mature biofilm
ggplot(melt(Sup.Sol.F), aes(x = variable, y = value)) +
geom_point(aes(col=L1), size=1, na.rm = TRUE, position = position_jitterdodge(jitter.width = 0.15, dodge.width = 0.5))+
stat_summary(aes(fill=L1), fun.ymin = function(x) mean(x) - 0, fun.ymax = function(x) mean(x) + sd(x),
geom = "errorbar", position=position_dodge(width=0.5), size=1, width=0.2, na.rm = TRUE)+
scale_fill_manual(name= c("Material"), values = c("white", "gray"), position = "left") +
scale_x_discrete(name= '[ ]Solenopsins Extract (ug/mL)', drop=FALSE)+
scale_y_continuous(name= '% Inhibition', limits=c(-30,100), breaks=c(0,25,50,75,100))+
theme_set(theme_bw())+
theme(panel.border = element_rect(color="black", size=0.5, linetype="solid"))+
theme(legend.position=c(0.1, 0.8), legend.title = element_text(size=11, face="bold") , axis.text.x = element_text(face="bold", size=11, angle=45, hjust=.5, vjust=.5), axis.title=element_text(size=15))+
labs(title = "Solenopsins", font="bold", size=16)
#Statistical Analysis
wilcox.test(melt(Sol.F1$Poly)$value,melt(Sol.F1$Steel)$value, paired = TRUE)# effect of solenopsin on both materials not different!
wilcox.test(melt(Sol.F1$Poly)$value[1:4],melt(Sol.F1$Steel)$value[1:4], paired = TRUE)#same, zero
wilcox.test(melt(Sol.F1$Poly)$value[5:8],melt(Sol.F1$Steel)$value[5:8], paired = TRUE)#V = 7, p-value = 0.625
wilcox.test(melt(Sol.F1$Poly)$value[9:12],melt(Sol.F1$Steel)$value[9:12], paired = TRUE)#V = 1, p-value = 0.25
wilcox.test(melt(Sol.F1$Poly)$value[13:16],melt(Sol.F1$Steel)$value[13:16], paired = TRUE)#V = 7, p-value = 0.625
wilcox.test(melt(Sol.F1$Poly)$value[17:20],melt(Sol.F1$Steel)$value[17:20], paired = TRUE)#V = 4, p-value = 0.875
wilcox.test(melt(Sol.F1$Poly)$value[21:24],melt(Sol.F1$Steel)$value[21:24], paired = TRUE)#V = 6, p-value = 0.875
dunn.test( melt(Sol.F1)$value[1:28], melt(Sol.F1)$variable[1:28])#testing between treatments in Solenopsins on Polystirene
#dunn.test shows no difference from first group to control which is rather nuts
# Kruskal-Wallis chi-squared = 24.716, df = 5, p-value = 0
#
#
# Comparison of x by group
# (No adjustment)
#Col Mean-|
#Row Mean | CTL 100 500 750 1000
#---------+-------------------------------------------------------
# 100 | -1.205031
# | 0.1141
# |
# 500 | -2.108805 -0.782690
# | 0.0175 0.2169
# |
# 750 | -3.213417 -1.739313 -0.956622
# | 0.0007 0.0410 0.1694
# |
# 1000 | -3.514675 -2.000210 -1.217519 -0.260896
# | 0.0002 0.0227 0.1117 0.3971
# |
# 5000 | -4.016771 -2.435038 -1.652347 -0.695725 -0.434828
# | 0.0000 0.0074 0.0492 0.2433 0.3318
#
dunn.test( melt(Sol.F1)$value[25:48], melt(Sol.F1)$variable[25:48])#testing between treatments in Solenopsins on Steel
#
# Kruskal-Wallis rank sum test
#
#data: x and group
#Kruskal-Wallis chi-squared = 21.855, df = 5, p-value = 0
#
#
# Comparison of x by group
# (No adjustment)
#Col Mean-|
#Row Mean | CTL 100 500 750 1000
#---------+-------------------------------------------------------
# 100 | -0.801744
# | 0.2114
# |
# 500 | -1.603489 -0.801744
# | 0.0544 0.2114
# |
# 750 | -2.405234 -1.603489 -0.801744
# | 0.0081 0.0544 0.2114
# |
# 1000 | -3.607851 -2.806106 -2.004362 -1.202617
# | 0.0002 0.0025 0.0225 0.1146
# |
# 5000 | -3.607851 -2.806106 -2.004362 -1.202617 0.000000
# | 0.0002 0.0025 0.0225 0.1146 0.5000
#
Now between conditioning on the same materials
#Polysterene
wilcox.test(melt(Sol.F1$Poly)$value,melt(Rham.F1$Poly)$value)#W = 733, p-value = 0.00228# conditioning with solenopsin was different from rhamnolipid
wilcox.test(melt(Sol.F1$Poly)$value[5:8],melt(Rham.F1$Poly)$value[13:18])#[100]#W = 12, p-value = 1, not different
wilcox.test(melt(Sol.F1$Poly)$value[9:12],melt(Rham.F1$Poly)$value[25:30])#[500]#W = 23, p-value = 0.01905
wilcox.test(melt(Sol.F1$Poly)$value[13:16],melt(Rham.F1$Poly)$value[31:36])#[750]#W = 24, p-value = 0.009524
wilcox.test(melt(Sol.F1$Poly)$value[17:20],melt(Rham.F1$Poly)$value[37:42])#[1000]#W = 23, p-value = 0.01905
#Steel
wilcox.test(melt(Sol.F1$Steel)$value,melt(Rham.F1$Steel)$value)#W = 271, p-value = 0.2352, no difference of conditioning on steel!!
wilcox.test(melt(Sol.F1$Steel)$value[5:8],melt(Rham.F1$Steel)$value[9:12])#[100]#W = 0, p-value = 0.0294#borderline
wilcox.test(melt(Sol.F1$Steel)$value[9:12] ,melt(Rham.F1$Steel)$value[18:20])#[500]#W = 0, p-value = 0.05714#borderline
wilcox.test(melt(Sol.F1$Steel)$value[13:16] ,melt(Rham.F1$Steel)$value[21:24])#[750]#W = 0, p-value = 0.02857#broderline
wilcox.test(melt(Sol.F1$Steel)$value[17:20] ,melt(Rham.F1$Steel)$value[25:28])#[1000]、W = 7, p-value = 0.8857#same!
wilcox.test(melt(Sup.Sol.F$Poly)$value,melt(Sup.Sol.F$Steel)$value) #W = 426, p-value = 9.445e-08# effect of solenopsin on both materials is different
wilcox.test(melt(Sup.Sol.F$Poly)$value[1:4],melt(Sup.Sol.F$Steel)$value[1:3])#same, zero
wilcox.test(melt(Sup.Sol.F$Poly)$value[5:8],melt(Sup.Sol.F$Steel)$value[4:7])#W = 16, p-value = 0.02857
wilcox.test(melt(Sup.Sol.F$Poly)$value[9:12],melt(Sup.Sol.F$Steel)$value[8:10])#W = 12, p-value = 0.05714 # borderline
wilcox.test(melt(Sup.Sol.F$Poly)$value[13:16],melt(Sup.Sol.F$Steel)$value[11:13])#V = 7, p-value = 0.625 # W = 12, p-value = 0.05714
wilcox.test(melt(Sup.Sol.F$Poly)$value[17:20],melt(Sup.Sol.F$Steel)$value[13:15])#V = 4, p-value = 0.875 # W = 12, p-value = 0.05714
wilcox.test(melt(Sup.Sol.F$Poly)$value[21:24],melt(Sup.Sol.F$Steel)$value[16:18])#V = 6, p-value = 0.875 # W = 12, p-value = 0.05714, likely N was too low
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment