Description Usage Arguments Details Value Author(s) See Also Examples
Pull out a “quad” of samples from a larger data frame, then plot the pairs of samples in the quad against one another.
1 2 | quad.table(otu, control.before, control.after, treatment.before, treatment.after)
quad.plot(quad)
|
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 |
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.
quad.table |
returns a data frame |
quad.plot |
returns a ggplot object |
Scott Olesen swo@mit.edu
z.transform.table
f.transform.table
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 | # 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)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.