Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: variables topX and normalize to Phyloseq Bar Plot #6665

Merged
merged 8 commits into from
Jan 10, 2025

Conversation

MaraBesemer
Copy link
Contributor

@MaraBesemer MaraBesemer commented Jan 8, 2025

FOR CONTRIBUTOR:

  • I have read the CONTRIBUTING.md document and this tool is appropriate for the tools-iuc repo.
  • License permits unrestricted use (educational + commercial)
  • This PR adds a new tool or tool collection
  • This PR updates an existing tool or tool collection
  • This PR does something else (explain below)

@MaraBesemer
Copy link
Contributor Author

@paulzierep

@@ -49,14 +58,52 @@ if (is.null(opt$output) || opt$output == "") {
print(paste("Trying to read:", opt$input))
physeq <- readRDS(opt$input)

print(rank_names(physeq))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

tools/phyloseq/phyloseq_plot_bar.xml Outdated Show resolved Hide resolved
]]></command>
<inputs>
<expand macro="phyloseq_input"/>
<param name="x" type="text" label="X-axis variable" help="Variable for the x-axis (e.g., Sample, Phylum)" />
<param name="fill" type="text" label="Fill variable" help="Variable to color the bars (e.g., Genus, Order)" />
<param name="facet" type="text" optional="true" label="Facet by variable" help="Optional: Variable to facet the chart by (e.g., SampleType)" />
<param name="topX" type="integer" optional="true" label="Top X" help="Optional: Only show the top X values" />
<param name="keepOthers" type="boolean" optional="true" label="Keep 'Others'" help="Optional: Keep an 'Others' category for values not in the top X" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean parameters can't be optional.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaraBesemer can you remove the optional and add a value for topX ? 10 should be a good default.

]]></command>
<inputs>
<expand macro="phyloseq_input"/>
<param name="x" type="text" label="X-axis variable" help="Variable for the x-axis (e.g., Sample, Phylum)" />
<param name="fill" type="text" label="Fill variable" help="Variable to color the bars (e.g., Genus, Order)" />
<param name="facet" type="text" optional="true" label="Facet by variable" help="Optional: Variable to facet the chart by (e.g., SampleType)" />
<param name="topX" type="integer" optional="true" label="Top X" help="Optional: Only show the top X values" />
<param name="keepOthers" type="boolean" optional="true" label="Keep 'Others'" help="Optional: Keep an 'Others' category for values not in the top X" />
<param name="normalize" type="boolean" optional="true" label="Normalize" help="Optional: Normalize abundances to sum to 100%" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if you normalize and do not keep others?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the way I wrote the script, normalization happens after pruning. Now that I think about it, the other way around makes more sense. I did to allow renormalization when unassigned OTUs are present. But now I adjusted the script to assign those cases as unassigned. MaraBesemer#2
With this update, the normalization is done first and then pruning. So if you normalize and do not keep others you get something like:

and with others:

@paulzierep
Copy link
Contributor

@MaraBesemer can you also add wrapper options for

  width = 10, 
  height = 8,
  device="png"

To the wrapper ? Usually one needs to play around a bit with this, device should allow at least for pdf, png and some of: https://ggplot2.tidyverse.org/reference/ggsave.html

Copy link
Contributor

@paulzierep paulzierep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks !

@bgruening bgruening merged commit 26f87cc into galaxyproject:main Jan 10, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants