Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The html_vignette output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The html_vignette format:

Vignette Info

Note the various macros within the vignette section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the title field and the \VignetteIndexEntry to match the title of your vignette.

Styles

The html_vignette template includes a basic CSS theme. To override this theme you can specify your own CSS in the document metadata as follows:

output: 
  rmarkdown::html_vignette:
    css: mystyles.css

Figures

The figure sizes have been customised so that you can easily put two images side-by-side.

plot(1:10)
plot(10:1)

You can enable figure captions by fig_caption: yes in YAML:

output:
  rmarkdown::html_vignette:
    fig_caption: yes

Then you can use the chunk option fig.cap = "Your figure caption." in knitr.

More Examples

You can write math expressions, e.g. $Y = X\beta + \epsilon$, footnotes^[A footnote here.], and tables, e.g. using knitr::kable().

knitr::kable(head(mtcars, 10))

Also a quote using >:

"He who gives up [code] safety for [code] speed deserves neither." (via)

z<- (dlply(cz2,"fileName",function(x){ unlist(apply(x,1,function(x){as.numeric(rep(x["binDiameter"],x["binCounts"]))})) }))
datadir <- "./exampleFlowDataset2/"
souqce("./src/coulterZ2reader.R")
lrgdf <- coulterZ2reader(datadir)

This next part must be customized for your application! Look at the comments!

# here we put into the next column (ncol+1) through to 
#   enough columns (ncol+4), the colsplit of
lrgdf[,(ncol(lrgdf)+1):(ncol(lrgdf)+4)] <- colsplit(
# splitting the filename, sans extension, on underscores...
  string=sub(".=#Z2","",lrgdf$fz),pattern="_",
# and give them names for each field.
  names=c("date","time","media","blankOrNot"))
# for this to work, you have to have the same number of underscore
#   delimited fields in each filename. You can use something other
#   than underscore too, just change it in colsplit argument pattern
head(lrgdf)
lrgdf$fz <- as.character(lrgdf$fz)
lrgdf$date <- as.Date(x=as.character(lrgdf$date),format="%y%m%d")
lrgdf$time <- 
  as.numeric(sub("(\\d{1,2})\\d{2}","\\1",lrgdf$time))*60+
  as.numeric(sub("\\d{1,2}(\\d{2})","\\1",lrgdf$time))
lrgdf$blankOrNot <- grepl("blank",lrgdf$blankOrNot)
lrgdf$media<-factor(lrgdf$media)
head(lrgdf)

For coulter, blanks are important to see how big the background bubbles and crud are.

ggplot(lrgdf)+aes(x=bins,y=height,col=factor(time))+
    geom_point()+facet_wrap(~blankOrNot)+scale_y_log10()

ggplot(subset(lrgdf,bins>2.0))+aes(x=bins,y=height,col=factor(time))+
    geom_point()+facet_wrap(~blankOrNot)+scale_y_log10()

ggplot(subset(lrgdf,bins>2.5))+aes(x=bins,y=height,col=factor(time))+
    geom_point()+facet_wrap(~blankOrNot)+scale_y_log10()

ggplot(subset(lrgdf,bins>3.0))+aes(x=bins,y=height,col=factor(time))+
    geom_point()+facet_wrap(~blankOrNot)+scale_y_log10()

subdf <- subset(lrgdf,bins>2.5&bins<7.0&blankOrNot==F)

Below we use aggregate to just wrap up all events detected per sample. Then we adjust by a scaling factor to adjust for the ammount counted, and the dilution factor. You will need to change this!

counts <- aggregate(height~fz+date+time+media,data=subdf,FUN=sum)
counts$e6cellsml <- counts$height/2000
# that adjustment must be adjusted!

g<-ggplot(counts)+
    aes(x=time/60,y=e6cellsml)+
    geom_point()+
    scale_y_log10(limits=c(1,7),breaks=seq(1,7,1))+
    scale_x_continuous(breaks=seq(09,21,1),labels=(09:21))+
    xlab("Hours")+
    ylab("million cells per ml")
g
#ggsave("151206exp152counts.pdf",g,width=8,height=6)

How about going back to distributions for alternative stats and representations?

distributions <- list()
for (fz in unique(subdf$fz)) {
  distributions[[fz]] <- df2distribution(subset(subdf,fz==fz))
}
hist(distributions[[1]])


darachm/rheocyto documentation built on May 14, 2019, 6:07 p.m.