Skip to content

Commit

Permalink
version 0.1-5
Browse files Browse the repository at this point in the history
  • Loading branch information
Claus Ekstrom authored and gaborcsardi committed Apr 11, 2011
0 parents commit 5db7315
Show file tree
Hide file tree
Showing 19 changed files with 614 additions and 0 deletions.
14 changes: 14 additions & 0 deletions DESCRIPTION
@@ -0,0 +1,14 @@
Package: kulife
Version: 0.1-5
Title: Data sets and functions from the Faculty of Life Sciences,
University of Copenhagen
Author: Claus Ekstrom <ekstrom@life.ku.dk>, Ib M. Skovgaard
<ims@life.ku.dk>, Torben Martinussen <tma@life.ku.dk>
Maintainer: Claus Ekstrom <ekstrom@life.ku.dk>
Enhances: XML
Description: Provides various functions and data sets from experiments
at the Faculty of Life Sciences, University of Copenhagen
License: GPL-2
Packaged: 2011-04-11 19:17:53 UTC; claus
Repository: CRAN
Date/Publication: 2011-04-12 06:22:23
77 changes: 77 additions & 0 deletions R/rootonorm.r
@@ -0,0 +1,77 @@
rootonorm <- function(x, breaks="Sturges",
type=c("hanging", "deviation"),
scale=c("sqrt", "raw"),
zeroline=TRUE,
linecol="red", rectcol="lightgrey",
xlab=xname,
ylab="Sqrt(frequency)",
ylim=NULL,
mu=mean(x), s=sd(x),
gap=0.1, ...) {


if (!is.numeric(x))
stop("'x' must be numeric")

# Fix the xlabel if it isn't specified
xname <- deparse(substitute(x))

scale <- match.arg(scale)
if (is.character(scale) && scale == "raw") {
scale <- match.fun("as.numeric")
if (missing(ylab)) {
ylab <- "Frequency"
}
}
else {
scale <- match.fun(scale)
}

type <- match.arg(type)

h <- hist(x, breaks=breaks, plot=FALSE)
if (!h$equidist) stop("breaks must be equally spaced")

nbins <- length(h$counts)
nobs <- sum(h$counts)

expected <- nobs*diff(pnorm(h$breaks, mu, s))

d.gap <- min(diff(h$breaks)) * gap /2

plot.range <- range(pretty(h$breaks))
z <- seq(plot.range[1], plot.range[2], length.out=200)
z.y <- min(diff(h$breaks))*nobs*dnorm(z, mu, s)

minval <- min(scale(expected)-scale(h$counts))

if (is.null(ylim)) {
ylim <- c(minval, scale(max(expected,z.y)))
}

plot(z, z, type="n",
xlab=xlab,
ylab=ylab,
yaxt="n",
ylim=ylim,
...)

if (type=="deviation") {
for(i in 1:nbins) {
rect(h$breaks[i]+d.gap, scale(expected[i])-scale(h$counts[i]),
h$breaks[i+1]-d.gap, 0, col=rectcol)
}
}
else {
for(i in 1:nbins) {
rect(h$breaks[i]+d.gap, scale(expected[i])-scale(h$counts[i]),
h$breaks[i+1]-d.gap, scale(expected[i]), col=rectcol)
}
}

lines(z, scale(z.y), col=linecol, ...)
if (zeroline) {
abline(h=0, lty=3)
}
return(h$counts)
}
30 changes: 30 additions & 0 deletions R/writexml.R
@@ -0,0 +1,30 @@
write.xml <- function(data, file=NULL) {
# require(XML)

# Check that packages is available
if (! "XML" %in% row.names(installed.packages()) )
stop("package XML must be installed")

if(is.null(file))
stop("filename not specified")

if (!is.data.frame(data))
stop("data must be a data frame")

# Start empty XML document tree
doc <- XML:::newXMLDoc()
# Start by adding a document tag at the root of the XML file
root <- XML:::newXMLNode("document", doc=doc)

# Make output invisible
invisible(
# Iterate over all rows
lapply(1:nrow(data),
function(rowi) {
r <- XML:::newXMLNode("row", parent=root) # Create row tag
for(var in names(data)) { # Iterate over variables
XML:::newXMLNode(var, data[rowi, var], parent = r)
}
}))
invisible(XML:::saveXML(doc, file=file))
}
19 changes: 19 additions & 0 deletions build/qpcr.r
@@ -0,0 +1,19 @@
# Hent read.xls

library(gdata)

indata <- read.xls("qpcr.xls", header=TRUE)


cycle <- rep(1:45, 162/3)

line <- rep(c("wt", "rnt", "empty"), times=45*c(20, 20, 14))


flour <- indata[, seq(3, 162, 3)]

qpcr <- data.frame(flour= as.vector(as.matrix(flour[,c(1:7,seq(21,33,2))])),
lines=factor(rep(c("wt", "rnt"), times=45*c(7, 7))),
cycle=rep(1:45, 14),
experiment=rep(1:14,times=rep(45,14)))

Binary file added build/qpcr.xls
Binary file not shown.
Binary file added data/bees.rda
Binary file not shown.
Binary file added data/clotting.RData
Binary file not shown.
Binary file added data/greenland.rda
Binary file not shown.
Binary file added data/qpcr.rda
Binary file not shown.
Binary file added data/rainman.rda
Binary file not shown.
Binary file added data/superroot2.rda
Binary file not shown.
45 changes: 45 additions & 0 deletions man/bees.Rd
@@ -0,0 +1,45 @@
\name{bees}
\alias{bees}
\docType{data}
\title{
Bee data. Number of different types of bees caught.}
\description{
Number of different types of bees caught in plates of different
colours. There are four locations and within each location there are
three replicates consisting of three plates of the three different
colours (yellow, white and blue). Data are collected at 5 different
dates over the summer season. Only data from one date available until
data has been published.}
\usage{data(bees)}
\format{
A data frame with 72 observations on the following 7 variables.
\describe{
\item{\code{Locality}}{a factor with levels \code{Havreholm} \code{Kragevig} \code{Saltrup} \code{Svaerdborg}. Four different localities in Denmark.}
\item{\code{Replicate}}{a factor with levels \code{A} \code{B} \code{C}}
\item{\code{Color}}{a factor with levels \code{Blue} \code{White} \code{Yellow}. Colour of plates}
\item{\code{Time}}{a factor with levels \code{july1} \code{july14}
\code{june17} \code{june3} \code{june6}. Data collected at
different dates in summer season. Only one day is present in the
current data frame until the full data has been released.}
\item{\code{Type}}{a factor with levels \code{Bumblebees} \code{Solitary}. Type of bee.}
\item{\code{Number}}{a numeric vector. The response variable with number of bees catched.}
\item{\code{id}}{a numeric vector. The id of the clusters (each containg three plates).}
}
}
%\details{
%% ~~ If necessary, more details than the __description__ above ~~
%}
\source{
Data were kindly provided by Casper Ingerslev Henriksen, Department of
Agricultural Sciences, KU-LIFE.
Added by Torben Martinussen <tma@life.ku.dk>
}
%\references{
%% ~~ possibly secondary sources and usages ~~
%}
\examples{
data(bees)
model <- glm(Number ~ Locality + Type*Color,
family=poisson, data=bees)
}
\keyword{datasets}
52 changes: 52 additions & 0 deletions man/clotting.Rd
@@ -0,0 +1,52 @@
\name{clotting}
\alias{clotting}
\docType{data}
\title{Blood clotting for 158 rats}
\description{
Blood clotting activity (PCA) is measured for 158 Norway rats
from two locations just before (baseline) and four days after injection of
an anticoagulant (bromadiolone). Normally this would cause reduced
blood clotting after 4 days compared to the baseline, but these rats are
known to possess anticoagulent resistence to varying extent. The purpose
is to relate anticoagulent resistence to gender and location and perhaps
weight. Dose of injection is, however, admistered according to weight and gender.
}
\usage{data(clotting)}
\format{
A data frame with 158 observations on the following 6 variables.
\describe{
\item{\code{rat}}{a numeric vector}
\item{\code{locality}}{a factor with levels \code{Loc1} \code{Loc2}}
\item{\code{sex}}{a factor with levels \code{F} \code{M}}
\item{\code{weight}}{a numeric vector}
\item{\code{PCA0}}{a numeric vector with percent blood clotting activity at baseline}
\item{\code{PCA4}}{a numeric vector with percent blood clotting activity on day 4}
}
}
%\details{
%% ~~ If necessary, more details than the __description__ above ~~
%}
\source{
Ann-Charlotte Heiberg, project at
The Royal Veterinary and Agricultural University, 1999. \cr
Added by Ib M. Skovgaard <ims@life.ku.dk>
}
%\references{
%}
\examples{
data(clotting)
dim(clotting)
head(clotting)
day0= transform(clotting, day=0, pca=PCA0)
day4= transform(clotting, day=4, pca=PCA4)
day.both= rbind(day0,day4)
m1= lm(pca ~ rat + day*locality + day*sex, data=day.both)
anova(m1)
summary(m1)
m2= lm(pca ~ rat + day, data=day.both)
anova(m2)
## Log transformation suggested.
## Random effect of rat.
## maybe str(clotting) ; plot(clotting) ...
}
\keyword{datasets}
36 changes: 36 additions & 0 deletions man/greenland.Rd
@@ -0,0 +1,36 @@
\name{greenland}
\alias{greenland}
\docType{data}
\title{
Average yearly summer air temperature for Tasiilaq, Greenland
}
\description{
Average yearly summer (June, July, August) air temperature for Tasiilaq, Greenland
}
\usage{data(greenland)}
\format{
A data frame with 51 observations on the following 2 variables.
\describe{
\item{\code{year}}{year}
\item{\code{airtemp}}{average air temperature (degrees Celcius)}
}
}
%\details{
%% ~~ If necessary, more details than the __description__ above ~~
%}
\source{
Data provided by Sebastian Mernild.\cr
Originally obtained from http://www.dmi.dk/dmi/index/gronland/vejrarkiv-gl.htm. \cr
Added by Claus Ekstrom <ekstrom@life.ku.dk>
}
\references{
Aktuelt Naturvidenskab september 2010. \cr
http://aktuelnaturvidenskab.dk/fileadmin/an/nr-4/an4_2010gletscher.pdf
}
\examples{
data(greenland)
model <- lm(airtemp ~ year, data=greenland)
plot(greenland$year, greenland$airtemp, xlab="Year", ylab="Air temperature")
abline(model, col="red")
}
\keyword{datasets}
55 changes: 55 additions & 0 deletions man/qpcr.Rd
@@ -0,0 +1,55 @@
\name{qpcr}
\alias{qpcr}
\docType{data}
\title{Gene expression from real-time quantitative PCR}
\description{
Gene expression levels from real-time quantitative polymerase chain
reaction (qPCR) experiments on two different plant lines. Each line was used
for 7 experiments each with 45 cycles.
}
\usage{data(qpcr)}
\format{
A data frame with 630 observations on the following 4 variables.
\tabular{lll}{
\code{flour} \tab numeric \tab Fluorescence level\cr
\code{line} \tab factor \tab Plant lines \code{rnt} (mutant) and \code{wt} (wildtype)\cr
\code{cycle} \tab numeric \tab Cycle number for the experiment\cr
\code{transcript}\tab factor \tab Transcript used for the different runs\cr
}

% \describe{
% \item{\code{flour}}{numeric Fluorescence level}
% \item{\code{lines}}{factor Plant lines \code{rnt}
% (mutant) and \code{wt} (wildtype)}
% \item{\code{cycle}}{numeric Cycle number for the experiment}
% \item{\code{experiment}}{numeric Experiment number}
% }
}
%\details{
%% ~~ If necessary, more details than the __description__ above ~~
%}
\source{
Data provided by Kirsten Jorgensen <kij@life.ku.dk>. \cr
Added by Claus Ekstrom <ekstrom@life.ku.dk>
}
\references{
Morant, M. et al. (2010). Metabolomic, Transcriptional, Hormonal and
Signaling Cross-Talk in Superroot2. \emph{Molecular Plant}. 3, p.192--211.
}
\examples{
data(qpcr)

#
# Analyze a single run for the wt line, transcript 1
#
run1 <- subset(qpcr, transcript==1 & line=="wt")

model <- nls(flour ~ fmax/(1+exp(-(cycle-c)/b))+fb,
start=list(c=25, b=1, fmax=100, fb=0), data=run1)

print(model)

plot(run1$cycle, run1$flour, xlab="Cycle", ylab="Fluorescence")
lines(run1$cycle, predict(model))
}
\keyword{datasets}

0 comments on commit 5db7315

Please sign in to comment.