Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
anomaly
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
Container Registry
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
umrf
anomaly
Commits
bca98b60
Commit
bca98b60
authored
5 years ago
by
Sebastien Theil
Browse files
Options
Downloads
Patches
Plain Diff
Add colors and options.
parent
3de500f9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
markdown/bars2.Rmd
+24
-20
24 additions, 20 deletions
markdown/bars2.Rmd
plot_stats/bars.R
+34
-20
34 additions, 20 deletions
plot_stats/bars.R
plot_stats/diversity_beta.R
+1
-1
1 addition, 1 deletion
plot_stats/diversity_beta.R
with
59 additions
and
41 deletions
markdown/bars2.Rmd
+
24
−
20
View file @
bca98b60
...
...
@@ -26,17 +26,19 @@ if('bars' %in% names(rmd_data)){
```
```{r hold=TRUE, echo=FALSE, comment = FALSE, message= FALSE, warning = FALSE, results='asis', fig.keep='all', fig.align='left', fig.width = 20, fig.height = 10}
cat('## Phylum')
cat('\n')
rmd_data$bars[['Phylum']]
```
```{r hold=TRUE, echo=FALSE, comment = FALSE, message= FALSE, warning = FALSE, results='asis', fig.keep='all', fig.align='left', fig.width = 20, fig.height = 10}
cat('\n')
cat('## Family')
cat('\n')
grid.draw(rmd_data$bars[['Family']])
```
```{r hold=TRUE, echo=FALSE, comment = FALSE, message= FALSE, warning = FALSE, results='asis', fig.keep='all', fig.align='left', fig.width = 20, fig.height = 10}
cat('## Genus')
cat('\n')
rmd_data$bars[['Genus']]
```
```{r hold=TRUE, echo=FALSE, comment = FALSE, message= FALSE, warning = FALSE, results='asis', fig.keep='all', fig.align='left', fig.width = 20, fig.height = 10}
cat('\n')
cat('## Genus')
cat('\n')
grid.draw(rmd_data$bars[['Genus']])
```
```{r hold=TRUE, echo=FALSE, comment = FALSE, message= FALSE, warning = FALSE, results='asis',fig.keep='all', fig.align='left', fig.width = 20, fig.height = 10}
if('compo' %in% names(rmd_data)){
...
...
@@ -45,15 +47,17 @@ if('compo' %in% names(rmd_data)){
}
```
```{r hold=TRUE, echo=FALSE, comment = FALSE, message= FALSE, warning = FALSE, results='asis', fig.keep='all', fig.align='left', fig.width = 20, fig.height = 10}
cat('## Phylum')
cat('\n')
rmd_data$compo[['Phylum']]
```
```{r hold=TRUE, echo=FALSE, comment = FALSE, message= FALSE, warning = FALSE, results='asis', fig.keep='all', fig.align='left', fig.width = 20, fig.height = 10}
cat('\n')
cat('## Family')
cat('\n')
grid.draw(rmd_data$compo[['Family']])
```
```{r hold=TRUE, echo=FALSE, comment = FALSE, message= FALSE, warning = FALSE, results='asis', fig.keep='all', fig.align='left', fig.width = 20, fig.height = 10}
cat('## Genus')
cat('\n')
rmd_data$compo[['Genus']]
```
```{r hold=TRUE, echo=FALSE, comment = FALSE, message= FALSE, warning = FALSE, results='asis', fig.keep='all', fig.align='left', fig.width = 20, fig.height = 10}
cat('\n')
cat('## Genus')
cat('\n')
grid.draw(rmd_data$compo[['Genus']])
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
plot_stats/bars.R
+
34
−
20
View file @
bca98b60
...
...
@@ -13,10 +13,14 @@ option_list = list(
help
=
"output .Rdata file name for plot_bar. [default= %default]"
,
metavar
=
"path"
),
make_option
(
c
(
"-a"
,
"--column1"
),
type
=
"character"
,
default
=
""
,
help
=
"Column name. [default= %default]"
,
metavar
=
"STR"
),
make_option
(
c
(
"-b"
,
"--column2"
),
type
=
"character"
,
default
=
""
,
help
=
"Column name. [default= %default]"
,
metavar
=
"STR"
),
make_option
(
c
(
"-s"
,
"--sname"
),
type
=
"logical"
,
default
=
FALSE
,
help
=
"Change sample.id by they factor in graph. [default= %default]"
,
metavar
=
"STR"
),
make_option
(
c
(
"-n"
,
"--num"
),
type
=
"integer"
,
default
=
10
,
help
=
"Number of top taxon to display. [default= %default]"
,
metavar
=
"STR"
),
make_option
(
c
(
"-e"
,
"--rare"
),
type
=
"character"
,
default
=
NULL
,
help
=
"Column name for rare curves. [default= %default]"
,
metavar
=
"STR"
),
make_option
(
c
(
"-b"
,
"--column2"
),
type
=
"character"
,
default
=
""
,
help
=
"Column name. [default= %default]"
,
metavar
=
"STR"
),
make_option
(
c
(
"-i"
,
"--rank"
),
type
=
"character"
,
default
=
"Genus"
,
help
=
"Taxonomic rank name. You can provide multiple ranks seperate by comma.[default= %default]"
,
metavar
=
"STR"
)
);
...
...
@@ -59,6 +63,7 @@ suppressMessages(library('ggplot2'))
suppressMessages
(
library
(
'gridExtra'
))
suppressMessages
(
library
(
'grid'
))
suppressMessages
(
library
(
'microbiome'
))
suppressMessages
(
library
(
'viridis'
))
suppressMessages
(
source
(
"https://raw.githubusercontent.com/mahendra-mariadassou/phyloseq-extended/master/load-extra-functions.R"
))
suppressMessages
(
library
(
plotly
))
load
(
opt
$
rdata
)
...
...
@@ -78,12 +83,17 @@ if(opt$bar==TRUE){
for
(
i
in
1
:
length
(
taxonomy
)){
j
<-
taxonomy
[
i
];
print
(
j
)
psobj.top
10
<-
microbiome
::
aggregate_top_taxa
(
data
,
j
,
top
=
10
)
psobj.top
<-
microbiome
::
aggregate_top_taxa
(
data
,
j
,
top
=
opt
$
num
)
if
(
opt
$
column1
!=
''
&
opt
$
column2
==
''
){
flog.info
(
'Plotting bar (%s)...'
,
j
)
plot.composition.COuntAbun
<-
microbiome
::
plot_composition
(
psobj.top10
,
x.label
=
"sample.id"
,
sample.sort
=
opt
$
column1
)
+
theme
(
legend.position
=
"bottom"
)
+
scale_fill_brewer
(
j
,
palette
=
"Paired"
)
+
theme_bw
()
+
if
(
opt
$
sname
==
TRUE
){
plot.composition.COuntAbun
<-
microbiome
::
plot_composition
(
psobj.top
,
x.label
=
opt
$
column1
,
sample.sort
=
opt
$
column1
)
}
else
{
plot.composition.COuntAbun
<-
microbiome
::
plot_composition
(
psobj.top
,
x.label
=
"sample.id"
,
sample.sort
=
opt
$
column1
)
}
plot.composition.COuntAbun
<-
plot.composition.COuntAbun
+
theme
(
legend.position
=
"bottom"
)
+
theme_bw
()
+
scale_fill_viridis
(
discrete
=
TRUE
)
+
theme
(
axis.text.x
=
element_text
(
angle
=
90
))
+
ggtitle
(
"Raw abundance"
)
+
theme
(
legend.title
=
element_text
(
size
=
18
))
...
...
@@ -93,17 +103,23 @@ if(opt$bar==TRUE){
else
if
(
opt
$
column1
!=
''
&
opt
$
column2
!=
''
){
flog.info
(
'Plotting bar (%s)...'
,
j
)
sdata
=
psobj.top
10
@
sam_data
@
.Data
names
(
sdata
)
=
psobj.top
10
@
sam_data
@
names
sdata
=
psobj.top
@
sam_data
@
.Data
names
(
sdata
)
=
psobj.top
@
sam_data
@
names
FACT1
=
sdata
[[
opt
$
column2
]]
lvls
=
levels
(
sdata
[[
opt
$
column2
]])
LL
<-
list
()
for
(
i
in
1
:
length
(
lvls
)){
fun
<-
paste
(
"ppp <- subset_samples(psobj.top
10
, "
,
opt
$
column2
,
" %in% '"
,
lvls
[
i
],
"')"
,
sep
=
""
)
fun
<-
paste
(
"ppp <- subset_samples(psobj.top, "
,
opt
$
column2
,
" %in% '"
,
lvls
[
i
],
"')"
,
sep
=
""
)
eval
(
parse
(
text
=
fun
))
p1
<-
microbiome
::
plot_composition
(
ppp
,
x.label
=
"sample.id"
,
verbose
=
TRUE
,
sample.sort
=
opt
$
column1
)
+
theme
(
legend.position
=
"bottom"
)
+
scale_fill_brewer
(
j
,
palette
=
"Paired"
)
+
theme_bw
()
+
if
(
opt
$
sname
){
p1
<-
microbiome
::
plot_composition
(
ppp
,
x.label
=
opt
$
column1
,
verbose
=
TRUE
,
sample.sort
=
opt
$
column1
)
}
else
{
p1
<-
microbiome
::
plot_composition
(
ppp
,
x.label
=
"sample.id"
,
verbose
=
TRUE
,
sample.sort
=
opt
$
column1
)
}
p1
<-
p1
+
theme
(
legend.position
=
"bottom"
)
+
theme_bw
()
+
scale_fill_viridis
(
discrete
=
TRUE
)
+
theme
(
axis.text.x
=
element_text
(
angle
=
90
),
legend.title
=
element_text
(
size
=
18
))
+
ggtitle
(
paste
(
"Raw abundance"
,
opt
$
column2
,
"="
,
lvls
[
i
]))
...
...
@@ -117,8 +133,6 @@ if(opt$bar==TRUE){
leg
=
ggpubr
::
get_legend
(
p1
)
LL
[[
i
+1
]]
<-
ggpubr
::
as_ggplot
(
leg
)
}
}
plot.composition.COuntAbun
<-
p3
<-
gridExtra
::
grid.arrange
(
grobs
=
LL
,
ncol
=
length
(
lvls
)
+1
)
...
...
@@ -149,10 +163,10 @@ compo <- function (rankList, psobj, var = 'sample.id', col2='') {
fun
<-
paste
(
"ppp <- subset_samples(psobj, "
,
opt
$
column2
,
" %in% '"
,
LVL
,
"')"
,
sep
=
""
)
eval
(
parse
(
text
=
fun
))
flog.info
(
'Plotting %s composition (%s)...'
,
var
,
j
)
psobj.fam
<-
microbiome
::
aggregate_top_taxa
(
ppp
,
j
,
top
=
10
)
psobj.fam
<-
microbiome
::
aggregate_top_taxa
(
ppp
,
j
,
top
=
opt
$
num
)
psobj.rel
<-
microbiome
::
transform
(
psobj.fam
,
"compositional"
)
p1
<-
microbiome
::
plot_composition
(
psobj.rel
,
x.label
=
"sample.id"
,
sample.sort
=
opt
$
column1
)
+
theme
()
+
scale_fill_brewer
(
j
,
pal
et
t
e
=
"Paired"
)
+
theme_bw
(
)
+
p1
<-
microbiome
::
plot_composition
(
psobj.rel
,
x.label
=
opt
$
column1
,
sample.sort
=
opt
$
column1
)
+
theme
()
+
theme_bw
()
+
scale_fill_viridis
(
discr
ete
=
TRUE
)
+
theme
(
axis.text.x
=
element_text
(
angle
=
90
),
legend.title
=
element_text
(
size
=
18
))
+
ggtitle
(
paste
(
"Raw abundance"
,
opt
$
column2
,
"="
,
LVL
))
...
...
@@ -182,10 +196,10 @@ compo <- function (rankList, psobj, var = 'sample.id', col2='') {
for
(
i
in
1
:
length
(
rankList
)){
j
<-
rankList
[
i
]
flog.info
(
'Plotting %s composition (%s)...'
,
var
,
j
)
psobj.fam
<-
microbiome
::
aggregate_top_taxa
(
psobj
,
j
,
top
=
10
)
psobj.fam
<-
microbiome
::
aggregate_top_taxa
(
psobj
,
j
,
top
=
opt
$
num
)
psobj.rel
<-
microbiome
::
transform
(
psobj.fam
,
"compositional"
)
p1
<-
microbiome
::
plot_composition
(
psobj.rel
,
x.label
=
"sample.id"
,
sample.sort
=
opt
$
column1
)
+
theme
()
+
scale_fill_brewer
(
j
,
pal
et
t
e
=
"Paired"
)
+
theme_bw
(
)
+
p1
<-
microbiome
::
plot_composition
(
psobj.rel
,
x.label
=
opt
$
column1
,
sample.sort
=
opt
$
column1
)
+
theme
()
+
theme_bw
()
+
scale_fill_viridis
(
discr
ete
=
TRUE
)
+
theme
(
axis.text.x
=
element_text
(
angle
=
90
),
legend.title
=
element_text
(
size
=
18
))
+
ggtitle
(
"Relative abundance"
)
fun
<-
paste
(
'rmd_data$compo$'
,
j
,
' <- p1'
,
sep
=
''
)
...
...
This diff is collapsed.
Click to expand it.
plot_stats/diversity_beta.R
+
1
−
1
View file @
bca98b60
library
(
futile.logger
)
suppressMessages
(
library
(
"optparse"
))
suppressMessages
(
library
(
"optparse"
))
options
(
warn
=
-1
)
option_list
=
list
(
...
...
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