Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
stat_methods_bioinf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bernd Klaus
stat_methods_bioinf
Commits
92831134
Commit
92831134
authored
Aug 15, 2017
by
Bernd Klaus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added LOESS example and outline for the normalization section
parent
2acedcef
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
236 additions
and
59 deletions
+236
-59
graphics_bioinf.R
graphics_bioinf.R
+33
-0
graphics_bioinf.Rmd
graphics_bioinf.Rmd
+80
-1
graphics_bioinf.html
graphics_bioinf.html
+123
-58
No files found.
graphics_bioinf.R
View file @
92831134
...
...
@@ -36,6 +36,9 @@ library("limma")
library
(
"Single.mTEC.Transcriptomes"
)
library
(
"DESeq2"
)
library
(
"tibble"
)
library
(
"broom"
)
library
(
"scran"
)
library
(
"locfit"
)
theme_set
(
theme_gray
(
base_size
=
18
))
...
...
@@ -138,6 +141,36 @@ scatter_tra +
lm_tra
<-
lm
(
tra
~
total_detected
,
data
=
tra_detected
)
lm_tra
## ----loessExampleLinFit, dependson="fit_model"---------------------------
# 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
)
# linear fit
linreg
<-
lm
(
a
~
y
,
data
=
dataL
)
(
qplot
(
y
,
a
,
data
=
dataL
)
+
geom_abline
(
slope
=
tidy
(
linreg
,
quick
=
TRUE
)[
2
,
2
],
intercept
=
tidy
(
linreg
,
quick
=
TRUE
)[
1
,
2
]))
tidy
(
linreg
)
dataL
$
LinReg
<-
predict
(
linreg
)
## ----loessExampleFit, dependson="loessExampleLinFit"---------------------
dataL
$
locFit
<-
predict
(
locfit
(
y
~
lp
(
a
,
nn
=
0.5
,
deg
=
1
),
data
=
dataL
),
newdata
=
dataL
$
a
)
(
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"
))
## ----session_info, cache = FALSE-----------------------------------------
sessionInfo
()
graphics_bioinf.Rmd
View file @
92831134
...
...
@@ -64,6 +64,9 @@ library("limma")
library
(
"Single.mTEC.Transcriptomes"
)
library
(
"DESeq2"
)
library
(
"tibble"
)
library
(
"broom"
)
library
(
"scran"
)
library
(
"locfit"
)
theme_set
(
theme_gray
(
base_size
=
18
))
...
...
@@ -311,13 +314,89 @@ We can of course always add more predictors to the linear function. The coeffici
\(
b
\)
is
called
the
__slope__
and
\(
a
\)
is
called
the
__intercept__
.
We
can
fit
a
linear
regression
via
a
call
to
the
function
`
lm
()`.
The
regression
model
is
specified
using
R
's formula notation.
model
is
specified
using
R
's formula notation.
```{r regresssion_tra}
lm_tra <- lm(tra ~ total_detected, data = tra_detected)
lm_tra
```
As we can see, the estimated
slope is ~ `r tidy(lm_tra, quick = TRUE)[2, "estimate"]`, indicating
that we have a proportion of `r tidy(lm_tra, quick = TRUE)[2, "estimate"]`
tra expressing genes on average per cell for the highly variable genes.
This is in line with the supplementary figure 1 of the original publication,
which uses the full set of expressed genes, not just the highly variable
ones.
# Local regression (LOESS)
Local regression is a commonly used approach for fitting flexible non--linear
functions, which involves computing many local linear regression fits and combining
them. Local regression is a very useful technique both for data visualization and
trend fitting. Fitting many local models requires quite some computational power,
but it usually feasible with today'
s
hardware
.
We
illustrate
the
local
regression
using
the
`
r
CRANpkg
(
"locfit"
)
`
package
on
simulated
data
.
We
first
fit
a
linear
regression
line
to
simulated
data
that
follows
a
polynomial
trend
and
see
that
it
does
not
really
fit
well
.
```{
r
loessExampleLinFit
,
dependson
=
"fit_model"
}
#
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
)
#
linear
fit
linreg
<-
lm
(
a
~
y
,
data
=
dataL
)
(
qplot
(
y
,
a
,
data
=
dataL
)
+
geom_abline
(
slope
=
tidy
(
linreg
,
quick
=
TRUE
)[
2
,
2
],
intercept
=
tidy
(
linreg
,
quick
=
TRUE
)[
1
,
2
]))
tidy
(
linreg
)
dataL
$
LinReg
<-
predict
(
linreg
)
```
We
now
use
the
function
`
locfit
`
to
perform
a
local
regression
on
the
data
.
It
takes
the
predictors
wrapped
in
a
call
to
`
lp
()`.
Within
this
function
we
can
also
set
tunning
parameters
.
An
important
one
is
the
`
nn
`
one
,
which
set
the
proportion
of
nearest
--
neighbors
to
be
used
for
the
local
fits
.
The
lower
this
percentage
,
the
more
closely
the
line
will
follow
the
data
points
.
```{
r
loessExampleFit
,
dependson
=
"loessExampleLinFit"
}
dataL
$
locFit
<-
predict
(
locfit
(
y
~
lp
(
a
,
nn
=
0.5
,
deg
=
1
),
data
=
dataL
),
newdata
=
dataL
$
a
)
(
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"
))
```
#
Normalization
and
confounding
factors
.
##
Normalization
of
single
cell
data
*
use
scran
size
factors
##
Confounding
factors
*
ZINBA
Wave
#
Session
Info
...
...
graphics_bioinf.html
View file @
92831134
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment