## ----setup, echo=FALSE--------------------------------------------------- library(LearnBioconductor) stopifnot(BiocInstaller::biocVersion() == "3.1") ## ----style, echo = FALSE, results = 'asis'------------------------------- BiocStyle::markdown() knitr::opts_chunk$set(tidy=FALSE) ## ------------------------------------------------------------------------ x <- rnorm(1000) # atomic vectors y <- x + rnorm(1000, sd=.5) df <- data.frame(x=x, y=y) # object of class 'data.frame' plot(y ~ x, df) # generic plot, method plot.formula fit <- lm(y ~x, df) # object of class 'lm' methods(class=class(fit)) # introspection ## ----echo=TRUE, eval=FALSE----------------------------------------------- # fname <- file.choose() ## "ALLphenoData.tsv" # stopifnot(file.exists(fname)) # pdata <- read.delim(fname) ## ----echo=FALSE---------------------------------------------------------- fname <- system.file("extdata", "ALLphenoData.tsv", package="LearnBioconductor") stopifnot(file.exists(fname)) pdata <- read.delim(fname) ## ----ALL-properties------------------------------------------------------ class(pdata) colnames(pdata) dim(pdata) head(pdata) summary(pdata$sex) summary(pdata$cyto.normal) ## ----ALL-subset---------------------------------------------------------- pdata[1:5, 3:4] pdata[1:5, ] head(pdata[, 3:5]) tail(pdata[, 3:5], 3) head(pdata$age) head(pdata$sex) head(pdata[pdata$age > 21,]) ## ----ALL-subset-NA------------------------------------------------------- idx <- pdata$sex == "F" & pdata$age > 40 table(idx) dim(pdata[idx,]) ## ----ALL-BCR/ABL-subset-------------------------------------------------- bcrabl <- pdata[pdata$mol.biol %in% c("BCR/ABL", "NEG"),] ## ----ALL-BCR/ABL-drop-unused--------------------------------------------- bcrabl$mol.biol <- factor(bcrabl$mol.biol) ## ----ALL-BT-------------------------------------------------------------- levels(bcrabl$BT) ## ----ALL-BT-recode------------------------------------------------------- table(bcrabl$BT) levels(bcrabl$BT) <- substring(levels(bcrabl$BT), 1, 1) table(bcrabl$BT) ## ----ALL-BCR/ABL-BT------------------------------------------------------ xtabs(~ BT + mol.biol, bcrabl) ## ----ALL-aggregate------------------------------------------------------- aggregate(age ~ mol.biol + sex, bcrabl, mean) ## ----ALL-age------------------------------------------------------------- t.test(age ~ mol.biol, bcrabl) boxplot(age ~ mol.biol, bcrabl)