KasperSkytte / ampvis2

Tools for visualising microbial community amplicon data
https://kasperskytte.github.io/ampvis2/
GNU General Public License v3.0
66 stars 23 forks source link

Heatmap normalise_by only works by sample names #168

Open bernt-matthias opened 5 months ago

bernt-matthias commented 5 months ago

According to the docs I can

A variable or a specific sample in the metadata to normalise the counts by.

If I do

amp_heatmap(AalborgWWTPs, normalise=T, normalise_by = 'Plant')

I get: Error: Plant is not found among group names, cannot normalise

I debugged this a bit, and it seems that normalisation is only possible by a sample at the moment.

Note, For me it would be fine to fix the docs.

KasperSkytte commented 5 months ago

Hi. It uses the values in the variable supplied to group_by. So fx group by Plant, then supply normalise_by = "Aalborg West" should work. Could adjust docs if it's unclear.

bernt-matthias commented 5 months ago

Just tried

> data("AalborgWWTPs")
> amp_heatmap(AalborgWWTPs, normalise=T, normalise_by = "Aalborg West")
Error: Aalborg West is not found among group names, cannot normalise
KasperSkytte commented 5 months ago

Like this, but a different error. It's rarely used, but should be a quick fix.

library("ampvis2")
#> Loading required package: ggplot2
amp_heatmap(
  AalborgWWTPs,
  group_by = "Plant",
  tax_aggregate = "Genus",
  normalise_by = "Aalborg West"
)
#> Error in normalise_by %chin% unique(abund7$.Group): table is type 'integer' (must be 'character' or NULL)

Created on 2024-01-23 with reprex v2.1.0

bernt-matthias commented 5 months ago

I see. Combining group_by and normalise_by seems to make sense. At least I would have an intuition what happens in the normalisation.