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
umrf
ranomaly
Commits
39bf9ed5
Commit
39bf9ed5
authored
Sep 15, 2021
by
Etienne Rifa
Browse files
Merge branch 'master' into bars_update
parents
1ea939dd
a9fcc852
Changes
2
Hide whitespace changes
Inline
Side-by-side
R/deseq2_fun.R
View file @
39bf9ed5
...
...
@@ -134,25 +134,26 @@ deseq2_fun <- function(data = data, output = "./deseq/", column1 = "", verbose =
geoMeans
=
apply
(
DESeq2
::
counts
(
dseq
),
1
,
gm_mean
)
dseq2
=
estimateSizeFactors
(
dseq
,
geoMeans
=
geoMeans
)
flog.info
(
'DESeq2...'
)
print
(
dseq2
)
#
flog.info('DESeq2...')
#
print(dseq2)
dseq3
=
DESeq2
::
DESeq
(
dseq2
,
test
=
"Wald"
,
fitType
=
"parametric"
)
flog.debug
(
show
(
dseq3
))
res
=
results
(
dseq3
,
cooksCutoff
=
FALSE
)
res
=
results
(
dseq3
,
cooksCutoff
=
FALSE
,
contrast
=
c
(
column1
,
combinaisons
[
1
,
col
]
,
combinaisons
[
2
,
col
])
)
flog.debug
(
show
(
res
))
alpha
=
0.05
# outlist1 <- list()
flog.info
(
'Plot...'
)
alpha
=
0.05
if
(
length
(
which
(
res
$
padj
<
alpha
))
>
0
){
#
sigtab = res[which(res$padj < alpha), ]
sigtab
=
res
sig
tab
=
cbind
(
row.names
(
sigtab
),
as
(
sigtab
,
"data.frame"
),
as
(
tax_table
(
data
)[
rownames
(
sigtab
),
],
"matrix"
))
colnames
(
sigtab
)[
1
]
=
resultsNames
(
dseq3
)[
2
]
sigtab
=
res
[
which
(
res
$
padj
<
alpha
),
]
#
sigtab = res
tab
OUT
=
cbind
(
taxon_id
=
row.names
(
res
),
as
(
res
,
"data.frame"
),
as
(
tax_table
(
data
)[
rownames
(
res
),
],
"matrix"
))
colnames
(
res
)[
1
]
=
resultsNames
(
dseq3
)[
2
]
# save.image("debug.rdata")
write.table
(
sig
tab
,
file
=
paste
(
output
,
'/signtab_'
,
column1
,
'_'
,
paste
(
combinaisons
[,
col
],
collapse
=
"_vs_"
),
'.csv'
,
sep
=
''
),
quote
=
FALSE
,
sep
=
"\t"
,
row.names
=
FALSE
)
write.table
(
tab
OUT
,
file
=
paste
(
output
,
'/signtab_'
,
column1
,
'_'
,
paste
(
combinaisons
[,
col
],
collapse
=
"_vs_"
),
'.csv'
,
sep
=
''
),
quote
=
FALSE
,
sep
=
"\t"
,
row.names
=
FALSE
)
if
(
rank
!=
'ASV'
){
fun
<-
paste
(
'x = tapply(sigtab$log2FoldChange, sigtab$'
,
rank
,
', function(x) max(x))'
,
sep
=
''
)
...
...
@@ -174,7 +175,7 @@ deseq2_fun <- function(data = data, output = "./deseq/", column1 = "", verbose =
Ftable
=
sigtab
[,
c
(
"baseMean"
,
"log2FoldChange"
,
"stat"
,
"pvalue"
,
"padj"
,
rank
)]
ggtable
<-
ggtexttable
(
Ftable
,
theme
=
ttheme
(
"mOrange"
),
rows
=
NULL
)
pdf
(
file
=
paste
(
output
,
'/deseq2_'
,
column1
,
'.pdf'
,
sep
=
''
),
width
=
15
,
height
=
16
)
pdf
(
file
=
paste
(
output
,
'/deseq2_'
,
column1
,
"_"
,
paste
(
combinaisons
[,
col
],
collapse
=
"_vs_"
),
'.pdf'
,
sep
=
''
),
width
=
15
,
height
=
16
)
grid.arrange
(
p
,
ggtable
,
top
=
text_grob
(
paste
(
'Combination '
,
combinaisons
[
1
,
col
],
' VS '
,
combinaisons
[
2
,
col
],
sep
=
''
),
size
=
20
))
invisible
(
dev.off
())
...
...
R/diversity_beta_light.R
View file @
39bf9ed5
...
...
@@ -10,6 +10,7 @@
#' @param ord0 Currently supported method options are: c("DCA", "CCA", "RDA", "CAP", "DPCoA", "NMDS", "MDS", "PCoA")
#' @param output The output file directory.
#' @param tests Whether to compute tests or not (TRUE/FALSE)
#' @param axes Axes to plot (c(1,2))
#' @param verbose Verbose level. (1: quiet, 2: print infos, 3: print infos + debug)
#'
#' @return Return specific plots and tests in list and output them in the output directory.
...
...
@@ -25,7 +26,7 @@
# Decontam Function
diversity_beta_light
<-
function
(
psobj
,
rank
=
"ASV"
,
col
=
NULL
,
cov
=
NULL
,
dist0
=
"bray"
,
ord0
=
"MDS"
,
output
=
"./plot_div_beta/"
,
tests
=
TRUE
,
verbose
=
2
)
{
diversity_beta_light
<-
function
(
psobj
,
rank
=
"ASV"
,
col
=
NULL
,
cov
=
NULL
,
dist0
=
"bray"
,
ord0
=
"MDS"
,
output
=
"./plot_div_beta/"
,
axes
=
c
(
1
,
2
),
tests
=
TRUE
,
verbose
=
2
)
{
if
(
verbose
==
3
){
invisible
(
flog.threshold
(
DEBUG
))
...
...
@@ -69,10 +70,10 @@ diversity_beta_light <- function(psobj, rank = "ASV", col = NULL, cov = NULL, di
flog.info
(
'Plot ...'
)
resBeta
<-
list
()
if
(
!
is.null
(
cov
)){
p1
<-
plot_samples
(
data_rank
,
ordinate
(
data_rank
,
ord0
,
dist0
),
color
=
col
,
shape
=
cov1
[
length
(
cov1
)]
)
+
p1
<-
plot_samples
(
data_rank
,
ordinate
(
data_rank
,
ord0
,
dist0
),
color
=
col
,
shape
=
cov1
[
length
(
cov1
)]
,
axes
=
axes
)
+
theme_bw
()
+
ggtitle
(
glue
::
glue
(
"{ord0} + {dist0}"
))
+
stat_ellipse
()
+
scale_shape_manual
(
values
=
0
:
10
)
}
else
{
p1
<-
plot_samples
(
data_rank
,
ordinate
(
data_rank
,
ord0
,
dist0
),
color
=
col
)
+
p1
<-
plot_samples
(
data_rank
,
ordinate
(
data_rank
,
ord0
,
dist0
),
color
=
col
,
axes
=
axes
)
+
theme_bw
()
+
ggtitle
(
glue
::
glue
(
"{ord0} + {dist0}"
))
+
stat_ellipse
()
}
# plot(p1)
...
...
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