Learn R Programming

texmexseq (version 0.3)

quad.table: Create and plot ``quads'' of samples

Description

Pull out a ``quad'' of samples from a larger data frame, then plot the pairs of samples in the quad against one another.

Usage

quad.table(otu, control.before, control.after, treatment.before, treatment.after) quad.plot(quad)

Arguments

otu
data frame of a z- or F-transformed OTU table
control.before
name of the sample (in the OTU table) from the control unit before the treatment is applied to the treatment unit
control.after
sample from the control unit after treatment is applied
treatment.before
sample from the treatment unit before the treatment is applied
treatment.after
sample from the treatment unit after the treatment is applied
quad
a quad generated by quad.table

Value

Details

texmexseq was designed to compare four samples at a time: two are ``control'' samples (before and after the treatment was applied to the ``treatment'' samples), the other two are the treatment samples.

quad.table will grab the columns with the four given names and make them into a new data frame (with OTU IDs kept as a separate column). This object can be plugged into quad.plot for viewing. quad.plot expects that the OTU table will be z- or F-transformed.

See Also

z.transform.table f.transform.table

Examples

Run this code
# make up some data
sim.data <- function() rpoilog(1000, 1.0, 1.0, condS=TRUE)
otu <- data.frame(sample0=sim.data())
for (i in 1:10) otu[[paste('sample', i, sep='')]] <- sim.data()
otu.ids <- paste('otu', seq(1:1000), sep='')
rownames(otu) <- otu.ids
z.table <- z.transform.table(otu)

# pull out a quad, imagining that samples 1 and 2 were the control samples
# and 3 and 4 were the treatment
q <- quad.table(z.table, 'sample1', 'sample2', 'sample3', 'sample4')

# plot it
p <- quad.plot(q)
p

# ok, it's just a blob because we generated the data, but imagine we
# were particularly interested in OTUs that bloomed in the treatment
# but not in the control
interesting.otus <- filter(q, d.treatment > 2, d.control < 0)

# we can plot those in a different color
p + geom_point(data=interesting.otus, color='red')

# or see what their names are
head(arrange(interesting.otus, desc(d.treatment)))

Run the code above in your browser using DataLab