Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amine GHOZLANE
shaman
Commits
43b5d356
Commit
43b5d356
authored
Jul 11, 2017
by
Amine GHOZLANE
Browse files
Add total counts normalization
parent
99025f24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Rfunctions/Data_Management.R
View file @
43b5d356
...
...
@@ -560,7 +560,7 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
CT
=
OrderCounts
(
counts
=
CT
,
labels
=
labels
)
$
CountsOrder
CT_noNorm
=
CT
RowProd
=
sum
(
apply
(
CT_noNorm
,
1
,
prod
))
merged_table
=
merge
(
CT
,
taxo
,
by
=
"row.names"
)
CT
=
as.data.frame
(
merged_table
[,
2
:
(
dim
(
CT
)[
2
]
+1
)])
taxo
=
as.data.frame
(
merged_table
[,(
dim
(
CT
)[
2
]
+2
)
:
dim
(
merged_table
)[
2
]])
...
...
@@ -573,7 +573,7 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
## Create the dds object
dds
<-
DESeqDataSetFromMatrix
(
countData
=
CT
,
colData
=
target
,
design
=
design
,
ignoreRank
=
TRUE
)
#save(dds,file="testdds.RData")
if
(
is.null
(
VarNorm
)){
## Counts normalisation
...
...
@@ -581,6 +581,7 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
if
(
input
$
AccountForNA
==
"NonNull"
||
RowProd
==
0
)
dds
=
estimateSizeFactors
(
dds
,
locfunc
=
eval
(
as.name
(
input
$
locfunc
)),
geoMeans
=
GeoMeansCT
(
CT
))
if
(
input
$
AccountForNA
==
"All"
&&
RowProd
!=
0
)
dds
=
estimateSizeFactors
(
dds
,
locfunc
=
eval
(
as.name
(
input
$
locfunc
)))
if
(
input
$
AccountForNA
==
"Weighted"
&&
input
$
AccountForNA
!=
"NonNull"
)
{
dds
=
estimateSizeFactors
(
dds
,
locfunc
=
eval
(
as.name
(
input
$
locfunc
)),
geoMeans
=
GeoMeansCT
(
CT
));
sizeFactors
(
dds
)
=
w.sizefactor
(
CT
)}
if
(
input
$
AccountForNA
==
"Total counts"
)
{
sizeFactors
(
dds
)
=
colSums
(
CT
)
/
mean
(
colSums
(
CT
))}
normFactors
=
sizeFactors
(
dds
)
}
else
{
...
...
@@ -600,13 +601,13 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
if
(
input
$
AccountForNA
==
"NonNull"
)
{
dds_tmp
=
estimateSizeFactors
(
dds_tmp
,
locfunc
=
eval
(
as.name
(
input
$
locfunc
)),
geoMeans
=
GeoMeansCT
(
CT_tmp
));
normFactors
[
indgrp
]
=
sizeFactors
(
dds_tmp
)}
if
(
input
$
AccountForNA
==
"All"
)
{
dds_tmp
=
estimateSizeFactors
(
dds_tmp
,
locfunc
=
eval
(
as.name
(
input
$
locfunc
)));
normFactors
[
indgrp
]
=
sizeFactors
(
dds_tmp
)}
if
(
input
$
AccountForNA
==
"Weighted"
&&
input
$
AccountForNA
!=
"NonNull"
)
{
dds_tmp
=
estimateSizeFactors
(
dds_tmp
,
locfunc
=
eval
(
as.name
(
input
$
locfunc
)),
geoMeans
=
GeoMeansCT
(
CT_tmp
));
normFactors
[
indgrp
]
=
w.sizefactor
(
CT_tmp
)}
if
(
input
$
AccountForNA
==
"Total counts"
)
{
normFactors
[
indgrp
]
=
colSums
(
CT_tmp
)
/
mean
(
colSums
(
CT_tmp
))}
}
}
else
{
if
(
input
$
AccountForNA
==
"NonNull"
||
RowProd
==
0
)
dds
=
estimateSizeFactors
(
dds
,
locfunc
=
eval
(
as.name
(
input
$
locfunc
)),
geoMeans
=
GeoMeansCT
(
CT
))
if
(
input
$
AccountForNA
==
"All"
&&
RowProd
!=
0
)
dds
=
estimateSizeFactors
(
dds
,
locfunc
=
eval
(
as.name
(
input
$
locfunc
)))
if
(
input
$
AccountForNA
==
"Weighted"
&&
input
$
AccountForNA
!=
"NonNull"
)
{
dds
=
estimateSizeFactors
(
dds
,
locfunc
=
eval
(
as.name
(
input
$
locfunc
)),
geoMeans
=
GeoMeansCT
(
CT
));
sizeFactors
(
dds
)
=
w.sizefactor
(
CT
)}
if
(
input
$
AccountForNA
==
"Total counts"
)
{
sizeFactors
(
dds
)
=
colSums
(
CT
)
/
mean
(
colSums
(
CT
))}
normFactors
=
sizeFactors
(
dds
)
}
...
...
@@ -618,15 +619,15 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
# Only interesting OTU
# merged_table = merge(CT, taxo[order(rownames(CT)),], by="row.names")
# merged_table = merge(CT, taxo, by="row.names")
# CT = as.data.frame(merged_table[,2: (dim(CT)[2]+1)])
# taxo = as.data.frame(merged_table[,(dim(CT)[2]+2):dim(merged_table)[2]])
#
# rownames(CT) = merged_table[,1]
# rownames(taxo) = merged_table[,1]
# #ordOTU = order(rownames(taxo))
# counts_annot = CT
# merged_table = merge(CT, taxo, by="row.names")
# CT = as.data.frame(merged_table[,2: (dim(CT)[2]+1)])
# taxo = as.data.frame(merged_table[,(dim(CT)[2]+2):dim(merged_table)[2]])
#
# rownames(CT) = merged_table[,1]
# rownames(taxo) = merged_table[,1]
# #ordOTU = order(rownames(taxo))
# counts_annot = CT
# ordOTU = order(rownames(taxo))
# indOTU_annot = which(rownames(CT)%in%rownames(taxo))
# counts_annot = CT[indOTU_annot[ordOTU],]
...
...
ui.R
View file @
43b5d356
...
...
@@ -569,7 +569,7 @@ body <- dashboardBody(
tabPanel
(
"Normalization"
,
fluidRow
(
column
(
width
=
3
,
selectizeInput
(
"AccountForNA"
,
h6
(
strong
(
"Normalization method"
)),
choices
=
c
(
"Usual"
=
"All"
,
"Remove null counts"
=
"NonNull"
,
"Weighted"
=
"Weighted"
),
selected
=
"NonNull"
)),
selectizeInput
(
"AccountForNA"
,
h6
(
strong
(
"Normalization method"
)),
choices
=
c
(
"Usual"
=
"All"
,
"Remove null counts"
=
"NonNull"
,
"Weighted"
=
"Weighted"
,
"Total counts"
=
"Total counts"
),
selected
=
"NonNull"
)),
column
(
width
=
3
,
uiOutput
(
"SelectVarNorm"
)),
column
(
width
=
3
,
...
...
Write
Preview
Supports
Markdown
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