Commit 4bd3e6ac authored by Bernd Klaus's avatar Bernd Klaus

refined LOESS section, added background on normalization

parent a5082e43
......@@ -36,7 +36,7 @@ library("vsn")
library("matrixStats")
library("pheatmap")
library("tidyverse")
#library("printr")
theme_set(theme_gray(base_size = 18))
......@@ -94,13 +94,21 @@ load(file.path(data_dir, "mtec_cell_anno.RData"))
load(file.path(data_dir, "mtec_gene_anno.RData"))
load(file.path(data_dir, "tras.RData"))
## ----mtec_count_table----------------------------------------------------
## ----mtec_count_table, results="asis"------------------------------------
mtec_counts
## ----mtec_cell_anno, results="asis"--------------------------------------
mtec_cell_anno
## ----trasENSEMBL, results="asis"-----------------------------------------
tras
mtec_gene_anno
## ----tidy_count----------------------------------------------------------
mtec_counts_tidy <- gather(mtec_counts, key = "cell_id", value = "count",
-ensembl_id) %>%
dplyr::mutate(is_tra = ensembl_id %in% tras$gene.ids,
dplyr::mutate(
is_tra = ensembl_id %in% tras$gene.ids,
is_detected = count > 0) %>%
left_join(mtec_cell_anno,
by = c("cell_id" = "cellID"))
......@@ -128,7 +136,7 @@ scatter_tra
scatter_tra +
geom_rug(alpha = I(0.2))
## ----ex_geom-------------------------------------------------------------
## ----ex_geom, echo=FALSE-------------------------------------------------
ggplot(tra_detected, aes(x = total_detected, y = tra))
scatter_tra +
......@@ -140,33 +148,46 @@ lm_tra <- lm(tra ~ total_detected, data = tra_detected)
lm_tra
## ----loessExampleLinFit, dependson="fit_model"---------------------------
sim_data <- tibble(x = seq(from=1, to=10, length.out=100),
y = x^3 +x^2 + rnorm(100,mean=0, sd=60))
# create_data
y <- seq(from=1, to=10, length.out=100)
a <- y^3 +y^2 + rnorm(100,mean=0, sd=30)
dataL <- data.frame(a=a, y=y)
qplot(y, a, data = dataL)
ggplot(aes(x, y), data = sim_data) +
geom_point() +
geom_smooth(method = "lm")
# linear fit
linreg <- lm(a~y, data = dataL)
## ----loessExampleFit, dependson="loessExampleLinFit"---------------------
(qplot(y, a, data = dataL) +
geom_abline(slope = tidy(linreg, quick = TRUE)[2,2],
intercept = tidy(linreg, quick = TRUE)[1,2]))
tidy(linreg)
sim_data$locFit <- predict(locfit(y~lp(x, nn=0.5, deg=1), data=sim_data),
newdata = sim_data$x)
dataL$LinReg <- predict(linreg)
ggplot(aes(x, y), data = sim_data) +
geom_point() +
geom_smooth(method = "lm") +
ggtitle("Linear vs. local regression") +
geom_line(aes(x = x, y = locFit), color = "coral3")
## ----loessExampleFit, dependson="loessExampleLinFit"---------------------
dataL$locFit <- predict(locfit(y~lp(a, nn=0.5, deg=1), data=dataL),
newdata = dataL$a)
## ----loessExercise, dependson="loessExampleLinFit", echo=FALSE-----------
sim_data$locFit <- predict(locfit(y~lp(x, nn=0.1, deg=1), data=sim_data),
newdata = sim_data$x)
ggplot(aes(x, y), data = sim_data) +
geom_point() +
geom_smooth() +
ggtitle("Linear vs. local regression") +
geom_line(aes(x = x, y = locFit), color = "coral3")
## ----compCells-----------------------------------------------------------
(qplot(a, y, data = dataL, main = "Linear vs. local regression")
+ geom_line(aes(x = a, y = locFit), color = "dodgerblue3")
+ geom_line(aes(x = a, y = LinReg), color = "coral3"))
ggplot(aes(x = cell_id, y = log(count)),
data = filter(mtec_counts_tidy,
cell_id %in% c("cell77", "cell6S35"),
is_detected == TRUE)) +
geom_boxplot()
## ----import_crc----------------------------------------------------------
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment