Skip to content

Commit

Permalink
Add info on pruning tree (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
TuomasBorman authored Nov 5, 2024
1 parent d3460b2 commit dd023b6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: OMA
Title: Orchestrating Microbiome Analysis with Bioconductor
Version: 0.98.28
Version: 0.98.29
Date: 2024-10-04
Authors@R:
c(person("Leo", "Lahti", role = c("aut"),
Expand Down
40 changes: 39 additions & 1 deletion inst/pages/taxonomy.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,47 @@ table. For instance, we can check all the taxa that matches with "Escherichia".

```{r}
#| label: mapTaxonomy
mapTaxonomy(GlobalPatterns, taxa = "Escherichia")
mapTaxonomy(tse, taxa = "Escherichia")
```

## Prune taxonomy tree {#sec-update-tree}

Subsetting is explained in detail in [@sec-treese_subsetting]. However, if
you've already subsetted your data, you may have noticed that the taxonomy tree
does not automatically update when using the `[]` operators. Although the
linakges between rows and tree nodes remain correct, the tree retains its
original, complex structure. You may be wondering how to update the tree to
reflect the newly simplified data.

`mia` package functions `subsetBy*` and `agglomerateBy*` (see
[@sec-agglomeration]) include an `update.tree` parameter to handle this
adjustment. However, when using `[]`, tree pruning must be done as an additional
step.

Let's start by selecting 5 arbitrary rows.

```{r}
#| label: subset_tse
tse_sub <- tse[1:5, ]
tse_sub
```

ven though we have only 5 rows, the tree still retains its original number of
tips. To align the tree with the subsetted data, we can use the
`TreeSummarizedExperiment::subsetByLeaf()` function, which allows us to select
specific tips from the tree, effectively pruning it to match the current subset
of data.

```{r}
#| label: subset_tree
tse_sub <- subsetByLeaf(tse_sub, rowLeaf = rownames(tse_sub))
tse_sub
```

Now, we can see that the taxonomy tree has a simpler structure, including only
the selected leaves.

## Generate a hierarchy tree on the fly {#sec-fly-tree}

Expand Down

0 comments on commit dd023b6

Please sign in to comment.