Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
criblejurkat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LBMC
Jalinot
criblejurkat
Commits
12be6207
Unverified
Commit
12be6207
authored
6 years ago
by
Laurent Modolo
Browse files
Options
Downloads
Patches
Plain Diff
add lm version of the computation
parent
f37e67f9
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
R/anova.R
+51
-1
51 additions, 1 deletion
R/anova.R
R/project.R
+9
-3
9 additions, 3 deletions
R/project.R
criblejurkat_final.pbs
+1
-1
1 addition, 1 deletion
criblejurkat_final.pbs
criblejurkat_full.pbs
+1
-1
1 addition, 1 deletion
criblejurkat_full.pbs
with
62 additions
and
6 deletions
R/anova.R
+
51
−
1
View file @
12be6207
...
@@ -116,7 +116,36 @@ batch_effect <- function(data) {
...
@@ -116,7 +116,36 @@ batch_effect <- function(data) {
return
(
data
)
return
(
data
)
}
}
#' build rm model between drugs accounting for batch effect
#' build lm model between drugs accounting for batch effect
#'
#' @param data a data.frame
#' @param formula (default: "ratio ~ drug + batch") the formula of the model
#' @param lower (default: TRUE) tests if "y" (the ratio) is lower than in controls
#' @param outdir set the outdir directory to a path (default extracted from fcs)
#' @return a data.frame
#' @examples
#' \dontrun{
#' data <- anova_lm(data)
#' }
#' @importFrom grDevices dev.off pdf
#' @importFrom stats as.formula quantile
#' @export anova_lm
anova_lm
<-
function
(
data
,
formula
=
"ratio ~ drug + batch"
,
lower
=
TRUE
,
outdir
)
{
variable_name
<-
gsub
(
"(.*) ~.*"
,
"\\1"
,
formula
)
model
<-
lm
(
stats
::
as.formula
(
formula
),
data
=
data
)
model_anova
<-
compute_pval
(
model
,
lower
=
lower
)
if
(
missing
(
outdir
))
{
outdir
<-
mk_outdir
(
data
,
"/test"
)
}
data
<-
export_lm_results
(
data
,
model_anova
)
save
(
data
,
model
,
file
=
paste0
(
outdir
,
"anova_rlm.Rdata"
))
export_drug_table
(
data
,
model_anova
,
outdir
)
return
(
data
)
}
#' build rlm model between drugs accounting for batch effect
#'
#'
#' @param data a data.frame
#' @param data a data.frame
#' @param formula (default: "ratio ~ drug + batch") the formula of the model
#' @param formula (default: "ratio ~ drug + batch") the formula of the model
...
@@ -181,6 +210,27 @@ export_rlm_results <- function(data, model_anova) {
...
@@ -181,6 +210,27 @@ export_rlm_results <- function(data, model_anova) {
return
(
data
)
return
(
data
)
}
}
#' @importFrom utils write.csv
export_lm_results
<-
function
(
data
,
model_anova
)
{
data
$
coef
<-
NA
data
$
coef_std
<-
NA
data
$
pval
<-
NA
data
$
tval
<-
NA
for
(
drug
in
levels
(
data
$
drug
))
{
if
(
!
(
drug
%in%
"None"
))
{
data
$
coef
[
data
$
drug
%in%
drug
]
<-
model_anova
$
Estimate
[
grepl
(
drug
,
rownames
(
model_anova
))]
data
$
coef_std
[
data
$
drug
%in%
drug
]
<-
model_anova
[
grepl
(
drug
,
rownames
(
model_anova
)),
2
]
data
$
tval
[
data
$
drug
%in%
drug
]
<-
model_anova
$
t.value
[
grepl
(
drug
,
rownames
(
model_anova
))]
data
$
pval
[
data
$
drug
%in%
drug
]
<-
model_anova
$
pval
[
grepl
(
drug
,
rownames
(
model_anova
))]
}
}
return
(
data
)
}
export_drug_table
<-
function
(
data
,
model_anova
,
outdir
,
export_drug_table
<-
function
(
data
,
model_anova
,
outdir
,
channels
=
c
(
"Y1.A"
,
"B1.A"
))
{
channels
=
c
(
"Y1.A"
,
"B1.A"
))
{
drug_table
<-
model_anova
[
grepl
(
"drug"
,
rownames
(
model_anova
)),
]
drug_table
<-
model_anova
[
grepl
(
"drug"
,
rownames
(
model_anova
)),
]
...
...
This diff is collapsed.
Click to expand it.
R/project.R
+
9
−
3
View file @
12be6207
...
@@ -37,13 +37,14 @@ set_analysis <- function(data_path = "data/", meta = F) {
...
@@ -37,13 +37,14 @@ set_analysis <- function(data_path = "data/", meta = F) {
#' perform all the analysis for a set of data sets
#' perform all the analysis for a set of data sets
#'
#'
#' @param data_path path to folder containing the data sets
#' @param data_path path to folder containing the data sets
#' @param rlm_model (default: TRUE) should rlm model be use or lm ?
#' @return TRUE if everythings ran correclty
#' @return TRUE if everythings ran correclty
#' @examples
#' @examples
#' \dontrun{
#' \dontrun{
#' analysis("data/set_test")
#' analysis("data/set_test")
#' }
#' }
#' @export analysis
#' @export analysis
analysis
<-
function
(
data_path
=
"data/"
)
{
analysis
<-
function
(
data_path
=
"data/"
,
rlm_model
=
TRUE
)
{
if
(
base
::
file.info
(
data_path
)
$
isdir
)
{
if
(
base
::
file.info
(
data_path
)
$
isdir
)
{
set_folders
<-
list.dirs
(
data_path
,
full.names
=
F
)[
-1
]
set_folders
<-
list.dirs
(
data_path
,
full.names
=
F
)[
-1
]
}
else
{
}
else
{
...
@@ -88,8 +89,13 @@ analysis <- function(data_path = "data/") {
...
@@ -88,8 +89,13 @@ analysis <- function(data_path = "data/") {
rm
(
set_data
)
rm
(
set_data
)
}
}
data
$
set
<-
as.factor
(
data
$
set
)
data
$
set
<-
as.factor
(
data
$
set
)
data
<-
anova_rlm
(
data
,
formula
=
"ratio ~ drug + batch + set"
,
if
(
rlm_model
)
{
outdir
=
outdir_rlm
)
data
<-
anova_rlm
(
data
,
formula
=
"ratio ~ drug + batch + set"
,
outdir
=
outdir_rlm
)
}
else
{
data
<-
anova_lm
(
data
,
formula
=
"ratio ~ drug + batch + set"
,
outdir
=
outdir_rlm
)
}
print
(
summary
(
data
))
print
(
summary
(
data
))
for
(
folder
in
set_folders
)
{
for
(
folder
in
set_folders
)
{
message
(
paste0
(
"plotting for "
,
folder
))
message
(
paste0
(
"plotting for "
,
folder
))
...
...
This diff is collapsed.
Click to expand it.
criblejurkat_final.pbs
+
1
−
1
View file @
12be6207
...
@@ -24,6 +24,6 @@ source /usr/share/lmod/lmod/init/bash
...
@@ -24,6 +24,6 @@ source /usr/share/lmod/lmod/init/bash
ml R/3.4.3
ml R/3.4.3
export
R_LIBS
=
"/Xnfs/lbmcdb/common/R/x86_64-pc-linux-gnu-library/3.4/"
export
R_LIBS
=
"/Xnfs/lbmcdb/common/R/x86_64-pc-linux-gnu-library/3.4/"
R
-e
'.libPaths(); library("criblejurkat"); analysis("data/final"); traceback()'
R
-e
'.libPaths(); library("criblejurkat"); analysis("data/final"
, rlm_model = F
); traceback()'
This diff is collapsed.
Click to expand it.
criblejurkat_full.pbs
+
1
−
1
View file @
12be6207
...
@@ -24,6 +24,6 @@ source /usr/share/lmod/lmod/init/bash
...
@@ -24,6 +24,6 @@ source /usr/share/lmod/lmod/init/bash
ml R/3.4.3
ml R/3.4.3
export
R_LIBS
=
"/Xnfs/lbmcdb/common/R/x86_64-pc-linux-gnu-library/3.4/"
export
R_LIBS
=
"/Xnfs/lbmcdb/common/R/x86_64-pc-linux-gnu-library/3.4/"
R
-e
'.libPaths(); library("criblejurkat"); analysis("data/full"); traceback()'
R
-e
'.libPaths(); library("criblejurkat"); analysis("data/full"
, rlm_model = F
); traceback()'
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment