visReps: Visualize where replicates occur in an ionomics run

Description Usage Arguments Value Author(s) Examples

Description

Takes a vector of when each replicate occurred (e.g. if two samples A and B were run twice in this order A,B,A,B the vector would be 1,1,2,2 if the replicates were run A,A,B,B the vector would be 1,2,1,2)

Usage

1
visReps(vec)

Arguments

vec

Vector of replicate counts.

Value

Returns ggplot object

Author(s)

Greg Ziegler

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
set.seed(1)
x <- rnorm(100)
y <- rnorm(100)
z <- rnorm(100)
x <- c(-10, x, 10)
y <- c(-20, y, 20)
z <- c(-30, z, 30)
df <- data.frame(id=sample(LETTERS,length(x),replace=TRUE),x,y,z)
numReps <- as.data.frame(table(df$id))
for(i in numReps$Var1){
  df$repNum[df$id == i & !is.na(df$id)] <- c(1:numReps$Freq[numReps$Var1 == i])
}  
visReps(df$repNum)


## The function is currently defined as
function (vec) 
{
    require(ggplot2)
    vec <- na.omit(vec)
    df <- data.frame(sampleNum = factor(1:length(vec), ordered = TRUE), 
        repNum = as.factor(vec), one = 1)
    p <- ggplot(df, aes(x = sampleNum, y = one, fill = repNum, 
        colour = repNum, width = 0.5)) + geom_bar(stat = "identity", 
        position = "dodge") + theme(axis.line = element_blank(), 
        axis.text.x = element_blank(), axis.text.y = element_blank(), 
        axis.ticks = element_blank(), axis.title.y = element_blank(), 
        panel.background = element_blank(), panel.border = element_blank(), 
        panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        plot.background = element_blank())
    print(p)
  }

gziegler/ionomicsUtils documentation built on June 20, 2019, 8:04 p.m.