plot.CT: Plot function

Description Usage Arguments Author(s) Examples

View source: R/plot.CT.R

Description

Plot Barplot with Error Bar(se or sd)

Usage

1
2
3
4
5
## S3 method for class 'CT'
plot(x, ...)


 

Arguments

x

~~Describe cal.CT ~~

...

Author(s)

yz pan, xy yan, jx li

Examples

 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")
  }

Example output

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")
}

qPCR.CT documentation built on May 30, 2017, 3:51 a.m.