Description Usage Arguments Author(s) Examples
Plot Barplot with Error Bar(se or sd)
1 2 3 4 5 |
x |
~~Describe |
... |
yz pan, xy yan, jx li
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function(cal.CT = cal.CT, ...)
{
cal.mean<-mean(cal.CT)
cal.sd <-sd(cal.CT)
cal.se <-sd(cal.CT)/sqrt(length(cal.CT[,1]))
cal.sdd <-cal.sd/cal.mean
cal.see <-cal.se/cal.mean
#plot
# barplot(as.matrix(cal.CT)
# barplot(as.matrix(cal.mean), beside=TRUE,
# legend.text=names(cal.mean),
# args.legend=list(bty="n",horiz=TRUE),
# col=brewer.pal(3,"Set2"),
# border="white",
# ylim=c(0,2),
# ylab=paste("Gene Expression of", tr_gene_name,sep = ""),
# main="QPCR Figures")
#
# box(bty="l")
#Creating Bar charts with vertical error bars
maxy <-max(round(cal.mean, digits = 0))+1
x<-barplot(cal.mean,beside=T,legend.text=names(cal.mean),
args.legend=list(bty="n",horiz=T),
col=brewer.pal(3,"Set2"),border="white",ylim=c(0,maxy),
ylab=paste("Gene Expression of", tr_gene_name,sep = ""),
main="QPCR Figures")
# arrows(x0=x,
# y0=cal.mean*0.95,
# x1=x,
# y1=cal.mean*1.05,
# angle=90,
# code=3,
# length=0.04,
# lwd=0.4)
#Creating a function
errorbars<-function(x,y,upper,lower=upper,length=0.04,lwd=0.4,...) {
arrows(x0=x,
y0=y+upper,
x1=x,
y1=y-lower,
angle=90,
code=3,
length=length,
lwd=lwd)
}
#errorbars(x,cal.mean,0.05*cal.mean)
errorbars(x,cal.mean, cal.see)
box(bty="l")
}
|
Loading required package: RColorBrewer
function (cal.CT = cal.CT, ...)
{
cal.mean <- mean(cal.CT)
cal.sd <- sd(cal.CT)
cal.se <- sd(cal.CT)/sqrt(length(cal.CT[, 1]))
cal.sdd <- cal.sd/cal.mean
cal.see <- cal.se/cal.mean
maxy <- max(round(cal.mean, digits = 0)) + 1
x <- barplot(cal.mean, beside = T, legend.text = names(cal.mean),
args.legend = list(bty = "n", horiz = T), col = brewer.pal(3,
"Set2"), border = "white", ylim = c(0, maxy), ylab = paste("Gene Expression of",
tr_gene_name, sep = ""), main = "QPCR Figures")
errorbars <- function(x, y, upper, lower = upper, length = 0.04,
lwd = 0.4, ...) {
arrows(x0 = x, y0 = y + upper, x1 = x, y1 = y - lower,
angle = 90, code = 3, length = length, lwd = lwd)
}
errorbars(x, cal.mean, cal.see)
box(bty = "l")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.