Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
yeguanhuav committed May 15, 2019
1 parent e7acb5a commit a401e91
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 12 deletions.
2 changes: 2 additions & 0 deletions R/plot_stacked_bar.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ plot_stacked_bar <- function(phyloseq = NULL, level = NA, feature = NA,
# Join metadata
left_join(sample_feature) %>%
# Group by feature parameter
# group_by_() can pass variable to group_by()
group_by_(feature) %>%
# Arrange order by total abundance and by group
# Set .by_group = TRUE to arrange by group
arrange(desc(total), .by_group = TRUE) %>%
select(-total)
levels_SampleID <- plot_tab$SampleID
Expand Down
39 changes: 33 additions & 6 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,44 @@ track_reads_dada2(demo_dada2_result$reads_track, single_end = FALSE,

# Stacked barplot of phylogenetic composition

Use plot_stacked_bar function to plot the Family level abundance in every sample. You can change the 'level' argument to plot abundance in different level, or change the 'feature' to choose different feature you want to show in x-axis.
Use plot_stacked_bar function to plot the taxonomy level abundance in every sample. You can change the 'level' argument to plot abundance in different level, or change the 'feature' to choose different feature you want to show in x-axis.

Note:
### Minimum usage

```{r Stacked barplot 1, fig.height=10}
plot_stacked_bar(phyloseq = demo_phyloseq_object, level = "Family")
```

### Plot in relative abundance

```{r Stacked barplot 2, fig.height=10}
plot_stacked_bar(phyloseq = demo_phyloseq_object, level = "Family",
relative_abundance = TRUE)
```

If the legend is too much to show, set legend_position to "none".
### If legends are too many to show, set legend_position to "none"

```{r Stacked barplot 3, fig.height=10}
plot_stacked_bar(phyloseq = demo_phyloseq_object, level = "Family",
legend_position = "none")
```

### If you want to show feature information in x-axis, set "feature" parameter

```{r Stacked barplot 4, fig.height=10}
plot_stacked_bar(phyloseq = demo_phyloseq_object, level = "Family",
legend_position = "none",
feature = "diagnosis")
```

### Family level
### If you want the sample in specific order, pass ordered sample names to "order" parameter

```{r Stacked barplot, fig.height=10}
```{r Stacked barplot 5, fig.height=10}
sample_order <- sample_names(demo_phyloseq_object)
plot_stacked_bar(phyloseq = demo_phyloseq_object, level = "Family",
feature = "diagnosis", legend_position = "top")
legend_position = "none",
feature = "diagnosis",
order = sample_order)
```

# Alpha diversity
Expand Down
47 changes: 41 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,55 @@ track_reads_dada2(demo_dada2_result$reads_track, single_end = FALSE,
Stacked barplot of phylogenetic composition
===========================================

Use plot\_stacked\_bar function to plot the Family level abundance in every sample. You can change the 'level' argument to plot abundance in different level, or change the 'feature' to choose different feature you want to show in x-axis.
Use plot\_stacked\_bar function to plot the taxonomy level abundance in every sample. You can change the 'level' argument to plot abundance in different level, or change the 'feature' to choose different feature you want to show in x-axis.

Note:
### Minimum usage

``` r
plot_stacked_bar(phyloseq = demo_phyloseq_object, level = "Family")
```

![](README_files/figure-markdown_github/Stacked%20barplot%201-1.png)

### Plot in relative abundance

``` r
plot_stacked_bar(phyloseq = demo_phyloseq_object, level = "Family",
relative_abundance = TRUE)
```

![](README_files/figure-markdown_github/Stacked%20barplot%202-1.png)

### If legends are too many to show, set legend\_position to "none"

``` r
plot_stacked_bar(phyloseq = demo_phyloseq_object, level = "Family",
legend_position = "none")
```

![](README_files/figure-markdown_github/Stacked%20barplot%203-1.png)

### If you want to show feature information in x-axis, set "feature" parameter

``` r
plot_stacked_bar(phyloseq = demo_phyloseq_object, level = "Family",
legend_position = "none",
feature = "diagnosis")
```

If the legend is too much to show, set legend\_position to "none".
![](README_files/figure-markdown_github/Stacked%20barplot%204-1.png)

### Family level
### If you want the sample in specific order, pass ordered sample names to "order" parameter

``` r
sample_order <- sample_names(demo_phyloseq_object)
plot_stacked_bar(phyloseq = demo_phyloseq_object, level = "Family",
feature = "diagnosis", legend_position = "top")
legend_position = "none",
feature = "diagnosis",
order = sample_order)
```

![](README_files/figure-markdown_github/Stacked%20barplot-1.png)
![](README_files/figure-markdown_github/Stacked%20barplot%205-1.png)

Alpha diversity
===============
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a401e91

Please sign in to comment.