Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
TuomasBorman committed Feb 5, 2024
1 parent 3979973 commit 0441f6d
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions vignettes/MGnifyR.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ cutting-edge tools in microbiome down-stream analytics.

# Installation

`MGnifyR` is currently hosted on GitHub, and can be installed using via
`devtools`. `MGnifyR` should be built using the following snippet.
`MGnifyR` is hosted on Bioconductor, and can be installed using via
`BiocManager`.

```{r install, eval=FALSE}
BiocManager::install(MGnifyR)
Expand Down Expand Up @@ -72,7 +72,9 @@ mg

## Search data

Below, we fetch information on samples of drinking water.
`doQuery()` function can be utilized to search results such as samples and
studies from MGnify database. Below, we fetch information drinking water
samples.

```{r search_studies1, eval=FALSE}
# Fetch studies
Expand All @@ -87,6 +89,9 @@ samples <- doQuery(
samples <- vignette_MGnifyR[["samples"]]
```

The result is a table containing accession IDs and description -- in this case
-- on samples.

```{r search_studies3}
head(samples)
```
Expand All @@ -105,13 +110,17 @@ analyses_accessions <- searchAnalysis(mg, "samples", samples$accession)
analyses_accessions <- vignette_MGnifyR[["analyses_accessions"]]
```

By running the `searchAnalysis()` function, we get analysis IDs of samples that
we fed as an input.

```{r convert_to_analyses3}
head(analyses_accessions)
```

## Fetch metadata

We can now check the metadata to get hint of what kind of data we have.
We can now check the metadata to get hint of what kind of data we have. We use
`getMetadata()` function to fetch data based on analysis IDs.

```{r get_metadata1, eval=FALSE}
analyses_metadata <- getMetadata(mg, analyses_accessions)
Expand All @@ -121,6 +130,9 @@ analyses_metadata <- getMetadata(mg, analyses_accessions)
analyses_metadata <- vignette_MGnifyR[["analyses_metadata"]]
```

Metadata includes for example information on how analysis was conducted and
what kind of samples were analyzed.

```{r get_metadata3}
head(analyses_metadata)
```
Expand Down Expand Up @@ -156,7 +168,7 @@ mae[[1]]

`TreeSE` object is uniquely positioned to support `SummarizedExperiment`-based
microbiome data manipulation and visualization. Moreover, it enables access
to `miaverse` tools. For example, we can estimate diversity of samples.
to `miaverse` tools. For example, we can estimate diversity of samples...

```{r calculate_diversity, fig.width=9}
mae[[1]] <- estimateDiversity(mae[[1]], index = "shannon")
Expand All @@ -166,6 +178,8 @@ library(scater)
plotColData(mae[[1]], "shannon", x = "sample_environment..biome.")
```

... and plot abundances of most abundant phyla.

```{r plot_abundance}
# Agglomerate data
altExps(mae[[1]]) <- splitByRanks(mae[[1]])
Expand All @@ -177,8 +191,8 @@ top_taxa <- getTopFeatures(altExp(mae[[1]], "Phylum"), 10)
plotAbundance(altExp(mae[[1]], "Phylum")[top_taxa, ], rank = "Phylum")
```

We can perform principal component analysis to microbial profiling data by
utilizing miaverse tools.
We can also perform other analyses such as principal component analysis to
microbial profiling data by utilizing miaverse tools.

```{r pcoa}
# Apply relative transformation
Expand All @@ -201,14 +215,16 @@ of the functional analyses.
With `searchFile()`, we can search files from the database.

```{r get_download_urls1, eval=FALSE}
# Find list of available downloads, and filter for
dl_urls <- searchFile(mg, analyses_accessions, type = "analyses")
```

```{r get_download_urls2, eval=TRUE, include=FALSE}
dl_urls <- vignette_MGnifyR[["dl_urls"]]
```

The returned table contains search results related to analyses that we fed as
an input. The table contains information on file and also URL address from
where the file can be loaded.

```{r get_download_urls3}
target_urls <- dl_urls[
Expand All @@ -228,6 +244,8 @@ cached_location <- getFile(mg, file_url)
cached_location <- vignette_MGnifyR[["cached_location"]]
```

The function returns a path where the file is stored.

```{r download_file3}
# Where are the files?
cached_location
Expand Down

0 comments on commit 0441f6d

Please sign in to comment.